Rebuild the PicoCalc F-key lane per JP's spec: five fixed 9-cell chips (F1 DESCRI, "10" standing in for the overflow F10 label), gray fill on the plain F1-F5 bank and green while Shift's bank is showing, white text on both. DEFAULT_LANE moves to an adjacent-plain-key priority model: commit/leave take the easiest- to-reach F4/F5 with no Shift needed, jump-to-top/end take F1/F2 with paging as their Shift companions, and F3 stays the one lone slot a screen's own lane reaches for first. FPair's Shift half is now optional, so a lone slot renders blank in the shifted bank instead of forcing an unrelated opposite action onto it. Also bridges the on-device quirk where the MCU's F6-F10 translation can appear to release Shift an instant before the translated code lands, flipping the lane back mid-chord: modifier_watch now latches shift_down() true for a short grace window after any F6-F10 press resolves, on top of the raw watcher state. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
42 lines
1.3 KiB
Python
42 lines
1.3 KiB
Python
"""The F-key lane's Shift-state watcher: the raw flag and the shift-bank latch."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from meshterm.services import modifier_watch
|
|
|
|
|
|
def _reset() -> None:
|
|
modifier_watch._shift_down = False
|
|
modifier_watch._last_shift_bank_at = None
|
|
|
|
|
|
def test_shift_down_reflects_the_raw_flag() -> None:
|
|
_reset()
|
|
try:
|
|
assert modifier_watch.shift_down() is False
|
|
modifier_watch._shift_down = True
|
|
assert modifier_watch.shift_down() is True
|
|
finally:
|
|
_reset()
|
|
|
|
|
|
def test_shift_bank_key_latches_over_the_release_flicker(monkeypatch) -> None:
|
|
"""An F6-F10 press keeps the lane's shifted read for a grace window, even if the raw
|
|
watcher (wrongly, per the MCU quirk) reports Shift already back up."""
|
|
_reset()
|
|
try:
|
|
clock = [100.0]
|
|
monkeypatch.setattr(modifier_watch.time, "monotonic", lambda: clock[0])
|
|
|
|
assert modifier_watch.shift_down() is False
|
|
modifier_watch.note_shift_bank_key()
|
|
assert modifier_watch.shift_down() is True # latched, raw flag never went true
|
|
|
|
clock[0] += modifier_watch._SHIFT_BANK_GRACE_S - 0.05
|
|
assert modifier_watch.shift_down() is True # still inside the grace window
|
|
|
|
clock[0] += 0.1
|
|
assert modifier_watch.shift_down() is False # grace lapsed, Shift really let go
|
|
finally:
|
|
_reset()
|