Просмотр исходного кода

Don't enable extended features for GameSir controllers over Bluetooth

Sam Lantinga 1 неделя назад
Родитель
Сommit
f600c74c80
2 измененных файлов с 13 добавлено и 3 удалено
  1. 2 1
      src/joystick/SDL_gamepad.c
  2. 11 2
      src/joystick/hidapi/SDL_hidapi_gamesir.c

+ 2 - 1
src/joystick/SDL_gamepad.c

@@ -1267,7 +1267,8 @@ static GamepadMapping_t *SDL_CreateMappingForHIDAPIGamepad(SDL_GUID guid)
                 // Apex 5 has additional shoulder macro buttons
                 SDL_strlcat(mapping_string, "misc2:b15,misc3:b16,", sizeof(mapping_string));
             }
-        } else if (SDL_IsJoystickGameSirController(vendor, product)) {
+        } else if (SDL_IsJoystickGameSirController(vendor, product) &&
+                   guid.data[0] == SDL_HARDWARE_BUS_USB) {
             // The GameSir-G7 Pro 8K has a set of paddles and shoulder macro buttons
             SDL_strlcat(mapping_string, "misc1:b11,paddle1:b13,paddle2:b12,misc2:b14,misc3:b15,", sizeof(mapping_string));
         } else if (vendor == USB_VENDOR_8BITDO && product == USB_PRODUCT_8BITDO_ULTIMATE2_WIRELESS) {

+ 11 - 2
src/joystick/hidapi/SDL_hidapi_gamesir.c

@@ -359,7 +359,11 @@ static bool HIDAPI_DriverGameSir_InitDevice(SDL_HIDAPI_Device *device)
     switch (device->product_id) {
     case USB_PRODUCT_GAMESIR_GAMEPAD_G7_PRO_8K:
         HIDAPI_SetDeviceName(device, "GameSir-G7 Pro 8K");
-        ctx->sensors_supported = true;
+        if (device->is_bluetooth) {
+            // Sensors are not supported over Bluetooth
+        } else {
+            ctx->sensors_supported = true;
+        }
         ctx->led_supported = false;
         SDL_LogDebug(SDL_LOG_CATEGORY_INPUT, "GameSir: Device detected - G7 Pro 8K mode (PID 0x%04X)", device->product_id);
         break;
@@ -400,7 +404,12 @@ static bool HIDAPI_DriverGameSir_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joy
         SDL_LogDebug(SDL_LOG_CATEGORY_INPUT, "GameSir: failed to send SDL mode switch command (0xA2, 0x01)");
     }
 
-    joystick->nbuttons = SDL_GAMEPAD_NUM_GAMESIR_BUTTONS;
+    if (device->is_bluetooth) {
+        // Extended buttons are not supported over Bluetooth
+        joystick->nbuttons = 11;
+    } else {
+        joystick->nbuttons = SDL_GAMEPAD_NUM_GAMESIR_BUTTONS;
+    }
     joystick->naxes = SDL_GAMEPAD_AXIS_COUNT;
     joystick->nhats = 1;