From 95844e60cfce5c92351b4a2d7ea3ab381e3ce537 Mon Sep 17 00:00:00 2001 From: fufesou Date: Tue, 10 Jan 2023 00:40:41 +0800 Subject: [PATCH] win filter scancodes that is greater than 255 Signed-off-by: fufesou --- src/keyboard.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/keyboard.rs b/src/keyboard.rs index 9fa53757f..f29eb27bc 100644 --- a/src/keyboard.rs +++ b/src/keyboard.rs @@ -65,7 +65,7 @@ pub mod client { #[cfg(not(feature = "cli"))] if let Some(handler) = CUR_SESSION.lock().unwrap().as_ref() { return handler.get_keyboard_mode(); - } + } "legacy".to_string() } @@ -372,7 +372,7 @@ pub fn get_peer_platform() -> String { #[cfg(not(feature = "cli"))] if let Some(handler) = CUR_SESSION.lock().unwrap().as_ref() { return handler.peer_platform(); - } + } "Windows".to_string() } @@ -615,7 +615,13 @@ pub fn map_keyboard_mode(event: &Event, mut key_event: KeyEvent) -> Option event.scan_code, + "windows" => { + // https://github.com/rustdesk/rustdesk/issues/1371 + if event.scan_code > 255 { + return None; + } + event.scan_code + } "macos" => { if hbb_common::config::LocalConfig::get_kb_layout_type() == "ISO" { rdev::win_scancode_to_macos_iso_code(event.scan_code)?