Repository navigation
DM_KEY_MAP gives keys of the Mac keyboard another control than the layout's: Space the R shoulder, a modifier key a button, an arrow a stick (issue #1216) - #2006
Closed
Atomsk-debug wants to merge 1 commit into
Conversation
…yout's: Space the R shoulder, a modifier key a button, an arrow a stick, through a map read once at start (issue seedds#1216) The Mac keyboard's layout was fixed in front_mac.m (key_bit, on_key): J K U I the buttons, Q E Z C the shoulders and triggers, WASD and the arrows the sticks and the D-pad, Space the shake. On a MacBook's keyboard Space drifts better than E in Mario Kart World, and no setting changed a key. key_map.h holds the names of the keys (macOS's virtual key codes, letters and digits as they are, then space, return, tab, escape, the punctuation, f1 to f12, the arrows and the modifiers) and of the controls (the buttons, the D-pad, both sticks' directions, shake, none), and the parser of DM_KEY_MAP="<key>:<control>,...": a key the map names takes that control and loses the layout's, every other key keeps it, and a wrong map is refused whole with the entry in a [RED] line, so a typo never leaves half a layout. front_mac.m asks the map first (key_action), then the layout. The two traps of the issue: a modifier key comes as a flagsChanged event with no key down or up, so the window's monitor takes those events too and reads the key's own bit of the flags (left and right apart); and a key pressed with Command held stays a menu shortcut unless a Command key is itself mapped, when such keys are the game's. docs/settings.md names the layout and the map; docs/env_switches.tsv has the row. Checked: t_key_map (names, the issue's map in any letter case and with either separator, a key given twice, the empty map, four wrong maps); the Mac host builds for Super Mario Bros. Wonder; test_env_switches and test_docs pass. Not pressed in a game yet: the map's keys reach on_key by the same path as the layout's, and the modifier path is new. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Atomsk-debug
force-pushed
the
mac-key-map
branch
from
November 10, 2026 11:16
8418a8c to
3f207d9
Compare
Owner
|
Thanks for documenting the MacBook controls that made drifting easier and for testing modifier keys. I checked the PR against the three current controls proposals in #2781, #2741 and #3141. A separate #1216 stays open for remapping. The Space-to-R example and the need to handle modifier-only |
chgpalmer
added a commit
to chgpalmer/nxnative
that referenced
this pull request
Nov 29, 2026
The Mac front end's half of the controller mapping (host/input: keymap.h, the remap in hle_hid.c): - In the game (front_mac.m, keyboard_mac.h): the keyboard goes through the map in place of the fixed key table, Shift, Control and Option keys included (flagsChanged). Each player's controller table goes to the host (dm_pad_map_set) at the start and after every change. - The mouse (mouselook_mac.h): with a mouse direction bound, a click on the game captures the pointer and its movement goes through keymap_mouse.h at 120 Hz, to player 1's sticks and buttons, or to the motion sensor as a controller turned in the hands (dm_motion_set_switch: upright in handheld mode, flat docked). Esc, a focus loss or the panel lets it go. - The settings window (Launcher.swift): Controls › Controller mapping › Customize…: a tab per player 1-8; player 1 has its keyboard and mouse or its controller; click a row and press a key or chord, click a mouse button, or press a controller's button or push its stick; right-click for Clear, Add Input… or a mouse direction; Mouse and trackpad puts the mouse on a stick or the motion controls with its sensitivity and Invert Y axis; a Preset menu per device (keymap_presets.h). Kept as the saved choice launcher.DM_KEYMAP, which launcher.c checks with the host's parser. - In the game, Window › Controller Mapping… (⌘⇧K, keymap_panel_mac.h) is the same map while playing: a change applies at once and is saved for the next start. - pad_apple.h's dm_pad_state is now the one reading of a GameController pad as the Switch's, used by the host's pad_read and the settings window's press-to-bind (pad_bridge.m). Covers seedds#2346 (mouse as a stick), seedds#2392's and seedds#356's asks (mouse look, the camera on plain arrows), the keyboard part of seedds#386 and seedds#2006's modifier keys; keys are tracked as pressed, so Shift let go before an arrow does not leave the right stick held (seedds#1535). Tests: test_launcher_storage (the window with the sheet's model), test_nsp_mac_app, test_docs, test_env_switches. Front-ends: new: launcher.DM_KEYMAP is a saved choice, checked by the host's parser (docs/frontends.md, Saved choices) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Open
1 task done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
For #1216. The Mac keyboard's layout was fixed in
front_mac.m(key_bit,on_key); on a MacBook's keyboard Space drifts better than E in Mario Kart World, and no setting changed a key.dm/host/key_map.hholds the names of the keys (macOS's virtual key codes: letters and digits as they are, thenspace,return,tab,escape, the punctuation,f1tof12, the arrows and the modifierslshift,rshift,lctrl,rctrl,lalt,ralt,lcmd,rcmd,capslock,fn) and of the controls (a,b,x,y,l,r,zl,zr,ls,rs,plus,minus, the D-pad, both sticks' directions,shake,none), and the parser ofDM_KEY_MAP="<key>:<control>,…": a key the map names takes that control and loses the layout's, every other key keeps it, and a wrong map is refused whole with the entry in a[RED]line.front_mac.masks the map first (key_action), then the layout; the issue's own map isDM_KEY_MAP=space:r,lshift:l,left:rleft,up:rup,right:rright,down:rdown,minus:minus,equal:plus.The two traps the issue names: a modifier key reaches the window as a
flagsChangedevent with no key down or up, so the window's monitor takes those events too and reads the key's own bit of the flags (left and right apart); and a key pressed with Command held stays a menu shortcut unless a Command key is itself mapped, when such keys are the game's (said in the docs).Docs: a Keyboard section under the Mac settings window in
docs/settings.md(the layout, which no page named, and the map), and the row indocs/env_switches.tsv.Checked
t_key_map(new): the names, the issue's map in any letter case and with either separator, a key given twice, the empty map, four wrong maps.make -C dm/host GAME=010015100B514000 dmhostbuilds;test_env_switchesandtest_docspass.on_keyby the same path as the layout's; the modifier path (flagsChanged) is new and has not been pressed in a game. I will add a run with the issue's map when I can; anyone with a keyboard and a game can tryDM_KEY_MAP=space:rin the game'senv.txt.lint_cnot run locally (no LLVM clang-tidy here).Docs
🤖 Generated with Claude Code