| 1 | 1 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,54 @@ |
| 1 |
+/* |
|
| 2 |
+ * Author: Pawel Jablonski |
|
| 3 |
+ * E-mail: pj@xirx.net |
|
| 4 |
+ * WWW: xirx.net |
|
| 5 |
+ * GIT: git.xirx.net |
|
| 6 |
+ * |
|
| 7 |
+ * License: You can use this code however you like |
|
| 8 |
+ * but leave information about the original author. |
|
| 9 |
+ * Code is free for non-commercial and commercial use. |
|
| 10 |
+ */ |
|
| 11 |
+ |
|
| 12 |
+#ifndef KEYBOARD_H |
|
| 13 |
+#define KEYBOARD_H |
|
| 14 |
+ |
|
| 15 |
+#include <QObject> |
|
| 16 |
+#include <QList> |
|
| 17 |
+ |
|
| 18 |
+//! This class contains keyboard functions |
|
| 19 |
+class Keyboard : public QObject |
|
| 20 |
+{
|
|
| 21 |
+ Q_OBJECT |
|
| 22 |
+ |
|
| 23 |
+ public: |
|
| 24 |
+ static const int KEY_ESC = 0x1b; //!< Escape key code |
|
| 25 |
+ static const int KEY_BACKSPACE = 0x08; //!< Backspace key code |
|
| 26 |
+ static const int KEY_TAB = 0x09; //!< Tab key code |
|
| 27 |
+ static const int KEY_ENTER = 0x0d; //!< Enter key code |
|
| 28 |
+ static const int KEY_DELETE = 0x7f; //!< Delete key code |
|
| 29 |
+ static const int KEY_UP = 0x11; //!< Up arrow key code |
|
| 30 |
+ static const int KEY_DOWN = 0x12; //!< Down arrow key code |
|
| 31 |
+ static const int KEY_LEFT = 0x13; //!< Left arrow key code |
|
| 32 |
+ static const int KEY_RIGHT = 0x14; //!< Right arrow key code |
|
| 33 |
+ |
|
| 34 |
+ static const int CTRL_MASK = 0x80; //!< Mask used to check if the control key is pressed too |
|
| 35 |
+ |
|
| 36 |
+ static const int MAX_CODE = 0x7f; //!< Maximum correctly key code |
|
| 37 |
+ static const int MIN_CODE = 0x20; //!< Minimum correctly key code |
|
| 38 |
+ |
|
| 39 |
+ Keyboard(QObject *parent = nullptr); |
|
| 40 |
+ |
|
| 41 |
+ void reset(); |
|
| 42 |
+ |
|
| 43 |
+ void keyPress(int key, Qt::KeyboardModifiers modifiers); |
|
| 44 |
+ |
|
| 45 |
+ unsigned char getKey(); |
|
| 46 |
+ |
|
| 47 |
+ private: |
|
| 48 |
+ QList<unsigned char> buffer; //!< Input key buffer |
|
| 49 |
+ |
|
| 50 |
+ signals: |
|
| 51 |
+ void dataReadySignal(bool ready); |
|
| 52 |
+}; |
|
| 53 |
+ |
|
| 54 |
+#endif |