Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 3009 was 2816, checked in by patrick, 20 years ago

orxonox/trunk/src: new list implemented

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* bound;  //!< List of WorldEntites that recieve commands from this CommandNode
44  Sint32 coord[2];
45 
46
47  void relay (Command* cmd);
48  int* name_to_index (char* name);
49  void process_local ();
50  void process_network ();
51  void send_over_network (Command* cmd);
52 
53 public:
54  CommandNode (int ID);
55  CommandNode (char* filename);
56  ~CommandNode ();
57
58  void reset(); 
59  void load_bindings (char* filename);
60  void bind (WorldEntity* entity);
61  void unbind (WorldEntity* entity);
62  void process ();
63 
64  void set_netID (int ID);
65};
66
67#endif
Note: See TracBrowser for help on using the repository browser.