Tests updated. Attempt to fix remaining problems with forward keypress and numlock reporting.
This commit is contained in:
@@ -28,15 +28,21 @@ class command:
|
||||
# Only announce numlock changes if an actual numlock key was pressed
|
||||
# AND the LED state actually changed (some numpads send spurious NUMLOCK events)
|
||||
current_input = self.env["input"]["curr_input"]
|
||||
previous_input = self.env["input"]["prev_input"]
|
||||
relevant_input = current_input or previous_input
|
||||
|
||||
# Check if this is a genuine numlock key press by verifying:
|
||||
# 1. KEY_NUMLOCK is in the current input sequence
|
||||
# 2. The LED state has actually changed
|
||||
# 3. This isn't just a side effect from a KP_ key (which some buggy numpads do)
|
||||
is_genuine_numlock = (
|
||||
current_input and
|
||||
"KEY_NUMLOCK" in current_input and
|
||||
not any(key.startswith("KEY_KP") for key in current_input if isinstance(key, str))
|
||||
relevant_input and
|
||||
"KEY_NUMLOCK" in relevant_input and
|
||||
not any(
|
||||
key.startswith("KEY_KP")
|
||||
for key in relevant_input
|
||||
if isinstance(key, str)
|
||||
)
|
||||
)
|
||||
|
||||
if is_genuine_numlock:
|
||||
|
||||
@@ -302,6 +302,35 @@ class driver(screenDriver):
|
||||
return
|
||||
self.env["runtime"]["OutputManager"].interrupt_output()
|
||||
|
||||
def handle_stdin_input(self, msg_bytes, event_queue):
|
||||
if self.synthesize_backspace_shortcut(msg_bytes, event_queue):
|
||||
return
|
||||
self.interrupt_output_on_stdin_input(msg_bytes)
|
||||
self.inject_text_to_screen(msg_bytes)
|
||||
|
||||
def synthesize_backspace_shortcut(self, msg_bytes, event_queue):
|
||||
if msg_bytes not in [b"\x7f", b"\x08"]:
|
||||
return False
|
||||
if "KEY_FENRIR" not in self.env["input"]["curr_input"]:
|
||||
return False
|
||||
|
||||
event_time = time.time()
|
||||
for event_state in [1, 0]:
|
||||
event_queue.put(
|
||||
{
|
||||
"Type": FenrirEventType.keyboard_input,
|
||||
"data": {
|
||||
"event_name": "KEY_BACKSPACE",
|
||||
"event_value": 0,
|
||||
"event_sec": int(event_time),
|
||||
"event_usec": int((event_time % 1) * 1000000),
|
||||
"event_state": event_state,
|
||||
"event_type": 0,
|
||||
},
|
||||
}
|
||||
)
|
||||
return True
|
||||
|
||||
def get_session_information(self):
|
||||
self.env["screen"]["autoIgnoreScreens"] = []
|
||||
self.env["general"]["prev_user"] = getpass.getuser()
|
||||
@@ -434,8 +463,7 @@ class driver(screenDriver):
|
||||
)
|
||||
break
|
||||
try:
|
||||
self.interrupt_output_on_stdin_input(msg_bytes)
|
||||
self.inject_text_to_screen(msg_bytes)
|
||||
self.handle_stdin_input(msg_bytes, event_queue)
|
||||
except Exception as e:
|
||||
self.env["runtime"][
|
||||
"DebugManager"
|
||||
|
||||
Reference in New Issue
Block a user