In development. It changes without notice.
Topic
HID Profiles & Keyboard Tables
From text to key presses: the typer, the codes of the keys, and the accented letters each keyboard layout can type.
kleidos::
The layout must be the one the computer uses: a keyboard sends keys, and the computer decides which letter each is.
- See also
- BLE Facade & HID Manager, BLE Types
Files | |
| file | src/ |
| What the Battery Level characteristic serves, and when it notifies. | |
| file | src/ |
| Pure HID Boot Protocol report helpers (transport-agnostic). | |
| file | src/ |
| A burst typed as the host will read it: its Caps Lock off, its HID protocol held, every key lifted when it ends early. | |
| file | src/ |
| One keystroke on the air: a press, its release, and what happens when the release cannot go out. | |
| file | src/ |
| Static definition of the BLE HID keyboard profile. | |
| file | src/ |
| Shared HID keyboard scancodes and modifier bits. | |
| file | src/ |
| Pure UTF-8 → HID report typer, independent of any transport. | |
| file | src/ |
Abstract HID report sink decoupling HidTyper from any transport. | |
| file | src/ |
| Per-layout Latin-1 codepoint → HID keystroke tables. | |
Typedefs | |
| using | kleidos:: |
| One 8-byte keyboard input report. | |
Functions | |
| constexpr uint8_t | kleidos:: |
| The byte the Battery Level characteristic serves for a sample. | |
| constexpr bool | kleidos:: |
| Whether the Battery Level may be notified on the host's link now. | |
| constexpr std::array< uint8_t, kBootKeyboardReportSize > | kleidos:: |
| Build the fixed 8-byte HID boot keyboard input report. | |
| constexpr ReportPath | kleidos:: |
| Decide which characteristic a keystroke should be notified on. | |
| constexpr ProtocolModeWrite | kleidos:: |
| Judge a host's write to Protocol Mode before anything is stored. | |
| constexpr bool | kleidos:: |
| Whether a write to a keyboard Output Report carries the LED byte. | |
| constexpr bool | kleidos:: |
| Whether the host's LED byte says its Caps Lock is on. | |
| bool | kleidos:: |
Send one key through sink, lifting every key if it fails. | |
| PaceVerdict | kleidos:: |
| Whether a press may go out now. | |
| PacedStep | kleidos:: |
| One try at a keystroke that waits for its transmit buffers. | |
| template<typename Attempt, typename Wait> | |
| PacedStep | kleidos:: |
| Try a keystroke until it goes out, fails, or gives up. | |
| constexpr bool | kleidos:: |
| Whether a burst that ends early owes the host an all-zero report. | |
| KeystrokeOutcome | kleidos:: |
| Send one keystroke and leave no key held. | |
| KeystrokeOutcome | kleidos:: |
| Send one all-zero report, as a release is sent: retried, else the link ends. | |
| Latin1Table | kleidos:: |
Returns the Latin-1 table for the given layout, or {nullptr, 0} if no extra coverage is provided (US default — falls back to printable-ASCII only). | |
Variables | |
| constexpr uint8_t | kleidos:: |
| Highest value the Battery Level characteristic carries, in percent. | |
| constexpr uint8_t | kleidos:: |
| constexpr uint8_t | kleidos:: |
| HOGP Protocol Mode value for Boot Protocol (host wrote 0x00 to 0x2A4E). | |
| constexpr uint8_t | kleidos:: |
| HOGP Protocol Mode value for Report Protocol (default; host wrote 0x01). | |
| constexpr std::size_t | kleidos:: |
| Fixed size of a boot keyboard report: [modifier][reserved][keycode×6]. | |
| constexpr std::size_t | kleidos:: |
| Size of the keyboard LED output report the host writes: one byte of LED bits. | |
| constexpr uint8_t | kleidos:: |
| constexpr uint32_t | kleidos:: |
| How long the host has to confirm, in its LED byte, a Caps Lock keystroke. | |
| constexpr uint32_t | kleidos:: |
| How often the LED byte is looked at while waiting for that confirmation. | |
| constexpr uint32_t | kleidos:: |
| How long a key is held, from its press to its release. | |
| constexpr KeystrokePacing | kleidos:: |
| constexpr uint8_t | kleidos:: |
| 'a' — base of the letter range. | |
| constexpr uint8_t | kleidos:: |
| '1' — base of the digit range. | |
| constexpr uint8_t | kleidos:: |
| '0'. | |
| constexpr uint8_t | kleidos:: |
| Return / Enter. | |
| constexpr uint8_t | kleidos:: |
| Escape. | |
| constexpr uint8_t | kleidos:: |
| Backspace. | |
| constexpr uint8_t | kleidos:: |
| Tab. | |
| constexpr uint8_t | kleidos:: |
| Space. | |
| constexpr uint8_t | kleidos:: |
| Caps Lock (toggles the host's lock). | |
| constexpr uint8_t | kleidos:: |
| Left Ctrl. | |
| constexpr uint8_t | kleidos:: |
| Left Shift. | |
| constexpr uint8_t | kleidos:: |
| Left Alt. | |
| constexpr uint8_t | kleidos:: |
| Left GUI (Win/Cmd). | |
| constexpr uint8_t | kleidos:: |
| Right Ctrl. | |
| constexpr uint8_t | kleidos:: |
| Right Shift. | |
| constexpr uint8_t | kleidos:: |
| Right Alt (AltGr). | |
| constexpr uint8_t | kleidos:: |
| Right GUI (Win/Cmd). | |
Enumeration Type Documentation
BurstAbort #
BurstStart #
KeystrokeOutcome #
How a keystroke ended.
PacedStep #
How one try at a paced keystroke ended.
PaceVerdict #
ProtocolModeWrite #
ReportPath #
TypingOutcome #
Function Documentation
batteryNotifyAllowed() #
Whether the Battery Level may be notified on the host's link now.
Only the connected host, subscribed, on the link its pairing secured: the same bar a keystroke meets (security:: encrypted, MITM-authenticated, bonded, 16-byte key). A link short of it is sent nothing, whatever its subscription says.
- Parameters
-
Name Direction Meaning subscribed in The host enabled notifications on the CCCD. connected in A host's link is up. encrypted in The link is encrypted. authenticated in The pairing was MITM-authenticated. bonded in The host is bonded. keySize in The link's encryption key length, in bytes.
- Return values
-
Value Meaning true The level may go out on this link. false Send nothing.
buildBootKeyboardReport() #
Build the fixed 8-byte HID boot keyboard input report.
The boot keyboard report is [modifier][reserved=0][keycode][0×5]: a single key plus modifiers, with the reserved byte fixed at 0 and the remaining five key slots empty (we type one keycode at a time, matching the report-protocol path). A zero keycode with zero modifiers yields the all-zero "release" report.
- Parameters
-
Name Direction Meaning modifiers in Modifier bitmap (LeftCtrl … RightGUI). keycode in HID usage ID for the pressed key (0 = none / release).
- Returns
- The 8-byte boot keyboard report.
capsLockOn() #
Whether the host's LED byte says its Caps Lock is on.
- Parameters
-
Name Direction Meaning leds in The LED byte the host last wrote on this link (0 when it wrote none: a HID keyboard's LEDs start off, and a host writes them when it has one on).
- Return values
-
Value Meaning true Caps Lock is on.
checkProtocolModeWrite() #
Judge a host's write to Protocol Mode before anything is stored.
HOGP defines the value as one byte, 0x00 (Boot) or 0x01 (Report); anything else is refused and leaves the mode the host last chose (finding C32).
- Parameters
-
Name Direction Meaning data in The written bytes (may be null when lenis 0).len in How many bytes the host wrote.
- Returns
- Whether the write is stored, and why not.
getLatin1Table() #
Returns the Latin-1 table for the given layout, or {nullptr, 0} if no extra coverage is provided (US default — falls back to printable-ASCII only).
- Parameters
-
Name Meaning layout Keyboard layout identifier.
- Returns
- Lightweight view over the sorted
Latin1Entryarray forlayout.
keystrokeStep() #
One try at a keystroke that waits for its transmit buffers.
Looks at the free buffers (paceVerdict), then sends the keystroke; a press whose two buffers cannot be taken counts as a wait, never as a failure, since nothing went out and no key is held.
- Parameters
-
Name Direction Meaning link in, out The notify path. modifiers in Modifier byte of the press. keycode in HID usage of the press. waitedMs in How long this keystroke has waited already. pacing in Timing and bounds.
- Returns
- How the try ended.
ledWriteValid() #
Whether a write to a keyboard Output Report carries the LED byte.
The Output Report (report protocol) and the Boot Keyboard Output Report both carry one byte of LED bits; a write of any other length is refused and the LED state the host last wrote is kept.
- Parameters
-
Name Direction Meaning len in How many bytes the host wrote.
- Return values
-
Value Meaning true The write is the LED byte. false It is not; nothing is stored.
liftAllKeys() #
Send one all-zero report, as a release is sent: retried, else the link ends.
What a burst that ends early sends while its link is up, so the last report the host saw is all-zero whatever the burst was doing.
- Parameters
-
Name Direction Meaning link in, out The notify path. pacing in The release bounds.
- Returns
Sent, orLinkDropped.
liftOwed() #
Whether a burst that ends early owes the host an all-zero report.
Every keystroke ends with its release queued, or with the link ended, on the characteristic it went to; so a key can be held only on a characteristic other than the one the last report went to, that is when the host switched Protocol Mode between a press and its release. Anything else is lifted already, and an all-zero report would only cost a buffer that may be short.
- Parameters
-
Name Direction Meaning targetAttr in The input report a keystroke would go to now. lastReportAttr in The input report the last report on this link went to; 0 when none went out.
- Return values
-
Value Meaning true Send the all-zero report on targetAttr.false No key can be held.
paceVerdict() #
Whether a press may go out now.
- Parameters
-
Name Direction Meaning freeBuffers in The stack's free transmit buffers. waitedMs in How long this press has waited already. pacing in The bounds.
- Returns
- The verdict.
runPacedKeystroke() #
Try a keystroke until it goes out, fails, or gives up.
The adapter runs each try under the host lock and waits between them outside it, so a teardown never waits on a paced keystroke.
- Template Parameters
-
Name Meaning Attempt Callable (uint32_t waitedMs) ->PacedStep:one try.Wait Callable (uint32_t ms): the wait between two tries.
- Parameters
-
Name Direction Meaning attempt in One try. wait in The wait. pacing in Timing and bounds.
- Returns
- The step that ended it: never
Wait.
selectReportPath() #
Decide which characteristic a keystroke should be notified on.
Report Protocol (the default and the common phone/PC case) routes to the Report characteristic; Boot Protocol routes to the Boot Keyboard Input Report characteristic. Any unexpected mode value is treated as Report Protocol so a malformed Protocol Mode write can never silently divert typing away from the default path.
- Parameters
-
Name Direction Meaning protocolMode in The last value the host wrote to Protocol Mode (0x2A4E).
- Returns
- The report path to use for this keystroke.
sendKey() #
Send one key through sink, lifting every key if it fails.
For the keys a burst sends outside the typer (Tab between the fields, Return after them).
- Parameters
-
Name Direction Meaning sink in, out The sink. modifiers in Modifier byte. scancode in HID usage.
- Return values
-
Value Meaning true It went out. false It did not; releaseAll()was sent.
sendKeystroke() #
Send one keystroke and leave no key held.
- Parameters
-
Name Direction Meaning link in, out The notify path. modifiers in Modifier byte of the press. keycode in HID usage of the press. pacing in Timing and bounds.
- Returns
- How it ended.
servedBatteryLevel() #
The byte the Battery Level characteristic serves for a sample.
- Parameters
-
Name Direction Meaning known in The battery sampler holds a good reading. percent in That reading's charge estimate, in percent.
- Returns
percentclamped to 0..100, or kBatteryLevelUnknown when no good reading exists.
Variable Documentation
kBatteryLevelUnknown #
What the characteristic serves while no good reading exists: full, so a host raises no low-battery warning from a reading that was never taken.
kHidLedCapsLock #
Bit of the LED output byte (HID usage page 0x08, usage 0x02) the host sets while its Caps Lock is on.
kKeystrokePacing #
The device's keystroke: an 8 ms hold; a press waits for six free buffers (two notifications of two buffers each, and room for what the host sends meanwhile) for up to 5 s, past one connection event at the longest interval a central sets in practice (4 s); four tries at a release 20 ms apart.