Sync Numpad status

This commit is contained in:
Asura
2022-07-18 02:19:33 -07:00
parent e0a7238cc1
commit 72273f4546
2 changed files with 26 additions and 8 deletions

View File

@@ -597,24 +597,32 @@ fn rdev_key_down_or_up(key: RdevKey, down_or_up: bool) {
fn sync_status(evt: &KeyEvent) {
let mut en = ENIGO.lock().unwrap();
// sync CAPS status
// remote caps status
let caps_locking = evt
.modifiers
.iter()
.position(|&r| r == ControlKey::CapsLock.into())
.is_some();
println!(
"[*] remote, client: {:?} {:?}",
caps_locking,
en.get_key_state(enigo::Key::CapsLock)
);
// remote numpad status
let num_locking = evt
.modifiers
.iter()
.position(|&r| r == ControlKey::NumLock.into())
.is_some();
if (caps_locking && !en.get_key_state(enigo::Key::CapsLock))
|| (!caps_locking && en.get_key_state(enigo::Key::CapsLock))
{
println!("[*]: Changing status");
rdev_key_down_or_up(RdevKey::CapsLock, true);
rdev_key_down_or_up(RdevKey::CapsLock, false);
};
if (num_locking && !en.get_key_state(enigo::Key::NumLock))
|| (!num_locking && en.get_key_state(enigo::Key::NumLock))
{
rdev_key_down_or_up(RdevKey::NumLock, true);
rdev_key_down_or_up(RdevKey::NumLock, false);
};
}
fn map_keyboard_map(evt: &KeyEvent) {