Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 2097 was 2096, checked in by chris, 21 years ago

orxonox/branches/chris: Messed with the Player class, added stuff here and there, debug world now creates a player and bind IO to it. Added some doxygen tags.

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