Player12
An open source football management simulator
Loading...
Searching...
No Matches
Input Namespace Reference

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).
 

Detailed Description

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).

Typedef Documentation

◆ ActionId

using Input::ActionId = typedef std::size_t

Handle of a registered action (index, stable for the run).

Enumeration Type Documentation

◆ Category

enum class Input::Category : std::uint8_t
strong

Group an action is listed under in Settings > Controls.

Enumerator
NAVIGATION 

Screens, history, command palette.

CAREER 

Continue, save, help.

MATCH 

Pause, speed, panels, mute.

CAMERA 

Match view and camera presets.

SHOUTS 

Touchline shouts.

PLAY 

On-pitch controls of the play mode.

COUNT 

◆ Context

enum class Input::Context : std::uint8_t
strong

Where an action is listened to (decides what conflicts).

Enumerator
GLOBAL 

Everywhere.

MANAGEMENT 

The career screens (sidebar, top bar).

MATCH 

The live match, watching as manager.

PLAY 

The live match, controlling the team on the pitch (replaces the MATCH keys while active).

Function Documentation

◆ capturePressedChord()

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.

◆ categoryKey()

const char * Input::categoryKey ( Category  category)

Language key of a category's heading.

◆ chordFromString()

std::optional< ImGuiKeyChord > Input::chordFromString ( std::string_view  text)

Parses chordToString() output; nullopt when invalid.

◆ chordLabel()

std::string Input::chordLabel ( ImGuiKeyChord  chord)

Name shown to the player ("Ctrl+K", "Alt+Left", "-").

◆ chordsOfEvent()

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).

◆ chordToString()

std::string Input::chordToString ( ImGuiKeyChord  chord)

Stable name of a chord for the settings file ("Ctrl+K").

◆ contextsOverlap()

bool Input::contextsOverlap ( Context  first,
Context  second 
)

True when two contexts can be live at once.

◆ isBindableKey()

bool Input::isBindableKey ( ImGuiKey  key)

True for keys that can be bound (letters, digits, F-keys...).

◆ registry()

ActionRegistry & Input::registry ( )

The registry of the running game, with the built-in actions.

Variable Documentation

◆ BINDING_SLOTS

constexpr std::size_t Input::BINDING_SLOTS = 2
inlineconstexpr

Number of chords an action can have (primary, alternate).