mirror of
https://github.com/feschber/lan-mouse.git
synced 2026-04-25 03:43:19 +03:00
Compare commits
1 Commits
improve-co
...
macos-fix-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1c69d4d209 |
@@ -318,8 +318,11 @@ fn get_events(
|
|||||||
})))
|
})))
|
||||||
}
|
}
|
||||||
CGEventType::ScrollWheel => {
|
CGEventType::ScrollWheel => {
|
||||||
let v = ev.get_integer_value_field(EventField::SCROLL_WHEEL_EVENT_POINT_DELTA_AXIS_1);
|
if ev.get_integer_value_field(EventField::SCROLL_WHEEL_EVENT_IS_CONTINUOUS) != 0 {
|
||||||
let h = ev.get_integer_value_field(EventField::SCROLL_WHEEL_EVENT_POINT_DELTA_AXIS_2);
|
let v =
|
||||||
|
ev.get_integer_value_field(EventField::SCROLL_WHEEL_EVENT_POINT_DELTA_AXIS_1);
|
||||||
|
let h =
|
||||||
|
ev.get_integer_value_field(EventField::SCROLL_WHEEL_EVENT_POINT_DELTA_AXIS_2);
|
||||||
if v != 0 {
|
if v != 0 {
|
||||||
result.push(CaptureEvent::Input(Event::Pointer(PointerEvent::Axis {
|
result.push(CaptureEvent::Input(Event::Pointer(PointerEvent::Axis {
|
||||||
time: 0,
|
time: 0,
|
||||||
@@ -334,6 +337,29 @@ fn get_events(
|
|||||||
value: h as f64,
|
value: h as f64,
|
||||||
})));
|
})));
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// line based scrolling
|
||||||
|
const LINES_PER_STEP: i32 = 3;
|
||||||
|
const V120_STEPS_PER_LINE: i32 = 120 / LINES_PER_STEP;
|
||||||
|
let v = ev.get_integer_value_field(EventField::SCROLL_WHEEL_EVENT_DELTA_AXIS_1);
|
||||||
|
let h = ev.get_integer_value_field(EventField::SCROLL_WHEEL_EVENT_DELTA_AXIS_2);
|
||||||
|
if v != 0 {
|
||||||
|
result.push(CaptureEvent::Input(Event::Pointer(
|
||||||
|
PointerEvent::AxisDiscrete120 {
|
||||||
|
axis: 0, // Vertical
|
||||||
|
value: V120_STEPS_PER_LINE * v as i32,
|
||||||
|
},
|
||||||
|
)));
|
||||||
|
}
|
||||||
|
if h != 0 {
|
||||||
|
result.push(CaptureEvent::Input(Event::Pointer(
|
||||||
|
PointerEvent::AxisDiscrete120 {
|
||||||
|
axis: 1, // Horizontal
|
||||||
|
value: V120_STEPS_PER_LINE * h as i32,
|
||||||
|
},
|
||||||
|
)));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -223,9 +223,6 @@ async fn ping_pong(
|
|||||||
) {
|
) {
|
||||||
loop {
|
loop {
|
||||||
let (buf, len) = ProtoEvent::Ping.into();
|
let (buf, len) = ProtoEvent::Ping.into();
|
||||||
|
|
||||||
// send 4 pings, at least one must be answered
|
|
||||||
for _ in 0..4 {
|
|
||||||
if let Err(e) = conn.send(&buf[..len]).await {
|
if let Err(e) = conn.send(&buf[..len]).await {
|
||||||
log::warn!("{addr}: send error `{e}`, closing connection");
|
log::warn!("{addr}: send error `{e}`, closing connection");
|
||||||
let _ = conn.close().await;
|
let _ = conn.close().await;
|
||||||
@@ -234,7 +231,6 @@ async fn ping_pong(
|
|||||||
log::trace!("PING >->->->->- {addr}");
|
log::trace!("PING >->->->->- {addr}");
|
||||||
|
|
||||||
tokio::time::sleep(Duration::from_millis(500)).await;
|
tokio::time::sleep(Duration::from_millis(500)).await;
|
||||||
}
|
|
||||||
|
|
||||||
if !ping_response.borrow_mut().remove(&addr) {
|
if !ping_response.borrow_mut().remove(&addr) {
|
||||||
log::warn!("{addr} did not respond, closing connection");
|
log::warn!("{addr} did not respond, closing connection");
|
||||||
|
|||||||
Reference in New Issue
Block a user