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§

CursorPosition
Cursor position in the operating system’s global screen coordinate space, scaled so it lines up with GPUI’s own logical (DIP) display bounds — the Windows backend divides physical GetCursorPos pixels by the cursor’s monitor DPI scale to match; macOS CGEvent points and Linux root-window coordinates are already resolution-independent.
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.
ForegroundApp
One application, named the way a per-app profile names it.
ForegroundApplicationObserver
RAII owner of the current platform’s foreground-application observer.
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 — the same type a KeyTrigger is written with, so an event’s modifiers compare against a binding’s without a conversion. Detectable modifier state: what a keyboard trigger requires, and what the OS hook reports with each key event (openlogi-hook re-exports this type). Fn is absent: firmware-internal, never reported on non-function-row keys, and so unusable as a trigger (function-key-remapper spec, Appendix A).
PointerContext
Application identity and native window captured by one pointer lookup.

Enums§

ButtonId
One of the user-rebindable controls on a Logi device: a mouse hotspot, or a keyboard key addressed by its HID++ 0x1b04 control ID.
EventDisposition
What the hook callback wants the OS to do with the captured event.
ForegroundApplicationObserverError
Failure to install or operate a native foreground-application observer.
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.
PointerTarget
Native window identity under the pointer, or an explicit non-window outcome.
ScrollDelta
A signed two-axis scroll distance with an explicit unit.
TapLocation
Where in the event stream a tap is inserted (macOS CGEventTapLocation).

Constants§

LOGITECH_VENDOR_ID
Logitech’s USB/Bluetooth vendor id (0x046D), widened from openlogi_core::hid::LOGITECH_VENDOR_ID because the hook’s identity sources (IOKit, evdev) hand it back as a u32.
SOFTWARE_SCROLL_INVERSION
Whether this platform can invert the wheel in software.

Functions§

cursor_position
Return the current global cursor position without installing an input hook.
frontmost_application
Return the currently frontmost application.
frontmost_safari_pid
Return the Safari process captured by the latest macOS foreground-app observation without querying AppKit on the caller’s thread.
pointer_context
Query the window currently under the pointer, without activating anything.
pointer_context_supported
Whether this session has a pointer-window backend; does not probe permissions or connect to the window server. Unsupported Wayland never falls back to X11.
pointer_target_is_focused
Verify that this exact window, not merely another window of its application, is focused now. Returns false on any lookup failure or non-window target.
scroll_inversion
Whether set_scroll_inversion is currently on.
set_scroll_inversion
Turn software scroll inversion on or off for the captured pointers.
source_is_remappable
Whether the OS hook may suppress/remap a button event from this source.
watch_frontmost_application_changes
Observe native foreground-application changes.