Tracks connected SDL game controllers and manages per-port ignore lists.
More...
#include <ConnectedPhysicalDeviceManager.h>
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.
◆ ConnectedPhysicalDeviceManager()
| Ship::ConnectedPhysicalDeviceManager::ConnectedPhysicalDeviceManager |
( |
| ) |
|
Constructs the manager and performs an initial scan of connected gamepads.
◆ ~ConnectedPhysicalDeviceManager()
| Ship::ConnectedPhysicalDeviceManager::~ConnectedPhysicalDeviceManager |
( |
| ) |
|
◆ 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
-
| portIndex | Zero-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
-
| portIndex | Zero-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
-
| sdlDeviceIndex | SDL 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
-
| sdlJoystickInstanceId | SDL 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
-
| portIndex | Zero-based controller port index. |
| instanceId | SDL 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
-
| portIndex | Zero-based controller port index. |
| instanceId | SDL 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
-
| portIndex | Zero-based controller port index. |
| instanceId | SDL joystick instance ID to stop ignoring. |
The documentation for this class was generated from the following file: