mirror of
https://github.com/feschber/lan-mouse.git
synced 2026-04-08 02:21:28 +03:00
Compare commits
2 Commits
fix-duplic
...
reset-doub
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
feb8461527 | ||
|
|
2d1a037eba |
@@ -88,7 +88,7 @@ impl MacOSEmulation {
|
|||||||
button_state,
|
button_state,
|
||||||
previous_button: None,
|
previous_button: None,
|
||||||
previous_button_click: None,
|
previous_button_click: None,
|
||||||
button_click_state: 1,
|
button_click_state: 0,
|
||||||
repeat_task: None,
|
repeat_task: None,
|
||||||
notify_repeat_task: Arc::new(Notify::new()),
|
notify_repeat_task: Arc::new(Notify::new()),
|
||||||
modifier_state: Rc::new(Cell::new(XMods::empty())),
|
modifier_state: Rc::new(Cell::new(XMods::empty())),
|
||||||
@@ -104,6 +104,9 @@ impl MacOSEmulation {
|
|||||||
// there can only be one repeating key and it's
|
// there can only be one repeating key and it's
|
||||||
// always the last to be pressed
|
// always the last to be pressed
|
||||||
self.cancel_repeat_task().await;
|
self.cancel_repeat_task().await;
|
||||||
|
// initial key event
|
||||||
|
key_event(self.event_source.clone(), key, 1, self.modifier_state.get());
|
||||||
|
// repeat task
|
||||||
let event_source = self.event_source.clone();
|
let event_source = self.event_source.clone();
|
||||||
let notify = self.notify_repeat_task.clone();
|
let notify = self.notify_repeat_task.clone();
|
||||||
let modifiers = self.modifier_state.clone();
|
let modifiers = self.modifier_state.clone();
|
||||||
@@ -239,8 +242,10 @@ impl Emulation for MacOSEmulation {
|
|||||||
event: Event,
|
event: Event,
|
||||||
_handle: EmulationHandle,
|
_handle: EmulationHandle,
|
||||||
) -> Result<(), EmulationError> {
|
) -> Result<(), EmulationError> {
|
||||||
|
log::trace!("{event:?}");
|
||||||
match event {
|
match event {
|
||||||
Event::Pointer(pointer_event) => match pointer_event {
|
Event::Pointer(pointer_event) => {
|
||||||
|
match pointer_event {
|
||||||
PointerEvent::Motion { time: _, dx, dy } => {
|
PointerEvent::Motion { time: _, dx, dy } => {
|
||||||
let mut mouse_location = match self.get_mouse_location() {
|
let mut mouse_location = match self.get_mouse_location() {
|
||||||
Some(l) => l,
|
Some(l) => l,
|
||||||
@@ -391,7 +396,13 @@ impl Emulation for MacOSEmulation {
|
|||||||
};
|
};
|
||||||
event.post(CGEventTapLocation::HID);
|
event.post(CGEventTapLocation::HID);
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
|
||||||
|
// reset button click state in case it's not a button event
|
||||||
|
if !matches!(pointer_event, PointerEvent::Button { .. }) {
|
||||||
|
self.button_click_state = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
Event::Keyboard(keyboard_event) => match keyboard_event {
|
Event::Keyboard(keyboard_event) => match keyboard_event {
|
||||||
KeyboardEvent::Key {
|
KeyboardEvent::Key {
|
||||||
time: _,
|
time: _,
|
||||||
@@ -405,18 +416,12 @@ impl Emulation for MacOSEmulation {
|
|||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
update_modifiers(&self.modifier_state, key, state);
|
||||||
match state {
|
match state {
|
||||||
// pressed
|
// pressed
|
||||||
1 => self.spawn_repeat_task(code).await,
|
1 => self.spawn_repeat_task(code).await,
|
||||||
_ => self.cancel_repeat_task().await,
|
_ => self.cancel_repeat_task().await,
|
||||||
}
|
}
|
||||||
update_modifiers(&self.modifier_state, key, state);
|
|
||||||
key_event(
|
|
||||||
self.event_source.clone(),
|
|
||||||
code,
|
|
||||||
state,
|
|
||||||
self.modifier_state.get(),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
KeyboardEvent::Modifiers {
|
KeyboardEvent::Modifiers {
|
||||||
depressed,
|
depressed,
|
||||||
|
|||||||
Reference in New Issue
Block a user