From 002f06a767c4d80787d691065d9a4f2a335898de Mon Sep 17 00:00:00 2001 From: Asura Date: Fri, 1 Jul 2022 00:16:08 -0700 Subject: [PATCH 1/3] fix: stupid bug, remove keycode_flag --- pynput_service.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pynput_service.py b/pynput_service.py index 3aa4f6175..dd12b7df8 100644 --- a/pynput_service.py +++ b/pynput_service.py @@ -33,6 +33,7 @@ DEAD_KEYS = { } + def my_keyboard_mapping(display): """Generates a mapping from *keysyms* to *key codes* and required modifier shift states. @@ -151,8 +152,8 @@ class MyController(Controller): try: with self.modifiers as modifiers: alt_gr = Key.alt_gr in modifiers - - if alt_gr or keycode_flag: + # !!!: Send_event can't support lock screen, this condition cann't be modified + if alt_gr: self.send_event( event, keycode, shift_state) else: From 9e8d8e43577ac28cd136b363a14bb7eaaf51e7b3 Mon Sep 17 00:00:00 2001 From: Asura Date: Mon, 4 Jul 2022 02:14:47 -0700 Subject: [PATCH 2/3] fix(pynput): Add dead key detection condition to support German keyboard --- pynput_service.py | 8 +++++--- src/ui/remote.rs | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/pynput_service.py b/pynput_service.py index dd12b7df8..c51e9a524 100644 --- a/pynput_service.py +++ b/pynput_service.py @@ -139,8 +139,10 @@ class MyController(Controller): else: keycode, shift_state = self._display.keysym_to_keycode(keysym), 0 - # The keycode of the dead key is inconsistent - if keycode != self._display.keysym_to_keycode(keysym): + keycode_set = set(map(lambda x: x[0], self.keyboard_mapping[keysym])) + # The keycode of the dead key is inconsistent, The keysym has multiple combinations of a keycode. + if keycode != self._display.keysym_to_keycode(keysym) \ + or (keycode_flag == False and keycode == list(keycode_set)[0] and len(keycode_set) == 1): deakkey_chr = str(key).replace("'", '') keysym = DEAD_KEYS[deakkey_chr] keycode, shift_state = self.keyboard_mapping[keysym][0] @@ -226,7 +228,7 @@ def loop(): else: keyboard.release(name) except Exception as e: - print(e) + print('[x] error key',e) loop() diff --git a/src/ui/remote.rs b/src/ui/remote.rs index a073b81c6..5917314ca 100644 --- a/src/ui/remote.rs +++ b/src/ui/remote.rs @@ -276,6 +276,7 @@ impl Handler { KeyRelease(k) => (k, 0), _ => return, }; + log::debug!("{:?}", key); let alt = get_key_state(enigo::Key::Alt); #[cfg(windows)] let ctrl = { From 80a41e2ecd80ab82830795bd2d1d101439c70f9f Mon Sep 17 00:00:00 2001 From: Asura <99897242+asur4s@users.noreply.github.com> Date: Mon, 4 Jul 2022 17:50:47 +0800 Subject: [PATCH 3/3] style: Remove key log --- src/ui/remote.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/ui/remote.rs b/src/ui/remote.rs index 2561f1d3e..96cca5301 100644 --- a/src/ui/remote.rs +++ b/src/ui/remote.rs @@ -276,7 +276,6 @@ impl Handler { KeyRelease(k) => (k, 0), _ => return, }; - log::debug!("{:?}", key); let alt = get_key_state(enigo::Key::Alt); #[cfg(windows)] let ctrl = {