Merge branch 'refact/keyboard_led_state' of github.com:fufesou/rustdesk into refact/keyboard_led_state

This commit is contained in:
fufesou 2023-03-26 12:24:56 +08:00
commit 9d2b096626
2 changed files with 12 additions and 31 deletions

2
Cargo.lock generated
View File

@ -4674,7 +4674,7 @@ dependencies = [
[[package]]
name = "rdev"
version = "0.5.0-2"
source = "git+https://github.com/fufesou/rdev#cd0d6ad907f8fda5cf77487bc962ef4246221d0c"
source = "git+https://github.com/fufesou/rdev#0dad4a59f911fe14934fefc8eed18d58cb057a81"
dependencies = [
"cocoa",
"core-foundation 0.9.3",

View File

@ -46,35 +46,6 @@ lazy_static::lazy_static! {
m.insert(Key::MetaRight, false);
Mutex::new(m)
};
static ref NUMPAD_POSITION_CODES: Arc<Vec<KeyCode>> = {
let numpad_keys = [
Key::KpMinus,
Key::KpPlus,
Key::KpMultiply,
Key::KpDivide,
Key::KpDecimal,
Key::KpReturn,
Key::KpEqual,
Key::KpComma,
Key::Kp0,
Key::Kp1,
Key::Kp2,
Key::Kp3,
Key::Kp4,
Key::Kp5,
Key::Kp6,
Key::Kp7,
Key::Kp8,
Key::Kp9,
];
#[cfg(target_os = "windows")]
let codes = numpad_keys.iter().filter_map(|k| rdev::win_scancode_from_key(*k)).collect();
#[cfg(target_os = "linux")]
let codes = numpad_keys.iter().filter_map(|k| rdev::linux_keycode_from_key(*k)).collect();
#[cfg(target_os = "macos")]
let codes = numpad_keys.iter().filter_map(|k| rdev::macos_keycode_from_key(*k)).collect();
Arc::new(codes)
};
}
pub mod client {
@ -390,6 +361,16 @@ pub fn get_keyboard_mode_enum() -> KeyboardMode {
}
}
#[inline]
fn is_numpad_key(event: &Event) -> bool {
matches!(event.event_type, EventType::KeyPress(key) | EventType::KeyRelease(key) if match key {
Key::Kp0 | Key::Kp1 | Key::Kp2 | Key::Kp3| Key::Kp4| Key::Kp5| Key::Kp6|
Key::Kp7| Key::Kp8| Key::Kp9 | Key::KpMinus | Key::KpMultiply |
Key::KpDivide | Key::KpPlus | Key::KpDecimal => true,
_ => false
})
}
#[cfg(not(any(target_os = "android", target_os = "ios")))]
fn parse_add_lock_modes_modifiers(key_event: &mut KeyEvent, lock_modes: i32, is_numpad_key: bool) {
const CAPS_LOCK: i32 = 1;
@ -496,7 +477,7 @@ pub fn event_to_key_events(
};
if keyboard_mode != KeyboardMode::Translate {
let is_numpad_key = NUMPAD_POSITION_CODES.contains(&(event.position_code as _));
let is_numpad_key = is_numpad_key(&event.event_type);
for key_event in &mut key_events {
#[cfg(not(any(target_os = "android", target_os = "ios")))]
if let Some(lock_modes) = lock_modes {