From e342e0d4dd0de356d7114cb4d0aead40d3d5b17f Mon Sep 17 00:00:00 2001 From: Kevin F Date: Sun, 5 Mar 2023 19:51:45 -0600 Subject: [PATCH] Add backlog --- server/Sendkeys.md | 3 +++ tools/RawCapture.md | 11 ++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/server/Sendkeys.md b/server/Sendkeys.md index 4b7c96b..81988d6 100644 --- a/server/Sendkeys.md +++ b/server/Sendkeys.md @@ -12,6 +12,9 @@ if strings.HasPrefix(message_string, "{KEYDWN}") { } else if strings.HasPrefix(message_string, "{KEYUP}") { key = strings.TrimPrefix(string(message_string), "{KEYUP}") k.Write(0, key) +} else if strings.HasPrefix(message_string, "{KEYHLD}") { + key = strings.TrimPrefix(string(message_string), "{KEYHLD}") + k.Write(2, key) } else{ for _, key := range message_string { // write once will simulate keyboard press/release, for long press or release, lookup at Write diff --git a/tools/RawCapture.md b/tools/RawCapture.md index 8e97390..26de2ac 100644 --- a/tools/RawCapture.md +++ b/tools/RawCapture.md @@ -70,14 +70,20 @@ print("Enter numbers, press enter (Ctrl-C to exit).") write_queue = queue.Queue() def write_loop(): + backlog = [] while True: try: + while backlog: + with open(fifo, "w") as f: + f.write(backlog.pop(0)) + data = write_queue.get() with open(fifo, "w") as f: f.write(data) except Exception as e: print("Error writing to fifo: " + str(e)) traceback.print_exc() + backlog write_thread = threading.Thread(target=write_loop, daemon=True) write_thread.start() @@ -231,7 +237,8 @@ try: for event in device.read_loop(): if event.type == evdev.ecodes.EV_KEY: - print(event) + if event: + print(event) #e_code = event.code - 1 e_code = event.code @@ -245,6 +252,8 @@ try: quit_if_necessry(log) elif event.value == 0: key_str = "{KEYUP}" + key_str + elif event.value == 2: + key_str = "{KEYHLD}" + key_str else: print("Unknown value: " + str(event.value)) continue