HID Usage Code (Keyboard Page 0x07) → ASCII char translator (US ANSI layout)
More...
#include <cstdint>
Go to the source code of this file.
|
| namespace | m5 |
| | Top level namespace of M5Stack.
|
| |
HID Usage Code (Keyboard Page 0x07) → ASCII char translator (US ANSI layout)
◆ hidUsageToChar()
| char m5::unit::tab5_keyboard::hidUsageToChar |
( |
const uint8_t | keycode, |
|
|
const uint8_t | modifier ) |
Translate HID Usage Code + modifier to ASCII character (US ANSI layout)
- Parameters
-
| keycode | HID Usage ID per USB HID spec Keyboard/Keypad Page 0x07 |
| modifier | HID modifier byte. Bit 1 (0x02) = Left Shift, Bit 5 (0x20) = Right Shift. Other bits (Ctrl/Alt/GUI) are ignored. |
- Return values
-
| !=0 | ASCII character (printable or whitespace) |
| 0 | Not translatable (modifier-only keys, F-keys, navigation, invalid) |
- Note
- Caps Lock state is NOT tracked here; caller is responsible if needed.
-
US ANSI layout only. JIS / DE / FR layouts unsupported.
-
Covers HID Usage IDs 0x04..0x38 (letters, digits, common symbols, whitespace).
◆ isPrintableHidKey()
| bool m5::unit::tab5_keyboard::isPrintableHidKey |
( |
const uint8_t | keycode, |
|
|
const uint8_t | modifier ) |
Convenience: returns true if hidUsageToChar result is printable ASCII (0x20-0x7E)
- Parameters
-
| keycode | HID Usage ID |
| modifier | HID modifier byte |
- Return values
-
| true | Suitable for direct c display |
| false | Either not translatable or non-printable control character |