ASAPCabinetFE
 
Loading...
Searching...
No Matches
IKeybindProvider Class Referenceabstract

Interface for keybind providers (forward declaration). More...

#include <screenshot_manager.h>

+ Inheritance diagram for IKeybindProvider:
+ Collaboration diagram for IKeybindProvider:

Public Member Functions

virtual ~IKeybindProvider ()=default
 Virtual destructor for proper cleanup of derived classes.
 
virtual std::string getActionForKey (const std::string &key) const =0
 
virtual SDL_Keycode getKey (const std::string &action) const =0
 Gets the keyboard keycode for an action.
 
virtual void setKey (const std::string &action, SDL_Keycode key)=0
 Sets the keyboard keycode for an action.
 
virtual std::vector< std::string > getActions () const =0
 Gets the list of supported actions.
 
virtual void setJoystickButton (const std::string &action, int joystickId, uint8_t button)=0
 Sets a joystick button binding for an action.
 
virtual void setJoystickHat (const std::string &action, int joystickId, uint8_t hat, uint8_t direction)=0
 Sets a joystick hat binding for an action.
 
virtual void setJoystickAxis (const std::string &action, int joystickId, uint8_t axis, bool positiveDirection)=0
 Sets a joystick axis binding for an action.
 
virtual std::string eventToString (const SDL_Event &event) const =0
 Converts an SDL event to a string representation.
 
virtual bool isAction (const SDL_KeyboardEvent &event, const std::string &action) const =0
 Checks if a keyboard event matches an action.
 
virtual bool isJoystickAction (const SDL_JoyButtonEvent &event, const std::string &action) const =0
 Checks if a joystick button event matches an action.
 
virtual bool isJoystickHatAction (const SDL_JoyHatEvent &event, const std::string &action) const =0
 Checks if a joystick hat event matches an action.
 
virtual bool isJoystickAxisAction (const SDL_JoyAxisEvent &event, const std::string &action) const =0
 Checks if a joystick axis event matches an action.
 
virtual void loadKeybinds (const std::map< std::string, std::string > &keybindData)=0
 Loads keybind configurations from a data map.
 
virtual void saveKeybinds (std::map< std::string, std::string > &keybinds) const =0
 Saves keybind configurations to a map.
 

Detailed Description

Interface for keybind providers (forward declaration).

Interface for managing keyboard and joystick input bindings.

This pure virtual class defines methods for retrieving, setting, and validating input bindings for application actions, including keyboard keys, joystick buttons, hats, and axes. It also provides utilities for converting events to strings and managing keybind persistence.

Member Function Documentation

◆ eventToString()

virtual std::string IKeybindProvider::eventToString ( const SDL_Event &  event) const
pure virtual

Converts an SDL event to a string representation.

Generates a human-readable string describing the input event (key, button, hat, or axis).

Parameters
eventThe SDL event to convert.
Returns
A string describing the event.

Implemented in KeybindManager.

+ Here is the caller graph for this function:

◆ getActions()

virtual std::vector< std::string > IKeybindProvider::getActions ( ) const
pure virtual

Gets the list of supported actions.

Returns a vector of action identifiers that can be bound to inputs.

Returns
A vector of action identifier strings.

Implemented in KeybindManager.

+ Here is the caller graph for this function:

◆ getKey()

virtual SDL_Keycode IKeybindProvider::getKey ( const std::string &  action) const
pure virtual

Gets the keyboard keycode for an action.

Retrieves the SDL keycode associated with the specified action.

Parameters
actionThe action identifier (e.g., "LaunchTable").
Returns
The SDL keycode for the action, or SDLK_UNKNOWN if not found.

Implemented in KeybindManager.

+ Here is the caller graph for this function:

◆ isAction()

virtual bool IKeybindProvider::isAction ( const SDL_KeyboardEvent &  event,
const std::string &  action 
) const
pure virtual

Checks if a keyboard event matches an action.

Determines if the keyboard event corresponds to the specified action's keybinding.

Parameters
eventThe SDL keyboard event.
actionThe action identifier.
Returns
True if the event matches the action's keybinding, false otherwise.

Implemented in KeybindManager.

+ Here is the caller graph for this function:

◆ isJoystickAction()

virtual bool IKeybindProvider::isJoystickAction ( const SDL_JoyButtonEvent &  event,
const std::string &  action 
) const
pure virtual

Checks if a joystick button event matches an action.

Determines if the joystick button event corresponds to the specified action's binding.

Parameters
eventThe SDL joystick button event.
actionThe action identifier.
Returns
True if the event matches the action's binding, false otherwise.

Implemented in KeybindManager.

◆ isJoystickAxisAction()

virtual bool IKeybindProvider::isJoystickAxisAction ( const SDL_JoyAxisEvent &  event,
const std::string &  action 
) const
pure virtual

Checks if a joystick axis event matches an action.

Determines if the joystick axis event corresponds to the specified action's binding.

Parameters
eventThe SDL joystick axis event.
actionThe action identifier.
Returns
True if the event matches the action's binding, false otherwise.

Implemented in KeybindManager.

◆ isJoystickHatAction()

virtual bool IKeybindProvider::isJoystickHatAction ( const SDL_JoyHatEvent &  event,
const std::string &  action 
) const
pure virtual

Checks if a joystick hat event matches an action.

Determines if the joystick hat event corresponds to the specified action's binding.

Parameters
eventThe SDL joystick hat event.
actionThe action identifier.
Returns
True if the event matches the action's binding, false otherwise.

Implemented in KeybindManager.

◆ loadKeybinds()

virtual void IKeybindProvider::loadKeybinds ( const std::map< std::string, std::string > &  keybindData)
pure virtual

Loads keybind configurations from a data map.

Populates the keybind mappings from a provided map of action-to-input strings.

Parameters
keybindDataA map of action identifiers to input configuration strings.

Implemented in KeybindManager.

+ Here is the caller graph for this function:

◆ saveKeybinds()

virtual void IKeybindProvider::saveKeybinds ( std::map< std::string, std::string > &  keybinds) const
pure virtual

Saves keybind configurations to a map.

Populates a map with the current keybind mappings for JSON serialization.

Parameters
keybindsThe map to populate with action-to-input string pairs.

Implemented in KeybindManager.

+ Here is the caller graph for this function:

◆ setJoystickAxis()

virtual void IKeybindProvider::setJoystickAxis ( const std::string &  action,
int  joystickId,
uint8_t  axis,
bool  positiveDirection 
)
pure virtual

Sets a joystick axis binding for an action.

Assigns a joystick axis direction to the specified action.

Parameters
actionThe action identifier.
joystickIdThe ID of the joystick.
axisThe joystick axis index.
positiveDirectionTrue for positive axis direction, false for negative.

Implemented in KeybindManager.

◆ setJoystickButton()

virtual void IKeybindProvider::setJoystickButton ( const std::string &  action,
int  joystickId,
uint8_t  button 
)
pure virtual

Sets a joystick button binding for an action.

Assigns a joystick button to the specified action.

Parameters
actionThe action identifier.
joystickIdThe ID of the joystick.
buttonThe joystick button index.

Implemented in KeybindManager.

◆ setJoystickHat()

virtual void IKeybindProvider::setJoystickHat ( const std::string &  action,
int  joystickId,
uint8_t  hat,
uint8_t  direction 
)
pure virtual

Sets a joystick hat binding for an action.

Assigns a joystick hat direction to the specified action.

Parameters
actionThe action identifier.
joystickIdThe ID of the joystick.
hatThe joystick hat index.
directionThe hat direction (e.g., SDL_HAT_UP).

Implemented in KeybindManager.

◆ setKey()

virtual void IKeybindProvider::setKey ( const std::string &  action,
SDL_Keycode  key 
)
pure virtual

Sets the keyboard keycode for an action.

Assigns a new SDL keycode to the specified action.

Parameters
actionThe action identifier.
keyThe SDL keycode to assign.

Implemented in KeybindManager.


The documentation for this class was generated from the following file: