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

Tracks connected SDL game controllers 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_GameController * > 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 sdlDeviceIndex)
 Handles an SDL device-added event by opening the new controller.
 
void HandlePhysicalDeviceDisconnect (int32_t sdlJoystickInstanceId)
 Handles an SDL device-removed event by closing the controller.
 
void RefreshConnectedSDLGamepads ()
 Re-scans all connected SDL gamepads and rebuilds the internal maps.
 

Detailed Description

Tracks connected SDL game controllers and manages per-port ignore lists.

ConnectedPhysicalDeviceManager maintains a live map of SDL game controllers that are currently connected to the system. It also supports per-port ignore lists so that specific controllers can be excluded from a given controller port's input processing.

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_GameController * > 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_GameController 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  sdlDeviceIndex)

Handles an SDL device-added event by opening the new controller.

Parameters
sdlDeviceIndexSDL device index from the SDL_CONTROLLERDEVICEADDED event.

◆ HandlePhysicalDeviceDisconnect()

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

Handles an SDL device-removed event by closing the controller.

Parameters
sdlJoystickInstanceIdSDL joystick instance ID from the SDL_CONTROLLERDEVICEREMOVED event.

◆ 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 all connected SDL gamepads and rebuilds the internal maps.

◆ 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: