Skip to main content

Crate openlogi_hook

Crate openlogi_hook 

Source
Expand description

OS-level mouse-event hook for OpenLogi.

PlatformImplementation
macOSCGEventTap (same primitive used by Logi Options+)
Linuxevdev grab + uinput re-injection
WindowsWH_MOUSE_LL low-level mouse hook (motion is edge-clamped)

§Usage

use openlogi_hook::{Hook, MouseEvent, EventDisposition};

if !Hook::has_accessibility() {
    eprintln!("grant Accessibility access first");
    return;
}

let hook = Hook::start(|event| {
    println!("{event:?}");
    EventDisposition::PassThrough
}).unwrap();

// … later, on shutdown:
hook.stop();

Structs§

EventDevice
Best-effort identity for the physical device that produced an OS event.
EventTapInfo
A live event tap installed somewhere in the system, as reported by Hook::list_event_taps. Read-only diagnostic snapshot — enumerating taps needs no Accessibility grant and any process in the session sees them all.
Hook
A running OS-level mouse hook. Call Hook::stop to tear down.
KeyEvent
A keyboard event observed by the hook.
KeyModifiers
Which modifier keys were held when a key event fired. Mirrors the detectable macOS modifier flags. Note Fn is deliberately absent — it is firmware-internal and never reported on non-function-row keys (see the function-key-remapper spec, Appendix A).

Enums§

ButtonId
One of the user-rebindable hotspots on a Logi mouse. The order matches the physical layout from front to side; ButtonId::ALL is consumed by the default-binding generator and the popover trigger list.
EventDisposition
What the hook callback wants the OS to do with the captured event.
HookError
Errors that Hook::start and related functions can produce.
HookEvent
Anything the OS hook can observe. Mouse preserves the existing callback payload; Key is the keyboard path added by the function-key remapper. Wrapping both in a union means Hook::start’s callback widens once and stays stable as further event classes arrive.
MouseEvent
An event captured at the OS layer.
TapLocation
Where in the event stream a tap is inserted (macOS CGEventTapLocation).

Constants§

LOGITECH_VENDOR_ID
Logitech’s USB/Bluetooth vendor id (0x046D).

Functions§

frontmost_bundle_id
Return an opaque string identifying the currently frontmost application.
source_is_remappable
Whether the OS hook may suppress/remap a button event from this source.