|
Player12
An open source football management simulator
|
Rebindable keyboard shortcuts. More...
Namespaces | |
| namespace | Ids |
| Ids of the built-in actions. | |
Classes | |
| struct | Action |
| A registered action with its current chords. More... | |
| struct | ActionDef |
| Description of an action, given once at registration. More... | |
| class | ActionRegistry |
| Registry of every action. One instance per run (registry()). More... | |
| struct | RebindResult |
| Outcome of a rebind request. More... | |
Typedefs | |
| using | ActionId = std::size_t |
| Handle of a registered action (index, stable for the run). | |
Enumerations | |
| enum class | Context : std::uint8_t { GLOBAL , MANAGEMENT , MATCH , PLAY } |
| Where an action is listened to (decides what conflicts). More... | |
| enum class | Category : std::uint8_t { NAVIGATION , CAREER , MATCH , CAMERA , SHOUTS , PLAY , COUNT } |
| Group an action is listed under in Settings > Controls. More... | |
Functions | |
| const char * | categoryKey (Category category) |
| Language key of a category's heading. | |
| bool | contextsOverlap (Context first, Context second) |
| True when two contexts can be live at once. | |
| bool | isBindableKey (ImGuiKey key) |
| True for keys that can be bound (letters, digits, F-keys...). | |
| std::string | chordToString (ImGuiKeyChord chord) |
| Stable name of a chord for the settings file ("Ctrl+K"). | |
| std::optional< ImGuiKeyChord > | chordFromString (std::string_view text) |
| Parses chordToString() output; nullopt when invalid. | |
| std::string | chordLabel (ImGuiKeyChord chord) |
| Name shown to the player ("Ctrl+K", "Alt+Left", "-"). | |
| std::optional< ImGuiKeyChord > | capturePressedChord () |
| The chord pressed this frame, for "press a key" capture: the first bindable key pressed with the modifiers held. Modifier keys alone and the mouse never count. | |
| std::array< ImGuiKeyChord, 2 > | chordsOfEvent (const SDL_KeyboardEvent &event) |
| The chord of an SDL key-down event. Letters and digits match both the character and the physical key, so the number row keeps working on layouts where it types symbols (Shift+1 on AZERTY). | |
| ActionRegistry & | registry () |
| The registry of the running game, with the built-in actions. | |
Variables | |
| constexpr std::size_t | BINDING_SLOTS = 2 |
| Number of chords an action can have (primary, alternate). | |
Rebindable keyboard shortcuts.
Every shortcut is an action with a stable id ("nav.home", "match.pause"), a label key, a category and up to two key chords (primary and alternate). Screens ask whether an action was pressed instead of testing keys, so the player can rebind anything from Settings > Controls. Only bindings that differ from the defaults are written to the settings file, by name (never by ImGuiKey value), so an action registered later (or renamed) never breaks the file.
Two actions conflict when they share a chord and can be active at the same time: actions of one context, or any action and a GLOBAL one. Space can therefore be Continue in the management screens and Pause in a match. PLAY actions are listened to instead of the MATCH ones while the player controls the team, so they only clash with each other (and GLOBAL).
| using Input::ActionId = typedef std::size_t |
Handle of a registered action (index, stable for the run).
|
strong |
|
strong |
| std::optional< ImGuiKeyChord > Input::capturePressedChord | ( | ) |
The chord pressed this frame, for "press a key" capture: the first bindable key pressed with the modifiers held. Modifier keys alone and the mouse never count.
| const char * Input::categoryKey | ( | Category | category | ) |
Language key of a category's heading.
| std::optional< ImGuiKeyChord > Input::chordFromString | ( | std::string_view | text | ) |
Parses chordToString() output; nullopt when invalid.
| std::string Input::chordLabel | ( | ImGuiKeyChord | chord | ) |
Name shown to the player ("Ctrl+K", "Alt+Left", "-").
| std::array< ImGuiKeyChord, 2 > Input::chordsOfEvent | ( | const SDL_KeyboardEvent & | event | ) |
The chord of an SDL key-down event. Letters and digits match both the character and the physical key, so the number row keeps working on layouts where it types symbols (Shift+1 on AZERTY).
| std::string Input::chordToString | ( | ImGuiKeyChord | chord | ) |
Stable name of a chord for the settings file ("Ctrl+K").
True when two contexts can be live at once.
| bool Input::isBindableKey | ( | ImGuiKey | key | ) |
True for keys that can be bound (letters, digits, F-keys...).
| ActionRegistry & Input::registry | ( | ) |
The registry of the running game, with the built-in actions.
|
inlineconstexpr |
Number of chords an action can have (primary, alternate).