Use keycode mapping table
This commit is contained in:
parent
cb493ec297
commit
7775a14c9e
11
Cargo.lock
generated
11
Cargo.lock
generated
@ -4053,6 +4053,7 @@ dependencies = [
|
||||
"mouce",
|
||||
"num_cpus",
|
||||
"objc",
|
||||
"once_cell",
|
||||
"parity-tokio-ipc",
|
||||
"rdev",
|
||||
"repng",
|
||||
@ -4071,6 +4072,7 @@ dependencies = [
|
||||
"simple_rc",
|
||||
"sys-locale",
|
||||
"sysinfo",
|
||||
"tfc",
|
||||
"tray-item",
|
||||
"trayicon",
|
||||
"uuid",
|
||||
@ -4755,6 +4757,15 @@ version = "0.15.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b1141d4d61095b28419e22cb0bbf02755f5e54e0526f97f1e3d1d160e60885fb"
|
||||
|
||||
[[package]]
|
||||
name = "tfc"
|
||||
version = "0.6.1"
|
||||
source = "git+https://github.com/asur4s/The-Fat-Controller#35ed0bc8dd8516bdb99e45ebfc94409637a92c6b"
|
||||
dependencies = [
|
||||
"core-graphics 0.22.3",
|
||||
"unicode-segmentation",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thiserror"
|
||||
version = "1.0.31"
|
||||
|
@ -73,6 +73,8 @@ sys-locale = "0.2"
|
||||
enigo = { path = "libs/enigo", features = [ "with_serde" ] }
|
||||
clipboard = { path = "libs/clipboard" }
|
||||
rdev = { git = "https://github.com/asur4s/rdev" }
|
||||
tfc = { git = "https://github.com/asur4s/The-Fat-Controller" }
|
||||
once_cell = "1.13.0"
|
||||
ctrlc = "3.2"
|
||||
arboard = "2.0"
|
||||
#minreq = { version = "2.4", features = ["punycode", "https-native"] }
|
||||
@ -103,6 +105,7 @@ async-process = "1.3"
|
||||
mouce = { git="https://github.com/fufesou/mouce.git" }
|
||||
evdev = { git="https://github.com/fufesou/evdev" }
|
||||
|
||||
|
||||
[target.'cfg(target_os = "android")'.dependencies]
|
||||
android_logger = "0.11"
|
||||
jni = "0.19"
|
||||
|
@ -9,6 +9,7 @@ use std::{
|
||||
sync::atomic::{AtomicBool, Ordering},
|
||||
time::Instant,
|
||||
};
|
||||
use tfc::{traits::*, Context};
|
||||
|
||||
#[derive(Default)]
|
||||
struct StateCursor {
|
||||
@ -179,6 +180,7 @@ lazy_static::lazy_static! {
|
||||
};
|
||||
static ref KEYS_DOWN: Arc<Mutex<HashMap<u64, Instant>>> = Default::default();
|
||||
static ref LATEST_INPUT: Arc<Mutex<Input>> = Default::default();
|
||||
static ref KBD_CONTEXT: Mutex<Context> = Mutex::new(Context::new().expect("kbd context error"));
|
||||
}
|
||||
static EXITING: AtomicBool = AtomicBool::new(false);
|
||||
|
||||
@ -820,9 +822,12 @@ fn legacy_keyboard_mode(evt: &KeyEvent) {
|
||||
}
|
||||
|
||||
fn translate_keyboard_mode(evt: &KeyEvent) {
|
||||
dbg!(evt.chr());
|
||||
let chr = char::from_u32(evt.chr()).unwrap_or_default();
|
||||
rdev::simulate_char(chr, evt.down);
|
||||
if evt.down {
|
||||
KBD_CONTEXT.lock().unwrap().unicode_char_down(chr).expect("unicode_char_down error");
|
||||
} else {
|
||||
KBD_CONTEXT.lock().unwrap().unicode_char_up(chr).expect("unicode_char_up error");
|
||||
}
|
||||
}
|
||||
|
||||
fn handle_key_(evt: &KeyEvent) {
|
||||
|
Loading…
Reference in New Issue
Block a user