diff options
author | Maxim Devaev <[email protected]> | 2022-07-22 09:14:49 +0300 |
---|---|---|
committer | Maxim Devaev <[email protected]> | 2022-07-22 09:14:49 +0300 |
commit | 3a9b43300081fb5e54e0996e2cdd2ae24a8496c7 (patch) | |
tree | 6f5b20fa28a49d9837ba4045713f0b5dd3e1b30f /hid/lib/drivers-stm32/usb/keyboard-stm32.h | |
parent | d3dbf19399c09399fce96d5303fe684d2aeb1150 (diff) |
stm32 hid cleanup
Diffstat (limited to 'hid/lib/drivers-stm32/usb/keyboard-stm32.h')
-rw-r--r-- | hid/lib/drivers-stm32/usb/keyboard-stm32.h | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/hid/lib/drivers-stm32/usb/keyboard-stm32.h b/hid/lib/drivers-stm32/usb/keyboard-stm32.h index b788be19..be8c7bd1 100644 --- a/hid/lib/drivers-stm32/usb/keyboard-stm32.h +++ b/hid/lib/drivers-stm32/usb/keyboard-stm32.h @@ -19,16 +19,18 @@ # # *****************************************************************************/ + #pragma once +#include <USBComposite.h> + +#include "tools.h" #include "keyboard.h" #include "hid-wrapper-stm32.h" -#include <USBComposite.h> #include "keymap.h" -#include "tools.h" -namespace DRIVERS { +namespace DRIVERS { const uint8_t reportDescriptionKeyboard[] = { HID_KEYBOARD_REPORT_DESCRIPTOR(), }; @@ -51,25 +53,30 @@ namespace DRIVERS { void sendKey(uint8_t code, bool state) override { uint16_t usb_code = keymapUsb(code); - if (usb_code == KEY_ERROR_UNDEFINED) { + if (usb_code == 0) { return; } - if(usb_code >= KEY_LEFT_CTRL && usb_code <= KEY_RIGHT_WINDOWS) { - usb_code = usb_code - KEY_LEFT_CTRL + 0x80; + // 0xE0 is a prefix from HID-Project keytable + if (usb_code >= 0xE0 && usb_code <= 0xE7) { + usb_code = usb_code - 0xE0 + 0x80; } else { usb_code += KEY_HID_OFFSET; } - state ? _keyboard.press(usb_code) : _keyboard.release(usb_code); + if (state) { + _keyboard.press(usb_code); + } else { + _keyboard.release(usb_code); + } } bool isOffline() override { - return USBComposite == false; + return (USBComposite == false); } KeyboardLedsState getLeds() override { - uint8 leds = _keyboard.getLEDs(); + uint8_t leds = _keyboard.getLEDs(); KeyboardLedsState result = { .caps = leds & 0b00000010, .scroll = leds & 0b00000100, @@ -81,6 +88,5 @@ namespace DRIVERS { private: HidWrapper& _hidWrapper; HIDKeyboard _keyboard; - static constexpr uint8 KEY_ERROR_UNDEFINED = 3; }; } |