diff --git a/src/joystick/hidapi/SDL_hidapi_gamesir.c b/src/joystick/hidapi/SDL_hidapi_gamesir.c index 27d5cc5596..23f94f6811 100644 --- a/src/joystick/hidapi/SDL_hidapi_gamesir.c +++ b/src/joystick/hidapi/SDL_hidapi_gamesir.c @@ -159,25 +159,10 @@ static bool SendGameSirModeSwitch(SDL_HIDAPI_Device *device) for (int attempt = 0; attempt < 3; ++attempt) { int result = SDL_hid_write(handle, buf, sizeof(buf)); - if (result < 0) { - return false; - } - for (int i = 0; i < 10; ++i) { - SDL_Delay(1); - - Uint8 data[USB_PACKET_LENGTH] = {0}; - int size = SDL_hid_read_timeout(handle, data, sizeof(data), 0); - if (size < 0) { - break; - } - if (size == 0) { - continue; - } - - if (size == 64 && data[0] == 0xA1 && data[1] == 0x43 && data[2] == 0x01) { - return true; - } + if (result >= 0) { + return true; } + SDL_Delay(1); } return false; } @@ -356,7 +341,7 @@ static bool HIDAPI_DriverGameSir_InitDevice(SDL_HIDAPI_Device *device) HIDAPI_SetDeviceName(device, "GameSir-G7 Pro 8K"); ctx->sensors_supported = true; ctx->led_supported = false; - SDL_LogDebug(SDL_LOG_CATEGORY_INPUT, "GameSir: Device detected - G7 Pro 8K HID mode (PID 0x%04X)", device->product_id); + SDL_LogDebug(SDL_LOG_CATEGORY_INPUT, "GameSir: Device detected - G7 Pro 8K mode (PID 0x%04X)", device->product_id); break; default: HIDAPI_SetDeviceName(device, "GameSir Controller"); @@ -391,17 +376,11 @@ static bool HIDAPI_DriverGameSir_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joy SDL_zeroa(ctx->last_state); ctx->last_state_initialized = false; - bool extended_report_mode = SendGameSirModeSwitch(device); - if (!extended_report_mode) { - ctx->sensors_supported = false; - ctx->led_supported = false; + if (!SendGameSirModeSwitch(device)) { + SDL_LogDebug(SDL_LOG_CATEGORY_INPUT, "GameSir: failed to send SDL mode switch command (0xA2, 0x01)"); } - if (extended_report_mode) { - joystick->nbuttons = 35; - } else { - joystick->nbuttons = 11; - } + joystick->nbuttons = 35; joystick->naxes = SDL_GAMEPAD_AXIS_COUNT; joystick->nhats = 1; @@ -434,8 +413,8 @@ static bool HIDAPI_DriverGameSir_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_J SDL_zero(buf); buf[0] = 0xA2; buf[1] = 0x03; - buf[2] = (Uint8)(low_frequency_rumble / 256); - buf[3] = (Uint8)(high_frequency_rumble / 256); + buf[2] = (Uint8)(low_frequency_rumble >> 8); + buf[3] = (Uint8)(high_frequency_rumble >> 8); SDL_hid_device *handle = HIDAPI_DriverGameSir_GetOutputHandle(device); if (handle == NULL) { diff --git a/src/joystick/usb_ids.h b/src/joystick/usb_ids.h index cd1a0db86f..269729c234 100644 --- a/src/joystick/usb_ids.h +++ b/src/joystick/usb_ids.h @@ -85,7 +85,7 @@ #define USB_PRODUCT_FLYDIGI_V1_GAMEPAD 0x2412 #define USB_PRODUCT_FLYDIGI_V2_APEX 0x2501 #define USB_PRODUCT_FLYDIGI_V2_VADER 0x2401 -#define USB_PRODUCT_GAMESIR_GAMEPAD_G7_PRO_8K 0x10B8 // Wired/2.4G/Bluetooth 8K HID mode +#define USB_PRODUCT_GAMESIR_GAMEPAD_G7_PRO_8K 0x10B8 // Wired/2.4G/Bluetooth 8K mode #define USB_PRODUCT_HORI_FIGHTING_STICK_ALPHA_PS4 0x011c #define USB_PRODUCT_HORI_FIGHTING_STICK_ALPHA_PS5 0x0184 #define USB_PRODUCT_HORI_FIGHTING_STICK_ALPHA_PS5 0x0184