pub struct Keymap<A: ActionSet> { /* private fields */ }Expand description
Lookup from chord, and from controller button or button chord, to actions, plus repeat and chord timings. A chord or button is on at most one action of each group (game ADR-0068), so one press can give an action of each group: the screen on top reacts to the ones it uses.
Implementations§
Source§impl<A: ActionSet> Keymap<A>
impl<A: ActionSet> Keymap<A>
Sourcepub fn new(
bindings: impl IntoIterator<Item = (Chord, A)>,
repeat: RepeatDef,
) -> Self
pub fn new( bindings: impl IntoIterator<Item = (Chord, A)>, repeat: RepeatDef, ) -> Self
A keymap with bindings plus the game’s
fixed keys. A chord listed twice for one
group keeps its last action of that group;
reserved chords (plain Escape and Delete)
are left out.
Sourcepub fn with_pad<B: Into<ButtonChord>>(
self,
pad: impl IntoIterator<Item = (B, A)>,
) -> Self
pub fn with_pad<B: Into<ButtonChord>>( self, pad: impl IntoIterator<Item = (B, A)>, ) -> Self
This keymap with pad as its controller buttons and button chords,
replacing any it had. A button or chord listed twice for one group
keeps its last action of that group.
Sourcepub fn with_chord(self, chord: ChordDef) -> Self
pub fn with_chord(self, chord: ChordDef) -> Self
This keymap with chord as its button chords’ timing.
Sourcepub fn with_default_pad(self, def: &KeymapDef<A>) -> Self
pub fn with_default_pad(self, def: &KeymapDef<A>) -> Self
This keymap with the default controller buttons from a validated keymap definition (the same in every layout and the layout picker) and its chord timing.
Sourcepub fn for_layout(def: &KeymapDef<A>, layout: Layout) -> Self
pub fn for_layout(def: &KeymapDef<A>, layout: Layout) -> Self
layout’s default bindings from a validated keymap definition (no
player changes; for those see
PlayerKeys), with its repeat
timings and the default controller buttons. A definition without
that layout gives a keymap with only the fixed keys and the buttons.
Sourcepub fn layout_picker(def: &KeymapDef<A>) -> Self
pub fn layout_picker(def: &KeymapDef<A>) -> Self
The keys that work before any layout is chosen, from the keymap
definition’s layout_picker section, so the layout picker can be
used whichever hand the player types with. Actions it doesn’t list
have no key. The controller buttons are the default ones, as in
every layout.
Sourcepub fn actions(&self, chord: Chord) -> &[A]
pub fn actions(&self, chord: Chord) -> &[A]
The actions bound to chord, one at most of each group, in group
order. Shift+h and h are distinct: there is no fallback from a
shifted chord to the plain one.
Sourcepub fn action(&self, chord: Chord) -> Option<A>
pub fn action(&self, chord: Chord) -> Option<A>
The first of actions, if any: the only one for a
chord of a single group.
Sourcepub fn pad_actions(&self, button: Button) -> &[A]
pub fn pad_actions(&self, button: Button) -> &[A]
The actions bound to the controller button button on its own, as
actions.
Sourcepub fn pad_action(&self, button: Button) -> Option<A>
pub fn pad_action(&self, button: Button) -> Option<A>
The first of pad_actions, if any.
Sourcepub fn chord_actions(&self, chord: ButtonChord) -> &[A]
pub fn chord_actions(&self, chord: ButtonChord) -> &[A]
The actions bound to chord (a button chord, or one button), as
actions.
Every controller button and button chord bound to action, in the
order they were given (file order for the keymap file).
Sourcepub fn chord_wait(&self, button: Button) -> ChordWait
pub fn chord_wait(&self, button: Button) -> ChordWait
How long button holds back its own actions when pressed, so that
a button chord with it can fire instead (ticket
1034). A button in no chord, or whose own action
repeats (the D-pad on the cursor), acts
on press. Otherwise it waits until it is let go if a partner of its
acts on press (B in B+←: hold it as long as you like before ←)
or it has no action of its own; else for the chord window or its
release, whichever is first (A in A+B). A pad with no chords
acts on press throughout, exactly as before chords.
Sourcepub fn chords_for(&self, action: A) -> Vec<Chord>
pub fn chords_for(&self, action: A) -> Vec<Chord>
Every chord bound to action (its key slots), in the order they
were given: slot order for the player’s bindings, file order for
the keymap file. Leaves out the fixed keys (see
fixed_chords_for).
Sourcepub fn fixed_chords_for(action: A) -> Vec<Chord>
pub fn fixed_chords_for(action: A) -> Vec<Chord>
The fixed chords that also trigger
action in every keymap and can’t be rebound.
Sourcepub fn cursor_keys_name(&self, arrows_name: &str) -> Option<String>
pub fn cursor_keys_name(&self, arrows_name: &str) -> Option<String>
What moves the cursor, for help text: arrows (the language’s word
for them) when the primary chords of the actions the game takes for
up, left, down and right are the plain arrow keys,
otherwise those chords in up-left-down-right order (wasd). None
if any of them is unbound, or the game has no such action. Lives
here, not with the help text, because it names keys.
What moves the cursor on a pad of kind, for help text: the whole
sets of direction buttons the four cursor actions are on, joined
with / (D-pad/L-stick with this game’s defaults); if they are on
no whole set, each one’s primary_button’s
name in up-left-down-right order. None if any cursor action has no
button.
The button (or button chord) help text names for action: the
first of buttons_for, or None if it has
none.
Sourcepub fn primary(&self, action: A) -> Option<Chord>
pub fn primary(&self, action: A) -> Option<Chord>
The chord help text names for action: the first of
chords_for, or None if it has none.