Made code -Wshadow clean, missed a bunch of issues in the last commit
[supertux.git] / src / control / joystick_manager.cpp
index 169cad5..5043b60 100644 (file)
@@ -1,5 +1,5 @@
 //  SuperTux
-//  Copyright (C) 2013 Ingo Ruhnke <grumbel@gmx.de>
+//  Copyright (C) 2014 Ingo Ruhnke <grumbel@gmail.com>
 //
 //  This program is free software: you can redistribute it and/or modify
 //  it under the terms of the GNU General Public License as published by
 #include <iostream>
 #include <algorithm>
 
+#include "gui/menu_manager.hpp"
 #include "control/input_manager.hpp"
 #include "lisp/list_iterator.hpp"
 #include "supertux/menu/joystick_menu.hpp"
-#include "supertux/menu/menu_storage.hpp"
 #include "util/gettext.hpp"
 #include "util/log.hpp"
 #include "util/writer.hpp"
 
-JoystickManager::JoystickManager(InputManager* parent) :
-  parent(parent),
+JoystickManager::JoystickManager(InputManager* parent_) :
+  parent(parent_),
   joy_button_map(),
   joy_axis_map(),
   joy_hat_map(),
-  dead_zone(4000),
+  dead_zone(8000),
   min_joybuttons(),
   max_joybuttons(),
   max_joyaxis(),
@@ -81,7 +81,7 @@ JoystickManager::~JoystickManager()
 void
 JoystickManager::on_joystick_added(int joystick_index)
 {
-  std::cout << "joydeviceadded: " << joystick_index << std::endl;
+  log_debug << "on_joystick_added(): " << joystick_index << std::endl;
   SDL_Joystick* joystick = SDL_JoystickOpen(joystick_index);
   if (!joystick)
   {
@@ -109,7 +109,7 @@ JoystickManager::on_joystick_added(int joystick_index)
 void
 JoystickManager::on_joystick_removed(int instance_id)
 {
-  std::cout << "joydeviceremoved: " << static_cast<int>(instance_id) << std::endl;
+  log_debug << "on_joystick_removed: " << static_cast<int>(instance_id) << std::endl;
   for(auto& joy : joysticks)
   {
     SDL_JoystickID id = SDL_JoystickInstanceID(joy);
@@ -143,7 +143,7 @@ JoystickManager::process_hat_event(const SDL_JoyHatEvent& jhat)
     if (changed & SDL_HAT_RIGHT && jhat.value & SDL_HAT_RIGHT)
       bind_joyhat(jhat.which, SDL_HAT_RIGHT, Controller::Control(wait_for_joystick));
 
-    MenuStorage::get_joystick_options_menu()->update();
+    MenuManager::instance().refresh();
     wait_for_joystick = -1;
   }
   else
@@ -191,7 +191,7 @@ JoystickManager::process_axis_event(const SDL_JoyAxisEvent& jaxis)
       else
         bind_joyaxis(jaxis.which, jaxis.axis + 1, Controller::Control(wait_for_joystick));
 
-      MenuStorage::get_joystick_options_menu()->update();
+      MenuManager::instance().refresh();
       wait_for_joystick = -1;
     }
   }
@@ -232,7 +232,7 @@ JoystickManager::process_button_event(const SDL_JoyButtonEvent& jbutton)
     if(jbutton.state == SDL_PRESSED)
     {
       bind_joybutton(jbutton.which, jbutton.button, (Controller::Control)wait_for_joystick);
-      MenuStorage::get_joystick_options_menu()->update();
+      MenuManager::instance().refresh();
       parent->reset();
       wait_for_joystick = -1;
     }