Alex exoskeleton
ALEX SoftwareDocumentation
Keyboard.h
Go to the documentation of this file.
1 
9 #ifndef KEYBOARD_H_INCLUDED
10 #define KEYBOARD_H_INCLUDED
11 
12 #include <unistd.h>
13 
14 #include "InputDevice.h"
15 #include "termios.h"
16 #define NB_DISABLE 0
17 #define NB_ENABLE 1
18 
23 typedef struct keys {
24  bool a;
25  bool s;
26  bool d;
27  bool w;
28  bool x;
29  bool q;
30 } key_states;
31 
36 class Keyboard : public InputDevice {
37  private:
38  key_states lastKeyStates = {false, false, false, false, false, false};
39  key_states currentKeyStates = {false, false, false, false, false, false};
41 
42  public:
50  Keyboard();
51  ~Keyboard();
56  key_states getStates();
61  void setKeys();
67  void updateInput();
72  void clearCurrentStates();
77  void printPressed();
78  // Returns true if the key is pressed.
83  bool getA();
88  bool getS();
93  bool getD();
98  bool getW();
103  bool getX();
108  bool getQ();
113  struct termios original, noecho;
114  char ch;
119  int kbhit();
124  void nonblock(int state);
129  int getKeyboardActive();
134  void setKeyboardActive(int value);
135 };
136 #endif
char ch
Definition: Keyboard.h:114
bool q
Definition: Keyboard.h:29
struct keys key_states
Struct listing the Keys which exist on a Keyboard.
Example InputDevice which takes input in from a keyboard. Useful for testing without any other input ...
Definition: Keyboard.h:36
bool d
Definition: Keyboard.h:26
Abstract class representing any input device to be used in a Robot object.
Definition: InputDevice.h:21
int keyboardActive
Definition: Keyboard.h:40
bool w
Definition: Keyboard.h:27
bool x
Definition: Keyboard.h:28
Struct listing the Keys which exist on a Keyboard.
Definition: Keyboard.h:23
bool a
Definition: Keyboard.h:24
bool s
Definition: Keyboard.h:25