Sync Numpad status
This commit is contained in:
parent
e0a7238cc1
commit
72273f4546
@ -597,24 +597,32 @@ fn rdev_key_down_or_up(key: RdevKey, down_or_up: bool) {
|
|||||||
|
|
||||||
fn sync_status(evt: &KeyEvent) {
|
fn sync_status(evt: &KeyEvent) {
|
||||||
let mut en = ENIGO.lock().unwrap();
|
let mut en = ENIGO.lock().unwrap();
|
||||||
// sync CAPS status
|
|
||||||
|
// remote caps status
|
||||||
let caps_locking = evt
|
let caps_locking = evt
|
||||||
.modifiers
|
.modifiers
|
||||||
.iter()
|
.iter()
|
||||||
.position(|&r| r == ControlKey::CapsLock.into())
|
.position(|&r| r == ControlKey::CapsLock.into())
|
||||||
.is_some();
|
.is_some();
|
||||||
println!(
|
// remote numpad status
|
||||||
"[*] remote, client: {:?} {:?}",
|
let num_locking = evt
|
||||||
caps_locking,
|
.modifiers
|
||||||
en.get_key_state(enigo::Key::CapsLock)
|
.iter()
|
||||||
);
|
.position(|&r| r == ControlKey::NumLock.into())
|
||||||
|
.is_some();
|
||||||
|
|
||||||
if (caps_locking && !en.get_key_state(enigo::Key::CapsLock))
|
if (caps_locking && !en.get_key_state(enigo::Key::CapsLock))
|
||||||
|| (!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, true);
|
||||||
rdev_key_down_or_up(RdevKey::CapsLock, false);
|
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) {
|
fn map_keyboard_map(evt: &KeyEvent) {
|
||||||
|
@ -988,6 +988,9 @@ impl Handler {
|
|||||||
if get_key_state(enigo::Key::CapsLock) {
|
if get_key_state(enigo::Key::CapsLock) {
|
||||||
key_event.modifiers.push(ControlKey::CapsLock.into());
|
key_event.modifiers.push(ControlKey::CapsLock.into());
|
||||||
}
|
}
|
||||||
|
if get_key_state(enigo::Key::NumLock) {
|
||||||
|
key_event.modifiers.push(ControlKey::NumLock.into());
|
||||||
|
}
|
||||||
|
|
||||||
self.send_key_event(key_event, 1);
|
self.send_key_event(key_event, 1);
|
||||||
}
|
}
|
||||||
@ -996,7 +999,14 @@ impl Handler {
|
|||||||
// // translate mode(2): locally generated characters are send to the peer.
|
// // translate mode(2): locally generated characters are send to the peer.
|
||||||
// }
|
// }
|
||||||
|
|
||||||
fn legacy_modifiers(&self, key_event: &mut KeyEvent, alt: bool, ctrl: bool, shift: bool, command: bool){
|
fn legacy_modifiers(
|
||||||
|
&self,
|
||||||
|
key_event: &mut KeyEvent,
|
||||||
|
alt: bool,
|
||||||
|
ctrl: bool,
|
||||||
|
shift: bool,
|
||||||
|
command: bool,
|
||||||
|
) {
|
||||||
if alt
|
if alt
|
||||||
&& !crate::is_control_key(&key_event, &ControlKey::Alt)
|
&& !crate::is_control_key(&key_event, &ControlKey::Alt)
|
||||||
&& !crate::is_control_key(&key_event, &ControlKey::RAlt)
|
&& !crate::is_control_key(&key_event, &ControlKey::RAlt)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user