#[cfg(any(target_os = "linux", target_os = "macos"))]
fn main() {
use std::time::Duration;
use openlogi_hook::{EventDisposition, Hook, HookEvent, MouseEvent};
let seconds: u64 = std::env::args()
.nth(1)
.and_then(|a| a.parse().ok())
.unwrap_or(20);
if !openlogi_hook::SOFTWARE_SCROLL_INVERSION {
println!("software scroll inversion is not available on this platform");
return;
}
let hook = match Hook::start(|event| {
if let HookEvent::Mouse(MouseEvent::Scroll {
delta,
from_trackpad,
device,
}) = &event
{
println!(
"scroll {delta:?} trackpad={from_trackpad} device={:?}",
device.as_ref().and_then(|d| d.product_name.as_deref())
);
}
EventDisposition::PassThrough
}) {
Ok(hook) => hook,
Err(e) => {
eprintln!("could not start the hook: {e}");
return;
}
};
openlogi_hook::set_scroll_inversion(false);
println!("=== PHASE A ({seconds}s): inversion OFF — scroll and note the direction");
std::thread::sleep(Duration::from_secs(seconds));
openlogi_hook::set_scroll_inversion(true);
println!("=== PHASE B ({seconds}s): inversion ON — scroll again; it must be the opposite");
std::thread::sleep(Duration::from_secs(seconds));
openlogi_hook::set_scroll_inversion(false);
println!("=== done — releasing the grab");
hook.stop();
}
#[cfg(not(any(target_os = "linux", target_os = "macos")))]
fn main() {
println!("software scroll inversion is not available on this platform");
}