CORC Project
CANOpen Robot Controller Software Documentation
Keyboard.h
Go to the documentation of this file.
1 
17 #ifndef KEYBOARD_H_INCLUDED
18 #define KEYBOARD_H_INCLUDED
19 
20 #include <unistd.h>
21 
22 #include "InputDevice.h"
23 #include "termios.h"
24 #define NB_DISABLE 0
25 #define NB_ENABLE 1
26 
31 typedef struct keys {
32  bool a;
33  bool s;
34  bool d;
35  bool w;
36  bool x;
37  bool q;
38 } key_states;
39 
44 class Keyboard : public InputDevice {
45  private:
46  key_states lastKeyStates = {false, false, false, false, false, false};
47  key_states currentKeyStates = {false, false, false, false, false, false};
49 
50  public:
58  Keyboard();
59  ~Keyboard();
64  key_states getStates();
69  void setKeys();
75  void updateInput();
80  void clearCurrentStates();
85  void printPressed();
86  // Returns true if the key is pressed.
91  bool getA();
96  bool getS();
101  bool getD();
106  bool getW();
111  bool getX();
116  bool getQ();
121  struct termios original, noecho;
122  char ch;
127  int kbhit();
132  void nonblock(int state);
137  int getKeyboardActive();
142  void setKeyboardActive(int value);
143 };
144 #endif
char ch
Definition: Keyboard.h:122
bool q
Definition: Keyboard.h:37
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:44
bool d
Definition: Keyboard.h:34
The Input class is a abstract class which represents an input device. The Update function is called i...
Abstract class representing any input device to be used in a Robot object.
Definition: InputDevice.h:23
int keyboardActive
Definition: Keyboard.h:48
bool w
Definition: Keyboard.h:35
bool x
Definition: Keyboard.h:36
Struct listing the Keys which exist on a Keyboard.
Definition: Keyboard.h:31
bool a
Definition: Keyboard.h:32
bool s
Definition: Keyboard.h:33