feat(sim): long-press context menu + pixel-perfect real font rendering

Two prototype polish fixes ahead of the website embed work:

1. Holding Enter (the sim's main way into "the rest of the options") did
   nothing -- the JS bridge's sim_enqueue_key() went straight to
   enqueueKey(), bypassing UITask::handleLongPress() entirely, so
   KEY_CONTEXT_MENU could never be reached. Add injectSimKeyLongPress()/
   sim_enqueue_key_longpress(), which does route through the real
   handleLongPress() (same code a real MomentaryButton(pin, 1000, ...)
   reaches), and wire up press-and-hold (buttons + Enter/Space key) in both
   web harnesses with the same 1000ms threshold real hardware uses.

2. SimDisplayDriverCanvas::print() drew text with the browser's own system
   font (ctx.fillText, '8px monospace') instead of the real bitmap font a
   MeshCore-Solo board renders with OLED_MISC_FIXED_FONT=1 (see
   solo/heltec_v3/platformio.ini). Vendor the real Adafruit_GFX (unmodified,
   from the same PlatformIO registry package a real board build pulls) into
   variants/sim/thirdparty/gfx/, and render print() through the real,
   shared src/helpers/ui/MiscFixedRenderer.h + MiscFixedFont.h -- byte-
   identical glyphs to real hardware, not a look-alike.

Verified in a real Chromium (Playwright): short Enter -> "CLOCK TOOLS",
held Enter -> "CLOCK FIELDS" (gotoDashboardConfig(), proving
KEY_CONTEXT_MENU is really reached); font renders as hard square pixels,
inverse/selected-row text still punches correctly through a filled bar.
Full regression re-run clean: all 3 native envs, wasm companion_radio, and
the two-instance + repeater mesh demo (relay routing, DM delivery).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Jakub
2026-09-03 10:06:44 +02:00
co-authored by Claude Sonnet 5
parent 288a7d856b
commit 725e3b715e
14 changed files with 3765 additions and 35 deletions
+17 -1
View File
@@ -100,6 +100,7 @@ SRCS=(
variants/sim/thirdparty/crypto/SHA512.cpp
variants/sim/thirdparty/cayennelpp/CayenneLPP.cpp
variants/sim/thirdparty/cayennelpp/CayenneLPPPolyline.cpp
variants/sim/thirdparty/gfx/Adafruit_GFX.cpp
examples/companion_radio/main.cpp
examples/companion_radio/MyMesh.cpp
examples/companion_radio/DataStore.cpp
@@ -112,6 +113,7 @@ INCLUDES=(
-Ivariants/sim/thirdparty/crypto
-Ivariants/sim/thirdparty/cayennelpp
-Ivariants/sim/thirdparty/arduinojson
-Ivariants/sim/thirdparty/gfx
-Ilib/ed25519
-Isrc
-Iexamples/companion_radio
@@ -158,7 +160,21 @@ OBJS=()
for src in "${SRCS[@]}"; do
obj="$OBJ_DIR/${src%.*}.o"
mkdir -p "$(dirname "$obj")"
"$EMXX" -c "${COMMON_FLAGS[@]}" "$src" -o "$obj"
extra_flags=()
if [ "$src" = "variants/sim/thirdparty/gfx/Adafruit_GFX.cpp" ]; then
# Adafruit_GFX.h/.cpp branch on `#if ARDUINO >= 100` in exactly two spots
# (which Arduino.h to #include, and whether write(uint8_t) returns
# size_t or void) -- ARDUINO is deliberately never defined globally for
# this build (CayenneLPP.cpp/ArduinoJson branch on #ifdef ARDUINO to
# pick their portable std:: path instead of Arduino String/Stream), so
# this is scoped to just this one file's own compile, matching the same
# `#define ARDUINO 100` target.cpp does locally before its own
# #include <Adafruit_GFX.h> (see that file's comment) -- both need it so
# Adafruit_GFX's declaration (parsed by target.cpp) and its out-of-line
# definition (parsed here) agree on the same write(uint8_t) signature.
extra_flags=(-DARDUINO=100)
fi
"$EMXX" -c "${COMMON_FLAGS[@]}" ${extra_flags[@]+"${extra_flags[@]}"} "$src" -o "$obj"
OBJS+=("$obj")
done