Skip to content

fix(hook): remap aux buttons that arrive without HID attribution on macOS 26 - #733

Open
tims2002 wants to merge 1 commit into
AprilNEA:masterfrom
tims2002:fix/macos26-aux-button-attribution
Open

fix(hook): remap aux buttons that arrive without HID attribution on macOS 26#733
tims2002 wants to merge 1 commit into
AprilNEA:masterfrom
tims2002:fix/macos26-aux-button-attribution

Conversation

@tims2002

Copy link
Copy Markdown

Problem

On macOS 26, all OS-hook button remaps and hold+swipe gestures silently stop working, while HID++-diverted single-action bindings keep working. This makes the breakage look device-specific (it isn't) — observed with an ERGO M575 over both Bluetooth LE and a Unifying receiver, and it should affect every device whose Middle/Back/Forward go through the CGEventTap hook.

Root cause

macOS 26 delivers other-mouse (aux button) CGEvents without a backing IOHIDEventCGEventCopyIOHIDEvent returns null — so event_sender_id yields None and button_source_may_remap fails closed, passing every Middle/Back/Forward press through untouched.

Verified with a listen-only diagnostic tap on macOS 26.6.2 (arm64), pressing buttons on the same physical device:

event type=1  button=0 hidEvent=yes senderID=0x10001e970 Product=USB Receiver VendorID=1133   ← left click: attribution intact
event type=25 button=4 hidEvent=NULL                                                          ← aux button: no HID backing
event type=26 button=4 hidEvent=NULL

Left clicks still attribute correctly, so the regression is specific to aux-button events in the macOS 26 input pipeline.

Fix

Allow an unattributed event through the gate only for the OS-hook buttons (Middle/Back/Forward). The fail-closed rule exists so the built-in trackpad can never be swallowed — but trackpads never emit those buttons, so that rationale doesn't apply to them. Attributed events keep the existing Logitech/non-trackpad check, and everything else keeps failing closed.

Testing

  • macOS 26.6.2 (arm64), ERGO M575 via Bluetooth LE and via Unifying receiver (slot 2)
  • Click remaps and all five per-direction gesture slots on Back/Forward work again; Middle unaffected as a single-action HID++ divert and works as a gesture owner too
  • Trackpad input unaffected (left/right/primary pass-through preserved)

Possible follow-up (not in this PR)

The M575 (and likely other non-MX devices) reports divertable, raw-xy on CIDs 0x52/0x53/0x56 (openlogi diag controls), so per-direction gestures for these buttons could be delivered over HID++ raw-XY diversion like the MX gesture button — transport-independent and immune to CGEvent pipeline changes like this one. Happy to file a separate issue if useful.

🤖 Generated with Claude Code

…acOS 26

macOS 26 delivers other-mouse (aux button) CGEvents with no backing
IOHIDEvent: CGEventCopyIOHIDEvent returns null for otherMouseDown/Up,
while left-click events from the same physical device still carry a
sender that resolves to the expected IOKit service (verified with a
listen-only tap on macOS 26.6.2 / arm64: left clicks report
Product="USB Receiver", VendorID=0x046d; button-4 events report a null
HID event).

The hook's fail-closed attribution gate therefore dropped every
Middle/Back/Forward press, silently disabling all OS-hook remaps and
hold+swipe gestures — while HID++-diverted single-action bindings kept
working, which made the breakage look device-specific.

Allow an unattributed event through the gate only for the OS-hook
buttons (Middle/Back/Forward): built-in trackpads never emit those
buttons, so the trackpad-protection rationale for failing closed does
not apply to them. Everything else keeps failing closed as before.

Tested on macOS 26.6.2 (arm64) with an ERGO M575 over both Bluetooth LE
and a Unifying receiver: click remaps and per-direction gestures on
Back/Forward/Middle work again; trackpad input is unaffected.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@tims2002
tims2002 requested a review from AprilNEA as a code owner August 20, 2026 21:48
@greptile-apps

greptile-apps Bot commented Aug 20, 2026

Copy link
Copy Markdown

Greptile Summary

The PR restores macOS 26 remapping for auxiliary mouse events that arrive without HID attribution while retaining source checks for attributed events and fail-closed behavior for primary buttons.

  • Passes the button ID into the source-remapping gate.
  • Allows unattributed Middle, Back, and Forward events on macOS.
  • Preserves the existing Logitech/non-trackpad validation for attributed events.

Confidence Score: 5/5

The PR appears safe to merge, with no concrete blocking or independently actionable issue identified.

The relaxed path applies only to Middle, Back, and Forward events lacking device attribution; attributed events retain the existing source validation, and primary buttons remain excluded before remapping.

Important Files Changed

Filename Overview
crates/openlogi-agent-core/src/hook_runtime.rs Narrows the macOS missing-attribution exception to the three OS-hook auxiliary buttons without exposing primary-button events to suppression.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Mouse button event] --> B{Middle, Back, or Forward?}
  B -- No --> P[Pass through]
  B -- Yes --> C{Device attributed?}
  C -- Yes --> D{Logitech non-trackpad?}
  D -- No --> P
  D -- Yes --> R[Resolve configured remap]
  C -- No --> E{Running on macOS?}
  E -- No --> R
  E -- Yes --> R
Loading

Reviews (1): Last reviewed commit: "fix(hook): remap aux buttons that arrive..." | Re-trigger Greptile

@davidbudnick davidbudnick added type: bug Something is broken or behaves incorrectly platform: all Cross-platform issue labels Aug 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

platform: all Cross-platform issue type: bug Something is broken or behaves incorrectly

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants