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

Manages the single gyroscope (motion sensor) mapping for a controller port. More...

#include <ControllerGyro.h>

Public Member Functions

void SetControlDeck (std::shared_ptr< ControlDeck > controlDeck)
 Injects the owning ControlDeck.
 
 ControllerGyro (uint8_t portIndex, std::shared_ptr< ConsoleVariable > consoleVariable=nullptr, std::shared_ptr< ControlDeck > controlDeck=nullptr)
 Constructs a ControllerGyro for the given port.
 
 ~ControllerGyro ()
 
void ReloadGyroMappingFromConfig ()
 Clears any in-memory mapping and reloads it from Config.
 
void ClearGyroMapping ()
 Removes the in-memory gyro mapping (does not touch Config).
 
void SaveGyroMappingIdToConfig ()
 Writes the current gyro mapping ID to Config.
 
std::shared_ptr< ControllerGyroMappingGetGyroMapping ()
 Returns the current gyro mapping, or nullptr if none is assigned.
 
void SetGyroMapping (std::shared_ptr< ControllerGyroMapping > mapping)
 Sets the active gyro mapping, replacing any previously set one.
 
bool SetGyroMappingFromRawPress ()
 Listens for the next raw gyro input and creates a mapping from it.
 
void UpdatePad (float &x, float &y)
 Reads gyroscope data from the active mapping and writes it to x and y.
 
bool HasMappingForPhysicalDeviceType (PhysicalDeviceType physicalDeviceType)
 Returns true if the current gyro mapping targets the given device type.
 

Detailed Description

Manages the single gyroscope (motion sensor) mapping for a controller port.

Unlike buttons and sticks, a controller supports at most one ControllerGyroMapping at a time. ControllerGyro provides a thin wrapper that loads/saves the mapping from Config and exposes UpdatePad() to integrate gyroscope data into the game's pad state.

Constructor & Destructor Documentation

◆ ControllerGyro()

Ship::ControllerGyro::ControllerGyro ( uint8_t  portIndex,
std::shared_ptr< ConsoleVariable consoleVariable = nullptr,
std::shared_ptr< ControlDeck controlDeck = nullptr 
)

Constructs a ControllerGyro for the given port.

Parameters
portIndexZero-based port index.

◆ ~ControllerGyro()

Ship::ControllerGyro::~ControllerGyro ( )

Member Function Documentation

◆ ClearGyroMapping()

void Ship::ControllerGyro::ClearGyroMapping ( )

Removes the in-memory gyro mapping (does not touch Config).

◆ GetGyroMapping()

std::shared_ptr< ControllerGyroMapping > Ship::ControllerGyro::GetGyroMapping ( )

Returns the current gyro mapping, or nullptr if none is assigned.

◆ HasMappingForPhysicalDeviceType()

bool Ship::ControllerGyro::HasMappingForPhysicalDeviceType ( PhysicalDeviceType  physicalDeviceType)

Returns true if the current gyro mapping targets the given device type.

Parameters
physicalDeviceTypeDevice type to query.

◆ ReloadGyroMappingFromConfig()

void Ship::ControllerGyro::ReloadGyroMappingFromConfig ( )

Clears any in-memory mapping and reloads it from Config.

◆ SaveGyroMappingIdToConfig()

void Ship::ControllerGyro::SaveGyroMappingIdToConfig ( )

Writes the current gyro mapping ID to Config.

◆ SetControlDeck()

void Ship::ControllerGyro::SetControlDeck ( std::shared_ptr< ControlDeck controlDeck)
inline

Injects the owning ControlDeck.

◆ SetGyroMapping()

void Ship::ControllerGyro::SetGyroMapping ( std::shared_ptr< ControllerGyroMapping mapping)

Sets the active gyro mapping, replacing any previously set one.

Parameters
mappingNew mapping to use.

◆ SetGyroMappingFromRawPress()

bool Ship::ControllerGyro::SetGyroMappingFromRawPress ( )

Listens for the next raw gyro input and creates a mapping from it.

Returns
true if a mapping was successfully created.

◆ UpdatePad()

void Ship::ControllerGyro::UpdatePad ( float &  x,
float &  y 
)

Reads gyroscope data from the active mapping and writes it to x and y.

Parameters
xOutput X-axis (pitch) gyro value.
yOutput Y-axis (yaw/roll) gyro value.

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