diff --git a/flutter/lib/consts.dart b/flutter/lib/consts.dart index 808c24b7e..2ee6c49f4 100644 --- a/flutter/lib/consts.dart +++ b/flutter/lib/consts.dart @@ -233,16 +233,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..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,41 +101,18 @@ 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); } } 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); } 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 diff --git a/src/ui_session_interface.rs b/src/ui_session_interface.rs index 9f7391dac..a37a7c518 100644 --- a/src/ui_session_interface.rs +++ b/src/ui_session_interface.rs @@ -313,8 +313,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(); @@ -661,6 +659,9 @@ impl Session { _ => KeyboardMode::Legacy, }; + #[cfg(not(windows))] + let key = self.convert_numpad_keys(key); + match mode { KeyboardMode::Map => { if down_or_up == true { @@ -849,6 +850,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) => {