Last change
on this file since 4362 was
4362,
checked in by patrick, 19 years ago
|
orxonox/trunk: type specific event handling routine
|
File size:
1.3 KB
|
Line | |
---|
1 | /*! |
---|
2 | \file event_handler.h |
---|
3 | \brief Definition of the EventHandler |
---|
4 | |
---|
5 | */ |
---|
6 | |
---|
7 | #ifndef _EVENT_HANDLER_H |
---|
8 | #define _EVENT_HANDLER_H |
---|
9 | |
---|
10 | #include "base_object.h" |
---|
11 | #include "event_def.h" |
---|
12 | |
---|
13 | class EventListener; |
---|
14 | |
---|
15 | |
---|
16 | |
---|
17 | #define N_STD_KEYS SDLK_LAST |
---|
18 | #define N_BUTTONS 6 |
---|
19 | #define DEFAULT_KEYBIND_FILE "~/.orxonox/orxonox.conf" |
---|
20 | |
---|
21 | typedef enum elState |
---|
22 | { |
---|
23 | ES_GAME, |
---|
24 | ES_GAME_MENU, |
---|
25 | ES_MENU, |
---|
26 | |
---|
27 | ES_ALL, |
---|
28 | |
---|
29 | ES_NUMBER, |
---|
30 | }; |
---|
31 | |
---|
32 | //! Key aliasing structure |
---|
33 | /** |
---|
34 | This structure contains the key aliasing information, e.g. the command strings that |
---|
35 | have been bound to the keys. |
---|
36 | */ |
---|
37 | typedef struct |
---|
38 | { |
---|
39 | char keys[N_STD_KEYS][CMD_LENGHT]; |
---|
40 | char buttons[N_BUTTONS][CMD_LENGHT]; |
---|
41 | } KeyBindings; |
---|
42 | |
---|
43 | |
---|
44 | //! The one Event Handler from Orxonox |
---|
45 | class EventHandler : public BaseObject { |
---|
46 | |
---|
47 | public: |
---|
48 | static EventHandler* getInstance(void); |
---|
49 | virtual ~EventHandler(void); |
---|
50 | |
---|
51 | void setState(elState state); |
---|
52 | |
---|
53 | void subscribeListener(EventListener* el, elState state, int eventType); |
---|
54 | void unsubscribeListener(int eventType, elState state); |
---|
55 | void flush(); |
---|
56 | |
---|
57 | void loadKeyBindings(const char* fileName); |
---|
58 | |
---|
59 | void tick(float t); |
---|
60 | void process(); |
---|
61 | |
---|
62 | private: |
---|
63 | EventHandler(void); |
---|
64 | |
---|
65 | static EventHandler* singletonRef; |
---|
66 | |
---|
67 | KeyBindings* keyAliases; |
---|
68 | EventListener*** listeners; //!< a list of registered listeners |
---|
69 | elState state; |
---|
70 | |
---|
71 | }; |
---|
72 | |
---|
73 | #endif /* _EVENT_HANDLER_H */ |
---|
Note: See
TracBrowser
for help on using the repository browser.