M5Unit-KEYBOARD 0.1.0 git rev:b58d024
Loading...
Searching...
No Matches
hid_keycode.cpp File Reference

HID Usage ID → ASCII translation tables (US ANSI layout) More...

#include "hid_keycode.hpp"
#include <cctype>

Namespaces

namespace  m5
 Top level namespace of M5Stack.
 

Functions

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)
 
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)
 

Detailed Description

HID Usage ID → ASCII translation tables (US ANSI layout)

Function Documentation

◆ 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
keycodeHID Usage ID per USB HID spec Keyboard/Keypad Page 0x07
modifierHID modifier byte. Bit 1 (0x02) = Left Shift, Bit 5 (0x20) = Right Shift. Other bits (Ctrl/Alt/GUI) are ignored.
Return values
!=0ASCII character (printable or whitespace)
0Not 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
keycodeHID Usage ID
modifierHID modifier byte
Return values
trueSuitable for direct c display
falseEither not translatable or non-printable control character