Notes for anyone changing the code. The README covers what the app does; this covers the constraints that are easy to violate without noticing.
Everything intuitive in this app works by demonstration, not description:
| Works well | Because |
|---|---|
| Record | you perform the buttons |
| Press keys… | you press the shortcut |
| Browse… | you click through the app's real menus |
| Pick… | you point at the control |
| Choose… | you pick the file |
The features that felt wrong before being reworked were all the opposite: typing a menu path from memory, ticking modifier boxes, "edit the steps in JSON". When adding anything, ask which side it falls on.
The same principle applies to hardware. The buttons a mouse has cannot be read from its HID descriptor (an MX Master 3S declares sixteen, and some keyboards declare eight), so the mouse diagram goes by what the device says it is, and unions in whatever it has actually seen pressed.
The engine synthesizes mouse events, so a bug here can latch a button system-wide. These are non-negotiable:
- Never emit a mouse-down without its up on any exit path, including errors, early returns, and the tap being disabled by timeout.
- Keep synthesized press/release pairs adjacent. Posting a synthesized press while returning the real release from the tap callback puts the two events on different paths and leaves their ordering to the window server. That exact bug shipped once, and it presented as a latch even though every release was accounted for.
- No state API can detect a latch, so you cannot add a watchdog that notices one. Prevention is the only defense.
- Never withhold a primary button's press. Left and right pass straight through and are only observed; the pass-through path never withholds anything, so it cannot latch.
If clicking ever breaks system-wide while testing: ./scripts/unstick.sh, or Release stuck
buttons in the editor, which does the same thing without needing a working terminal.
Macros may start on any button, under three policies rather than one:
- Thumb / wheel buttons are withheld until release, then replayed if no macro followed. There is deliberately no timeout that delivers the press mid-hold: one existed once, and holding Back while deciding on a second button navigated the browser back. The cost is that a button some macro holds cannot press-and-drag while so assigned.
- Left and right pass straight through. A macro still fires if a second button arrives while they are held, and Escape is sent to dismiss the context menu or cancel the drag.
- The button below the wheel (MX Master) is not an event at all: the mouse keeps it to toggle the ratchet. With diversion enabled it reports over HID++ instead, joins macro matching, and posts nothing, so that path cannot latch either. It is the one button that stops working when this app does, which is why diversion is off by default.
scripts/preview-editor.sh renders the whole editor offscreen, one image per action type; it is
the fastest way to check anything visual. Two blind spots:
- In a forced-dark cached display, standard AppKit controls and semantic colours render as
nothing, so a dark preview only proves out custom
draw(_:)code. - The preview window is never key, so selected and emphasised states are unreachable through the table: a white-on-white selected row once sailed through it.
Exercised end to end: macros firing, text actions typing, the master–detail editor, secure text via the Keychain, the Mouse tab, and diverting the below-wheel button including all three restore paths (untick the setting, quit the app, disconnect the mouse).
Driven little or not at all:
- Browse…: building another app's menu tree and picking an item from it.
- Pick…: pointing at a control or screen position and capturing it.
- Drag-reordering the macro list.
- Typing after an authentication prompt.
runTextwaits 300ms before typing when the secret required authentication, on the theory that the auth panel does not hand focus back instantly. That number is a guess. If an authenticated macro types nothing, raise it; the failure logs.
sequencehas no editor. Removed from the type list rather than shipping "edit the JSON". Hand-written sequences survive a round trip through the editor untouched. Offering the type again needs a real step editor: add, remove, reorder steps of text, key combo, delay.shellactions cannot use the Keychain, so a command containing a token sits in plaintext inbindings.json.textactions can; the same mechanism applies to both.- No way to type a shell command's output, which blocks date stamps, generated passwords,
clipboard transforms. Would be a flag on
shellto type stdout. - Notarization unresolved, so the release is source-only.
MouseHardware.knownLayoutsis a lookup table mapping product names to buttons; anything unrecognised shows the full set. The honest upgrade is remembering which button numbers each device has actually emitted, per device: demonstration rather than a table, like the rest of the app.- Other divertable controls. Feature
0x1B04reports the wheel click, back, forward and the thumb button as divertable too. Only the below-wheel button needs it; diverting the others would only be worth it to stop them reaching other apps at all.
See the end of the README's "How it works": report descriptors differ per transport, replies are zero-padded, and register read-back does not reflect tactile behavior. All three have bitten.