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

Maps a physical input to a virtual controller button. More...

#include <ControllerButtonMapping.h>

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

Public Member Functions

 ControllerButtonMapping (PhysicalDeviceType physicalDeviceType, uint8_t portIndex, CONTROLLERBUTTONS_T bitmask, std::shared_ptr< ControlDeck > controlDeck=nullptr)
 Constructs a ControllerButtonMapping.
 
virtual ~ControllerButtonMapping ()
 
virtual std::string GetButtonMappingId ()=0
 Returns a unique string identifier for this button mapping.
 
CONTROLLERBUTTONS_T GetBitmask ()
 Returns the button bitmask this mapping is bound to.
 
virtual void UpdatePad (CONTROLLERBUTTONS_T &padButtons)=0
 Reads the physical input state and sets the corresponding bits in padButtons.
 
virtual int8_t GetMappingType ()
 Returns the mapping type identifier (e.g. gamepad, keyboard).
 
void SetPortIndex (uint8_t portIndex)
 Sets the controller port index for this mapping.
 
std::shared_ptr< ControlDeckGetControlDeck () const
 
virtual void SaveToConfig ()=0
 Persists this mapping to the application configuration.
 
virtual void EraseFromConfig ()=0
 Removes this mapping from the application configuration.
 
- Public Member Functions inherited from Ship::ControllerInputMapping
 ControllerInputMapping (PhysicalDeviceType physicalDeviceType)
 Constructs a ControllerInputMapping for the given physical device type.
 
 ~ControllerInputMapping ()
 
virtual std::string GetPhysicalInputName ()
 Returns a human-readable name for the physical input this mapping represents.
 
- Public Member Functions inherited from Ship::ControllerMapping
 ControllerMapping (PhysicalDeviceType physicalDeviceType)
 Constructs a ControllerMapping for the given physical device type.
 
 ~ControllerMapping ()
 
virtual std::string GetPhysicalDeviceName ()
 Returns a human-readable name for the physical device associated with this mapping.
 
PhysicalDeviceType GetPhysicalDeviceType ()
 Returns the physical device type for this mapping.
 

Protected Attributes

uint8_t mPortIndex
 
CONTROLLERBUTTONS_T mBitmask
 
std::shared_ptr< ControlDeckmControlDeck
 
- Protected Attributes inherited from Ship::ControllerMapping
PhysicalDeviceType mPhysicalDeviceType
 

Detailed Description

Maps a physical input to a virtual controller button.

Subclasses implement the details for specific device types (keyboard keys, SDL gamepad buttons/axes, etc.) and set the corresponding button bits when the physical input is active.

Constructor & Destructor Documentation

◆ ControllerButtonMapping()

Ship::ControllerButtonMapping::ControllerButtonMapping ( PhysicalDeviceType  physicalDeviceType,
uint8_t  portIndex,
CONTROLLERBUTTONS_T  bitmask,
std::shared_ptr< ControlDeck controlDeck = nullptr 
)

Constructs a ControllerButtonMapping.

Parameters
physicalDeviceTypeThe type of physical device this mapping targets.
portIndexThe controller port index this mapping is assigned to.
bitmaskThe button bitmask this mapping controls.

◆ ~ControllerButtonMapping()

virtual Ship::ControllerButtonMapping::~ControllerButtonMapping ( )
virtual

Member Function Documentation

◆ EraseFromConfig()

virtual void Ship::ControllerButtonMapping::EraseFromConfig ( )
pure virtual

◆ GetBitmask()

CONTROLLERBUTTONS_T Ship::ControllerButtonMapping::GetBitmask ( )

Returns the button bitmask this mapping is bound to.

Returns
The button bitmask value.

◆ GetButtonMappingId()

virtual std::string Ship::ControllerButtonMapping::GetButtonMappingId ( )
pure virtual

Returns a unique string identifier for this button mapping.

Returns
The mapping identifier string.

Implemented in Ship::KeyboardKeyToButtonMapping, Ship::MouseButtonToButtonMapping, Ship::MouseWheelToButtonMapping, Ship::SDLAxisDirectionToButtonMapping, and Ship::SDLButtonToButtonMapping.

◆ GetControlDeck()

std::shared_ptr< ControlDeck > Ship::ControllerButtonMapping::GetControlDeck ( ) const

◆ GetMappingType()

virtual int8_t Ship::ControllerButtonMapping::GetMappingType ( )
virtual

Returns the mapping type identifier (e.g. gamepad, keyboard).

Returns
The mapping type as a MAPPING_TYPE constant.

Reimplemented in Ship::KeyboardKeyToButtonMapping, Ship::MouseButtonToButtonMapping, Ship::MouseWheelToButtonMapping, Ship::SDLAxisDirectionToButtonMapping, and Ship::SDLButtonToButtonMapping.

◆ SaveToConfig()

virtual void Ship::ControllerButtonMapping::SaveToConfig ( )
pure virtual

◆ SetPortIndex()

void Ship::ControllerButtonMapping::SetPortIndex ( uint8_t  portIndex)

Sets the controller port index for this mapping.

Parameters
portIndexThe new port index.

◆ UpdatePad()

virtual void Ship::ControllerButtonMapping::UpdatePad ( CONTROLLERBUTTONS_T padButtons)
pure virtual

Reads the physical input state and sets the corresponding bits in padButtons.

Parameters
padButtonsReference to the button state bitfield to update.

Implemented in Ship::KeyboardKeyToButtonMapping, Ship::MouseButtonToButtonMapping, Ship::MouseWheelToButtonMapping, Ship::SDLAxisDirectionToButtonMapping, and Ship::SDLButtonToButtonMapping.

Member Data Documentation

◆ mBitmask

CONTROLLERBUTTONS_T Ship::ControllerButtonMapping::mBitmask
protected

◆ mControlDeck

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

◆ mPortIndex

uint8_t Ship::ControllerButtonMapping::mPortIndex
protected

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