Files
wadamesh/web/platform/WebM9Keyboard.cpp
Kaj SchittecatandClaude Opus 5.5 82238d3f7c web: ThinkNode M9 flavour of the host build for scripted d-pad tests
cmake -DWADA_HOST_BOARD=m9 compiles the M9's key path (HAS_M9_KEYBOARD: the
d-pad, the function keys, the Back ladder, the chat message walk) into the
host app on the web board, so M9 navigation runs headless with
--size 320x240 instead of only on a device. The rest stays the web board
(its caps, no SD). platform/WebM9Keyboard.cpp feeds the host keys in as the
controller's bytes.

Scripts: `key NAME [COUNT]` takes a raw byte (`key 0x81` = MSG) and a count
(several keys queued before one render, as on a busy device). The demo
backend takes WADA_DEMO_CHATTER_MS / WADA_DEMO_CHATTER_BURST so messages
arrive at known times.

UITask gates that named the board where they meant its keyboard now name
HAS_M9_KEYBOARD (keyboard backlight level, map pan, nav always on), the nav
globals and CAP_KEYPAD_NAV also take the host flavour, the M9 loop's
lock-screen service sits behind CAP_LOCK_SCREEN and the CardKB drain steps
aside for the M9 keys. Unchanged on every device build.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 10:14:01 +01:00

23 lines
1.0 KiB
C++

// SPDX-License-Identifier: GPL-3.0-or-later
// The ThinkNode M9 keyboard controller for the M9 flavour of the host build
// (cmake -DWADA_HOST_BOARD=m9). The controller hands the UI one byte per key: printable
// ASCII, or an M9_KEY_* sentinel for the d-pad and the function keys. The host keys
// arrive through the same ring the web board's CardKB path reads (WebKeyboard.cpp):
// Esc stands in for the BACK key, the arrows and Enter are already the M9's own bytes,
// and a script sends any other sentinel with `key 0x82` (HOME), `key 0xA3` (held OK), ...
#if defined(HAS_M9_KEYBOARD)
#include <M9Keyboard.h>
int cardKbReadKey(); // WebKeyboard.cpp: the host key ring
void m9KeyboardBegin() {}
void m9KeyboardPoll() {}
int m9KeyboardReadKey() {
const int k = cardKbReadKey();
if (k == 0x1B) return M9_KEY_HW_BACK;
return k & 0xFF; // the controller only ever sends one byte
}
bool m9KeyboardSetBacklight(uint8_t) { return true; }
uint8_t m9KeyboardAddr() { return 0x6C; }
void m9KeyboardSetFoundCallback(void (*cb)(uint8_t)) { if (cb) cb(0x6C); }
#endif