Renamed JoystickKeyboardController to InputManager
authorIngo Ruhnke <grumbel@gmail.com>
Wed, 6 Aug 2014 19:23:28 +0000 (21:23 +0200)
committerIngo Ruhnke <grumbel@gmail.com>
Wed, 6 Aug 2014 19:33:30 +0000 (21:33 +0200)
28 files changed:
src/control/game_controller_manager.cpp
src/control/game_controller_manager.hpp
src/control/input_manager.cpp [new file with mode: 0644]
src/control/input_manager.hpp [new file with mode: 0644]
src/control/joystick_manager.cpp
src/control/joystick_manager.hpp
src/control/joystickkeyboardcontroller.cpp [deleted file]
src/control/joystickkeyboardcontroller.hpp [deleted file]
src/control/keyboard_manager.cpp
src/control/keyboard_manager.hpp
src/gui/menu.cpp
src/gui/menu_manager.cpp
src/object/player.cpp
src/supertux/game_session.cpp
src/supertux/gameconfig.cpp
src/supertux/globals.cpp
src/supertux/globals.hpp
src/supertux/levelintro.cpp
src/supertux/main.cpp
src/supertux/menu/joystick_menu.cpp
src/supertux/menu/joystick_menu.hpp
src/supertux/menu/keyboard_menu.cpp
src/supertux/menu/keyboard_menu.hpp
src/supertux/menu/menu_storage.cpp
src/supertux/screen_manager.cpp
src/supertux/textscroller.cpp
src/worldmap/tux.cpp
src/worldmap/worldmap.cpp

index a9478ce..bb8b567 100644 (file)
 
 #include <algorithm>
 
-#include "control/joystickkeyboardcontroller.hpp"
+#include "control/input_manager.hpp"
 #include "util/log.hpp"
 
-GameControllerManager::GameControllerManager(JoystickKeyboardController* parent) :
+GameControllerManager::GameControllerManager(InputManager* parent) :
   m_parent(parent),
   m_deadzone(8000),
   m_game_controllers()
index c6fa357..e07b819 100644 (file)
 
 #include "SDL.h"
 
-class JoystickKeyboardController;
+class InputManager;
 
 class GameControllerManager
 {
 private:
-  JoystickKeyboardController* m_parent;
+  InputManager* m_parent;
   int m_deadzone;
   std::vector<SDL_GameController*> m_game_controllers;
 
 public:
-  GameControllerManager(JoystickKeyboardController* parent);
+  GameControllerManager(InputManager* parent);
   ~GameControllerManager();
 
   void process_button_event(const SDL_ControllerButtonEvent& ev);
diff --git a/src/control/input_manager.cpp b/src/control/input_manager.cpp
new file mode 100644 (file)
index 0000000..f9d87d1
--- /dev/null
@@ -0,0 +1,155 @@
+//  SuperTux
+//  Copyright (C) 2006 Matthias Braun <matze@braunis.de>,
+//                2007 Ingo Ruhnke <grumbel@gmx.de>
+//
+//  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
+//  the Free Software Foundation, either version 3 of the License, or
+//  (at your option) any later version.
+//
+//  This program is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//  GNU General Public License for more details.
+//
+//  You should have received a copy of the GNU General Public License
+//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+#include "control/input_manager.hpp"
+
+#include <iostream>
+
+#include "control/keyboard_manager.hpp"
+#include "control/joystick_manager.hpp"
+#include "control/game_controller_manager.hpp"
+#include "gui/menu_manager.hpp"
+#include "lisp/list_iterator.hpp"
+#include "supertux/gameconfig.hpp"
+#include "util/gettext.hpp"
+#include "util/writer.hpp"
+
+InputManager::InputManager() :
+  controller(new Controller),
+  m_use_game_controller(true),
+  keyboard_manager(new KeyboardManager(this)),
+  joystick_manager(new JoystickManager(this)),
+  game_controller_manager(new GameControllerManager(this))
+{
+}
+
+InputManager::~InputManager()
+{
+}
+
+Controller*
+InputManager::get_controller()
+{
+  return controller.get();
+}
+
+void
+InputManager::read(const Reader& lisp)
+{
+  const lisp::Lisp* keymap_lisp = lisp.get_lisp("keymap");
+  if (keymap_lisp) 
+  {
+    keyboard_manager->read(keymap_lisp);
+  }
+
+  const lisp::Lisp* joystick_lisp = lisp.get_lisp(_("joystick"));
+  if (joystick_lisp) 
+  {
+    joystick_manager->read(joystick_lisp);
+  }
+}
+
+void
+InputManager::write(Writer& writer)
+{
+  writer.start_list("keymap");
+  keyboard_manager->write(writer);
+  writer.end_list("keymap");
+
+  writer.start_list("joystick");
+  joystick_manager->write(writer);
+  writer.end_list("joystick");
+}
+
+void
+InputManager::update()
+{
+  controller->update();
+}
+
+void
+InputManager::reset()
+{
+  controller->reset();
+}
+
+void
+InputManager::process_event(const SDL_Event& event)
+{
+  switch(event.type) {
+    case SDL_TEXTINPUT:
+      keyboard_manager->process_text_input_event(event.text);
+      break;
+
+    case SDL_KEYUP:
+    case SDL_KEYDOWN:
+      keyboard_manager->process_key_event(event.key);
+      break;
+
+    case SDL_JOYAXISMOTION:
+      if (!m_use_game_controller) joystick_manager->process_axis_event(event.jaxis);
+      break;
+
+    case SDL_JOYHATMOTION:
+      if (!m_use_game_controller) joystick_manager->process_hat_event(event.jhat);
+      break;
+
+    case SDL_JOYBUTTONDOWN:
+    case SDL_JOYBUTTONUP:
+      if (!m_use_game_controller) joystick_manager->process_button_event(event.jbutton);
+      break;
+
+    case SDL_JOYDEVICEADDED:
+      if (!m_use_game_controller) joystick_manager->on_joystick_added(event.jdevice.which);
+      break;
+
+    case SDL_JOYDEVICEREMOVED:
+      if (!m_use_game_controller) joystick_manager->on_joystick_removed(event.jdevice.which);
+      break;
+
+    case SDL_CONTROLLERAXISMOTION:
+      if (m_use_game_controller) game_controller_manager->process_axis_event(event.caxis);
+      break;
+
+    case SDL_CONTROLLERBUTTONDOWN:
+      if (m_use_game_controller) game_controller_manager->process_button_event(event.cbutton);
+      break;
+
+    case SDL_CONTROLLERBUTTONUP:
+      if (m_use_game_controller) game_controller_manager->process_button_event(event.cbutton);
+      break;
+
+    case SDL_CONTROLLERDEVICEADDED:
+      std::cout << "SDL_CONTROLLERDEVICEADDED" << std::endl;
+      if (m_use_game_controller) game_controller_manager->on_controller_added(event.cdevice.which);
+      break;
+
+    case SDL_CONTROLLERDEVICEREMOVED:
+      std::cout << "SDL_CONTROLLERDEVICEREMOVED" << std::endl;
+      if (m_use_game_controller) game_controller_manager->on_controller_removed(event.cdevice.which);
+      break;
+
+    case SDL_CONTROLLERDEVICEREMAPPED:
+      std::cout << "SDL_CONTROLLERDEVICEREMAPPED" << std::endl;
+      break;
+
+    default:
+      break;
+  }
+}
+
+/* EOF */
diff --git a/src/control/input_manager.hpp b/src/control/input_manager.hpp
new file mode 100644 (file)
index 0000000..7e5e377
--- /dev/null
@@ -0,0 +1,76 @@
+//  SuperTux
+//  Copyright (C) 2006 Matthias Braun <matze@braunis.de>
+//
+//  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
+//  the Free Software Foundation, either version 3 of the License, or
+//  (at your option) any later version.
+//
+//  This program is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//  GNU General Public License for more details.
+//
+//  You should have received a copy of the GNU General Public License
+//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+#ifndef HEADER_SUPERTUX_CONTROL_INPUT_MANAGER_HPP
+#define HEADER_SUPERTUX_CONTROL_INPUT_MANAGER_HPP
+
+#include "control/controller.hpp"
+
+#include <SDL.h>
+#include <map>
+#include <string>
+#include <vector>
+#include <memory>
+
+#include "util/reader_fwd.hpp"
+#include "util/writer_fwd.hpp"
+
+class Controller;
+class GameControllerManager;
+class JoystickManager;
+class JoystickMenu;
+class KeyboardManager;
+class KeyboardMenu;
+class Menu;
+
+class InputManager final
+{
+private:
+  friend class KeyboardMenu;
+  friend class JoystickMenu;
+
+  typedef Controller::Control Control;
+
+public:
+  InputManager();
+  virtual ~InputManager();
+
+  void process_event(const SDL_Event& event);
+
+  void write(Writer& writer);
+  void read(const Reader& lisp);
+  void update();
+  void reset();
+
+  Controller* get_controller();
+
+private:
+  std::unique_ptr<Controller> controller;
+
+public:
+  bool m_use_game_controller;
+  std::unique_ptr<KeyboardManager> keyboard_manager;
+  std::unique_ptr<JoystickManager> joystick_manager; 
+  std::unique_ptr<GameControllerManager> game_controller_manager;
+
+private:
+  InputManager(const InputManager&);
+  InputManager& operator=(const InputManager&);
+};
+
+#endif
+
+/* EOF */
index a9230b4..169cad5 100644 (file)
@@ -19,7 +19,7 @@
 #include <iostream>
 #include <algorithm>
 
-#include "control/joystickkeyboardcontroller.hpp"
+#include "control/input_manager.hpp"
 #include "lisp/list_iterator.hpp"
 #include "supertux/menu/joystick_menu.hpp"
 #include "supertux/menu/menu_storage.hpp"
@@ -27,7 +27,7 @@
 #include "util/log.hpp"
 #include "util/writer.hpp"
 
-JoystickManager::JoystickManager(JoystickKeyboardController* parent) :
+JoystickManager::JoystickManager(InputManager* parent) :
   parent(parent),
   joy_button_map(),
   joy_axis_map(),
index e30fdc4..771612b 100644 (file)
@@ -27,7 +27,7 @@
 #include "util/reader_fwd.hpp"
 #include "util/writer_fwd.hpp"
 
-class JoystickKeyboardController;
+class InputManager;
 
 class JoystickManager final
 {
@@ -39,7 +39,7 @@ private:
   typedef std::map<std::pair<JoyId, int>, Controller::Control> HatMap;
 
 private:
-  JoystickKeyboardController* parent;
+  InputManager* parent;
 
   ButtonMap joy_button_map;
   AxisMap joy_axis_map;
@@ -68,7 +68,7 @@ public:
   std::vector<SDL_Joystick*> joysticks;
 
 public:
-  JoystickManager(JoystickKeyboardController* parent);
+  JoystickManager(InputManager* parent);
   ~JoystickManager();
 
   void process_hat_event(const SDL_JoyHatEvent& jhat);
diff --git a/src/control/joystickkeyboardcontroller.cpp b/src/control/joystickkeyboardcontroller.cpp
deleted file mode 100644 (file)
index ea2d9ea..0000000
+++ /dev/null
@@ -1,155 +0,0 @@
-//  SuperTux
-//  Copyright (C) 2006 Matthias Braun <matze@braunis.de>,
-//                2007 Ingo Ruhnke <grumbel@gmx.de>
-//
-//  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
-//  the Free Software Foundation, either version 3 of the License, or
-//  (at your option) any later version.
-//
-//  This program is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-//  GNU General Public License for more details.
-//
-//  You should have received a copy of the GNU General Public License
-//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-#include "control/joystickkeyboardcontroller.hpp"
-
-#include <iostream>
-
-#include "control/keyboard_manager.hpp"
-#include "control/joystick_manager.hpp"
-#include "control/game_controller_manager.hpp"
-#include "gui/menu_manager.hpp"
-#include "lisp/list_iterator.hpp"
-#include "supertux/gameconfig.hpp"
-#include "util/gettext.hpp"
-#include "util/writer.hpp"
-
-JoystickKeyboardController::JoystickKeyboardController() :
-  controller(new Controller),
-  m_use_game_controller(true),
-  keyboard_manager(new KeyboardManager(this)),
-  joystick_manager(new JoystickManager(this)),
-  game_controller_manager(new GameControllerManager(this))
-{
-}
-
-JoystickKeyboardController::~JoystickKeyboardController()
-{
-}
-
-Controller*
-JoystickKeyboardController::get_controller()
-{
-  return controller.get();
-}
-
-void
-JoystickKeyboardController::read(const Reader& lisp)
-{
-  const lisp::Lisp* keymap_lisp = lisp.get_lisp("keymap");
-  if (keymap_lisp) 
-  {
-    keyboard_manager->read(keymap_lisp);
-  }
-
-  const lisp::Lisp* joystick_lisp = lisp.get_lisp(_("joystick"));
-  if (joystick_lisp) 
-  {
-    joystick_manager->read(joystick_lisp);
-  }
-}
-
-void
-JoystickKeyboardController::write(Writer& writer)
-{
-  writer.start_list("keymap");
-  keyboard_manager->write(writer);
-  writer.end_list("keymap");
-
-  writer.start_list("joystick");
-  joystick_manager->write(writer);
-  writer.end_list("joystick");
-}
-
-void
-JoystickKeyboardController::update()
-{
-  controller->update();
-}
-
-void
-JoystickKeyboardController::reset()
-{
-  controller->reset();
-}
-
-void
-JoystickKeyboardController::process_event(const SDL_Event& event)
-{
-  switch(event.type) {
-    case SDL_TEXTINPUT:
-      keyboard_manager->process_text_input_event(event.text);
-      break;
-
-    case SDL_KEYUP:
-    case SDL_KEYDOWN:
-      keyboard_manager->process_key_event(event.key);
-      break;
-
-    case SDL_JOYAXISMOTION:
-      if (!m_use_game_controller) joystick_manager->process_axis_event(event.jaxis);
-      break;
-
-    case SDL_JOYHATMOTION:
-      if (!m_use_game_controller) joystick_manager->process_hat_event(event.jhat);
-      break;
-
-    case SDL_JOYBUTTONDOWN:
-    case SDL_JOYBUTTONUP:
-      if (!m_use_game_controller) joystick_manager->process_button_event(event.jbutton);
-      break;
-
-    case SDL_JOYDEVICEADDED:
-      if (!m_use_game_controller) joystick_manager->on_joystick_added(event.jdevice.which);
-      break;
-
-    case SDL_JOYDEVICEREMOVED:
-      if (!m_use_game_controller) joystick_manager->on_joystick_removed(event.jdevice.which);
-      break;
-
-    case SDL_CONTROLLERAXISMOTION:
-      if (m_use_game_controller) game_controller_manager->process_axis_event(event.caxis);
-      break;
-
-    case SDL_CONTROLLERBUTTONDOWN:
-      if (m_use_game_controller) game_controller_manager->process_button_event(event.cbutton);
-      break;
-
-    case SDL_CONTROLLERBUTTONUP:
-      if (m_use_game_controller) game_controller_manager->process_button_event(event.cbutton);
-      break;
-
-    case SDL_CONTROLLERDEVICEADDED:
-      std::cout << "SDL_CONTROLLERDEVICEADDED" << std::endl;
-      if (m_use_game_controller) game_controller_manager->on_controller_added(event.cdevice.which);
-      break;
-
-    case SDL_CONTROLLERDEVICEREMOVED:
-      std::cout << "SDL_CONTROLLERDEVICEREMOVED" << std::endl;
-      if (m_use_game_controller) game_controller_manager->on_controller_removed(event.cdevice.which);
-      break;
-
-    case SDL_CONTROLLERDEVICEREMAPPED:
-      std::cout << "SDL_CONTROLLERDEVICEREMAPPED" << std::endl;
-      break;
-
-    default:
-      break;
-  }
-}
-
-/* EOF */
diff --git a/src/control/joystickkeyboardcontroller.hpp b/src/control/joystickkeyboardcontroller.hpp
deleted file mode 100644 (file)
index 24adfc4..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-//  SuperTux
-//  Copyright (C) 2006 Matthias Braun <matze@braunis.de>
-//
-//  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
-//  the Free Software Foundation, either version 3 of the License, or
-//  (at your option) any later version.
-//
-//  This program is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-//  GNU General Public License for more details.
-//
-//  You should have received a copy of the GNU General Public License
-//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-#ifndef HEADER_SUPERTUX_CONTROL_JOYSTICKKEYBOARDCONTROLLER_HPP
-#define HEADER_SUPERTUX_CONTROL_JOYSTICKKEYBOARDCONTROLLER_HPP
-
-#include "control/controller.hpp"
-
-#include <SDL.h>
-#include <map>
-#include <string>
-#include <vector>
-#include <memory>
-
-#include "util/reader_fwd.hpp"
-#include "util/writer_fwd.hpp"
-
-class Controller;
-class GameControllerManager;
-class JoystickManager;
-class JoystickMenu;
-class KeyboardManager;
-class KeyboardMenu;
-class Menu;
-
-class JoystickKeyboardController final
-{
-private:
-  friend class KeyboardMenu;
-  friend class JoystickMenu;
-
-  typedef Controller::Control Control;
-
-public:
-  JoystickKeyboardController();
-  virtual ~JoystickKeyboardController();
-
-  void process_event(const SDL_Event& event);
-
-  void write(Writer& writer);
-  void read(const Reader& lisp);
-  void update();
-  void reset();
-
-  Controller* get_controller();
-
-private:
-  std::unique_ptr<Controller> controller;
-
-public:
-  bool m_use_game_controller;
-  std::unique_ptr<KeyboardManager> keyboard_manager;
-  std::unique_ptr<JoystickManager> joystick_manager; 
-  std::unique_ptr<GameControllerManager> game_controller_manager;
-
-private:
-  JoystickKeyboardController(const JoystickKeyboardController&);
-  JoystickKeyboardController& operator=(const JoystickKeyboardController&);
-};
-
-#endif
-
-/* EOF */
index 15f498e..08011c8 100644 (file)
@@ -27,7 +27,7 @@
 #include "supertux/menu/menu_storage.hpp"
 #include "util/writer.hpp"
 
-KeyboardManager::KeyboardManager(JoystickKeyboardController* parent) :
+KeyboardManager::KeyboardManager(InputManager* parent) :
   m_parent(parent),
   keymap(),
   jump_with_up_kbd(false),
index 15d8043..09d3893 100644 (file)
@@ -26,7 +26,7 @@
 #include "util/reader_fwd.hpp"
 #include "util/writer_fwd.hpp"
 
-class JoystickKeyboardController;
+class InputManager;
 
 class KeyboardManager final
 {
@@ -35,7 +35,7 @@ private:
   typedef std::map<SDL_Keycode, Controller::Control> KeyMap;
 
 public:
-  KeyboardManager(JoystickKeyboardController* parent);
+  KeyboardManager(InputManager* parent);
   ~KeyboardManager();
 
   void process_key_event(const SDL_KeyboardEvent& event);
@@ -50,7 +50,7 @@ public:
   void write(Writer& writer);
 
 private:
-  JoystickKeyboardController* m_parent;
+  InputManager* m_parent;
   KeyMap keymap;
   bool jump_with_up_kbd;
   int wait_for_key;
index 55415ee..87fb73c 100644 (file)
 #include <math.h>
 #include <stdexcept>
 
-#include "control/joystickkeyboardcontroller.hpp"
+#include "control/input_manager.hpp"
 #include "gui/menu_item.hpp"
 #include "gui/menu_manager.hpp"
 #include "gui/mousecursor.hpp"
 #include "supertux/globals.hpp"
-#include "supertux/screen_manager.hpp"
 #include "supertux/resources.hpp"
+#include "supertux/screen_manager.hpp"
 #include "supertux/timer.hpp"
 #include "util/gettext.hpp"
 #include "video/drawing_context.hpp"
@@ -227,7 +227,7 @@ Menu::update()
     effect_progress = 0.0f;
   }
 
-  Controller* controller = g_jk_controller->get_controller();
+  Controller* controller = g_input_manager->get_controller();
   /** check main input controller... */
   if(controller->pressed(Controller::UP)) {
     menuaction = MENU_ACTION_UP;
index 7e91136..4025e29 100644 (file)
@@ -16,7 +16,7 @@
 
 #include "gui/menu_manager.hpp"
 
-#include "control/joystickkeyboardcontroller.hpp"
+#include "control/input_manager.hpp"
 #include "gui/menu.hpp"
 #include "supertux/globals.hpp"
 #include "supertux/timer.hpp"
@@ -75,7 +75,7 @@ MenuManager::set_current(Menu* menu)
   }
 
   // just to be sure...
-  g_jk_controller->reset();
+  g_input_manager->reset();
 }
 
 void
index ab6c519..2dbc8ef 100644 (file)
@@ -19,7 +19,7 @@
 
 #include "audio/sound_manager.hpp"
 #include "badguy/badguy.hpp"
-#include "control/joystickkeyboardcontroller.hpp"
+#include "control/input_manager.hpp"
 #include "math/random_generator.hpp"
 #include "object/bullet.hpp"
 #include "object/camera.hpp"
@@ -159,7 +159,7 @@ Player::Player(PlayerStatus* _player_status, const std::string& name) :
   climbing(0)
 {
   this->name = name;
-  controller = g_jk_controller->get_controller();
+  controller = g_input_manager->get_controller();
   scripting_controller.reset(new CodeController());
   // if/when we have complete penny gfx, we can
   // load those instead of Tux's sprite in the
index 2e76fa4..a9ee676 100644 (file)
@@ -20,7 +20,7 @@
 #include <fstream>
 
 #include "audio/sound_manager.hpp"
-#include "control/joystickkeyboardcontroller.hpp"
+#include "control/input_manager.hpp"
 #include "gui/menu.hpp"
 #include "gui/menu_manager.hpp"
 #include "math/random_generator.hpp"
@@ -100,7 +100,7 @@ GameSession::restart_level()
   game_pause   = false;
   end_sequence = 0;
 
-  g_jk_controller->reset();
+  g_input_manager->reset();
 
   currentsector = 0;
 
@@ -349,7 +349,7 @@ GameSession::process_events()
 
   // save input for demo?
   if(capture_demo_stream != 0) {
-    Controller *controller = g_jk_controller->get_controller();
+    Controller *controller = g_input_manager->get_controller();
     capture_demo_stream ->put(controller->hold(Controller::LEFT));
     capture_demo_stream ->put(controller->hold(Controller::RIGHT));
     capture_demo_stream ->put(controller->hold(Controller::UP));
@@ -436,7 +436,7 @@ void
 GameSession::update(float elapsed_time)
 {
   // handle controller
-  if(g_jk_controller->get_controller()->pressed(Controller::PAUSE_MENU))
+  if(g_input_manager->get_controller()->pressed(Controller::PAUSE_MENU))
     on_escape_press();
 
   process_events();
index 23c0d4f..8b41feb 100644 (file)
@@ -19,7 +19,7 @@
 #include <stdexcept>
 
 #include "addon/addon_manager.hpp"
-#include "control/joystickkeyboardcontroller.hpp"
+#include "control/input_manager.hpp"
 #include "lisp/writer.hpp"
 #include "lisp/parser.hpp"
 #include "util/reader.hpp"
@@ -94,8 +94,8 @@ Config::load()
   }
 
   const lisp::Lisp* config_control_lisp = config_lisp->get_lisp("control");
-  if(config_control_lisp && g_jk_controller) {
-    g_jk_controller->read(*config_control_lisp);
+  if(config_control_lisp && g_input_manager) {
+    g_input_manager->read(*config_control_lisp);
   }
 
   const lisp::Lisp* config_addons_lisp = config_lisp->get_lisp("addons");
@@ -139,9 +139,9 @@ Config::save()
   writer.write("music_enabled", music_enabled);
   writer.end_list("audio");
 
-  if(g_jk_controller) {
+  if(g_input_manager) {
     writer.start_list("control");
-    g_jk_controller->write(writer);
+    g_input_manager->write(writer);
     writer.end_list("control");
   }
 
index 207c119..2e0e267 100644 (file)
@@ -17,7 +17,7 @@
 #include "supertux/globals.hpp"
 #include <tinygettext/tinygettext.hpp>
 
-JoystickKeyboardController* g_jk_controller = 0;
+InputManager* g_input_manager = 0;
 tinygettext::DictionaryManager* dictionary_manager = 0;
 
 int SCREEN_WIDTH;
index 8902619..eeeb77e 100644 (file)
@@ -20,7 +20,7 @@
 typedef struct SDL_Surface SDL_Surface;
 namespace tinygettext { class DictionaryManager; }
 class Config;
-class JoystickKeyboardController;
+class InputManager;
 class PlayerStatus;
 class ScreenManager;
 class SoundManager;
@@ -40,7 +40,7 @@ extern int SCREEN_WIDTH;
 extern int SCREEN_HEIGHT;
 
 // global variables
-extern JoystickKeyboardController* g_jk_controller;
+extern InputManager* g_input_manager;
 
 extern ScreenManager* g_screen_manager;
 
index 8b3d3ed..8db1251 100644 (file)
@@ -16,7 +16,7 @@
 
 #include "supertux/levelintro.hpp"
 
-#include "control/joystickkeyboardcontroller.hpp"
+#include "control/input_manager.hpp"
 #include "math/random_generator.hpp"
 #include "sprite/sprite_manager.hpp"
 #include "supertux/fadeout.hpp"
@@ -53,7 +53,7 @@ LevelIntro::setup()
 void
 LevelIntro::update(float elapsed_time)
 {
-  Controller *controller = g_jk_controller->get_controller();
+  Controller *controller = g_input_manager->get_controller();
 
   // Check if it's time to exit the screen
   if(controller->pressed(Controller::JUMP)
index 509c60f..00a58a9 100644 (file)
@@ -34,7 +34,7 @@ extern "C" {
 
 #include "addon/addon_manager.hpp"
 #include "audio/sound_manager.hpp"
-#include "control/joystickkeyboardcontroller.hpp"
+#include "control/input_manager.hpp"
 #include "math/random_generator.hpp"
 #include "physfs/ifile_stream.hpp"
 #include "physfs/physfs_sdl.hpp"
@@ -485,7 +485,7 @@ Main::run(int argc, char** argv)
     Console::instance = new Console();
 
     timelog("controller");
-    g_jk_controller = new JoystickKeyboardController();
+    g_input_manager = new InputManager();
 
     timelog("config");
     init_config();
@@ -579,8 +579,8 @@ Main::run(int argc, char** argv)
     g_config->save();
   delete g_config;
   g_config = NULL;
-  delete g_jk_controller;
-  g_jk_controller = NULL;
+  delete g_input_manager;
+  g_input_manager = NULL;
   delete Console::instance;
   Console::instance = NULL;
   scripting::exit_squirrel();
index 27fe9f0..96c9e03 100644 (file)
@@ -22,7 +22,7 @@
 #include "control/joystick_manager.hpp"
 #include "util/gettext.hpp"
 
-JoystickMenu::JoystickMenu(JoystickKeyboardController* _controller) :
+JoystickMenu::JoystickMenu(InputManager* _controller) :
   controller(_controller),
   joysticks_available(false)
 {
index 8efbda8..b7498c0 100644 (file)
 #ifndef HEADER_SUPERTUX_CONTROL_JOYSTICK_MENU_HPP
 #define HEADER_SUPERTUX_CONTROL_JOYSTICK_MENU_HPP
 
-#include "control/joystickkeyboardcontroller.hpp"
+#include "control/input_manager.hpp"
 #include "gui/menu_item.hpp"
 
 class JoystickMenu : public Menu
 {
 public:
-  JoystickMenu(JoystickKeyboardController* controller);
+  JoystickMenu(InputManager* controller);
   virtual ~JoystickMenu();
 
   void update();
@@ -37,7 +37,7 @@ private:
   void recreateMenu();
 
 private:
-  JoystickKeyboardController* controller;
+  InputManager* controller;
   bool joysticks_available;
 
 private:
index e75b59d..2b90ae8 100644 (file)
@@ -22,7 +22,7 @@
 #include "supertux/globals.hpp"
 #include "util/gettext.hpp"
 
-KeyboardMenu::KeyboardMenu(JoystickKeyboardController* _controller) :
+KeyboardMenu::KeyboardMenu(InputManager* _controller) :
   controller(_controller)
 {
   add_label(_("Setup Keyboard"));
index b09c406..805b6c1 100644 (file)
 #ifndef HEADER_SUPERTUX_CONTROL_KEYBOARD_MENU_HPP
 #define HEADER_SUPERTUX_CONTROL_KEYBOARD_MENU_HPP
 
-#include "control/joystickkeyboardcontroller.hpp"
+#include "control/input_manager.hpp"
 #include "gui/menu_item.hpp"
 
 class KeyboardMenu : public Menu
 {
 public:
-  KeyboardMenu(JoystickKeyboardController* controller);
+  KeyboardMenu(InputManager* controller);
   ~KeyboardMenu();
 
   void update();
   std::string get_key_name(SDL_Keycode key);
   virtual void menu_action(MenuItem* item);
-  JoystickKeyboardController* controller;
+  InputManager* controller;
   void check_menu() {}
 private:
   KeyboardMenu(const KeyboardMenu&);
index 3a3ea91..7350849 100644 (file)
@@ -46,7 +46,7 @@ MenuStorage::get_key_options_menu()
 {
   if (!key_options_menu)
   { // FIXME: this in never freed
-    key_options_menu = new KeyboardMenu(g_jk_controller);
+    key_options_menu = new KeyboardMenu(g_input_manager);
   }
 
   return key_options_menu;
@@ -57,7 +57,7 @@ MenuStorage::get_joystick_options_menu()
 {
   if (!joystick_options_menu)
   { // FIXME: this in never freed
-    joystick_options_menu = new JoystickMenu(g_jk_controller);
+    joystick_options_menu = new JoystickMenu(g_input_manager);
   }
 
   return joystick_options_menu;
index e1e7f12..99eec34 100644 (file)
@@ -17,7 +17,7 @@
 #include "supertux/screen_manager.hpp"
 
 #include "audio/sound_manager.hpp"
-#include "control/joystickkeyboardcontroller.hpp"
+#include "control/input_manager.hpp"
 #include "gui/menu.hpp"
 #include "gui/menu_manager.hpp"
 #include "scripting/squirrel_util.hpp"
@@ -190,11 +190,11 @@ ScreenManager::update_gamelogic(float elapsed_time)
 void
 ScreenManager::process_events()
 {
-  g_jk_controller->update();
+  g_input_manager->update();
   SDL_Event event;
   while(SDL_PollEvent(&event)) 
   {
-    g_jk_controller->process_event(event);
+    g_input_manager->process_event(event);
 
     if(MenuManager::current() != NULL)
       MenuManager::current()->event(event);
index 2a023fb..f5e7863 100644 (file)
@@ -17,7 +17,7 @@
 #include "supertux/textscroller.hpp"
 
 #include "audio/sound_manager.hpp"
-#include "control/joystickkeyboardcontroller.hpp"
+#include "control/input_manager.hpp"
 #include "lisp/parser.hpp"
 #include "supertux/fadeout.hpp"
 #include "supertux/info_box_line.hpp"
@@ -93,7 +93,7 @@ TextScroller::setup()
 void
 TextScroller::update(float elapsed_time)
 {
-  Controller *controller = g_jk_controller->get_controller();
+  Controller *controller = g_input_manager->get_controller();
   if(controller->hold(Controller::UP)) {
     speed = -defaultspeed*5;
   } else if(controller->hold(Controller::DOWN)) {
index 85c4e78..5c1fcf9 100644 (file)
@@ -15,7 +15,7 @@
 //  You should have received a copy of the GNU General Public License
 //  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-#include "control/joystickkeyboardcontroller.hpp"
+#include "control/input_manager.hpp"
 #include "scripting/squirrel_util.hpp"
 #include "sprite/sprite.hpp"
 #include "sprite/sprite_manager.hpp"
@@ -290,7 +290,7 @@ Tux::tryContinueWalking(float elapsed_time)
 void
 Tux::updateInputDirection()
 {
-  Controller* controller = g_jk_controller->get_controller();
+  Controller* controller = g_input_manager->get_controller();
   if(controller->hold(Controller::UP))
     input_direction = D_NORTH;
   else if(controller->hold(Controller::DOWN))
index f30241b..e11aff4 100644 (file)
@@ -29,7 +29,7 @@
 #include <vector>
 
 #include "audio/sound_manager.hpp"
-#include "control/joystickkeyboardcontroller.hpp"
+#include "control/input_manager.hpp"
 #include "gui/menu.hpp"
 #include "gui/menu_manager.hpp"
 #include "gui/mousecursor.hpp"
@@ -648,7 +648,7 @@ WorldMap::update(float delta)
     }
 
     // handle input
-    Controller *controller = g_jk_controller->get_controller();
+    Controller *controller = g_input_manager->get_controller();
     bool enter_level = false;
     if(controller->pressed(Controller::ACTION)
        || controller->pressed(Controller::JUMP)