Removed made public variables private in JoystickManager and KeyboardManager
authorIngo Ruhnke <grumbel@gmail.com>
Thu, 28 Aug 2014 00:56:59 +0000 (02:56 +0200)
committerIngo Ruhnke <grumbel@gmail.com>
Thu, 28 Aug 2014 00:56:59 +0000 (02:56 +0200)
src/control/joystick_manager.cpp
src/control/joystick_manager.hpp
src/control/keyboard_manager.cpp
src/control/keyboard_manager.hpp
src/supertux/menu/joystick_menu.cpp
src/supertux/menu/keyboard_menu.cpp

index ebc164c..b6a31c2 100644 (file)
@@ -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 && 
index 898868e..f6f5271 100644 (file)
@@ -47,12 +47,12 @@ private:
 
   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();
@@ -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<int>(joysticks.size()); }
+
 private:
   JoystickManager(const JoystickManager&) = delete;
   JoystickManager& operator=(const JoystickManager&) = delete;
index 7818dc8..ca4e461 100644 (file)
@@ -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 */
index 9ddaba3..07885f9 100644 (file)
@@ -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;
index 5e47bba..bd11c9a 100644 (file)
@@ -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<Controller::Control>(item->id));
   }
   else if (item->id == MNID_JUMP_WITH_UP)
   {
index e88374c..9b25f8c 100644 (file)
@@ -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<Controller::Control>(item->id));
   } else if( item->id == Controller::CONTROLCOUNT) {
     g_config->keyboard_config.jump_with_up_kbd = item->toggled;
   }