mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-10-03 16:36:25 +00:00
Prefer USB input over Bluetooth for PS5/PS5/Switch controllers
Nintendo Switch controllers will automatically turn off Bluetooth when connected over USB, but this takes care of that a little more quickly. PS4 and PS5 controllers will happily send reports over both Bluetooth and USB, so we'll prefer USB if connected and switch back to Bluetooth if USB is disconnected.
This commit is contained in:
@@ -529,6 +529,41 @@ HIDAPI_SetDeviceSerial(SDL_HIDAPI_Device *device, const char *serial)
|
||||
}
|
||||
}
|
||||
|
||||
SDL_bool
|
||||
HIDAPI_HasConnectedUSBDevice(const char *serial)
|
||||
{
|
||||
SDL_HIDAPI_Device *device;
|
||||
|
||||
for (device = SDL_HIDAPI_devices; device; device = device->next) {
|
||||
if (device->is_bluetooth) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (device->serial && SDL_strcmp(serial, device->serial) == 0) {
|
||||
return SDL_TRUE;
|
||||
}
|
||||
}
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
HIDAPI_DisconnectBluetoothDevice(const char *serial)
|
||||
{
|
||||
SDL_HIDAPI_Device *device;
|
||||
|
||||
for (device = SDL_HIDAPI_devices; device; device = device->next) {
|
||||
if (!device->is_bluetooth) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (device->serial && SDL_strcmp(serial, device->serial) == 0) {
|
||||
while (device->num_joysticks && device->joysticks) {
|
||||
HIDAPI_JoystickDisconnected(device, device->joysticks[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SDL_bool
|
||||
HIDAPI_JoystickConnected(SDL_HIDAPI_Device *device, SDL_JoystickID *pJoystickID)
|
||||
{
|
||||
|
Reference in New Issue
Block a user