From 5216dedca6766e86d76c699782d0150caf71131f Mon Sep 17 00:00:00 2001 From: Asura Date: Mon, 26 Sep 2022 00:45:59 -0700 Subject: [PATCH 1/4] Fix numpad when linux -> windows --- src/ui_session_interface.rs | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/ui_session_interface.rs b/src/ui_session_interface.rs index 2feceb8fe..f850154cd 100644 --- a/src/ui_session_interface.rs +++ b/src/ui_session_interface.rs @@ -309,8 +309,6 @@ impl Session { } else { key }; - #[cfg(not(windows))] - let key = self.convert_numpad_keys(key); let peer = self.peer_platform(); let mut key_event = KeyEvent::new(); @@ -657,6 +655,9 @@ impl Session { _ => KeyboardMode::Legacy, }; + #[cfg(not(windows))] + let key = self.convert_numpad_keys(key); + match mode { KeyboardMode::Map => { if down_or_up == true { @@ -845,6 +846,24 @@ impl Session { key_event.set_chr(chr); } Key::ControlKey(key) => { + let key = if !get_key_state(enigo::Key::NumLock) { + match key { + ControlKey::Numpad0 => ControlKey::Insert, + ControlKey::Decimal => ControlKey::Delete, + ControlKey::Numpad1 => ControlKey::End, + ControlKey::Numpad2 => ControlKey::DownArrow, + ControlKey::Numpad3 => ControlKey::PageDown, + ControlKey::Numpad4 => ControlKey::LeftArrow, + ControlKey::Numpad5 => ControlKey::Clear, + ControlKey::Numpad6 => ControlKey::RightArrow, + ControlKey::Numpad7 => ControlKey::Home, + ControlKey::Numpad8 => ControlKey::UpArrow, + ControlKey::Numpad9 => ControlKey::PageUp, + _ => key, + } + }else{ + key + }; key_event.set_control_key(key.clone()); } Key::_Raw(raw) => { From 9ca71f6748550bcd2f795aa986e39c3c838765c6 Mon Sep 17 00:00:00 2001 From: Asura Date: Mon, 26 Sep 2022 00:50:12 -0700 Subject: [PATCH 2/4] Fix numpad convert error in flutter --- flutter/lib/consts.dart | 20 ++++++++++---------- flutter/lib/models/input_model.dart | 4 ++-- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/flutter/lib/consts.dart b/flutter/lib/consts.dart index ccacab5fb..a307aee5e 100644 --- a/flutter/lib/consts.dart +++ b/flutter/lib/consts.dart @@ -231,16 +231,16 @@ const Map physicalKeyMap = { 0x00070056: 'VK_SUBTRACT', 0x00070057: 'VK_ADD', 0x00070058: 'VK_ENTER', // num enter - 0x00070059: 'VK_NUMPAD0', - 0x0007005a: 'VK_NUMPAD1', - 0x0007005b: 'VK_NUMPAD2', - 0x0007005c: 'VK_NUMPAD3', - 0x0007005d: 'VK_NUMPAD4', - 0x0007005e: 'VK_NUMPAD5', - 0x0007005f: 'VK_NUMPAD6', - 0x00070060: 'VK_NUMPAD7', - 0x00070061: 'VK_NUMPAD8', - 0x00070062: 'VK_NUMPAD9', + 0x00070059: 'VK_NUMPAD1', + 0x0007005a: 'VK_NUMPAD2', + 0x0007005b: 'VK_NUMPAD3', + 0x0007005c: 'VK_NUMPAD4', + 0x0007005d: 'VK_NUMPAD5', + 0x0007005e: 'VK_NUMPAD6', + 0x0007005f: 'VK_NUMPAD7', + 0x00070060: 'VK_NUMPAD8', + 0x00070061: 'VK_NUMPAD9', + 0x00070062: 'VK_NUMPAD0', 0x00070063: 'VK_DECIMAL', 0x00070075: 'VK_HELP', 0x00070077: 'VK_SELECT', diff --git a/flutter/lib/models/input_model.dart b/flutter/lib/models/input_model.dart index f996daddf..2e4d45732 100644 --- a/flutter/lib/models/input_model.dart +++ b/flutter/lib/models/input_model.dart @@ -103,8 +103,8 @@ class Keyboard { void sendRawKey(RawKeyEvent e, {bool? down, bool? press}) { // for maximum compatibility - final label = logicalKeyMap[e.logicalKey.keyId] ?? - physicalKeyMap[e.physicalKey.usbHidUsage] ?? + final label = physicalKeyMap[e.physicalKey.usbHidUsage] ?? + logicalKeyMap[e.logicalKey.keyId] ?? e.logicalKey.keyLabel; _ffi.inputKey(label, down: down, press: press ?? false); } From ac52a55b071eeadae15c795e36e22eff51b7a2e9 Mon Sep 17 00:00:00 2001 From: Asura Date: Mon, 26 Sep 2022 20:01:01 -0700 Subject: [PATCH 3/4] Fix select by left button --- flutter/lib/models/input_model.dart | 54 +++++++++++++++++------------ 1 file changed, 31 insertions(+), 23 deletions(-) diff --git a/flutter/lib/models/input_model.dart b/flutter/lib/models/input_model.dart index 2e4d45732..d42eb7f2d 100644 --- a/flutter/lib/models/input_model.dart +++ b/flutter/lib/models/input_model.dart @@ -22,6 +22,37 @@ class Keyboard { keyboardMode = result.toString(); }); + final key = e.logicalKey; + if (e is RawKeyDownEvent) { + if (!e.repeat){ + if (e.isAltPressed && !_ffi.alt) { + _ffi.alt = true; + } else if (e.isControlPressed && !_ffi.ctrl) { + _ffi.ctrl = true; + } else if (e.isShiftPressed && !_ffi.shift) { + _ffi.shift = true; + } else if (e.isMetaPressed && !_ffi.command) { + _ffi.command = true; + } + } + } + if (e is RawKeyUpEvent) { + if (key == LogicalKeyboardKey.altLeft || + key == LogicalKeyboardKey.altRight) { + _ffi.alt = false; + } else if (key == LogicalKeyboardKey.controlLeft || + key == LogicalKeyboardKey.controlRight) { + _ffi.ctrl = false; + } else if (key == LogicalKeyboardKey.shiftRight || + key == LogicalKeyboardKey.shiftLeft) { + _ffi.shift = false; + } else if (key == LogicalKeyboardKey.metaLeft || + key == LogicalKeyboardKey.metaRight || + key == LogicalKeyboardKey.superKey) { + _ffi.command = false; + } + } + if (keyboardMode == 'map') { mapKeyboardMode(e); } else if (keyboardMode == 'translate') { @@ -70,33 +101,10 @@ class Keyboard { if (e.repeat) { sendRawKey(e, press: true); } else { - if (e.isAltPressed && !_ffi.alt) { - _ffi.alt = true; - } else if (e.isControlPressed && !_ffi.ctrl) { - _ffi.ctrl = true; - } else if (e.isShiftPressed && !_ffi.shift) { - _ffi.shift = true; - } else if (e.isMetaPressed && !_ffi.command) { - _ffi.command = true; - } sendRawKey(e, down: true); } } if (e is RawKeyUpEvent) { - if (key == LogicalKeyboardKey.altLeft || - key == LogicalKeyboardKey.altRight) { - _ffi.alt = false; - } else if (key == LogicalKeyboardKey.controlLeft || - key == LogicalKeyboardKey.controlRight) { - _ffi.ctrl = false; - } else if (key == LogicalKeyboardKey.shiftRight || - key == LogicalKeyboardKey.shiftLeft) { - _ffi.shift = false; - } else if (key == LogicalKeyboardKey.metaLeft || - key == LogicalKeyboardKey.metaRight || - key == LogicalKeyboardKey.superKey) { - _ffi.command = false; - } sendRawKey(e); } } From 29c32524587c7369ff4a4bb6bc4ddaae059667cc Mon Sep 17 00:00:00 2001 From: rustdesk Date: Tue, 27 Sep 2022 16:48:04 +0800 Subject: [PATCH 4/4] lower cmake requirement --- flutter/linux/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flutter/linux/CMakeLists.txt b/flutter/linux/CMakeLists.txt index 9391ed97e..c03d4c576 100644 --- a/flutter/linux/CMakeLists.txt +++ b/flutter/linux/CMakeLists.txt @@ -1,5 +1,5 @@ # Project-level configuration. -cmake_minimum_required(VERSION 3.12) +cmake_minimum_required(VERSION 3.10) project(runner LANGUAGES CXX) # The name of the executable created for the application. Change this to change