Skip to content

Commit

Permalink
Renamed JoystickKeyboardController to InputManager
Browse files Browse the repository at this point in the history
  • Loading branch information
Grumbel committed Aug 6, 2014
1 parent 6ff2ba5 commit fdd4409
Show file tree
Hide file tree
Showing 26 changed files with 74 additions and 74 deletions.
4 changes: 2 additions & 2 deletions src/control/game_controller_manager.cpp
Expand Up @@ -18,10 +18,10 @@

#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()
Expand Down
6 changes: 3 additions & 3 deletions src/control/game_controller_manager.hpp
Expand Up @@ -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<SDL_GameController*> m_game_controllers;

public:
GameControllerManager(JoystickKeyboardController* parent);
GameControllerManager(InputManager* parent);
~GameControllerManager();

void process_button_event(const SDL_ControllerButtonEvent& ev);
Expand Down
Expand Up @@ -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 <iostream>

Expand All @@ -28,7 +28,7 @@
#include "util/gettext.hpp"
#include "util/writer.hpp"

JoystickKeyboardController::JoystickKeyboardController() :
InputManager::InputManager() :
controller(new Controller),
m_use_game_controller(true),
keyboard_manager(new KeyboardManager(this)),
Expand All @@ -37,18 +37,18 @@ JoystickKeyboardController::JoystickKeyboardController() :
{
}

JoystickKeyboardController::~JoystickKeyboardController()
InputManager::~InputManager()
{
}

Controller*
JoystickKeyboardController::get_controller()
InputManager::get_controller()
{
return controller.get();
}

void
JoystickKeyboardController::read(const Reader& lisp)
InputManager::read(const Reader& lisp)
{
const lisp::Lisp* keymap_lisp = lisp.get_lisp("keymap");
if (keymap_lisp)
Expand All @@ -64,7 +64,7 @@ JoystickKeyboardController::read(const Reader& lisp)
}

void
JoystickKeyboardController::write(Writer& writer)
InputManager::write(Writer& writer)
{
writer.start_list("keymap");
keyboard_manager->write(writer);
Expand All @@ -76,19 +76,19 @@ JoystickKeyboardController::write(Writer& writer)
}

void
JoystickKeyboardController::update()
InputManager::update()
{
controller->update();
}

void
JoystickKeyboardController::reset()
InputManager::reset()
{
controller->reset();
}

void
JoystickKeyboardController::process_event(const SDL_Event& event)
InputManager::process_event(const SDL_Event& event)
{
switch(event.type) {
case SDL_TEXTINPUT:
Expand Down
Expand Up @@ -14,8 +14,8 @@
// 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
#ifndef HEADER_SUPERTUX_CONTROL_INPUT_MANAGER_HPP
#define HEADER_SUPERTUX_CONTROL_INPUT_MANAGER_HPP

#include "control/controller.hpp"

Expand All @@ -36,7 +36,7 @@ class KeyboardManager;
class KeyboardMenu;
class Menu;

class JoystickKeyboardController final
class InputManager final
{
private:
friend class KeyboardMenu;
Expand All @@ -45,8 +45,8 @@ class JoystickKeyboardController final
typedef Controller::Control Control;

public:
JoystickKeyboardController();
virtual ~JoystickKeyboardController();
InputManager();
virtual ~InputManager();

void process_event(const SDL_Event& event);

Expand All @@ -67,8 +67,8 @@ class JoystickKeyboardController final
std::unique_ptr<GameControllerManager> game_controller_manager;

private:
JoystickKeyboardController(const JoystickKeyboardController&);
JoystickKeyboardController& operator=(const JoystickKeyboardController&);
InputManager(const InputManager&);
InputManager& operator=(const InputManager&);
};

#endif
Expand Down
4 changes: 2 additions & 2 deletions src/control/joystick_manager.cpp
Expand Up @@ -19,15 +19,15 @@
#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"
#include "util/gettext.hpp"
#include "util/log.hpp"
#include "util/writer.hpp"

JoystickManager::JoystickManager(JoystickKeyboardController* parent) :
JoystickManager::JoystickManager(InputManager* parent) :
parent(parent),
joy_button_map(),
joy_axis_map(),
Expand Down
6 changes: 3 additions & 3 deletions src/control/joystick_manager.hpp
Expand Up @@ -27,7 +27,7 @@
#include "util/reader_fwd.hpp"
#include "util/writer_fwd.hpp"

class JoystickKeyboardController;
class InputManager;

class JoystickManager final
{
Expand All @@ -39,7 +39,7 @@ class JoystickManager final
typedef std::map<std::pair<JoyId, int>, Controller::Control> HatMap;

private:
JoystickKeyboardController* parent;
InputManager* parent;

ButtonMap joy_button_map;
AxisMap joy_axis_map;
Expand Down Expand Up @@ -68,7 +68,7 @@ class JoystickManager final
std::vector<SDL_Joystick*> joysticks;

public:
JoystickManager(JoystickKeyboardController* parent);
JoystickManager(InputManager* parent);
~JoystickManager();

void process_hat_event(const SDL_JoyHatEvent& jhat);
Expand Down
2 changes: 1 addition & 1 deletion src/control/keyboard_manager.cpp
Expand Up @@ -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),
Expand Down
6 changes: 3 additions & 3 deletions src/control/keyboard_manager.hpp
Expand Up @@ -26,7 +26,7 @@
#include "util/reader_fwd.hpp"
#include "util/writer_fwd.hpp"

class JoystickKeyboardController;
class InputManager;

class KeyboardManager final
{
Expand All @@ -35,7 +35,7 @@ class KeyboardManager final
typedef std::map<SDL_Keycode, Controller::Control> KeyMap;

public:
KeyboardManager(JoystickKeyboardController* parent);
KeyboardManager(InputManager* parent);
~KeyboardManager();

void process_key_event(const SDL_KeyboardEvent& event);
Expand All @@ -50,7 +50,7 @@ class KeyboardManager final
void write(Writer& writer);

private:
JoystickKeyboardController* m_parent;
InputManager* m_parent;
KeyMap keymap;
bool jump_with_up_kbd;
int wait_for_key;
Expand Down
6 changes: 3 additions & 3 deletions src/gui/menu.cpp
Expand Up @@ -19,13 +19,13 @@
#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"
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/gui/menu_manager.cpp
Expand Up @@ -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"
Expand Down Expand Up @@ -75,7 +75,7 @@ MenuManager::set_current(Menu* menu)
}

// just to be sure...
g_jk_controller->reset();
g_input_manager->reset();
}

void
Expand Down
4 changes: 2 additions & 2 deletions src/object/player.cpp
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions src/supertux/game_session.cpp
Expand Up @@ -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"
Expand Down Expand Up @@ -100,7 +100,7 @@ GameSession::restart_level()
game_pause = false;
end_sequence = 0;

g_jk_controller->reset();
g_input_manager->reset();

currentsector = 0;

Expand Down Expand Up @@ -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));
Expand Down Expand 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();
Expand Down
10 changes: 5 additions & 5 deletions src/supertux/gameconfig.cpp
Expand Up @@ -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"
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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");
}

Expand Down
2 changes: 1 addition & 1 deletion src/supertux/globals.cpp
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/supertux/globals.hpp
Expand Up @@ -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;
Expand All @@ -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;

Expand Down

0 comments on commit fdd4409

Please sign in to comment.