From: Ingo Ruhnke Date: Thu, 28 Aug 2014 00:56:59 +0000 (+0200) Subject: Removed made public variables private in JoystickManager and KeyboardManager X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=24eeaf3d9b6cda74bd5c8ba228776573167978b6;p=supertux.git Removed made public variables private in JoystickManager and KeyboardManager --- diff --git a/src/control/joystick_manager.cpp b/src/control/joystick_manager.cpp index ebc164c7f..b6a31c260 100644 --- a/src/control/joystick_manager.cpp +++ b/src/control/joystick_manager.cpp @@ -221,6 +221,12 @@ JoystickManager::process_button_event(const SDL_JoyButtonEvent& jbutton) } 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 && diff --git a/src/control/joystick_manager.hpp b/src/control/joystick_manager.hpp index 898868ea2..f6f527117 100644 --- a/src/control/joystick_manager.hpp +++ b/src/control/joystick_manager.hpp @@ -47,12 +47,12 @@ private: Uint8 hat_state; -public: int wait_for_joystick; -public: std::vector joysticks; + friend class KeyboardManager; + public: JoystickManager(InputManager* parent, JoystickConfig& joystick_config); ~JoystickManager(); @@ -61,11 +61,15 @@ public: 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(joysticks.size()); } + private: JoystickManager(const JoystickManager&) = delete; JoystickManager& operator=(const JoystickManager&) = delete; diff --git a/src/control/keyboard_manager.cpp b/src/control/keyboard_manager.cpp index 7818dc835..ca4e4617e 100644 --- a/src/control/keyboard_manager.cpp +++ b/src/control/keyboard_manager.cpp @@ -203,4 +203,10 @@ KeyboardManager::process_menu_key_event(const SDL_KeyboardEvent& event) 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 */ diff --git a/src/control/keyboard_manager.hpp b/src/control/keyboard_manager.hpp index 9ddaba308..07885f9e3 100644 --- a/src/control/keyboard_manager.hpp +++ b/src/control/keyboard_manager.hpp @@ -34,8 +34,6 @@ class KeyboardManager final private: InputManager* m_parent; KeyboardConfig& m_keyboard_config; - -public: int wait_for_key; public: @@ -47,6 +45,8 @@ 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; diff --git a/src/supertux/menu/joystick_menu.cpp b/src/supertux/menu/joystick_menu.cpp index 5e47bba90..bd11c9aef 100644 --- a/src/supertux/menu/joystick_menu.cpp +++ b/src/supertux/menu/joystick_menu.cpp @@ -60,7 +60,7 @@ JoystickMenu::recreate_menu() } else { - if (m_input_manager.joystick_manager->joysticks.size() > 0) + if (m_input_manager.joystick_manager->get_num_joysticks() > 0) { m_joysticks_available = true; @@ -118,7 +118,7 @@ JoystickMenu::menu_action(MenuItem* item) 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(item->id)); } else if (item->id == MNID_JUMP_WITH_UP) { diff --git a/src/supertux/menu/keyboard_menu.cpp b/src/supertux/menu/keyboard_menu.cpp index e88374c52..9b25f8ce9 100644 --- a/src/supertux/menu/keyboard_menu.cpp +++ b/src/supertux/menu/keyboard_menu.cpp @@ -96,7 +96,7 @@ KeyboardMenu::menu_action(MenuItem* item) { 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(item->id)); } else if( item->id == Controller::CONTROLCOUNT) { g_config->keyboard_config.jump_with_up_kbd = item->toggled; }