feat: keyboard map mode control side

This commit is contained in:
mcfans 2023-10-19 13:40:12 +08:00
parent b3e2ab0f3b
commit 28c11801f3
3 changed files with 32 additions and 3 deletions

28
Cargo.lock generated
View File

@ -1811,7 +1811,7 @@ dependencies = [
"log",
"objc",
"pkg-config",
"rdev",
"rdev 0.5.0-2 (git+https://github.com/fufesou/rdev)",
"serde 1.0.163",
"serde_derive",
"tfc",
@ -4911,6 +4911,30 @@ dependencies = [
"x11 2.21.0",
]
[[package]]
name = "rdev"
version = "0.5.0-2"
source = "git+https://github.com/mcfans/rdev#d643ea4542e61931cb20e1ecd390d6a3c9569171"
dependencies = [
"cocoa",
"core-foundation",
"core-foundation-sys 0.8.4",
"core-graphics",
"dispatch",
"enum-map",
"epoll",
"inotify",
"lazy_static",
"libc",
"log",
"mio",
"strum 0.24.1",
"strum_macros 0.24.3",
"widestring",
"winapi 0.3.9",
"x11 2.21.0",
]
[[package]]
name = "rdrand"
version = "0.4.0"
@ -5196,7 +5220,7 @@ dependencies = [
"os-version",
"pam",
"parity-tokio-ipc",
"rdev",
"rdev 0.5.0-2 (git+https://github.com/mcfans/rdev)",
"repng",
"reqwest",
"ringbuf",

View File

@ -64,7 +64,7 @@ default-net = "0.14"
wol-rs = "1.0"
flutter_rust_bridge = { version = "1.75", features = ["uuid"], optional = true}
errno = "0.3"
rdev = { git = "https://github.com/fufesou/rdev" }
rdev = { git = "https://github.com/mcfans/rdev" }
url = { version = "2.3", features = ["serde"] }
crossbeam-queue = "0.3"
hex = "0.4"

View File

@ -28,6 +28,8 @@ const OS_LOWER_WINDOWS: &str = "windows";
const OS_LOWER_LINUX: &str = "linux";
#[allow(dead_code)]
const OS_LOWER_MACOS: &str = "macos";
#[allow(dead_code)]
const OS_LOWER_ANDROID: &str = "android";
#[cfg(any(target_os = "windows", target_os = "macos"))]
static KEYBOARD_HOOKED: AtomicBool = AtomicBool::new(false);
@ -865,12 +867,14 @@ pub fn map_keyboard_mode(_peer: &str, event: &Event, mut key_event: KeyEvent) ->
rdev::win_scancode_to_macos_code(event.position_code)?
}
}
OS_LOWER_ANDROID => rdev::win_scancode_to_android_key_code(event.position_code)?,
_ => rdev::win_scancode_to_linux_code(event.position_code)?,
};
#[cfg(target_os = "macos")]
let keycode = match _peer {
OS_LOWER_WINDOWS => rdev::macos_code_to_win_scancode(event.platform_code as _)?,
OS_LOWER_MACOS => event.platform_code as _,
OS_LOWER_ANDROID => rdev::macos_code_to_android_key_code(event.platform_code as _)?,
_ => rdev::macos_code_to_linux_code(event.platform_code as _)?,
};
#[cfg(target_os = "linux")]
@ -883,6 +887,7 @@ pub fn map_keyboard_mode(_peer: &str, event: &Event, mut key_event: KeyEvent) ->
rdev::linux_code_to_macos_code(event.position_code as _)?
}
}
OS_LOWER_ANDROID => rdev::linux_code_to_android_key_code(event.position_code as _)?,
_ => event.position_code as _,
};
#[cfg(any(target_os = "android", target_os = "ios"))]