AprilNEA / AprilNEA/OpenLogi

Event-driven device enumeration to replace the 2s polling probe

Open
#156 1 comment 0 reactions 0 assignees View on GitHub
area: hid needs: decision platform: all type: enhancement
Dominant language
Rust
Stars
21k
Forks
675
Avg merge
1d 6h
Merged PRs (30d)
180

Description

### Context

Device discovery is a ~2s polling loop (`crates/openlogi-gui/src/watchers/inventory.rs`) calling `openlogi_hid::enumerate`. PR #147 cut the per-tick cost (concurrent probing + a per-device probe cache), but the model is still poll-and-reprobe.

### Problem (inherent to polling)

- A sleeping / unresponsive device must be *actively* probed, hit the 5s `PROBE_BUDGET`, and be retried — producing the recurring `device probe timed out — skipping (asleep/unresponsive)` warning and a standing per-tick cost (common when a device is dual-paired over both a Bolt dongle and Bluetooth, with one path dormant).
- Even with the cache, every tick still does cheap per-slot receiver reads and periodic re-probes; nothing reacts to actual device arrival / removal.

### Proposed direction (event-driven + stateful)

- React to OS HID hot-plug (arrival / removal) and to the Bolt receiver's own HID++ connection / wake notifications (`BoltEvent::DeviceConnection`, which we already drain once per tick) instead of polling.
- Probe a device once on (re)connection; keep a persistent device model; only react to pushed changes (wake, battery).
- This eliminates the periodic re-probe and the asleep-device timeout dance entirely.

### Blocker

`async-hid 0.4` exposes no hot-plug listener API, and a cross-platform event source (IOKit matching on macOS, udev/netlink on Linux, `WM_DEVICECHANGE` on Windows) is the hard part — which is why polling was chosen for simplicity (see the module comment in `watchers/inventory.rs`). Likely needs an `async-hid` upgrade or platform-specific code.

Large / epic. Tracking the architecture.

_Surfaced by the code review of #147 and the surrounding discussion._

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with crates/openlogi-gui/src/watchers/inventory.rs, its module comment, and the current openlogi_hid::enumerate loop. Trace how BoltEvent::DeviceConnection is drained and review the async-hid 0.4 limitation described in the issue. Done means the architecture reacts to device arrival, removal, and pushed connection changes without periodic probing or asleep-device timeout retries.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
desktop, operating-systems
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.