Player12
An open source football management simulator
Loading...
Searching...
No Matches
input_actions.h File Reference
#include <SDL3/SDL.h>
#include <imgui.h>
#include <array>
#include <cstddef>
#include <cstdint>
#include <functional>
#include <map>
#include <optional>
#include <string>
#include <string_view>
#include <unordered_map>
#include <vector>

Go to the source code of this file.

Classes

struct  Input::ActionDef
 Description of an action, given once at registration. More...
 
struct  Input::Action
 A registered action with its current chords. More...
 
struct  Input::RebindResult
 Outcome of a rebind request. More...
 
class  Input::ActionRegistry
 Registry of every action. One instance per run (registry()). More...
 
struct  Input::ActionRegistry::StringHash
 

Namespaces

namespace  Input
 Rebindable keyboard shortcuts.
 
namespace  Input::Ids
 Ids of the built-in actions.
 

Typedefs

using Input::ActionId = std::size_t
 Handle of a registered action (index, stable for the run).
 

Enumerations

enum class  Input::Context : std::uint8_t { Input::GLOBAL , Input::MANAGEMENT , Input::MATCH , Input::PLAY }
 Where an action is listened to (decides what conflicts). More...
 
enum class  Input::Category : std::uint8_t {
  Input::NAVIGATION , Input::CAREER , Input::MATCH , Input::CAMERA ,
  Input::SHOUTS , Input::PLAY , Input::COUNT
}
 Group an action is listed under in Settings > Controls. More...
 

Functions

const char * Input::categoryKey (Category category)
 Language key of a category's heading.
 
bool Input::contextsOverlap (Context first, Context second)
 True when two contexts can be live at once.
 
std::string Input::chordToString (ImGuiKeyChord chord)
 Stable name of a chord for the settings file ("Ctrl+K").
 
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", "-").
 
bool Input::isBindableKey (ImGuiKey key)
 True for keys that can be bound (letters, digits, F-keys...).
 
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.
 
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).
 
ActionRegistry & Input::registry ()
 The registry of the running game, with the built-in actions.
 
std::string Input::Ids::shout (std::size_t index)
 

Variables

constexpr std::size_t Input::BINDING_SLOTS = 2
 Number of chords an action can have (primary, alternate).
 
constexpr std::string_view Input::Ids::NAV_HOME = "nav.home"
 
constexpr std::string_view Input::Ids::NAV_INBOX = "nav.inbox"
 
constexpr std::string_view Input::Ids::NAV_SQUAD = "nav.squad"
 
constexpr std::string_view Input::Ids::NAV_TRAINING = "nav.training"
 
constexpr std::string_view Input::Ids::NAV_MATCHES = "nav.matches"
 
constexpr std::string_view Input::Ids::NAV_RECRUITMENT = "nav.recruitment"
 
constexpr std::string_view Input::Ids::NAV_CLUB = "nav.club"
 
constexpr std::string_view Input::Ids::NAV_PALETTE = "nav.palette"
 
constexpr std::string_view Input::Ids::NAV_BACK = "nav.back"
 
constexpr std::string_view Input::Ids::NAV_FORWARD = "nav.forward"
 
constexpr std::string_view Input::Ids::NAV_CLOSE = "nav.close"
 
constexpr std::string_view Input::Ids::CAREER_CONTINUE = "career.continue"
 
constexpr std::string_view Input::Ids::CAREER_SAVE = "career.save"
 
constexpr std::string_view Input::Ids::CAREER_HELP = "career.help"
 
constexpr std::string_view Input::Ids::MATCH_PAUSE = "match.pause"
 
constexpr std::string_view Input::Ids::MATCH_FASTER = "match.faster"
 
constexpr std::string_view Input::Ids::MATCH_SLOWER = "match.slower"
 
constexpr std::string_view Input::Ids::MATCH_SUBSTITUTIONS = "match.substitutions"
 
constexpr std::string_view Input::Ids::MATCH_TACTICS = "match.tactics"
 
constexpr std::string_view Input::Ids::MATCH_MUTE = "match.mute"
 
constexpr std::string_view Input::Ids::MATCH_PITCH_FOCUS = "match.pitch_focus"
 
constexpr std::string_view Input::Ids::MATCH_BACK = "match.back"
 
constexpr std::string_view Input::Ids::MATCH_FULLSCREEN = "match.fullscreen"
 
constexpr std::string_view Input::Ids::CAMERA_VIEW_TOGGLE = "camera.view_toggle"
 
constexpr std::string_view Input::Ids::CAMERA_BROADCAST = "camera.broadcast"
 
constexpr std::string_view Input::Ids::CAMERA_TACTICAL = "camera.tactical"
 
constexpr std::string_view Input::Ids::CAMERA_END = "camera.end"
 
constexpr std::string_view Input::Ids::CAMERA_PLAYER = "camera.player"
 
constexpr std::string_view Input::Ids::CAMERA_FREE = "camera.free"
 
constexpr std::string_view Input::Ids::CAMERA_DIRECTOR = "camera.director"
 
constexpr std::string_view Input::Ids::CAMERA_FOLLOW_BALL = "camera.follow_ball"
 
constexpr std::string_view Input::Ids::CAMERA_RESET = "camera.reset"
 
constexpr std::string_view Input::Ids::SCREENSHOT = "general.screenshot"
 
constexpr std::string_view Input::Ids::PLAY_UP = "play.up"
 
constexpr std::string_view Input::Ids::PLAY_DOWN = "play.down"
 
constexpr std::string_view Input::Ids::PLAY_LEFT = "play.left"
 
constexpr std::string_view Input::Ids::PLAY_RIGHT = "play.right"
 
constexpr std::string_view Input::Ids::PLAY_PASS = "play.pass"
 
constexpr std::string_view Input::Ids::PLAY_SHOOT = "play.shoot"
 
constexpr std::string_view Input::Ids::PLAY_THROUGH = "play.through"
 
constexpr std::string_view Input::Ids::PLAY_LOB = "play.lob"
 
constexpr std::string_view Input::Ids::PLAY_SWITCH = "play.switch"
 
constexpr std::string_view Input::Ids::PLAY_JOCKEY = "play.jockey"
 
constexpr std::string_view Input::Ids::PLAY_PAUSE = "play.pause"
 
constexpr std::size_t Input::Ids::SHOUT_COUNT = 11