X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fcontrol%2Fjoystick_manager.hpp;h=f6f5271178330301d2e4dc7db9c4dbcdceef6810;hb=2740fa90c947ec4d1ff9c7d3eeb12cf31ce4d26e;hp=c0e11d3de759d857abb16a413a97c7b283598f98;hpb=f79ead8440107e01c4845315d8532e29497b1068;p=supertux.git diff --git a/src/control/joystick_manager.hpp b/src/control/joystick_manager.hpp index c0e11d3de..f6f527117 100644 --- a/src/control/joystick_manager.hpp +++ b/src/control/joystick_manager.hpp @@ -1,6 +1,6 @@ // SuperTux // Copyright (C) 2006 Matthias Braun -// 2014 Ingo Ruhnke +// 2014 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 @@ -27,26 +27,14 @@ #include "util/reader_fwd.hpp" #include "util/writer_fwd.hpp" -class JoystickKeyboardController; +class InputManager; +class JoystickConfig; -class JoystickManager +class JoystickManager final { private: - typedef Uint8 JoyId; - - typedef std::map, Controller::Control> ButtonMap; - typedef std::map, Controller::Control> AxisMap; - typedef std::map, Controller::Control> HatMap; - -private: - JoystickKeyboardController* parent; - bool m_use_game_controller; - - ButtonMap joy_button_map; - AxisMap joy_axis_map; - HatMap joy_hat_map; - - int dead_zone; + InputManager* parent; + JoystickConfig& m_joystick_config; /// the number of buttons all joysticks have int min_joybuttons; @@ -59,45 +47,28 @@ private: Uint8 hat_state; -public: - bool jump_with_up_joy; - -public: int wait_for_joystick; -public: std::vector joysticks; -private: - std::vector game_controllers; + friend class KeyboardManager; public: - JoystickManager(JoystickKeyboardController* parent); + JoystickManager(InputManager* parent, JoystickConfig& joystick_config); ~JoystickManager(); void process_hat_event(const SDL_JoyHatEvent& jhat); void process_axis_event(const SDL_JoyAxisEvent& jaxis); void process_button_event(const SDL_JoyButtonEvent& jbutton); - void print_joystick_mappings(); - - int reversemap_joybutton(Controller::Control c); - int reversemap_joyaxis(Controller::Control c); - int reversemap_joyhat(Controller::Control c); - - void unbind_joystick_control(Controller::Control c); - - void bind_joybutton(JoyId joy_id, int button, Controller::Control c); - void bind_joyaxis(JoyId joy_id, int axis, Controller::Control c); - void bind_joyhat(JoyId joy_id, int dir, Controller::Control c); + void bind_next_event_to(Controller::Control id); - void set_joy_controls(Controller::Control id, bool value); + void set_joy_controls(Controller::Control id, bool value); void on_joystick_added(int joystick_index); void on_joystick_removed(int instance_id); - void read(const lisp::Lisp* joystick_lisp); - void write(Writer& writer); + int get_num_joysticks() const { return static_cast(joysticks.size()); } private: JoystickManager(const JoystickManager&) = delete;