libultraship
Reimplementations of libultra (N64 SDK) functions for modern hardware
Loading...
Searching...
No Matches
Ship::ButtonMappingFactory Class Reference

Factory for creating ControllerButtonMapping instances. More...

#include <ButtonMappingFactory.h>

Static Public Member Functions

static std::shared_ptr< ControllerButtonMappingCreateButtonMappingFromConfig (uint8_t portIndex, std::string id, std::shared_ptr< ConsoleVariable > consoleVariable, std::shared_ptr< ControlDeck > controlDeck, std::shared_ptr< Window > window)
 Deserializes a button mapping from the configuration string.
 
static std::vector< std::shared_ptr< ControllerButtonMapping > > CreateDefaultKeyboardButtonMappings (uint8_t portIndex, CONTROLLERBUTTONS_T bitmask, std::shared_ptr< ConsoleVariable > consoleVariable, std::shared_ptr< ControlDeck > controlDeck, std::shared_ptr< Window > window)
 Creates default keyboard mappings for the given button bitmask.
 
static std::vector< std::shared_ptr< ControllerButtonMapping > > CreateDefaultSDLButtonMappings (uint8_t portIndex, CONTROLLERBUTTONS_T bitmask, std::shared_ptr< ConsoleVariable > consoleVariable, std::shared_ptr< ControlDeck > controlDeck)
 Creates default SDL mappings for the given button bitmask.
 
static std::shared_ptr< ControllerButtonMappingCreateButtonMappingFromSDLInput (uint8_t portIndex, CONTROLLERBUTTONS_T bitmask, std::shared_ptr< ConsoleVariable > consoleVariable, std::shared_ptr< ControlDeck > controlDeck)
 Creates a button mapping from live SDL input for interactive binding.
 
static std::shared_ptr< ControllerButtonMappingCreateButtonMappingFromMouseWheelInput (uint8_t portIndex, CONTROLLERBUTTONS_T bitmask, std::shared_ptr< ConsoleVariable > consoleVariable, std::shared_ptr< ControlDeck > controlDeck)
 Creates a button mapping from mouse wheel input for interactive binding.
 

Detailed Description

Factory for creating ControllerButtonMapping instances.

ButtonMappingFactory provides static helpers to create ControllerButtonMapping instances that map physical input sources (keyboard, mouse, SDL gamepad) to game controller buttons. It supports deserializing button mappings from persisted configuration, generating default keyboard and SDL mappings, and creating mappings from live SDL or mouse-wheel input during interactive binding.

All factory methods require a ConsoleVariable and ControlDeck to track state and configuration. Keyboard methods also require a Window for key-capture state.

Typical usage (within ControlDeck or ConfigUI):

portIndex, mappingId, consoleVariable, controlDeck, window);
static std::shared_ptr< ControllerButtonMapping > CreateButtonMappingFromConfig(uint8_t portIndex, std::string id, std::shared_ptr< ConsoleVariable > consoleVariable, std::shared_ptr< ControlDeck > controlDeck, std::shared_ptr< Window > window)
Deserializes a button mapping from the configuration string.

Member Function Documentation

◆ CreateButtonMappingFromConfig()

static std::shared_ptr< ControllerButtonMapping > Ship::ButtonMappingFactory::CreateButtonMappingFromConfig ( uint8_t  portIndex,
std::string  id,
std::shared_ptr< ConsoleVariable consoleVariable,
std::shared_ptr< ControlDeck controlDeck,
std::shared_ptr< Window window 
)
static

Deserializes a button mapping from the configuration string.

Parameters
portIndexThe controller port index (0-based).
idConfiguration string encoding the input source and button.
consoleVariableConsoleVariable for persisting the mapping.
controlDeckControlDeck for physical device access.
windowWindow for keyboard input state tracking.
Returns
The deserialized mapping, or nullptr if the configuration string is invalid.

◆ CreateButtonMappingFromMouseWheelInput()

static std::shared_ptr< ControllerButtonMapping > Ship::ButtonMappingFactory::CreateButtonMappingFromMouseWheelInput ( uint8_t  portIndex,
CONTROLLERBUTTONS_T  bitmask,
std::shared_ptr< ConsoleVariable consoleVariable,
std::shared_ptr< ControlDeck controlDeck 
)
static

Creates a button mapping from mouse wheel input for interactive binding.

Parameters
portIndexThe controller port index (0-based).
bitmaskBitmask of buttons being mapped.
consoleVariableConsoleVariable for persisting the mapping.
controlDeckControlDeck for physical device access.
Returns
The newly created mapping, or nullptr if input detection failed.

◆ CreateButtonMappingFromSDLInput()

static std::shared_ptr< ControllerButtonMapping > Ship::ButtonMappingFactory::CreateButtonMappingFromSDLInput ( uint8_t  portIndex,
CONTROLLERBUTTONS_T  bitmask,
std::shared_ptr< ConsoleVariable consoleVariable,
std::shared_ptr< ControlDeck controlDeck 
)
static

Creates a button mapping from live SDL input for interactive binding.

Parameters
portIndexThe controller port index (0-based).
bitmaskBitmask of buttons being mapped.
consoleVariableConsoleVariable for persisting the mapping.
controlDeckControlDeck for physical device access.
Returns
The newly created mapping, or nullptr if input detection failed.

◆ CreateDefaultKeyboardButtonMappings()

static std::vector< std::shared_ptr< ControllerButtonMapping > > Ship::ButtonMappingFactory::CreateDefaultKeyboardButtonMappings ( uint8_t  portIndex,
CONTROLLERBUTTONS_T  bitmask,
std::shared_ptr< ConsoleVariable consoleVariable,
std::shared_ptr< ControlDeck controlDeck,
std::shared_ptr< Window window 
)
static

Creates default keyboard mappings for the given button bitmask.

Parameters
portIndexThe controller port index (0-based).
bitmaskBitmask of buttons to create mappings for.
consoleVariableConsoleVariable for persisting mappings.
controlDeckControlDeck for physical device access.
windowWindow for keyboard input state tracking.
Returns
Vector of keyboard button mappings.

◆ CreateDefaultSDLButtonMappings()

static std::vector< std::shared_ptr< ControllerButtonMapping > > Ship::ButtonMappingFactory::CreateDefaultSDLButtonMappings ( uint8_t  portIndex,
CONTROLLERBUTTONS_T  bitmask,
std::shared_ptr< ConsoleVariable consoleVariable,
std::shared_ptr< ControlDeck controlDeck 
)
static

Creates default SDL mappings for the given button bitmask.

Parameters
portIndexThe controller port index (0-based).
bitmaskBitmask of buttons to create mappings for.
consoleVariableConsoleVariable for persisting mappings.
controlDeckControlDeck for physical device access.
Returns
Vector of SDL button mappings.

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