mirror of
https://github.com/MCKero6423/uv-k5-v3-emulator.git
synced 2026-10-02 03:15:36 +00:00
Rejects unknown names in the server rather than letting them reach QMP as an error. A test parses keypad_key_names out of qemu/py32f071.c and fails if the lists drift, so adding a key to the model cannot silently leave the web UI behind. PTT is deliberately absent: the model wires it separately on GPIOC, so the press property rejects the name.
25 lines
692 B
Python
25 lines
692 B
Python
#!/usr/bin/env python3
|
|
"""Key names the keypad model accepts.
|
|
|
|
Mirrors keypad_key_names in qemu/py32f071.c. test_uvk5_keys.py parses that array
|
|
out of the model source and fails if the two drift apart.
|
|
|
|
PTT is absent on purpose: the keypad model has no PTT line -- it is wired
|
|
separately on GPIOC -- so the "press" property rejects the name. Offering a PTT
|
|
button would produce a QMP error rather than a transmission.
|
|
"""
|
|
|
|
KEYS = (
|
|
"MENU", "UP", "DOWN", "EXIT", "F", "STAR",
|
|
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
|
|
"SIDE1", "SIDE2",
|
|
)
|
|
|
|
|
|
def normalise(name) -> str:
|
|
return (name or "").strip().upper()
|
|
|
|
|
|
def is_valid(name) -> bool:
|
|
return normalise(name) in KEYS
|