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

Maps an SDL gamepad axis direction to a virtual controller button. More...

#include <SDLAxisDirectionToButtonMapping.h>

Inheritance diagram for Ship::SDLAxisDirectionToButtonMapping:
[legend]
Collaboration diagram for Ship::SDLAxisDirectionToButtonMapping:
[legend]

Public Member Functions

 SDLAxisDirectionToButtonMapping (uint8_t portIndex, CONTROLLERBUTTONS_T bitmask, int32_t sdlControllerAxis, int32_t axisDirection, std::shared_ptr< ControlDeck > controlDeck=nullptr, std::shared_ptr< ConsoleVariable > consoleVariable=nullptr)
 Constructs an SDL axis-direction-to-button mapping.
 
void UpdatePad (CONTROLLERBUTTONS_T &padButtons) override
 Updates the pad button state based on the current axis value.
 
int8_t GetMappingType () override
 Returns the mapping type identifier.
 
std::string GetButtonMappingId () override
 Returns the unique string identifier for this mapping.
 
void SaveToConfig () override
 Persists this mapping to the application configuration.
 
void EraseFromConfig () override
 Removes this mapping from the application configuration.
 
std::string GetPhysicalDeviceName () override
 Returns the human-readable name of the SDL gamepad device.
 
std::string GetPhysicalInputName () override
 Returns the human-readable name of the bound axis and direction.
 
- Public Member Functions inherited from Ship::ControllerButtonMapping
 ControllerButtonMapping (PhysicalDeviceType physicalDeviceType, uint8_t portIndex, CONTROLLERBUTTONS_T bitmask, std::shared_ptr< ControlDeck > controlDeck=nullptr)
 Constructs a ControllerButtonMapping.
 
virtual ~ControllerButtonMapping ()
 
CONTROLLERBUTTONS_T GetBitmask ()
 Returns the button bitmask this mapping is bound to.
 
void SetPortIndex (uint8_t portIndex)
 Sets the controller port index for this mapping.
 
std::shared_ptr< ControlDeckGetControlDeck () const
 
- Public Member Functions inherited from Ship::ControllerInputMapping
 ControllerInputMapping (PhysicalDeviceType physicalDeviceType)
 Constructs a ControllerInputMapping for the given physical device type.
 
 ~ControllerInputMapping ()
 
- Public Member Functions inherited from Ship::ControllerMapping
 ControllerMapping (PhysicalDeviceType physicalDeviceType)
 Constructs a ControllerMapping for the given physical device type.
 
 ~ControllerMapping ()
 
PhysicalDeviceType GetPhysicalDeviceType ()
 Returns the physical device type for this mapping.
 
- Public Member Functions inherited from Ship::SDLAxisDirectionToAnyMapping
 SDLAxisDirectionToAnyMapping (int32_t sdlControllerAxis, int32_t axisDirection)
 Constructs an SDL axis-direction mapping.
 
virtual ~SDLAxisDirectionToAnyMapping ()
 Destructor.
 
bool AxisIsTrigger ()
 Tests whether this axis represents a trigger (e.g. LT / RT).
 
bool AxisIsStick ()
 Tests whether this axis represents an analog stick axis.
 

Protected Attributes

std::shared_ptr< ConsoleVariablemConsoleVariable
 
std::shared_ptr< ControlDeckmControlDeck
 
- Protected Attributes inherited from Ship::ControllerButtonMapping
uint8_t mPortIndex
 
CONTROLLERBUTTONS_T mBitmask
 
std::shared_ptr< ControlDeckmControlDeck
 
- Protected Attributes inherited from Ship::ControllerMapping
PhysicalDeviceType mPhysicalDeviceType
 
- Protected Attributes inherited from Ship::SDLAxisDirectionToAnyMapping
SDL_GameControllerAxis mControllerAxis
 
AxisDirection mAxisDirection
 

Detailed Description

Maps an SDL gamepad axis direction to a virtual controller button.

When the bound axis exceeds the activation threshold in the configured direction, the corresponding button bitmask bit is set; otherwise it is cleared.

Constructor & Destructor Documentation

◆ SDLAxisDirectionToButtonMapping()

Ship::SDLAxisDirectionToButtonMapping::SDLAxisDirectionToButtonMapping ( uint8_t  portIndex,
CONTROLLERBUTTONS_T  bitmask,
int32_t  sdlControllerAxis,
int32_t  axisDirection,
std::shared_ptr< ControlDeck controlDeck = nullptr,
std::shared_ptr< ConsoleVariable consoleVariable = nullptr 
)

Constructs an SDL axis-direction-to-button mapping.

Parameters
portIndexThe controller port index.
bitmaskThe button bitmask to set when the axis is activated.
sdlControllerAxisThe SDL controller axis index.
axisDirectionThe axis half to bind (NEGATIVE or POSITIVE).

Member Function Documentation

◆ EraseFromConfig()

void Ship::SDLAxisDirectionToButtonMapping::EraseFromConfig ( )
overridevirtual

Removes this mapping from the application configuration.

Implements Ship::ControllerButtonMapping.

◆ GetButtonMappingId()

std::string Ship::SDLAxisDirectionToButtonMapping::GetButtonMappingId ( )
overridevirtual

Returns the unique string identifier for this mapping.

Implements Ship::ControllerButtonMapping.

◆ GetMappingType()

int8_t Ship::SDLAxisDirectionToButtonMapping::GetMappingType ( )
overridevirtual

Returns the mapping type identifier.

Reimplemented from Ship::ControllerButtonMapping.

◆ GetPhysicalDeviceName()

std::string Ship::SDLAxisDirectionToButtonMapping::GetPhysicalDeviceName ( )
overridevirtual

Returns the human-readable name of the SDL gamepad device.

Reimplemented from Ship::ControllerMapping.

◆ GetPhysicalInputName()

std::string Ship::SDLAxisDirectionToButtonMapping::GetPhysicalInputName ( )
overridevirtual

Returns the human-readable name of the bound axis and direction.

Reimplemented from Ship::ControllerInputMapping.

◆ SaveToConfig()

void Ship::SDLAxisDirectionToButtonMapping::SaveToConfig ( )
overridevirtual

Persists this mapping to the application configuration.

Implements Ship::ControllerButtonMapping.

◆ UpdatePad()

void Ship::SDLAxisDirectionToButtonMapping::UpdatePad ( CONTROLLERBUTTONS_T padButtons)
overridevirtual

Updates the pad button state based on the current axis value.

Parameters
padButtonsReference to the button bitfield to update.

Implements Ship::ControllerButtonMapping.

Member Data Documentation

◆ mConsoleVariable

std::shared_ptr<ConsoleVariable> Ship::SDLAxisDirectionToButtonMapping::mConsoleVariable
protected

◆ mControlDeck

std::shared_ptr<ControlDeck> Ship::SDLAxisDirectionToButtonMapping::mControlDeck
protected

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