2 // Copyright (C) 2006 Matthias Braun <matze@braunis.de>
3 // 2014 Ingo Ruhnke <grumbel@gmail.com>
5 // This program is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program. If not, see <http://www.gnu.org/licenses/>.
18 #ifndef HEADER_SUPERTUX_CONTROL_JOYSTICK_MANAGER_HPP
19 #define HEADER_SUPERTUX_CONTROL_JOYSTICK_MANAGER_HPP
26 #include "control/controller.hpp"
27 #include "util/reader_fwd.hpp"
28 #include "util/writer_fwd.hpp"
33 class JoystickManager final
37 JoystickConfig& m_joystick_config;
39 /// the number of buttons all joysticks have
42 /// the max number of buttons a joystick has
51 int wait_for_joystick;
54 std::vector<SDL_Joystick*> joysticks;
57 JoystickManager(InputManager* parent, JoystickConfig& joystick_config);
60 void process_hat_event(const SDL_JoyHatEvent& jhat);
61 void process_axis_event(const SDL_JoyAxisEvent& jaxis);
62 void process_button_event(const SDL_JoyButtonEvent& jbutton);
64 void set_joy_controls(Controller::Control id, bool value);
66 void on_joystick_added(int joystick_index);
67 void on_joystick_removed(int instance_id);
70 JoystickManager(const JoystickManager&) = delete;
71 JoystickManager& operator=(const JoystickManager&) = delete;