1// SuperTux
2// Copyright (C) 2006 Matthias Braun <matze@braunis.de>
3//
4// This program is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8//
9// This program is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17#ifndef HEADER_SUPERTUX_CONTROL_INPUT_MANAGER_HPP
18#define HEADER_SUPERTUX_CONTROL_INPUT_MANAGER_HPP
19
20#include "control/controller.hpp"
21
22#include <SDL.h>
23#include <map>
24#include <string>
25#include <vector>
26#include <memory>
27
28#include "util/currenton.hpp"
29
30class GameControllerManager;
31class JoystickManager;
32class JoystickMenu;
33class KeyboardManager;
34class KeyboardMenu;
35class KeyboardConfig;
36class JoystickConfig;
37
38class InputManager final : public Currenton<InputManager>
39{
40private:
41 friend class KeyboardMenu;
42 friend class JoystickMenu;
43
44public:
45 InputManager(KeyboardConfig& keyboard_config,
46 JoystickConfig& joystick_config);
47 virtual ~InputManager();
48
49 void process_event(const SDL_Event& event);
50
51 void update();
52 void reset();
53
54 void use_game_controller(bool v);
55 bool use_game_controller() const { return m_use_game_controller; }
56
57 const Controller& get_controller() const;
58 Controller& get_controller();
59
60private:
61 std::unique_ptr<Controller> controller;
62
63public:
64 bool& m_use_game_controller;
65 std::unique_ptr<KeyboardManager> keyboard_manager;
66 std::unique_ptr<JoystickManager> joystick_manager;
67 std::unique_ptr<GameControllerManager> game_controller_manager;
68
69private:
70 InputManager(const InputManager&) = delete;
71 InputManager& operator=(const InputManager&) = delete;
72};
73
74#endif
75
76/* EOF */
77