Don't set the serial number after the controller is opened

We'll use the USB value instead so it's available as soon as it's opened.
This commit is contained in:
Sam Lantinga 2020-11-25 01:35:45 -08:00
parent 7d92b14f46
commit 159d1b3df5

View File

@ -853,6 +853,7 @@ HIDAPI_DriverXboxOneBluetooth_HandleGuidePacket(SDL_Joystick *joystick, hid_devi
SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_GUIDE, (data[1] & 0x01) ? SDL_PRESSED : SDL_RELEASED); SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_GUIDE, (data[1] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
} }
#ifdef SET_SERIAL_AFTER_OPEN
static void static void
HIDAPI_DriverXboxOne_HandleSerialIDPacket(SDL_Joystick *joystick, SDL_DriverXboxOne_Context *ctx, Uint8 *data, int size) HIDAPI_DriverXboxOne_HandleSerialIDPacket(SDL_Joystick *joystick, SDL_DriverXboxOne_Context *ctx, Uint8 *data, int size)
{ {
@ -871,6 +872,7 @@ HIDAPI_DriverXboxOne_HandleSerialIDPacket(SDL_Joystick *joystick, SDL_DriverXbox
joystick->serial = SDL_strdup(serial); joystick->serial = SDL_strdup(serial);
} }
} }
#endif /* SET_SERIAL_AFTER_OPEN */
static SDL_bool static SDL_bool
HIDAPI_DriverXboxOne_UpdateInitState(SDL_HIDAPI_Device *device, SDL_DriverXboxOne_Context *ctx) HIDAPI_DriverXboxOne_UpdateInitState(SDL_HIDAPI_Device *device, SDL_DriverXboxOne_Context *ctx)
@ -1011,9 +1013,11 @@ HIDAPI_DriverXboxOne_UpdateJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joy
The controller sends that in response to this request: The controller sends that in response to this request:
0x1E 0x30 0x07 0x01 0x04 0x1E 0x30 0x07 0x01 0x04
*/ */
#ifdef SET_SERIAL_AFTER_OPEN
if (size == 20 && data[3] == 0x10) { if (size == 20 && data[3] == 0x10) {
HIDAPI_DriverXboxOne_HandleSerialIDPacket(joystick, ctx, data, size); HIDAPI_DriverXboxOne_HandleSerialIDPacket(joystick, ctx, data, size);
} }
#endif
break; break;
case 0x20: case 0x20:
if (ctx->init_state < XBOX_ONE_INIT_STATE_COMPLETE) { if (ctx->init_state < XBOX_ONE_INIT_STATE_COMPLETE) {