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

Maps an SDL gamepad's gyroscope sensor to a virtual gyro input. More...

#include <SDLGyroMapping.h>

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

Public Member Functions

 SDLGyroMapping (uint8_t portIndex, float sensitivity, float neutralPitch, float neutralYaw, float neutralRoll, std::shared_ptr< ControlDeck > controlDeck=nullptr, std::shared_ptr< ConsoleVariable > consoleVariable=nullptr)
 Constructs an SDL gyro mapping with calibration offsets.
 
void UpdatePad (float &x, float &y) override
 Reads the gyro sensor and writes the resulting X/Y values.
 
void SaveToConfig () override
 Persists this mapping to the application configuration.
 
void EraseFromConfig () override
 Removes this mapping from the application configuration.
 
void Recalibrate () override
 Samples the current sensor output and recalculates neutral offsets.
 
std::string GetGyroMappingId () override
 Returns the unique string identifier for this mapping.
 
std::string GetPhysicalDeviceName () override
 Returns the human-readable name of the SDL gamepad device.
 
- Public Member Functions inherited from Ship::ControllerGyroMapping
 ControllerGyroMapping (PhysicalDeviceType physicalDeviceType, uint8_t portIndex, float sensitivity)
 Constructs a ControllerGyroMapping.
 
virtual ~ControllerGyroMapping ()
 
float GetSensitivity ()
 Returns the current sensitivity multiplier.
 
uint8_t GetSensitivityPercent ()
 Returns the current sensitivity as a percentage of the default.
 
void SetSensitivity (uint8_t sensitivityPercent)
 Sets the gyro sensitivity from a percentage value.
 
void ResetSensitivityToDefault ()
 Resets the sensitivity to GYRO_SENSITIVITY_DEFAULT.
 
bool SensitivityIsDefault ()
 Checks whether the current sensitivity matches the default value.
 
void SetPortIndex (uint8_t portIndex)
 Sets the controller port index for this mapping.
 
- 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 ()
 
PhysicalDeviceType GetPhysicalDeviceType ()
 Returns the physical device type for this mapping.
 

Protected Attributes

std::shared_ptr< ConsoleVariablemConsoleVariable
 
std::shared_ptr< ControlDeckmControlDeck
 
- Protected Attributes inherited from Ship::ControllerGyroMapping
uint8_t mPortIndex
 
uint8_t mSensitivityPercent
 
float mSensitivity
 
- Protected Attributes inherited from Ship::ControllerMapping
PhysicalDeviceType mPhysicalDeviceType
 

Detailed Description

Maps an SDL gamepad's gyroscope sensor to a virtual gyro input.

Reads pitch, yaw, and roll from the SDL motion sensor and converts them into X/Y gyro values after subtracting the neutral calibration offsets.

Constructor & Destructor Documentation

◆ SDLGyroMapping()

Ship::SDLGyroMapping::SDLGyroMapping ( uint8_t  portIndex,
float  sensitivity,
float  neutralPitch,
float  neutralYaw,
float  neutralRoll,
std::shared_ptr< ControlDeck controlDeck = nullptr,
std::shared_ptr< ConsoleVariable consoleVariable = nullptr 
)

Constructs an SDL gyro mapping with calibration offsets.

Parameters
portIndexThe controller port index.
sensitivityGyro sensitivity multiplier.
neutralPitchPitch value at rest (calibration offset).
neutralYawYaw value at rest (calibration offset).
neutralRollRoll value at rest (calibration offset).

Member Function Documentation

◆ EraseFromConfig()

void Ship::SDLGyroMapping::EraseFromConfig ( )
overridevirtual

Removes this mapping from the application configuration.

Implements Ship::ControllerGyroMapping.

◆ GetGyroMappingId()

std::string Ship::SDLGyroMapping::GetGyroMappingId ( )
overridevirtual

Returns the unique string identifier for this mapping.

Implements Ship::ControllerGyroMapping.

◆ GetPhysicalDeviceName()

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

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

Reimplemented from Ship::ControllerMapping.

◆ Recalibrate()

void Ship::SDLGyroMapping::Recalibrate ( )
overridevirtual

Samples the current sensor output and recalculates neutral offsets.

Implements Ship::ControllerGyroMapping.

◆ SaveToConfig()

void Ship::SDLGyroMapping::SaveToConfig ( )
overridevirtual

Persists this mapping to the application configuration.

Implements Ship::ControllerGyroMapping.

◆ UpdatePad()

void Ship::SDLGyroMapping::UpdatePad ( float &  x,
float &  y 
)
overridevirtual

Reads the gyro sensor and writes the resulting X/Y values.

Parameters
xReference to receive the horizontal gyro component.
yReference to receive the vertical gyro component.

Implements Ship::ControllerGyroMapping.

Member Data Documentation

◆ mConsoleVariable

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

◆ mControlDeck

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

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