1 #ifndef INC_KEYBINDINGS_H
2 #define INC_KEYBINDINGS_H
3 
4 #include <config.h>
5 #ifdef HAVE_LIBCURL
6 #define HIGH_SCORE_REPORTING 1
7 #endif
8 
9 #include <string>
10 #include <vector>
11 #include <map>
12 using namespace std;
13 
14 #include <SDL/SDL.h>
15 
16 enum command
17 {
18     C_NONE,
19 
20     C_LEFT,
21     C_RIGHT,
22     C_DEZOOM,
23     C_DEAIM,
24 
25     C_SHOOT_GREEN,
26     C_SHOOT_YELLOW,
27     C_SHOOT_RED,
28     C_SHOOT_POD,
29 
30     C_PAUSE,
31     C_QUIT,
32 
33     C_MENU,
34     C_M_LEFT,
35     C_M_UP,
36     C_M_RIGHT,
37     C_M_DOWN,
38 
39     C_STARTGAME,
40 
41 #ifdef SOUND
42     C_SOUND,
43 #endif
44 
45     C_ZOOM,
46     C_ROTATE,
47     C_GRID,
48     C_DECAA,
49     C_INCAA,
50 
51     C_DECFPS,
52     C_INCFPS,
53 
54     C_DECRATE,
55     C_INCRATE,
56     C_RESETRATE,
57 
58 #ifdef HIGH_SCORE_REPORTING
59     C_REPORTHS,
60 #endif
61 
62     C_SCREENSHOT,
63 
64     C_INVULN,
65     C_WIN
66 };
67 
68 extern const command C_FIRST;
69 extern const command C_LAST;
70 extern const command C_LASTACTION;
71 extern const command C_LASTDEBUG;
72 
73 extern string longCommandNames[];
74 extern string shortCommandNames[];
75 
76 bool isMenuCommand(const command& c);
77 
78 command commandOfString(const string& str);
79 
80 struct Key
81 {
82     SDLKey sym;
83     SDLMod mod;
84 
85     string getString() const;
86 
87     bool operator==(const Key& other) const;
88     bool operator!=(const Key& other) const;
89 
90     bool isPressed();
91 
92     Key(SDL_keysym keysym);
93     Key(string keyString);
symKey94     Key(SDLKey sym=SDLK_UNKNOWN, SDLMod mod=KMOD_NONE) : sym(sym), mod(mod) {}
95 
96     private:
97 	SDLMod simpleMod(const SDLMod& in) const;
98 };
99 
100 extern Key KEY_NONE;
101 
102 struct Keybindings : public map<command,Key>
103 {
104     Key get(command command) const;
105 };
106 
107 Keybindings& defaultKeybindings();
108 
109 #endif /* INC_KEYBINDINGS_H */
110