Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 4425 was 4326, checked in by patrick, 20 years ago

orxonox/trunk: working on an alternativ flight mode and a new event handlig system at the same time. crazy…

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