From 422dadfef38652273f8a1ef1f918c674ddb9d749 Mon Sep 17 00:00:00 2001 From: sjpark Date: Sat, 29 Oct 2022 14:37:20 +0900 Subject: [PATCH] windows extended key input --- src/server/input_service.rs | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/src/server/input_service.rs b/src/server/input_service.rs index 27de001e4..ac2293e6a 100644 --- a/src/server/input_service.rs +++ b/src/server/input_service.rs @@ -640,17 +640,8 @@ fn sync_status(evt: &KeyEvent) -> (bool, bool) { || (!caps_locking && en.get_key_state(enigo::Key::CapsLock)); let click_numlock = (num_locking && !en.get_key_state(enigo::Key::NumLock)) || (!num_locking && en.get_key_state(enigo::Key::NumLock)); - return (click_capslock, click_numlock); -} - -fn map_keyboard_mode(evt: &KeyEvent) { - // map mode(1): Send keycode according to the peer platform. - let (click_capslock, click_numlock) = sync_status(evt); - #[cfg(windows)] let click_numlock = { - crate::platform::windows::try_change_desktop(); - let code = evt.chr(); let key = rdev::get_win_key(code, 0); //let key = rdev::windows::keycodes::key_from_code(code); @@ -664,13 +655,20 @@ fn map_keyboard_mode(evt: &KeyEvent) { RdevKey::DownArrow | RdevKey::PageDown | RdevKey::Insert | - RdevKey::Delete => { - let mut en = ENIGO.lock().unwrap(); - en.get_key_state(enigo::Key::NumLock) - }, + RdevKey::Delete => en.get_key_state(enigo::Key::NumLock), _ => click_numlock, } - }; + }; + return (click_capslock, click_numlock); +} + +fn map_keyboard_mode(evt: &KeyEvent) { + // map mode(1): Send keycode according to the peer platform. + #[cfg(windows)] + crate::platform::windows::try_change_desktop(); + + let (click_capslock, click_numlock) = sync_status(evt); + // Wayland #[cfg(target_os = "linux")] if !*IS_X11.lock().unwrap() {