Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/trunk/src/command_node.h @ 4048

Last change on this file since 4048 was 3608, checked in by patrick, 20 years ago

orxonox/trunk: now there is a real speedup in compiling time when dependencies are modified: just realy only includes, what is needed. Byside the speedup, there is more overview! never add an orxonox class to stdincl.h if it doesn't have to be

File size: 2.0 KB
Line 
1/*!
2    \file command_node.h
3    \brief Parses keyboard, mouse and remote input
4   
5    Contains methods to parse remote and local input and handles sending of input to remote CommandNodes
6*/
7
8#ifndef _COMMAND_NODE_H
9#define _COMMAND_NODE_H
10
11
12#include "comincl.h"
13
14template<class T> class tList;
15class WorldEntity;
16class World;
17
18#define N_STD_KEYS SDLK_LAST
19#define N_BUTTONS 6
20#define DEFAULT_KEYBIND_FILE "default.ini"
21
22//! Key aliasing structure
23/**
24   This structure contains the key aliasing information, e.g. the command strings that
25   have been bound to the keys.
26*/
27typedef struct
28{
29  char keys[N_STD_KEYS][CMD_LENGHT];
30  char buttons[N_BUTTONS][CMD_LENGHT];
31} KeyBindings;
32
33//! Command Node
34/**
35   This class gathers all incoming SDL_Events and processes them. Keyboard, mouse and joystick input is
36   captured and translated into command messages which are passed down to the bound WorldEntities (via WorldEntity::command()).
37   Other SDL_Events are passed to Orxonox::event_handler() to deal with them. If the CommandNode has been created
38   with bLocalInput set to false, it will query the network class for incoming commands that match his netID and pass
39   them on to it's WorldEntities.
40*/
41class CommandNode {
42 private:
43  bool bLocalInput;     //!< Identifies the CommandNode that processes local input
44  bool bEnabled;
45  int netID;    //!< Unique identifier that is used to determine between remote CommandNodes
46  KeyBindings* aliases;
47  tList<WorldEntity>* bound;    //!< List of WorldEntites that recieve commands from this CommandNode
48  Sint32 coord[2];
49  World* world;
50 
51
52  void relay (Command* cmd);
53  int* nameToIndex (char* name);
54  void processLocal ();
55  void processNetwork ();
56  void sendOverNetwork (Command* cmd);
57 
58 public:
59  CommandNode (int ID);
60  CommandNode (char* filename);
61  ~CommandNode ();
62
63  void reset ();
64  void enable (bool bEnabled);
65  void loadBindings (char* filename);
66  void bind (WorldEntity* entity);
67  void unbind (WorldEntity* entity);
68  void addToWorld (World* world);
69  void process ();
70 
71  void setNetID (int ID);
72};
73
74#endif /* _COMMAND_NODE_H */
Note: See TracBrowser for help on using the repository browser.