<feed xmlns='http://www.w3.org/2005/Atom'>
<title>lan-mouse/input-emulation/src/macos.rs, branch main</title>
<subtitle>a fork</subtitle>
<id>https://git.nsrddyn.com/lan-mouse/atom/input-emulation/src/macos.rs?h=main</id>
<link rel='self' href='https://git.nsrddyn.com/lan-mouse/atom/input-emulation/src/macos.rs?h=main'/>
<link rel='alternate' type='text/html' href='https://git.nsrddyn.com/lan-mouse/'/>
<updated>2026-10-25T14:04:44Z</updated>
<entry>
<title>fix locked getting unset with other key presses</title>
<updated>2026-10-25T14:04:44Z</updated>
<author>
<name>Ferdinand Schober</name>
<email>ferdinandschober20@gmail.com</email>
</author>
<published>2026-10-25T14:01:20Z</published>
<link rel='alternate' type='text/html' href='https://git.nsrddyn.com/lan-mouse/commit/?id=37df4124ecf8476f32b676e7ce2ad3e219b7a434'/>
<id>urn:sha1:37df4124ecf8476f32b676e7ce2ad3e219b7a434</id>
<content type='text'>
</content>
</entry>
<entry>
<title>fix(macos): treat Caps Lock as a lock/toggle, not a momentary modifier</title>
<updated>2026-10-25T14:04:44Z</updated>
<author>
<name>jtjones09</name>
<email>jones.jeremyt@hotashstudios.com</email>
</author>
<published>2026-06-16T21:04:16Z</published>
<link rel='alternate' type='text/html' href='https://git.nsrddyn.com/lan-mouse/commit/?id=b45d4eb1bc3c13c9e3cd007904e86a48ab0a64d4'/>
<id>urn:sha1:b45d4eb1bc3c13c9e3cd007904e86a48ab0a64d4</id>
<content type='text'>
Routing modifier keys out of the key-repeat path (#450) also rerouted Caps
Lock, which is classified as a modifier (LockMask). That made it momentary - it
only applied while the key was physically held instead of latching. Caps Lock
is a LOCKING modifier (XKB "locked"), so a press should toggle a persistent
state.

update_modifiers() now toggles LockMask on Caps Lock key-down and ignores
key-up, so the AlphaShift flag stays set on every subsequent keystroke until
Caps Lock is pressed again. A synthetic CGEvent can't flip the hardware Caps
Lock LED, but carrying the flag produces the correct upper-case output (and,
like real Caps Lock, leaves number-row symbols unshifted).

Co-Authored-By: Claude Opus 4.8 (1M context) &lt;noreply@anthropic.com&gt;
</content>
</entry>
<entry>
<title>fix(macos): correct modifier-key injection, incl. Virtualization.framework guests (#450)</title>
<updated>2026-10-25T14:04:44Z</updated>
<author>
<name>jtjones09</name>
<email>jones.jeremyt@hotashstudios.com</email>
</author>
<published>2026-06-16T20:08:53Z</published>
<link rel='alternate' type='text/html' href='https://git.nsrddyn.com/lan-mouse/commit/?id=400c6468ed0aaada30a25620818fca690aaf225e'/>
<id>urn:sha1:400c6468ed0aaada30a25620818fca690aaf225e</id>
<content type='text'>
Modifier-key injection on macOS was broken in several ways. This fixes the
CGEvent bugs diagnosed in #450 and additionally makes modifier chords register
inside Apple Virtualization.framework guest windows.

Layer 1 - CGEvent bugs (originally diagnosed and patched by bmajewski, #450):
- modifier_event() built a bare CGEvent, which defaults to keycode 0
  (kVK_ANSI_A), so every modifier change arrived in apps as a phantom "A" key
  (holding Ctrl registered as Ctrl+A; shortcut recorders captured "A"). It now
  posts a FlagsChanged event carrying the modifier's real keycode
  (modifier_key_event).
- Modifier keys went through the single-slot key-repeat task; pressing a second
  modifier cancelled the first's repeat task and released it while still held,
  tearing chords apart (also the likely cause of #357). Modifiers no longer
  enter the repeat machinery.
- The wholesale Modifiers state handler also posted a (bare) FlagsChanged,
  duplicating the per-key event / injecting the phantom "A"; it now only updates
  internal modifier state.
- to_cgevent_flags() silently dropped Mod5 (ISO_Level3_Shift / AltGr), so Alt
  reported as Mod5 (common on xkb keymaps) never set Option. Mod1 and Mod5 now
  both map to Option.

Layer 2 - Virtualization.framework guest modifiers:
VZVirtualMachineView (Apple Virtualization.framework, used by UTM's Apple
backend, Parallels' macOS guests, VirtualBuddy, etc.) derives the guest's
modifier state from AppKit's flagsChanged(with:) and reads the device-dependent
low-word flag bits, which macOS does not synthesize for posted events - so
Cmd/Ctrl/Shift/Opt chords reached the guest unmodified. modifier_flags_changed_flags()
now also sets the IOKit NX_DEVICE*KEYMASK bits and CGEventFlagNonCoalesced so the
synthetic FlagsChanged is byte-faithful to real hardware. Ordinary apps mask
incoming events to the device-independent word and ignore these bits, so this is
safe for every app and needs no VM/bundle-id detection.

See https://developer.apple.com/forums/thread/766014

Co-authored-by: bmajewski &lt;bmajewski@users.noreply.github.com&gt;
Co-Authored-By: Claude Opus 4.8 (1M context) &lt;noreply@anthropic.com&gt;
</content>
</entry>
<entry>
<title>fix(macos): respect Natural Scrolling for scroll direction, both directions (#498)</title>
<updated>2026-10-25T11:33:54Z</updated>
<author>
<name>Daniel Hanson</name>
<email>hansondr@users.noreply.github.com</email>
</author>
<published>2026-10-25T11:33:54Z</published>
<link rel='alternate' type='text/html' href='https://git.nsrddyn.com/lan-mouse/commit/?id=cf22560fad2eda18b7a3cba4d4e4e3be8cf83fe0'/>
<id>urn:sha1:cf22560fad2eda18b7a3cba4d4e4e3be8cf83fe0</id>
<content type='text'>
* fix(macos): respect Natural Scrolling for scroll direction, both directions

Scrolling from a non-macOS sender onto a macOS receiver is inverted
(wl_pointer.axis / libei use positive = scroll down/right, the opposite of
CGEvent's convention). Symmetrically, a macOS sender scrolls backwards on
non-macOS receivers.

Capture (input-capture/src/macos.rs): negate the delta at capture time on
both the continuous (PIXEL) and discrete (v120) paths and both axes, so the
wire stays source-agnostic (matches the approach in #470). Real hardware
deltas already reflect this Mac's own Natural Scrolling preference -- the OS
applies that transform upstream, before the event reaches this tap -- so a
fixed conversion is correct here; no preference read is needed.

Emulation (input-emulation/src/macos.rs): convert the wire sign to CGEvent's
sign, but -- unlike #470's fixed conversion -- read the receiver's
com.apple.swipescrolldirection preference and negate conditionally. This
revives the approach from #460, caching the CFString preference key on
MacOSEmulation instead of allocating it per scroll tick.

A synthetic CGEvent posted at the HID event tap produces the same on-screen
direction for a given sign regardless of Natural Scrolling (confirmed on
hardware, consistent with #470 and #481). But a real trackpad's delta sign is
flipped by the OS before the CGEvent exists, specifically because of Natural
Scrolling. So with a fixed conversion, turning Natural Scrolling on desyncs a
real trackpad from Lan Mouse's forwarded mouse-wheel input on the same Mac;
turning it off only re-syncs them because the fixed sign happens to match the
non-natural convention. Reading the preference keeps both in sync in either
state.

Verified on real hardware, both directions, against the exact 0.11.0 release
protocol (not just main, to rule out wire-compatibility noise):
- Windows (sender) -&gt; macOS/Apple Silicon (receiver): correct with Natural
  Scrolling both on and off; forwarded scroll stays in sync with the
  receiving Mac's own trackpad in both states.
- macOS/Apple Silicon (sender) -&gt; Windows (receiver): correct with Natural
  Scrolling both on and off, matching what a real trackpad in each state
  produces.

Prior art: #470 (capture-side fix reproduced here), #460 (the emulation-side
preference read this revives), #481 (the symptom report), #415 / #347 (as
noted in #470).

* invert scrolling for Axis events, not Axis120

this matches the wire convention from Linux / Libei, etc.

---------

Co-authored-by: Ferdinand Schober &lt;ferdinandschober20@gmail.com&gt;</content>
</entry>
<entry>
<title>macos: map Print Screen / Scroll Lock / Pause to F13/F14/F15 (#445)</title>
<updated>2026-09-23T08:17:00Z</updated>
<author>
<name>Ty Smith</name>
<email>ty@tysmith.me</email>
</author>
<published>2026-09-23T08:17:00Z</published>
<link rel='alternate' type='text/html' href='https://git.nsrddyn.com/lan-mouse/commit/?id=2789a465163ec32016929e7f392d663169ef7b69'/>
<id>urn:sha1:2789a465163ec32016929e7f392d663169ef7b69</id>
<content type='text'>
* macos: map Print Screen / Scroll Lock / Pause to F13/F14/F15

The keycode crate's Chromium-derived table has no macOS CGKeyCode for
these three PC-only keys, so they were silently dropped. Map them to
F13/F14/F15 respectively, which is the conventional macOS stand-in for
keys that do not exist on Apple keyboards.

* style: cargo fmt

Apply rustfmt to fix the failing Formatting CI check.</content>
</entry>
<entry>
<title>docs(macos): clarify repeat-task cleanup releases the key</title>
<updated>2026-06-12T10:07:03Z</updated>
<author>
<name>Ty Smith</name>
<email>ty@tysmith.me</email>
</author>
<published>2026-05-27T00:00:27Z</published>
<link rel='alternate' type='text/html' href='https://git.nsrddyn.com/lan-mouse/commit/?id=4b93be3228f860c7b96854cfa963fc94b380f458'/>
<id>urn:sha1:4b93be3228f860c7b96854cfa963fc94b380f458</id>
<content type='text'>
Address @feschber review feedback on PR #441. The repeat-task cleanup
already releases the key with the correct CGKeyCode via the existing
key_event call at the end of the closure — this commit just expands
the surrounding comment to make that explicit and to document why
update_modifiers is intentionally NOT called from this path (Mac
CGKeyCode vs Linux evdev scancode collision).

No behavioral change.

Co-Authored-By: Claude Opus 4.7 (1M context) &lt;noreply@anthropic.com&gt;
</content>
</entry>
<entry>
<title>macos: stop corrupting modifier state in repeat-task cleanup</title>
<updated>2026-06-12T10:07:03Z</updated>
<author>
<name>Ty Smith</name>
<email>ty@tysmith.me</email>
</author>
<published>2026-05-19T23:22:52Z</published>
<link rel='alternate' type='text/html' href='https://git.nsrddyn.com/lan-mouse/commit/?id=c32d695cd9cb6db89519188ac8e0e217e1cff47a'/>
<id>urn:sha1:c32d695cd9cb6db89519188ac8e0e217e1cff47a</id>
<content type='text'>
spawn_repeat_task() takes a Mac CGKeyCode, but the cleanup block was
passing that value to update_modifiers(), which expects a Linux evdev
scancode (it calls scancode::Linux::try_from(key)). The two codespaces
collide on several values, so cancelling the repeat task could
silently clear a still-held modifier:

  Mac LeftShift   = 56  == Linux KeyLeftAlt   = 56  -&gt; clears Mod1Mask
  Mac Down arrow  = 125 == Linux KeyLeftMeta  = 125 -&gt; clears Mod4Mask
  Mac Up arrow    = 126 == Linux KeyRightMeta = 126 -&gt; clears Mod4Mask
  Mac Backslash   = 42  == Linux KeyLeftShift = 42  -&gt; clears ShiftMask
  Mac "9"         = 29  == Linux KeyLeftCtrl  = 29  -&gt; clears ControlMask

In practice this broke chords such as Shift+Option+X and Cmd+Down:
pressing Shift while holding Option cancels Option's repeat task and
runs the buggy cleanup, which then interprets Mac LeftShift's code
(56) as Linux KeyLeftAlt and removes Option from the modifier state.
The next key arrives with Shift only, so window-manager bindings on
the original Option chord never fire.

Remove the buggy update_modifiers() call. Modifier state is owned by
the main consume() loop, which already calls update_modifiers() with
the correct Linux scancode on the real release event.

Co-Authored-By: Claude Opus 4.7 (1M context) &lt;noreply@anthropic.com&gt;
</content>
</entry>
<entry>
<title>macos: post NumericPad and SecondaryFn flags for synthesized arrow keys</title>
<updated>2026-06-12T10:07:03Z</updated>
<author>
<name>Ty Smith</name>
<email>ty@tysmith.me</email>
</author>
<published>2026-05-19T23:22:31Z</published>
<link rel='alternate' type='text/html' href='https://git.nsrddyn.com/lan-mouse/commit/?id=82d677f9c8c8fdf6beca900780ce24bd604e84c4'/>
<id>urn:sha1:82d677f9c8c8fdf6beca900780ce24bd604e84c4</id>
<content type='text'>
Hardware-generated arrow key events on macOS carry the NumericPad and
SecondaryFn flags in addition to any user-pressed modifiers. CGEventTap-
based hotkey matchers (tiling window managers, accessibility tools, etc.)
commonly check those flags to disambiguate navigation arrows from generic
chords, and reject events that lack them.

Before this change, synthesized Option+Arrow chords were silently
swallowed by the focused application instead of being captured by the
window manager, because the events arrived with only the Alternate flag
set. Hardware Option+Arrow chords on the local keyboard worked because
the OS itself set the missing flags.

Add NumericPad + SecondaryFn to the flags posted with arrow key events
(Mac key codes 0x7B-0x7E) so synthesized arrow chords match hardware
chords on the wire.

Co-Authored-By: Claude Opus 4.7 (1M context) &lt;noreply@anthropic.com&gt;
</content>
</entry>
<entry>
<title>macos: per-pane TCC navigation and Sequoia-tolerant permission flow</title>
<updated>2026-04-29T20:59:43Z</updated>
<author>
<name>Jon Kinney</name>
<email>jonkinney@gmail.com</email>
</author>
<published>2026-04-24T07:09:32Z</published>
<link rel='alternate' type='text/html' href='https://git.nsrddyn.com/lan-mouse/commit/?id=5e79743bd05a4bcfa48f9e9262896985e767a91b'/>
<id>urn:sha1:5e79743bd05a4bcfa48f9e9262896985e767a91b</id>
<content type='text'>
On macOS the three TCC grants (Accessibility, Input Monitoring, Post
Event) live in separate Privacy panes. Before this change the
"Reenable" row sent the user to Accessibility regardless of which
grant was actually missing, and the daemon's own permission checks
re-fired the Accessibility prompt on every retry.

- lan-mouse-gtk/src/macos_privacy.rs: new module that exposes silent
  preflight checks (AXIsProcessTrusted, CGPreflightListenEventAccess,
  CGPreflightPostEventAccess), per-pane URL-scheme navigation, and
  a Once-guarded fire_initial_prompts() called from build_ui. The
  initial-prompt path only fires the Accessibility prompt if AX is
  missing and then returns; secondary registrations run only after
  AX is granted, which prevents a double Accessibility alert on
  Sequoia where Post Event is nested under Accessibility.
- Input Monitoring registration attempts CGEventTapCreate at
  kCGSessionEventTap (not kCGHIDEventTap) so a failure surfaces as
  an Input Monitoring signal rather than triggering an Accessibility
  prompt as a side effect.
- lan-mouse-gtk/src/window/imp.rs: handle_capture / handle_emulation
  switch on the missing-pane enum and navigate to the specific pane
  via x-apple.systempreferences:... URLs before re-requesting.
- lan-mouse-gtk/resources/window.ui: pill class on the Reenable
  buttons so the hover padding matches the rest of libadwaita.
- input-capture/src/macos.rs, input-emulation/src/macos.rs: make
  request_*_permission() a silent preflight (AXIsProcessTrusted /
  CGPreflightListenEventAccess / CGPreflightPostEventAccess), so the
  daemon no longer fires TCC prompts on retry — all prompting is
  owned by the GUI.
- input-capture/src/error.rs, input-emulation/src/error.rs: new
  error variants so the GUI can distinguish missing-AX from
  missing-IM / missing-PostEvent for pane routing.

Verified on macOS 15.5: first launch fires a single AX prompt;
second launch (AX granted) registers under Input Monitoring via the
session-tap attempt and requests Post Event. Sequoia auto-grants the
listen-only path via AX so the IM list may stay empty, which is the
intended OS behavior and no longer blocks capture.

Co-Authored-By: Claude Opus 4.7 (1M context) &lt;noreply@anthropic.com&gt;
</content>
</entry>
<entry>
<title>fix(macos): forward back/forward mouse buttons in capture and emulation (#392)</title>
<updated>2026-02-22T16:45:53Z</updated>
<author>
<name>Ty Smith</name>
<email>ty@tysmith.me</email>
</author>
<published>2026-02-22T16:45:53Z</published>
<link rel='alternate' type='text/html' href='https://git.nsrddyn.com/lan-mouse/commit/?id=27225ed56435681b18cfbb0499320fc626359730'/>
<id>urn:sha1:27225ed56435681b18cfbb0499320fc626359730</id>
<content type='text'>
* fix(macos): forward back/forward mouse buttons in capture and emulation

OtherMouseDown/Up events on macOS carry a button number field that
distinguishes middle (2), back (3), and forward (4) buttons. The
capture backend was unconditionally mapping all OtherMouse events to
BTN_MIDDLE, silently dropping back/forward. The emulation backend had
no match arms for BTN_BACK/BTN_FORWARD, causing them to be dropped
with a warning.

Fix capture by reading MOUSE_EVENT_BUTTON_NUMBER and mapping 3-&gt;BTN_BACK,
4-&gt;BTN_FORWARD. Fix emulation by adding match arms for BTN_BACK/BTN_FORWARD
and setting MOUSE_EVENT_BUTTON_NUMBER on the emitted CGEvent so macOS
apps receive the correct button identity.

* fix(macos): track button state and double-clicks by evdev code instead of CGMouseButton

Back, forward, and middle buttons all map to CGMouseButton::Center on
macOS, which caused them to share a single pressed-state boolean and
alias in double-click detection. Replace the ButtonState struct with a
HashSet&lt;u32&gt; keyed by evdev button code so each button is tracked
independently.

---------

Co-authored-by: Ferdinand Schober &lt;ferdinandschober20@gmail.com&gt;</content>
</entry>
</feed>
