Castle Battle  1.0
keyboard.h
Go to the documentation of this file.
1 #ifndef KEYBOARD_H
2 #define KEYBOARD_H
3 #include<irrlicht.h>
4 #include <vector>
5 
6 using namespace irr;
8 namespace KEYBOARD{
9 
21  };
23  class Key{
24  private:
25  public:
27  EKEY_CODE key;
28  Key(ACTION_KEYBOARD act, EKEY_CODE k);
29  Key getKey();
30  };
31 // const Key KEYBOARD_TEMPLATE[] ={
32 // Key(INCLINATE_UP, KEY_KEY_W),
33 // Key(INCLINATE_DOWN, KEY_KEY_S),
34 // Key(INCLINATE_RIGHT, KEY_KEY_D),
35 // Key(INCLINATE_LEFT, KEY_KEY_A)
36 // };
37 //Maybe templates could be a bettere solution, but this is plain!
38 // const Key * KEYBOARD_DEFAULT = new Key[4];
40  const std::vector<Key> KEYBOARD_DEFAULT {
41  Key(INCLINATE_UP, KEY_KEY_W),
42  Key(INCLINATE_DOWN, KEY_KEY_S),
43  Key(INCLINATE_RIGHT, KEY_KEY_D),
44  Key(INCLINATE_LEFT, KEY_KEY_A),
45  Key(SHOOT, KEY_SPACE)
46  };
48  class Keyboard : public IEventReceiver{
49 
50  private:
52  bool keyDown[KEY_KEY_CODES_COUNT];
54  std::vector<Key> mapKeys;
57  public:
59  Keyboard();
66  void mapKeyboard(const std::vector<Key> keys = KEYBOARD_DEFAULT);
68  virtual bool OnEvent(const SEvent& event);
70  Key* getLastKey();
77  Key* IsKeyDown();
79  void resetLastKey();
80 
81 };
82 }
83 #endif
Definition: keyboard.h:11
Definition: keyboard.h:14
ACTION_KEYBOARD
Definition: keyboard.h:10
Definition: keyboard.h:12
EKEY_CODE key
Definition: keyboard.h:27
Definition: keyboard.h:17
ACTION_KEYBOARD action
Definition: keyboard.h:26
Definition: keyboard.h:19
Definition: keyboard.h:16
Definition: keyboard.h:18
std::vector< Key > mapKeys
Map key with the ACTION_KEYBOARD specified in the Keyboard vector.
Definition: keyboard.h:54
Key * lastkey
Last key pressed.
Definition: keyboard.h:56
Keyboard namespace with all things related to Keyboard, Key, and keyboard mapping.
Definition: keyboard.h:8
Definition: keyboard.h:20
Definition: keyboard.h:15
Key is a class that describe a irrlicht EKEY_CODE and what ACTION_KEYBOARD is referring.
Definition: keyboard.h:23
Keyboard class will handle keyboard input events.
Definition: keyboard.h:48
Definition: keyboard.h:13
const std::vector< Key > KEYBOARD_DEFAULT
Default Keybaord mapping.
Definition: keyboard.h:40