From: Ingo Ruhnke Date: Wed, 6 Aug 2014 19:23:28 +0000 (+0200) Subject: Renamed JoystickKeyboardController to InputManager X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=fdd4409cae442e2ccf092da87f4b7c6e0a6d7382;p=supertux.git Renamed JoystickKeyboardController to InputManager --- diff --git a/src/control/game_controller_manager.cpp b/src/control/game_controller_manager.cpp index a9478ce30..bb8b5678a 100644 --- a/src/control/game_controller_manager.cpp +++ b/src/control/game_controller_manager.cpp @@ -18,10 +18,10 @@ #include -#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() diff --git a/src/control/game_controller_manager.hpp b/src/control/game_controller_manager.hpp index c6fa357a1..e07b819bd 100644 --- a/src/control/game_controller_manager.hpp +++ b/src/control/game_controller_manager.hpp @@ -21,17 +21,17 @@ #include "SDL.h" -class JoystickKeyboardController; +class InputManager; class GameControllerManager { private: - JoystickKeyboardController* m_parent; + InputManager* m_parent; int m_deadzone; std::vector 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 index 000000000..f9d87d15b --- /dev/null +++ b/src/control/input_manager.cpp @@ -0,0 +1,155 @@ +// SuperTux +// Copyright (C) 2006 Matthias Braun , +// 2007 Ingo Ruhnke +// +// 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 . + +#include "control/input_manager.hpp" + +#include + +#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 index 000000000..7e5e377f6 --- /dev/null +++ b/src/control/input_manager.hpp @@ -0,0 +1,76 @@ +// SuperTux +// Copyright (C) 2006 Matthias Braun +// +// 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 . + +#ifndef HEADER_SUPERTUX_CONTROL_INPUT_MANAGER_HPP +#define HEADER_SUPERTUX_CONTROL_INPUT_MANAGER_HPP + +#include "control/controller.hpp" + +#include +#include +#include +#include +#include + +#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; + +public: + bool m_use_game_controller; + std::unique_ptr keyboard_manager; + std::unique_ptr joystick_manager; + std::unique_ptr game_controller_manager; + +private: + InputManager(const InputManager&); + InputManager& operator=(const InputManager&); +}; + +#endif + +/* EOF */ diff --git a/src/control/joystick_manager.cpp b/src/control/joystick_manager.cpp index a9230b47e..169cad593 100644 --- a/src/control/joystick_manager.cpp +++ b/src/control/joystick_manager.cpp @@ -19,7 +19,7 @@ #include #include -#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(), diff --git a/src/control/joystick_manager.hpp b/src/control/joystick_manager.hpp index e30fdc46f..771612bde 100644 --- a/src/control/joystick_manager.hpp +++ b/src/control/joystick_manager.hpp @@ -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, Controller::Control> HatMap; private: - JoystickKeyboardController* parent; + InputManager* parent; ButtonMap joy_button_map; AxisMap joy_axis_map; @@ -68,7 +68,7 @@ public: std::vector 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 index ea2d9ea2c..000000000 --- a/src/control/joystickkeyboardcontroller.cpp +++ /dev/null @@ -1,155 +0,0 @@ -// SuperTux -// Copyright (C) 2006 Matthias Braun , -// 2007 Ingo Ruhnke -// -// 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 . - -#include "control/joystickkeyboardcontroller.hpp" - -#include - -#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 index 24adfc427..000000000 --- a/src/control/joystickkeyboardcontroller.hpp +++ /dev/null @@ -1,76 +0,0 @@ -// SuperTux -// Copyright (C) 2006 Matthias Braun -// -// 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 . - -#ifndef HEADER_SUPERTUX_CONTROL_JOYSTICKKEYBOARDCONTROLLER_HPP -#define HEADER_SUPERTUX_CONTROL_JOYSTICKKEYBOARDCONTROLLER_HPP - -#include "control/controller.hpp" - -#include -#include -#include -#include -#include - -#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; - -public: - bool m_use_game_controller; - std::unique_ptr keyboard_manager; - std::unique_ptr joystick_manager; - std::unique_ptr game_controller_manager; - -private: - JoystickKeyboardController(const JoystickKeyboardController&); - JoystickKeyboardController& operator=(const JoystickKeyboardController&); -}; - -#endif - -/* EOF */ diff --git a/src/control/keyboard_manager.cpp b/src/control/keyboard_manager.cpp index 15f498e14..08011c805 100644 --- a/src/control/keyboard_manager.cpp +++ b/src/control/keyboard_manager.cpp @@ -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), diff --git a/src/control/keyboard_manager.hpp b/src/control/keyboard_manager.hpp index 15d804352..09d3893ae 100644 --- a/src/control/keyboard_manager.hpp +++ b/src/control/keyboard_manager.hpp @@ -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 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; diff --git a/src/gui/menu.cpp b/src/gui/menu.cpp index 55415ee4b..87fb73cfa 100644 --- a/src/gui/menu.cpp +++ b/src/gui/menu.cpp @@ -19,13 +19,13 @@ #include #include -#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; diff --git a/src/gui/menu_manager.cpp b/src/gui/menu_manager.cpp index 7e911365a..4025e293f 100644 --- a/src/gui/menu_manager.cpp +++ b/src/gui/menu_manager.cpp @@ -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 diff --git a/src/object/player.cpp b/src/object/player.cpp index ab6c51939..2dbc8efcc 100644 --- a/src/object/player.cpp +++ b/src/object/player.cpp @@ -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 diff --git a/src/supertux/game_session.cpp b/src/supertux/game_session.cpp index 2e76fa4e6..a9ee67633 100644 --- a/src/supertux/game_session.cpp +++ b/src/supertux/game_session.cpp @@ -20,7 +20,7 @@ #include #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(); diff --git a/src/supertux/gameconfig.cpp b/src/supertux/gameconfig.cpp index 23c0d4fc8..8b41febff 100644 --- a/src/supertux/gameconfig.cpp +++ b/src/supertux/gameconfig.cpp @@ -19,7 +19,7 @@ #include #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"); } diff --git a/src/supertux/globals.cpp b/src/supertux/globals.cpp index 207c119d8..2e0e267b2 100644 --- a/src/supertux/globals.cpp +++ b/src/supertux/globals.cpp @@ -17,7 +17,7 @@ #include "supertux/globals.hpp" #include -JoystickKeyboardController* g_jk_controller = 0; +InputManager* g_input_manager = 0; tinygettext::DictionaryManager* dictionary_manager = 0; int SCREEN_WIDTH; diff --git a/src/supertux/globals.hpp b/src/supertux/globals.hpp index 890261947..eeeb77e25 100644 --- a/src/supertux/globals.hpp +++ b/src/supertux/globals.hpp @@ -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; diff --git a/src/supertux/levelintro.cpp b/src/supertux/levelintro.cpp index 8b3d3ed95..8db125177 100644 --- a/src/supertux/levelintro.cpp +++ b/src/supertux/levelintro.cpp @@ -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) diff --git a/src/supertux/main.cpp b/src/supertux/main.cpp index 509c60fd7..00a58a979 100644 --- a/src/supertux/main.cpp +++ b/src/supertux/main.cpp @@ -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(); diff --git a/src/supertux/menu/joystick_menu.cpp b/src/supertux/menu/joystick_menu.cpp index 27fe9f0ba..96c9e03ab 100644 --- a/src/supertux/menu/joystick_menu.cpp +++ b/src/supertux/menu/joystick_menu.cpp @@ -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) { diff --git a/src/supertux/menu/joystick_menu.hpp b/src/supertux/menu/joystick_menu.hpp index 8efbda83a..b7498c04c 100644 --- a/src/supertux/menu/joystick_menu.hpp +++ b/src/supertux/menu/joystick_menu.hpp @@ -18,13 +18,13 @@ #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: diff --git a/src/supertux/menu/keyboard_menu.cpp b/src/supertux/menu/keyboard_menu.cpp index e75b59d90..2b90ae8bd 100644 --- a/src/supertux/menu/keyboard_menu.cpp +++ b/src/supertux/menu/keyboard_menu.cpp @@ -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")); diff --git a/src/supertux/menu/keyboard_menu.hpp b/src/supertux/menu/keyboard_menu.hpp index b09c4061c..805b6c1f8 100644 --- a/src/supertux/menu/keyboard_menu.hpp +++ b/src/supertux/menu/keyboard_menu.hpp @@ -18,19 +18,19 @@ #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&); diff --git a/src/supertux/menu/menu_storage.cpp b/src/supertux/menu/menu_storage.cpp index 3a3ea91f7..7350849ac 100644 --- a/src/supertux/menu/menu_storage.cpp +++ b/src/supertux/menu/menu_storage.cpp @@ -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; diff --git a/src/supertux/screen_manager.cpp b/src/supertux/screen_manager.cpp index e1e7f124a..99eec341d 100644 --- a/src/supertux/screen_manager.cpp +++ b/src/supertux/screen_manager.cpp @@ -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); diff --git a/src/supertux/textscroller.cpp b/src/supertux/textscroller.cpp index 2a023fb22..f5e7863a2 100644 --- a/src/supertux/textscroller.cpp +++ b/src/supertux/textscroller.cpp @@ -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)) { diff --git a/src/worldmap/tux.cpp b/src/worldmap/tux.cpp index 85c4e784a..5c1fcf9db 100644 --- a/src/worldmap/tux.cpp +++ b/src/worldmap/tux.cpp @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -#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)) diff --git a/src/worldmap/worldmap.cpp b/src/worldmap/worldmap.cpp index f30241bbc..e11aff446 100644 --- a/src/worldmap/worldmap.cpp +++ b/src/worldmap/worldmap.cpp @@ -29,7 +29,7 @@ #include #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)