Debian Codegraph @

src/gamepad.h

raw symbols SCIP
1 // (_||_/
2 // ( ) Gamepad class
3 // ( o 0 )
4 //-OOO°--(_)---°OOO---------------------------------------
5 // Copyright (C) 2026 By Johnny Jazeix
6 // .OOOo oOOO. [email protected]
7 //-( )------( )---------------------------------------
8 // ( ( ) /
9 // (_) (_/
10
11 // This program is free software; you can redistribute it and/or modify
12 // it under the terms of the GNU General Public License as published by
13 // the Free Software Foundation; either version 2 or version 3 of the License.
14
15 // This program is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU General Public License for more details.
19
20 // You should have received a copy of the GNU General Public License along
21 // with this program; if not, write to the Free Software Foundation, Inc.,
22 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23
24 #ifndef GAMEPAD_DOM_
25 #define GAMEPAD_DOM_
26
27 #include <SDL2/SDL_events.h>
28 #include <SDL2/SDL_gamecontroller.h>
29
30 #include <unordered_map>
31
32 class Gamepad
33 {
34 public:
35 ~Gamepad() = default;
36
37 void Initialize();
38 void GetEvent(SDL_Event &event);
39
40 private:
41 std::unordered_map<int, int> m_lastValuesPerDirection;
42 SDL_GameController *findController();
43 SDL_JoystickID getControllerInstanceID(SDL_GameController *controller);
44 SDL_GameController *m_controller = nullptr;
45 void OverrideEvent(SDL_Event &event, int key);
46 };
47
48 #endif