Ignore IMU-only Controllers in GUI (#387)

This commit is contained in:
Blueroom VR 2020-12-01 12:52:46 -08:00 committed by GitHub
commit ea4ff606f0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -11,6 +11,64 @@
#include <SDL.h>
#endif
static QSet<QString> chiaki_motion_controller_guids({
// Sony on Linux
"03000000341a00003608000011010000",
"030000004c0500006802000010010000",
"030000004c0500006802000010810000",
"030000004c0500006802000011010000",
"030000004c0500006802000011810000",
"030000006f0e00001402000011010000",
"030000008f0e00000300000010010000",
"050000004c0500006802000000010000",
"050000004c0500006802000000800000",
"050000004c0500006802000000810000",
"05000000504c415953544154494f4e00",
"060000004c0500006802000000010000",
"030000004c050000a00b000011010000",
"030000004c050000a00b000011810000",
"030000004c050000c405000011010000",
"030000004c050000c405000011810000",
"030000004c050000cc09000000010000",
"030000004c050000cc09000011010000",
"030000004c050000cc09000011810000",
"03000000c01100000140000011010000",
"050000004c050000c405000000010000",
"050000004c050000c405000000810000",
"050000004c050000c405000001800000",
"050000004c050000cc09000000010000",
"050000004c050000cc09000000810000",
"050000004c050000cc09000001800000",
// Sony on iOS
"050000004c050000cc090000df070000",
// Sony on Android
"050000004c05000068020000dfff3f00",
"030000004c050000cc09000000006800",
"050000004c050000c4050000fffe3f00",
"050000004c050000cc090000fffe3f00",
"050000004c050000cc090000ffff3f00",
"35643031303033326130316330353564",
// Sony on Mac OSx
"030000004c050000cc09000000000000",
"030000004c0500006802000000000000",
"030000004c0500006802000000010000",
"030000004c050000a00b000000010000",
"030000004c050000c405000000000000",
"030000004c050000c405000000010000",
"030000004c050000cc09000000010000",
"03000000c01100000140000000010000",
// Sony on Windows
"030000004c050000a00b000000000000",
"030000004c050000c405000000000000",
"030000004c050000cc09000000000000",
"03000000250900000500000000000000",
"030000004c0500006802000000000000",
"03000000632500007505000000000000",
"03000000888800000803000000000000",
"030000008f0e00001431000000000000",
});
static ControllerManager *instance = nullptr;
#define UPDATE_INTERVAL_MS 4
@ -56,6 +114,24 @@ void ControllerManager::UpdateAvailableControllers()
{
if(!SDL_IsGameController(i))
continue;
// We'll try to identify pads with Motion Control
SDL_JoystickGUID guid = SDL_JoystickGetGUID(SDL_JoystickOpen(i));
char guid_str[256];
SDL_JoystickGetGUIDString(guid, guid_str, sizeof(guid_str));
if(chiaki_motion_controller_guids.contains(guid_str))
{
SDL_Joystick *joy = SDL_JoystickOpen(i);
if(joy)
{
bool no_buttons = SDL_JoystickNumButtons(joy) == 0;
SDL_JoystickClose(joy);
if(no_buttons)
continue;
}
}
current_controllers.insert(SDL_JoystickGetDeviceInstanceID(i));
}