Input and on-screen controls
OpenLogi links physical input to user-selected actions and visible feedback. It observes system events, decides whether a binding replaces the original event, sends the result to the operating system or OpenLogi hardware, and uses overlays to show short-lived controls and status. Camera support adds webcam controls, preview, camera use state, and camera-aware lighting.
System role
The input and control path joins physical mouse and keyboard events, actions selected from on-screen controls, and camera state changes. The background agent coordinates these paths so the settings UI does not own global input capture or device I/O.
The main relationship between these systems is shown below.
flowchart LR
Device[Mouse or keyboard input] --> Observe[Input observation]
Observe --> Decide[Binding and action decision]
Decide -->|native event| App[Current application]
Decide -->|bound action| System[OS event or OpenLogi hardware]
Decide -->|show action ring| Overlay[On-screen overlay]
Overlay -->|hover, activate, cancel| Decide
Camera[Camera use and camera settings] --> CameraState[Camera state]
CameraState --> Lighting[Camera-linked lighting]
Agent ownership
The background agent is the control point for global input and action execution. It shares current bindings and device state with the event path, then reports state to the graphical interface through local IPC (inter-process communication). This separation lets the settings UI configure behavior without remaining in the operating system's input path.
References: crates/…/main.rs• L267-340 crates/…/server.rs• L1-7 crates/…/hook_runtime.rs• L1-6
Input observation
OpenLogi uses operating-system input hooks to see mouse events and supported keyboard events before they reach the active application. A shared event model lets the agent apply the same binding rules to buttons, movement, scrolling, and supported keys.
Global input hooks
The global hook can pass an event through or suppress it when OpenLogi replaces it with a bound action. The remap gate fails closed for unknown and trackpad-like sources. Linux adds a stricter boundary around managed Logitech relative mice and excludes touch devices, pointing sticks, foreign vendors, and OpenLogi's own virtual devices. See Global input hooks for the hook boundary and platform behavior.
The hook keeps source identity and scroll meaning where the platform provides them. This lets OpenLogi reject unsuitable sources and change wheel direction without changing unrelated pointer input. Linux keeps the hook available across device reconnects. macOS checks for a live filtering capability and releases a stalled or revoked tap. Secure Event Input is reported separately because it can hide key events while mouse events remain visible.
The hook reports capture interruption so an in-progress gesture can be canceled instead of using stale button state. Its callback stays a fast decision point. Slower action work runs outside it.
References: crates/…/lib.rs• L69-169 crates/…/lib.rs• L228-312 crates/…/linux.rs• L153-249 crates/…/linux.rs• L423-631 crates/…/macos.rs• L83-180 crates/…/watchdog.rs• L176-205 crates/…/watchdog.rs• L426-535
Foreground and pointer context
Foreground application context supplies the active application identity for app-aware bindings. It is observed outside the input callback, so a profile can change when focus changes without making every input event query the window system. Linux selects a native Wayland, GNOME Shell, or X11 source when available and reports no application when no source can provide a reliable identity.
Pointer context is a read-only snapshot of the native surface under the pointer and its application identity. It distinguishes a normal window from the desktop or an unavailable surface, so context-sensitive actions can fail closed instead of guessing.
References: crates/…/foreground.rs• L33-61 crates/…/foreground.rs• L100-179 crates/…/lifecycle.rs• L12-42 crates/…/x11.rs• L31-72 crates/…/pointer.rs• L1-39 crates/…/pointer.rs• L41-106
Binding and dispatch
The action dispatcher is the shared decision point for input from the global hook and device-side gesture watchers. It maps a resolved action to an operating-system event or an OpenLogi hardware operation such as a DPI or wheel-mode change.
Native input remains native when no remap is needed. A remapped event is suppressed only after its replacement enters the action path. If that path cannot accept the action, the original event passes through. A short cross-path guard prevents one physical press seen by both the OS hook and a device watcher from running the same action twice.
References: crates/…/hook_runtime.rs• L30-80 crates/…/hook_runtime.rs• L510-638
Input synthesis
Input synthesis turns a selected action into a native system event or a desktop service request. The public injection boundary is shared across platforms, while each platform maps the same action vocabulary to its own input and window controls. See Input injection for the supported action classes and platform differences.
Operating-system actions
The injection layer is the single system-facing destination for actions that affect the current application. It supports clicks, keyboard shortcuts, held keys, scrolling, media controls, window actions, scripts, and application opening where the platform provides a stable path. Unsupported work is skipped instead of being represented by a misleading substitute.
Linux uses one lazily created virtual input device for keys, clicks, media events, and wheel output. It registers scroll axes without pointer movement, which keeps the device from acting as a second cursor. Desktop and media services handle actions such as locking, sleep, workspace changes, and playback. GNOME, KDE, and Hyprland can use different native paths. Allowlisted Hyprland helpers have a bounded wait and a keyboard fallback. Text injection and pixel-scroll output remain unsupported.
macOS can use native event services, Accessibility controls, desktop services, symbolic hotkeys, and an optional virtual HID keyboard. The virtual path makes supported output look like keyboard input from a device. If it is unavailable or fails, the affected edges use the software event path, and each release stays on the path that pressed it. Key mappings preserve the relationship between USB HID usages and macOS virtual key positions. Print Screen uses the key macOS reads as F13, and layout-aware menu handling helps shortcuts such as browser navigation reach the frontmost application. Space switching confirms the target display's Space before it reports success.
Windows uses SendInput for keyboard and mouse output. Keys that depend on the foreground layout carry the matching scan code. Navigation keys also carry their extended form so applications can distinguish them from keypad keys. Browser and media actions use their Windows virtual keys. Sleep and text injection remain unsupported.
Held keyboard actions keep press and release edges balanced across overlapping actions. Shared modifier keys stay down until their last active owner ends. A modifier-only hold taps its ordinary key once, while a whole-chord hold keeps that key down. Fractional scroll distance is carried across frames so high-resolution input does not lose small movement. Scripts and workflows run away from the input callback.
| Platform | System-facing path | Important limits |
|---|---|---|
| macOS | Core Graphics events, Accessibility and AppKit controls, media events, desktop services, symbolic hotkeys, and optional virtual HID output | Some actions depend on the matching macOS service or active application. Space changes can fail closed when the target display state is unclear. |
| Linux | One shared virtual input device plus desktop, media, and compositor services | Text and pixel scroll output are not supported. Some desktop actions depend on the active desktop. |
| Windows | Win32 synthesized keyboard and mouse input | Keyboard output follows the foreground layout. Sleep and text injection are not synthesized. |
References: crates/…/lib.rs• L1-16 crates/…/inject.rs• L401-489 crates/…/inject.rs• L517-645 crates/…/linux.rs• L39-61 crates/…/linux.rs• L137-248 crates/…/linux.rs• L349-445 crates/…/linux.rs• L584-607 crates/…/macos.rs• L106-137 crates/…/macos.rs• L153-210 crates/…/macos.rs• L260-281 crates/…/keycode.rs• L127-162 crates/…/windows.rs• L102-129 crates/…/windows.rs• L210-299 crates/…/windows.rs• L507-620 crates/…/virtual_keyboard.rs• L1-24 crates/…/virtual_keyboard.rs• L109-169
Synthetic event boundaries
Injected events must not return to the observation path as new user input. macOS tags its synthetic mouse and keyboard events, while its virtual HID device has a product identity that the hook can recognize. This prevents a remapped click or shortcut from triggering its own binding again.
References: crates/…/inject.rs• L864-870 crates/…/macos.rs• L356-366 crates/…/virtual_keyboard.rs• L44-106
Overlay feedback
OpenLogi overlays provide short-lived visual controls and notices without taking ownership of the main application. The agent owns action and lifetime state. The overlay helper presents a snapshot and sends hover, activation, cancellation, and dismissal results back through local IPC.
Actions Ring
The Actions Ring is a cursor-centered overlay for actions that need a visible choice. A bound input reaches the dispatcher first. The agent then starts the ring session and may pair it with device haptic feedback. The ring shows available actions around a cancel control, selects by pointer direction outside a center dead zone, and closes on activation, cancellation, or timeout.
The ring stays within the display that contains the cursor. The overlay tries ordered native placement options and falls back when the compositor rejects one. It remains non-activating so a selection does not move focus away from the application the action controls. Session identities prevent a delayed click-away event from closing a newer ring. On GNOME Wayland, the shell extension removes the ring from window animations so its first pointer position stays valid.
References: crates/…/hook_runtime.rs• L41-80 crates/…/main.rs• L28-115 crates/…/ring.rs• L196-214 crates/…/ring.rs• L470-483 crates/…/ring.rs• L746-814 crates/…/platform.rs• L20-95 crates/…/session.rs• L19-159 crates/…/ringAnimation.js• L1-10
Status indicators and notices
Lock-key and backlight indicators give compact feedback without taking focus. Device notices show transient status such as low battery. The agent remains the source of truth, so the overlay can update one window in place, cap the visible notice stack, and keep local dismissal separate from the notice's underlying lifetime.
References: crates/…/lock_key.rs• L1-7 crates/…/lock_key.rs• L46-109 crates/…/backlight.rs• L1-89 crates/…/notice.rs• L28-107 crates/…/notice.rs• L192-335
Overlay lifecycle
The overlay helper stays ready so the first ring opens quickly, but it is an IPC client rather than an owner of action state. One helper claims one overlay role for an agent run. It reconnects after an agent interruption and starts a new observation cursor for each connection.
Windows can keep the helper headless while no window is open. It reconnects before each ring, notice, indicator, or backlight display and releases the display connection after idle time. Other platforms keep their display connection for the helper lifetime. See Visual overlay for the overlay boundary and interaction flow.
References: crates/…/overlay.rs• L1-12 crates/…/main.rs• L28-181 crates/…/agent.rs• L78-419 crates/…/platform.rs• L97-191 crates/…/windowing.rs• L1-111 crates/…/native.rs• L65-194
Camera control
Camera support treats Logitech webcams as standard USB Video Class devices. OpenLogi discovers supported cameras, exposes controls and capture features where the platform allows them, and stores settings against a stable camera identity. It can also report camera use by another process when the platform exposes that state.
Camera devices and settings
The camera control surface covers lens movement, focus, exposure, camera environment settings, and image tuning. Automatic modes are part of the shared control vocabulary. Each device reports only the controls and ranges it supports, so the UI does not offer invalid values. On Windows, standard USB Video Class controls provide the supported lens and image settings, and changes apply to the camera device for all applications that use it.
The service also reports supported stream modes and USB link limits where the platform can expose them. Discovery keeps Logitech cameras separate from other video devices and can expose the best supported resolution and frame rate as metadata. On macOS, discovery does not open a capture session, so it does not need Camera permission. Linux may expose more than one video node for one physical camera, so OpenLogi presents one camera entry and prefers the color-capable node. On Windows, the device path is the live capture identity, while a real USB serial number is preferred for saved settings; a parent-generated instance ID is not treated as a serial number. Without one, the settings key falls back to the camera model while the live capture ID still distinguishes connected devices. Ambiguous matches fail closed. See Camera control for the user-facing feature set.
The camera layer also reports whether another process is using a camera when the platform supports that check. On macOS, this is a metadata query that does not open the camera. The result can inform camera-use automation without taking control of the stream.
References: crates/…/controls.rs• L6-145 crates/…/lib.rs• L1-27 crates/…/lib.rs• L273-381 crates/…/lib.rs• L383-427 crates/…/macos.rs• L84-187 crates/…/linux.rs• L40-180 crates/…/uvc_linux.rs• L107-250 crates/…/uvc_macos.rs• L203-424 crates/…/uvc_windows.rs• L103-224 crates/…/uvc_windows.rs• L403-432 crates/…/camera.rs• L19-59
Camera capture
Camera capture supplies a single snapshot or a live preview stream for a selected camera. Both paths expose the same decoded frame shape to the UI. A live stream becomes ready only after its first decoded frame arrives, so the UI does not treat device setup alone as a usable preview.
References: crates/…/capture_types.rs• L6-41 crates/…/capture_windows.rs• L84-201 crates/…/capture_windows.rs• L206-280 crates/…/capture_windows.rs• L362-479
Camera-use automation
Camera-use automation turns aggregate camera activity into temporary state for linked lights. A supported watcher reports stable transitions instead of reacting to every short probe result. A failed probe keeps the last known state, and a brief inactive gap during a camera transition does not switch linked lights off.
When the agent receives a confirmed transition, it changes only the effective power of lights that opted into camera linking. Manual light settings remain saved. Platforms without a supported camera-use provider keep this behavior under manual control.
References: crates/…/camera.rs• L1-105 crates/…/main.rs• L313-385 crates/…/orchestrator.rs• L517-560
Change checklist
When these files or sections are changed, remember to consider these:
- Changes to hook event kinds or pass-through rules must stay aligned with the action dispatcher and the event monitor. Both consume the same observed event stream.
- Changes to action mappings must preserve the split between synthesized OS actions and hardware actions. A new action can silently become a no-op on platforms without a native mapping.
- Changes to held shortcut behavior must preserve balanced press and release edges across overlapping chords, bare-modifier holds, and modifiers already held by the user.
- Changes to scroll output must preserve fractional distance and the distinction between ordinary wheel output and phased gesture output.
- Changes to platform key maps must keep the shared HID usage set aligned with each backend. macOS mappings need a reverse path for virtual HID output. Windows navigation keys need their scan-code and extended-key form.
- Changes to the macOS virtual keyboard must preserve CGEvent fallback, key-release ownership, rollover limits, and recovery when the device rejects a report.
- Changes to Linux virtual-device capabilities must keep every mapped key and scroll axis registered. Device startup must still allow the display stack time to discover the device.
- Changes to Linux desktop helpers must preserve the allowlisted executable boundary, timeout, single in-flight request, and keyboard fallback.
- Changes to synthetic event markers or virtual-device identity must keep injected output out of the global remap path.
- Changes to ring session messages or click-away handling must preserve session identity and terminal command behavior. A delayed event for an older ring must not affect a newer one.
- Changes to overlay startup or placement must preserve single-role ownership, compositor fallback, display-scale setup, and non-activation of the ring window.
- Changes to shared camera controls, camera identity, or discovery metadata must stay aligned with platform backends and saved settings. Vendor filtering, metadata-only enumeration, and Linux's one-entry-per-physical-camera rule must remain intact.
- Changes to Windows camera discovery or control mapping must preserve exact device-path matching, USB serial filtering, and the distinction between supported and unsupported UVC properties.
- Changes to camera capture readiness must preserve the rule that startup completes only after a decoded frame is available.
- Changes to camera-use reporting must preserve the distinction between confirmed inactivity and a failed probe. A probe error must not turn linked lights off.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| An injected event re-enters the hook | OpenLogi can repeat its own action or start a false gesture | macOS synthetic events carry a marker, and the virtual keyboard has an OpenLogi product identity. |
| A held chord releases a modifier owned by another chord or by the user | Later input loses its modifier or a key remains stuck | Held output uses shared ownership and leaves already-down modifiers out of a tap's release edge. |
| macOS virtual HID output becomes unavailable during a hold | A key can be released on a different path from its press | The device removes itself, releases its known state, re-presses stranded keys through CGEvent, and falls back for later edges. |
| A macOS HID usage has no stable keycode or reverse mapping | A shortcut or virtual-HID report silently targets the wrong key or does nothing | The shared mapping is checked in both directions, with Print Screen represented as F13. |
| Windows omits a layout scan code or extended-key flag | Apps that read physical key shape ignore the shortcut or read a keypad key instead | Layout-sensitive keys carry scan codes, and navigation keys carry the extended form. |
| Linux cannot create or discover the virtual input device | The selected action has no effect | Device creation is lazy and non-panicking. Missing services log and return, while desktop helpers use bounded fallbacks. |
| A compositor rejects the preferred overlay surface or two helpers run | The ring may not appear or two helpers may compete for state | Placement uses ordered fallbacks, and role claiming permits one overlay owner per run. |
| A delayed click-away event belongs to an older ring | A newer ring can close without a user action | The overlay checks the event's session identity. |
| Camera identity is missing or ambiguous | A camera read or write can target the wrong device, or saved settings can follow a USB port instead of the device | Camera matching fails closed, rejects parent-generated Windows instance IDs as serials, and saves settings against the strongest available identity. |
| Capture setup completes without a decoded frame | Preview can appear ready but contain no usable image | Capture waits for the first decoded frame. |
| A camera-use probe fails | Linked lights can flicker off during a normal camera transition | The watcher keeps the last known state until it receives a stable transition. |
Key files
| File | Why to read it |
|---|---|
| crates/…/main.rs | Shows how the agent joins input, overlay, camera, and IPC paths. |
| crates/…/lib.rs | Defines the shared input event, source, and pass-through contract. |
| crates/…/linux.rs | Shows Linux device boundaries, pass-through, source identity, and wheel handling. |
| crates/…/macos.rs | Explains macOS capture, permission checks, and tap safety. |
| crates/…/lib.rs | Defines the public system-input boundary exposed to the agent. |
| crates/…/inject.rs | Defines cross-platform action output, held-key ownership, and scroll contracts. |
| crates/…/linux.rs | Shows Linux virtual input, desktop services, compositor helpers, and action limits. |
| crates/…/macos.rs | Shows macOS action output, layout-aware shortcuts, and native controls. |
| crates/…/keycode.rs | Defines the HID usage and macOS keycode relationship used for shortcut output. |
| crates/…/virtual_keyboard.rs | Explains optional virtual HID routing and fallback behavior. |
| crates/…/windows.rs | Shows Windows action output, layout-aware shortcuts, and native key shape handling. |
| crates/…/main.rs | Shows overlay role ownership, IPC observations, and ring lifetime. |
| crates/…/ring.rs | Explains directional ring selection, hover feedback, and panel placement. |
| crates/…/agent.rs | Explains overlay ownership, reconnects, and command delivery. |
| crates/…/session.rs | Defines ring lifetime and session identity. |
| crates/…/notice.rs | Explains notice stacking, dismissal, and display placement. |
| crates/…/controls.rs | Defines the shared camera control vocabulary and ranges. |
| crates/…/lib.rs | Defines camera discovery, stream capability, camera-use reporting, and stable settings identity. |
| crates/…/macos.rs | Shows macOS camera metadata discovery, format capability reporting, and camera-use checks. |
| crates/…/uvc_windows.rs | Shows Windows camera discovery, UVC control support, and stable identity selection. |
| crates/…/capture_types.rs | Defines the shared capture frame and error model. |
| crates/…/camera.rs | Explains camera-use observation and state stabilization. |
| crates/…/orchestrator.rs | Shows how confirmed camera activity affects linked light power. |