fixing win key problem https://github.com/rustdesk/rustdesk/issues/35
This commit is contained in:
parent
3200002e52
commit
ab4843b76e
@ -176,13 +176,13 @@ impl KeyboardControllable for Enigo {
|
||||
}
|
||||
|
||||
fn key_click(&mut self, key: Key) {
|
||||
let scancode = self.key_to_scancode(key);
|
||||
keybd_event(KEYEVENTF_SCANCODE, 0, scancode);
|
||||
keybd_event(KEYEVENTF_KEYUP | KEYEVENTF_SCANCODE, 0, scancode);
|
||||
let vk = self.key_to_keycode(key);
|
||||
keybd_event(0, vk, 0);
|
||||
keybd_event(KEYEVENTF_KEYUP, vk, 0);
|
||||
}
|
||||
|
||||
fn key_down(&mut self, key: Key) -> crate::ResultType {
|
||||
let res = keybd_event(KEYEVENTF_SCANCODE, 0, self.key_to_scancode(key));
|
||||
let res = keybd_event(0, self.key_to_keycode(key), 0);
|
||||
if res == 0 {
|
||||
let err = get_error();
|
||||
if !err.is_empty() {
|
||||
@ -193,11 +193,7 @@ impl KeyboardControllable for Enigo {
|
||||
}
|
||||
|
||||
fn key_up(&mut self, key: Key) {
|
||||
keybd_event(
|
||||
KEYEVENTF_KEYUP | KEYEVENTF_SCANCODE,
|
||||
0,
|
||||
self.key_to_scancode(key),
|
||||
);
|
||||
keybd_event(KEYEVENTF_KEYUP, self.key_to_keycode(key), 0);
|
||||
}
|
||||
|
||||
fn get_key_state(&mut self, key: Key) -> bool {
|
||||
@ -345,15 +341,9 @@ impl Enigo {
|
||||
Key::Raw(raw_keycode) => raw_keycode,
|
||||
Key::Layout(c) => self.get_layoutdependent_keycode(c.to_string()),
|
||||
Key::Super | Key::Command | Key::Windows | Key::Meta => EVK_LWIN,
|
||||
_ => 0,
|
||||
}
|
||||
}
|
||||
|
||||
fn key_to_scancode(&self, key: Key) -> u16 {
|
||||
let keycode = self.key_to_keycode(key);
|
||||
unsafe { MapVirtualKeyW(keycode as u32, 0) as u16 }
|
||||
}
|
||||
|
||||
fn get_layoutdependent_keycode(&self, string: String) -> u16 {
|
||||
// get the first char from the string ignore the rest
|
||||
// ensure its not a multybyte char
|
||||
|
@ -13,7 +13,7 @@ tokio-util = { version = "0.6", features = ["full"] }
|
||||
futures = "0.3"
|
||||
bytes = "1.0"
|
||||
log = "0.4"
|
||||
env_logger = "0.8"
|
||||
env_logger = "0.9"
|
||||
socket2 = { version = "0.3", features = ["reuseport"] }
|
||||
zstd = "0.9"
|
||||
quinn = {version = "0.6", optional = true }
|
||||
|
@ -305,14 +305,12 @@ fn handle_mouse_(evt: &MouseEvent, conn: i32) {
|
||||
let mut en = ENIGO.lock().unwrap();
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
let mut to_release = Vec::new();
|
||||
if evt_type == 1 {
|
||||
#[cfg(target_os = "macos")]
|
||||
en.reset_flag();
|
||||
if evt_type == 1 || evt_type == 2 {
|
||||
fix_modifiers(&evt.modifiers[..], &mut en, 0);
|
||||
}
|
||||
for ref ck in evt.modifiers.iter() {
|
||||
if let Some(key) = KEY_MAP.get(&ck.value()) {
|
||||
if evt_type == 1 || evt_type == 2 {
|
||||
#[cfg(target_os = "macos")]
|
||||
en.add_flag(key);
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
@ -511,6 +509,7 @@ fn handle_key_(evt: &KeyEvent) {
|
||||
let mut has_cap = false;
|
||||
#[cfg(windows)]
|
||||
let mut has_numlock = false;
|
||||
if evt.down {
|
||||
let ck = if let Some(key_event::Union::control_key(ck)) = evt.union {
|
||||
ck.value()
|
||||
} else {
|
||||
@ -540,6 +539,7 @@ fn handle_key_(evt: &KeyEvent) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
if crate::common::valid_for_capslock(evt) {
|
||||
if has_cap != en.get_key_state(Key::CapsLock) {
|
||||
|
Loading…
Reference in New Issue
Block a user