Fix numpad rod mapping on terminals without keypad constants
This commit is contained in:
@@ -17,17 +17,29 @@ from .state import PlantState
|
|||||||
|
|
||||||
LOGGER = logging.getLogger(__name__)
|
LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
_NUMPAD_ROD_KEYS = {
|
|
||||||
curses.KEY_C1: 0.1, # numpad 1
|
def _build_numpad_mapping() -> dict[int, float]:
|
||||||
curses.KEY_C2: 0.2, # numpad 2
|
# Use keypad matrix constants when available; skip missing ones to avoid import errors on some terminals.
|
||||||
curses.KEY_C3: 0.3, # numpad 3
|
mapping: dict[int, float] = {}
|
||||||
curses.KEY_B1: 0.4, # numpad 4
|
table = {
|
||||||
curses.KEY_B2: 0.5, # numpad 5
|
"KEY_C1": 0.1, # numpad 1
|
||||||
curses.KEY_B3: 0.6, # numpad 6
|
"KEY_C2": 0.2, # numpad 2
|
||||||
curses.KEY_A1: 0.7, # numpad 7
|
"KEY_C3": 0.3, # numpad 3
|
||||||
curses.KEY_A2: 0.8, # numpad 8
|
"KEY_B1": 0.4, # numpad 4
|
||||||
curses.KEY_A3: 0.9, # numpad 9
|
"KEY_B2": 0.5, # numpad 5
|
||||||
|
"KEY_B3": 0.6, # numpad 6
|
||||||
|
"KEY_A1": 0.7, # numpad 7
|
||||||
|
"KEY_A2": 0.8, # numpad 8
|
||||||
|
"KEY_A3": 0.9, # numpad 9
|
||||||
}
|
}
|
||||||
|
for name, value in table.items():
|
||||||
|
code = getattr(curses, name, None)
|
||||||
|
if code is not None:
|
||||||
|
mapping[code] = value
|
||||||
|
return mapping
|
||||||
|
|
||||||
|
|
||||||
|
_NUMPAD_ROD_KEYS = _build_numpad_mapping()
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
|
|||||||
Reference in New Issue
Block a user