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) {
|
||||
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) {
|
||||
|
@ -988,6 +988,9 @@ impl Handler {
|
||||
if get_key_state(enigo::Key::CapsLock) {
|
||||
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);
|
||||
}
|
||||
@ -996,7 +999,14 @@ impl Handler {
|
||||
// // 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
|
||||
&& !crate::is_control_key(&key_event, &ControlKey::Alt)
|
||||
&& !crate::is_control_key(&key_event, &ControlKey::RAlt)
|
||||
|
Loading…
x
Reference in New Issue
Block a user