Skip to content

macOS input improvements: control groups, Cmd-as-Ctrl, trackpad camera pan#22

Open
redbeard wants to merge 4 commits into
ammaarreshi:mainfrom
redbeard:macos-input-improvements
Open

macOS input improvements: control groups, Cmd-as-Ctrl, trackpad camera pan#22
redbeard wants to merge 4 commits into
ammaarreshi:mainfrom
redbeard:macos-input-improvements

Conversation

@redbeard

Copy link
Copy Markdown

Summary

Four related macOS input fixes and features, found while chasing why Ctrl+number control groups were dead on Mac:

  • sagepatch: move window snap off Ctrl+1..5 — the SagePatch SDL_PollEvent interposer consumed Ctrl+1..5 for window snapping, silently swallowing the game's control-group hotkeys on every run.sh launch (the dev run script doesn't load SagePatch, which made the bug look intermittent). Snap now lives on Cmd+Option+1..5.
  • macos: Cmd acts as Ctrl — Cmd+1..0 assigns/selects control groups and works for all other Ctrl combos; physical Ctrl unchanged; Linux Super key unaffected.
  • macos: reset keyboard state on focus gain — SDL3 has no DirectInput-style KEY_LOST, so modifier key-ups swallowed while Cmd-Tabbed away left Alt/Ctrl stuck down. Mirrors the Win32 device-loss reset.
  • input: trackpad two-finger scroll pans the camera — precise-delta detection separates trackpad scrolls from wheel notches (wheels keep classic zoom); honors natural scrolling; Option+scroll zooms; pan speed follows the in-game scroll-speed option; UI listbox scrolling unaffected.

Testing

  • Verified on macOS with the deployed ZH build: Cmd+1/Ctrl+1 create groups (log-traced end to end from SDL scancodes to CREATE_TEAM messages), trackpad pan verified in-game in all four directions, mouse-free zoom via Option+scroll, menus still scroll.
  • Both GeneralsXZH and GeneralsX targets build clean; shared Core changes keep the extra wheel-message arguments invisible to consumers that read only the first three.

🤖 Generated with Claude Code

redbeard and others added 4 commits July 25, 2026 13:55
SDL3 has no DirectInput-style KEY_LOST, so modifier key-up events
swallowed while unfocused (Cmd-Tab, Mission Control) left Alt/Ctrl
stuck down and silently broke modifier hotkeys. Mirror the Win32
device-loss path by calling resetKeys() on SDL_EVENT_WINDOW_FOCUS_GAINED,
and guard refreshAltKeys() against focus events arriving before the
message stream exists.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
SagePatch's SDL_PollEvent interposer consumed Ctrl+1..5 for window
snapping, which silently swallowed the game's control-group assignment
hotkeys on every launch that loads the patch. Cmd+Option+number is
unbound in the game (Cmd now acts as Ctrl in-game, so bare Cmd+number
must stay free for control groups too).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Cmd+1..0 now assigns/uses control groups just like Ctrl+1..0, and
Cmd works for every other Ctrl combo (force attack, etc). The
physical Ctrl key keeps working unchanged. macOS only: on Linux the
GUI scancode is the desktop's Super key and stays unmapped.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Trackpad scrolls are distinguished from mouse-wheel notches by their
precise fractional deltas and horizontal axis (with a 300ms latch for
mid-gesture whole-number ticks), un-flipped per SDL's natural-scrolling
direction flag, and carried as two extra arguments on the existing
MSG_RAW_MOUSE_WHEEL message so UI listbox scrolling keeps working.
LookAtXlat pans via userScrollBy using the same magnitude convention
and speed options as the other scroll modes; Alt/Option + scroll zooms,
since a trackpad has no discrete wheel, and real mouse wheels keep the
classic zoom. Horizontal-only pan events skip the window manager so it
does not misread zero vertical spin as a wheel-down.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant