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

Tracks connected SDL gamepads and manages per-port ignore lists. More...

#include <ConnectedPhysicalDeviceManager.h>

Public Member Functions

 ConnectedPhysicalDeviceManager ()
 Constructs the manager and performs an initial scan of connected gamepads.
 
 ~ConnectedPhysicalDeviceManager ()
 
std::unordered_map< int32_t, SDL_Gamepad * > GetConnectedSDLGamepadsForPort (uint8_t portIndex)
 Returns the connected SDL gamepads available for the given port.
 
std::unordered_map< int32_t, std::string > GetConnectedSDLGamepadNames ()
 Returns the display names of all connected SDL gamepads.
 
std::unordered_set< int32_t > GetIgnoredInstanceIdsForPort (uint8_t portIndex)
 Returns the set of SDL joystick instance IDs ignored for a port.
 
bool PortIsIgnoringInstanceId (uint8_t portIndex, int32_t instanceId)
 Checks whether a specific joystick instance is being ignored on a port.
 
void IgnoreInstanceIdForPort (uint8_t portIndex, int32_t instanceId)
 Adds a joystick instance to a port's ignore list.
 
void UnignoreInstanceIdForPort (uint8_t portIndex, int32_t instanceId)
 Removes a joystick instance from a port's ignore list.
 
void HandlePhysicalDeviceConnect (int32_t instanceId)
 Handles a gamepad-added event by refreshing the connected set.
 
void HandlePhysicalDeviceDisconnect (int32_t instanceId)
 Handles a gamepad-removed event by refreshing the connected set.
 
void RefreshConnectedSDLGamepads ()
 Re-scans SDL gamepads, preserving handles for devices that remain connected.
 

Detailed Description

Tracks connected SDL gamepads and manages per-port ignore lists.

Maintains a live map of connected SDL gamepads. Per-port ignore lists allow a controller to be excluded from a specific port.

Constructor & Destructor Documentation

◆ ConnectedPhysicalDeviceManager()

Ship::ConnectedPhysicalDeviceManager::ConnectedPhysicalDeviceManager ( )

Constructs the manager and performs an initial scan of connected gamepads.

◆ ~ConnectedPhysicalDeviceManager()

Ship::ConnectedPhysicalDeviceManager::~ConnectedPhysicalDeviceManager ( )

Member Function Documentation

◆ GetConnectedSDLGamepadNames()

std::unordered_map< int32_t, std::string > Ship::ConnectedPhysicalDeviceManager::GetConnectedSDLGamepadNames ( )

Returns the display names of all connected SDL gamepads.

Returns
Map of SDL joystick instance ID to human-readable gamepad name.

◆ GetConnectedSDLGamepadsForPort()

std::unordered_map< int32_t, SDL_Gamepad * > Ship::ConnectedPhysicalDeviceManager::GetConnectedSDLGamepadsForPort ( uint8_t  portIndex)

Returns the connected SDL gamepads available for the given port.

Gamepads on the port's ignore list are excluded from the result.

Parameters
portIndexZero-based controller port index.
Returns
Map of SDL joystick instance ID to SDL_Gamepad pointer.

◆ GetIgnoredInstanceIdsForPort()

std::unordered_set< int32_t > Ship::ConnectedPhysicalDeviceManager::GetIgnoredInstanceIdsForPort ( uint8_t  portIndex)

Returns the set of SDL joystick instance IDs ignored for a port.

Parameters
portIndexZero-based controller port index.
Returns
Set of ignored joystick instance IDs.

◆ HandlePhysicalDeviceConnect()

void Ship::ConnectedPhysicalDeviceManager::HandlePhysicalDeviceConnect ( int32_t  instanceId)

Handles a gamepad-added event by refreshing the connected set.

Parameters
instanceIdEvent joystick instance ID.

◆ HandlePhysicalDeviceDisconnect()

void Ship::ConnectedPhysicalDeviceManager::HandlePhysicalDeviceDisconnect ( int32_t  instanceId)

Handles a gamepad-removed event by refreshing the connected set.

Parameters
instanceIdEvent joystick instance ID.

◆ IgnoreInstanceIdForPort()

void Ship::ConnectedPhysicalDeviceManager::IgnoreInstanceIdForPort ( uint8_t  portIndex,
int32_t  instanceId 
)

Adds a joystick instance to a port's ignore list.

Parameters
portIndexZero-based controller port index.
instanceIdSDL joystick instance ID to ignore.

◆ PortIsIgnoringInstanceId()

bool Ship::ConnectedPhysicalDeviceManager::PortIsIgnoringInstanceId ( uint8_t  portIndex,
int32_t  instanceId 
)

Checks whether a specific joystick instance is being ignored on a port.

Parameters
portIndexZero-based controller port index.
instanceIdSDL joystick instance ID.
Returns
true if the instance is ignored for the given port.

◆ RefreshConnectedSDLGamepads()

void Ship::ConnectedPhysicalDeviceManager::RefreshConnectedSDLGamepads ( )

Re-scans SDL gamepads, preserving handles for devices that remain connected.

◆ UnignoreInstanceIdForPort()

void Ship::ConnectedPhysicalDeviceManager::UnignoreInstanceIdForPort ( uint8_t  portIndex,
int32_t  instanceId 
)

Removes a joystick instance from a port's ignore list.

Parameters
portIndexZero-based controller port index.
instanceIdSDL joystick instance ID to stop ignoring.

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