Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/trunk/src/util/event/event_handler.h @ 4361

Last change on this file since 4361 was 4355, checked in by patrick, 20 years ago

orxonox/trunk: started implementing the process function

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
13class EventListener;
14template<class T> class tList;
15
16
17#define N_STD_KEYS SDLK_LAST
18#define N_BUTTONS 6
19#define DEFAULT_KEYBIND_FILE "~/.orxonox/orxonox.conf"
20
21typedef enum elState
22  {
23    ES_GAME,
24    ES_GAME_MENU,
25    ES_MENU,
26
27    ES_NUMBER,
28  };
29
30//! Key aliasing structure
31/**
32   This structure contains the key aliasing information, e.g. the command strings that
33   have been bound to the keys.
34*/
35typedef struct
36{
37  char keys[N_STD_KEYS][CMD_LENGHT];
38  char buttons[N_BUTTONS][CMD_LENGHT];
39} KeyBindings;
40
41
42//! The one Event Handler from Orxonox
43class EventHandler : public BaseObject {
44
45 public:
46  static EventHandler* getInstance(void);
47  virtual ~EventHandler(void);
48
49  void setState(elState state);
50
51  void subscribeListener(EventListener* el, elState state, int eventType);
52  void unsubscribeListener(int eventType, elState state);
53  void flush();
54 
55  void loadKeyBindings(const char* fileName);
56
57  void tick(float t);
58  void process();
59
60 private:
61  EventHandler(void);
62
63  static EventHandler* singletonRef;
64
65  KeyBindings* keyAliases;
66  EventListener*** listeners;                         //!< a list of registered listeners
67  elState state;
68
69};
70
71#endif /* _EVENT_HANDLER_H */
Note: See TracBrowser for help on using the repository browser.