Root/
Source at commit dba6c32 created 10 years 6 months ago. By Paul Cercueil, Change API of InputManager: we don't care about key release events | |
---|---|
1 | /*************************************************************************** |
2 | * Copyright (C) 2006 by Massimiliano Torromeo * |
3 | * massimiliano.torromeo@gmail.com * |
4 | * * |
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 2 of the License, or * |
8 | * (at your option) any later version. * |
9 | * * |
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. * |
14 | * * |
15 | * You should have received a copy of the GNU General Public License * |
16 | * along with this program; if not, write to the * |
17 | * Free Software Foundation, Inc., * |
18 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
19 | ***************************************************************************/ |
20 | |
21 | #ifndef INPUTMANAGER_H |
22 | #define INPUTMANAGER_H |
23 | |
24 | #include <SDL.h> |
25 | #include <string> |
26 | #include <vector> |
27 | |
28 | class Menu; |
29 | |
30 | enum EventCode { |
31 | REMOVE_LINKS, |
32 | OPEN_PACKAGE, |
33 | OPEN_PACKAGES_FROM_DIR, |
34 | REPAINT_MENU, |
35 | }; |
36 | |
37 | class InputManager { |
38 | public: |
39 | enum Button { |
40 | UP, DOWN, LEFT, RIGHT, |
41 | ACCEPT, CANCEL, |
42 | ALTLEFT, ALTRIGHT, |
43 | MENU, SETTINGS, |
44 | REPAINT, |
45 | }; |
46 | #define BUTTON_TYPE_SIZE 10 |
47 | |
48 | InputManager(); |
49 | ~InputManager(); |
50 | |
51 | void init(const std::string &conffile, Menu *menu); |
52 | Button waitForPressedButton(); |
53 | bool pollButton(Button *button); |
54 | bool getButton(Button *button, bool wait); |
55 | |
56 | private: |
57 | void readConfFile(const std::string &conffile); |
58 | |
59 | enum ButtonSource { UNMAPPED, KEYBOARD, JOYSTICK }; |
60 | struct ButtonMapEntry { |
61 | ButtonSource source; |
62 | unsigned int code; |
63 | }; |
64 | |
65 | Menu *menu; |
66 | |
67 | ButtonMapEntry buttonMap[BUTTON_TYPE_SIZE]; |
68 | #ifndef SDL_JOYSTICK_DISABLED |
69 | std::vector<SDL_Joystick *> joysticks; |
70 | #endif |
71 | }; |
72 | |
73 | #endif |
74 |
Branches:
install_locations
master
opkrun
packages