}
void
+JoystickManager::bind_next_event_to(Controller::Control id)
+{
+ wait_for_joystick = id;
+}
+
+void
JoystickManager::set_joy_controls(Controller::Control id, bool value)
{
if (m_joystick_config.jump_with_up_joy &&
Uint8 hat_state;
-public:
int wait_for_joystick;
-public:
std::vector<SDL_Joystick*> joysticks;
+ friend class KeyboardManager;
+
public:
JoystickManager(InputManager* parent, JoystickConfig& joystick_config);
~JoystickManager();
void process_axis_event(const SDL_JoyAxisEvent& jaxis);
void process_button_event(const SDL_JoyButtonEvent& jbutton);
+ void bind_next_event_to(Controller::Control id);
+
void set_joy_controls(Controller::Control id, bool value);
void on_joystick_added(int joystick_index);
void on_joystick_removed(int instance_id);
+ int get_num_joysticks() const { return static_cast<int>(joysticks.size()); }
+
private:
JoystickManager(const JoystickManager&) = delete;
JoystickManager& operator=(const JoystickManager&) = delete;
m_parent->get_controller()->set_control(control, (event.type == SDL_KEYDOWN));
}
+void
+KeyboardManager::bind_next_event_to(Controller::Control id)
+{
+ wait_for_key = id;
+}
+
/* EOF */
private:
InputManager* m_parent;
KeyboardConfig& m_keyboard_config;
-
-public:
int wait_for_key;
public:
void process_console_key_event(const SDL_KeyboardEvent& event);
void process_menu_key_event(const SDL_KeyboardEvent& event);
+ void bind_next_event_to(Controller::Control id);
+
private:
KeyboardManager(const KeyboardManager&) = delete;
KeyboardManager& operator=(const KeyboardManager&) = delete;
}
else
{
- if (m_input_manager.joystick_manager->joysticks.size() > 0)
+ if (m_input_manager.joystick_manager->get_num_joysticks() > 0)
{
m_joysticks_available = true;
if (0 <= item->id && item->id < Controller::CONTROLCOUNT)
{
item->change_input(_("Press Button"));
- m_input_manager.joystick_manager->wait_for_joystick = item->id;
+ m_input_manager.joystick_manager->bind_next_event_to(static_cast<Controller::Control>(item->id));
}
else if (item->id == MNID_JUMP_WITH_UP)
{
{
if(item->id >= 0 && item->id < Controller::CONTROLCOUNT){
item->change_input(_("Press Key"));
- m_input_manager.keyboard_manager->wait_for_key = item->id;
+ m_input_manager.keyboard_manager->bind_next_event_to(static_cast<Controller::Control>(item->id));
} else if( item->id == Controller::CONTROLCOUNT) {
g_config->keyboard_config.jump_with_up_kbd = item->toggled;
}