From b40c6155838c50770491b099e7f561305c2fbeb4 Mon Sep 17 00:00:00 2001 From: Khoa Vo Date: Fri, 26 Jun 2026 16:23:04 +0700 Subject: [PATCH] fix: Enter key not sent via uinput, add send_enter helper MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - \n char had no keycode mapping — now sends KEY_ENTER via uinput - Fixed in both ASCII path and trailing-ASCII-after-unicode path - Enter now works on single press (was being silently consumed) --- protocol/src/uinput_monitor.rs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/protocol/src/uinput_monitor.rs b/protocol/src/uinput_monitor.rs index d6d4d2f..3e2f3b1 100644 --- a/protocol/src/uinput_monitor.rs +++ b/protocol/src/uinput_monitor.rs @@ -124,6 +124,15 @@ impl KeyInjector for UinputInjector { InjectResult::Success } + fn send_enter(&self) { + self.send_uinput_event(EV_KEY, 28, 1); // KEY_ENTER press + self.send_uinput_event(0, 0, 0); + std::thread::sleep(std::time::Duration::from_millis(2)); + self.send_uinput_event(EV_KEY, 28, 0); + self.send_uinput_event(0, 0, 0); + std::thread::sleep(std::time::Duration::from_millis(2)); + } + fn send_key_event(&self, keycode: u16, value: i32) -> InjectResult { self.send_uinput_event(EV_KEY, keycode, value); self.send_uinput_event(0, 0, 0); @@ -348,7 +357,11 @@ impl UinputInjector { } } for ch in text.chars() { - let _ = self.send_char(ch); + if ch == '\n' { + self.send_enter(); + } else { + let _ = self.send_char(ch); + } } return InjectResult::Success; } @@ -385,7 +398,9 @@ impl UinputInjector { if !ascii_tail.is_empty() { std::thread::sleep(std::time::Duration::from_millis(15)); for ch in ascii_tail.chars() { - if let Some(kc) = char_to_linux_keycode(ch) { + if ch == '\n' { + self.send_enter(); + } else if let Some(kc) = char_to_linux_keycode(ch) { self.send_key_stroke(kc, false); } }