Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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
RevLine 
[4329]1/*!
[4346]2    \file event_handler.h
3    \brief Definition of the EventHandler
[4329]4   
5*/
6
[4346]7#ifndef _EVENT_HANDLER_H
8#define _EVENT_HANDLER_H
[4329]9
10#include "base_object.h"
[4352]11#include "event_def.h"
[4329]12
[4346]13class EventListener;
[4329]14
[4352]15
[4362]16
[4352]17#define N_STD_KEYS SDLK_LAST
18#define N_BUTTONS 6
19#define DEFAULT_KEYBIND_FILE "~/.orxonox/orxonox.conf"
20
[4346]21typedef enum elState
22  {
23    ES_GAME,
24    ES_GAME_MENU,
25    ES_MENU,
[4329]26
[4362]27    ES_ALL,
28
[4346]29    ES_NUMBER,
30  };
31
[4352]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*/
37typedef struct
38{
39  char keys[N_STD_KEYS][CMD_LENGHT];
40  char buttons[N_BUTTONS][CMD_LENGHT];
41} KeyBindings;
[4346]42
[4352]43
[4346]44//! The one Event Handler from Orxonox
45class EventHandler : public BaseObject {
46
[4329]47 public:
[4346]48  static EventHandler* getInstance(void);
49  virtual ~EventHandler(void);
[4329]50
[4350]51  void setState(elState state);
52
[4354]53  void subscribeListener(EventListener* el, elState state, int eventType);
54  void unsubscribeListener(int eventType, elState state);
[4346]55  void flush();
56 
57  void loadKeyBindings(const char* fileName);
58
59  void tick(float t);
[4352]60  void process();
[4346]61
[4329]62 private:
[4346]63  EventHandler(void);
[4352]64
[4346]65  static EventHandler* singletonRef;
66
[4352]67  KeyBindings* keyAliases;
68  EventListener*** listeners;                         //!< a list of registered listeners
[4354]69  elState state;
70
[4329]71};
72
[4346]73#endif /* _EVENT_HANDLER_H */
Note: See TracBrowser for help on using the repository browser.