Merge branch 'master' of github.com-rustdesk:rustdesk/rustdesk

This commit is contained in:
rustdesk 2022-09-27 18:34:26 +08:00
commit 0eaa7d167e
4 changed files with 65 additions and 38 deletions

View File

@ -233,16 +233,16 @@ const Map<int, String> physicalKeyMap = <int, String>{
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',

View File

@ -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);
}

View File

@ -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

View File

@ -313,8 +313,6 @@ impl<T: InvokeUiSession> Session<T> {
} 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<T: InvokeUiSession> Session<T> {
_ => 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<T: InvokeUiSession> Session<T> {
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) => {