mirror of
https://github.com/feschber/lan-mouse.git
synced 2026-04-26 07:13:20 +03:00
Compare commits
1 Commits
macos-fix-
...
improve-co
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
253a6d1911 |
@@ -318,47 +318,21 @@ fn get_events(
|
|||||||
})))
|
})))
|
||||||
}
|
}
|
||||||
CGEventType::ScrollWheel => {
|
CGEventType::ScrollWheel => {
|
||||||
if ev.get_integer_value_field(EventField::SCROLL_WHEEL_EVENT_IS_CONTINUOUS) != 0 {
|
let v = ev.get_integer_value_field(EventField::SCROLL_WHEEL_EVENT_POINT_DELTA_AXIS_1);
|
||||||
let v =
|
let h = ev.get_integer_value_field(EventField::SCROLL_WHEEL_EVENT_POINT_DELTA_AXIS_2);
|
||||||
ev.get_integer_value_field(EventField::SCROLL_WHEEL_EVENT_POINT_DELTA_AXIS_1);
|
if v != 0 {
|
||||||
let h =
|
result.push(CaptureEvent::Input(Event::Pointer(PointerEvent::Axis {
|
||||||
ev.get_integer_value_field(EventField::SCROLL_WHEEL_EVENT_POINT_DELTA_AXIS_2);
|
time: 0,
|
||||||
if v != 0 {
|
axis: 0, // Vertical
|
||||||
result.push(CaptureEvent::Input(Event::Pointer(PointerEvent::Axis {
|
value: v as f64,
|
||||||
time: 0,
|
})));
|
||||||
axis: 0, // Vertical
|
}
|
||||||
value: v as f64,
|
if h != 0 {
|
||||||
})));
|
result.push(CaptureEvent::Input(Event::Pointer(PointerEvent::Axis {
|
||||||
}
|
time: 0,
|
||||||
if h != 0 {
|
axis: 1, // Horizontal
|
||||||
result.push(CaptureEvent::Input(Event::Pointer(PointerEvent::Axis {
|
value: h as f64,
|
||||||
time: 0,
|
})));
|
||||||
axis: 1, // Horizontal
|
|
||||||
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,14 +223,18 @@ async fn ping_pong(
|
|||||||
) {
|
) {
|
||||||
loop {
|
loop {
|
||||||
let (buf, len) = ProtoEvent::Ping.into();
|
let (buf, len) = ProtoEvent::Ping.into();
|
||||||
if let Err(e) = conn.send(&buf[..len]).await {
|
|
||||||
log::warn!("{addr}: send error `{e}`, closing connection");
|
|
||||||
let _ = conn.close().await;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
log::trace!("PING >->->->->- {addr}");
|
|
||||||
|
|
||||||
tokio::time::sleep(Duration::from_millis(500)).await;
|
// send 4 pings, at least one must be answered
|
||||||
|
for _ in 0..4 {
|
||||||
|
if let Err(e) = conn.send(&buf[..len]).await {
|
||||||
|
log::warn!("{addr}: send error `{e}`, closing connection");
|
||||||
|
let _ = conn.close().await;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
log::trace!("PING >->->->->- {addr}");
|
||||||
|
|
||||||
|
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