Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/branches/old.chris/src/command_node.h @ 3574

Last change on this file since 3574 was 2141, checked in by chris, 20 years ago

orxonox/branches/chris: added lots and lots of doxygen tags

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