Expand description
The keymap file format, generic over a game’s ActionSet (game ADR-0015,
game ADR-0031, game ADR-0034, tickets 1106 and 1107): Keys and Chords,
controller Buttons and ButtonChords (two buttons together), the
named Layouts a file lists, and
KeymapDef, a validated keymap file: each layout’s default keys, the
keys that work before a layout is chosen, the default buttons, key-repeat
timings and the sticks’ thresholds.
Nothing here names one game’s actions or layouts: a game gives its
actions as an ActionSet (action_set) and its file’s text. As a
format (ADR-0007): KeymapRon.
Re-exports§
Modules§
- action_
set - What a game’s input actions are to the input mechanism (ticket 1106):
ActionSet, implemented by the game’s own action enum, andUiAction, the few actions the generic widgets and screens react to.UiActionis an action set too, ready-made for a game that plays with the six moves alone (ADR-0036).
Structs§
- Button
Chord - What a controller binding is: one
Button, or two pressed together (a button chord, ticket 1034), written"South+East"in keymap files and saved bindings. The two are kept inButton::ALLorder, so"East+South"is the same chord as"South+East"(and is shown as the latter). How a chord fires is the input’s business (shuyi_ui::input::state). - Chord
- A key plus modifier state, e.g.
horShift+h.Shift+handhare different chords. - Chord
Def - How
ButtonChords fire (shuyi_ui::input::state): a chord button whose own action waits for its partner waits at mostwindow_ms(unless it waits for its release). - Crank
Def - How a crank turns into
Button::CrankBackandButton::CrankForwardpresses (shuyi_ui::input::crank): one pernotch_degreeswound. - Keymap
Def - The validated keymap: every
Layout’s default keys, the layout picker’s bindings, the default controller buttons, plus the key-repeat timings and stick thresholds they share. - Keymap
Ron - The keymap file (
keymap,.ron) of a game whose actions areA, checked asKeymapDef::from_sourcesays. - Layout
- A complete set of key bindings the player can pick: one entry of
layoutsin the keymap file, named by itsid. The file decides which layouts there are; this is only the name, kept inline so a layout isCopy. Names are ASCII letters, digits and_, at mostLAYOUT_NAME_MAXbytes (RightHanded). - Repeat
Def - Key-repeat timings for held repeatable actions.
- Stick
Def - How far a stick must be pushed to count as a held direction
(
Button::LeftStickUpand the rest), in percent of its full travel.release_percentis belowpress_percent, so a stick resting near the edge of the dead zone doesn’t flicker.
Enums§
- Button
- A controller button, named by its position on an Xbox-shaped
pad, whatever is printed on it (game ADR-0034). Each stick’s four
directions count as buttons too, and so does a crank wound one
notch either way (the Playdate’s, ticket 1035: pressed and let go
once per notch), and so does an item of the game’s own in the
system’s menu (pressed and let go when the player picks it,
ADR-0008 §3).
apptranslates what the platform reports to these; anything else on a pad is ignored, and so are the system’s own buttons (the Playdate’s Menu and Lock, the Deck’s Steam and Quick Access), which no keymap can name. - Key
- A hardware-agnostic keyboard key.
apptranslates platform key codes to these; anything without a variant is ignored.
Constants§
- LAYOUT_
NAME_ MAX - Most bytes in a
Layout’s name. - SLOTS
- Key slots per action: a layout lists at most this many chords for an
action, and the player can give each action up to this many keys
(
docs/design/controls.md, Rebinding keys). - SYSTEM_
MENU_ ITEMS - The system menu items a keymap can name:
Button::SystemMenu0toButton::SystemMenu7. A target holds fewer (shuyi_assets::target::Input::system_menu_slots).
Type Aliases§
- Bindings
- Validated bindings as a lookup: each chord maps to exactly one action (of one group). Unbound chords are absent.
- Layout
Keys - One layout’s default keys: every action with its chords in the order
the keymap file lists them (at most
SLOTS, none reserved), no chord on two actions of one group. The order matters: the first chord is the one help text names, and the chords fill the player’s key slots in this order. - Layout
Names - The layouts in file order, each with the text key of its name.
- PadKeys
- The default controller buttons: every action with its buttons and
button chords in the order the keymap file lists them (at
most
SLOTS), none on two actions of one group. One table for every layout.