diff options
author | tomaszduda23 <[email protected]> | 2022-07-10 04:43:54 +0900 |
---|---|---|
committer | GitHub <[email protected]> | 2022-07-09 22:43:54 +0300 |
commit | 38fae01cc01a0e984f52c004ade79256d8c90e17 (patch) | |
tree | fca48f9a0208aa5c0d79ed7f1da012b285d18025 /hid/lib/drivers | |
parent | 793edf8203ec7ea5aba934558ea26054628a5618 (diff) |
add keyboard interface (#95)
Diffstat (limited to 'hid/lib/drivers')
-rw-r--r-- | hid/lib/drivers/driver.h | 27 | ||||
-rw-r--r-- | hid/lib/drivers/keyboard.h | 42 | ||||
-rw-r--r-- | hid/lib/drivers/mouse.h | 6 |
3 files changed, 55 insertions, 20 deletions
diff --git a/hid/lib/drivers/driver.h b/hid/lib/drivers/driver.h index 520c7456..ea209c2e 100644 --- a/hid/lib/drivers/driver.h +++ b/hid/lib/drivers/driver.h @@ -25,18 +25,21 @@ namespace DRIVERS { - enum type { - USB_MOUSE_ABSOLUTE, - USB_MOUSE_RELATIVE, - USB_MOUSE_ABSOLUTE_WIN98, - }; + enum type { + DUMMY = 0, + USB_MOUSE_ABSOLUTE, + USB_MOUSE_RELATIVE, + USB_MOUSE_ABSOLUTE_WIN98, + USB_KEYBOARD, + PS2_KEYBOARD, + }; - class Driver { - public: - Driver(type _type) : _type(_type) {} - uint8_t getType() { return _type; } + class Driver { + public: + Driver(type _type) : _type(_type) {} + uint8_t getType() { return _type; } - private: - type _type; - }; + private: + type _type; + }; } diff --git a/hid/lib/drivers/keyboard.h b/hid/lib/drivers/keyboard.h index 44ffe61a..39517f68 100644 --- a/hid/lib/drivers/keyboard.h +++ b/hid/lib/drivers/keyboard.h @@ -26,9 +26,41 @@ namespace DRIVERS { - typedef struct { - bool caps; - bool scroll; - bool num; - } KeyboardLedsState; + typedef struct { + bool caps; + bool scroll; + bool num; + } KeyboardLedsState; + + + struct Keyboard : public Driver { + using Driver::Driver; + + virtual void begin() {} + + /** + * Release all keys + */ + virtual void clear() {} + + /** + * Sends key + * @param code ??? + * @param state true pressed, false released + */ + virtual void sendKey(uint8_t code, bool state) {} + + virtual void periodic() {} + + /** + * False if online or unknown. Otherwise true. + */ + virtual bool isOffline() { return false; } + + virtual KeyboardLedsState getLeds() { + KeyboardLedsState result = {}; + return result; + } + + }; } diff --git a/hid/lib/drivers/mouse.h b/hid/lib/drivers/mouse.h index 8f76b041..3ec29ee9 100644 --- a/hid/lib/drivers/mouse.h +++ b/hid/lib/drivers/mouse.h @@ -26,7 +26,7 @@ namespace DRIVERS { - class Mouse : public Driver { - using Driver::Driver; - }; + class Mouse : public Driver { + using Driver::Driver; + }; } |