浏览代码

Implement SInput Device Namings (#13391)

mitchellcairns 5 天之前
父节点
当前提交
4a30ee58ca
共有 1 个文件被更改,包括 21 次插入0 次删除
  1. 21 0
      src/joystick/hidapi/SDL_hidapi_sinput.c

+ 21 - 0
src/joystick/hidapi/SDL_hidapi_sinput.c

@@ -56,6 +56,8 @@
 #define SINPUT_DEVICE_COMMAND_PLAYERLED     0x03
 #define SINPUT_DEVICE_COMMAND_JOYSTICKRGB   0x04
 
+#define SINPUT_GENERIC_SUBTYPE_SUPERGAMEPADPLUS 0x01
+
 #define SINPUT_HAPTIC_TYPE_PRECISE          0x01
 #define SINPUT_HAPTIC_TYPE_ERMSIMULATION    0x02
 
@@ -266,6 +268,8 @@ static void ProcessSDLFeaturesResponse(SDL_HIDAPI_Device *device, Uint8 *data)
         SDL_Log("SInput Sub-type: %d", (data[5] & 0xF));
 #endif
 
+    ctx->sub_type = (data[5] & 0xF);
+
     ctx->polling_rate_ms = data[6];
 
     ctx->accelRange = EXTRACTUINT16(data, 8);
@@ -438,6 +442,23 @@ static bool HIDAPI_DriverSInput_InitDevice(SDL_HIDAPI_Device *device)
         return false;
     }
 
+    switch (device->product_id) {
+    case USB_PRODUCT_HANDHELDLEGEND_GCULTIMATE:
+        HIDAPI_SetDeviceName(device, "HHL GC Ultimate");
+        break;
+    case USB_PRODUCT_HANDHELDLEGEND_PROGCC:
+        HIDAPI_SetDeviceName(device, "HHL ProGCC");
+        break;
+    case USB_PRODUCT_HANDHELDLEGEND_SINPUT_GENERIC:
+        if (ctx->sub_type == SINPUT_GENERIC_SUBTYPE_SUPERGAMEPADPLUS) {
+            HIDAPI_SetDeviceName(device, "HHL SuperGamepad+");
+        }
+        break;
+    default:
+        // Use the USB product name
+        break;
+    }
+
     return HIDAPI_JoystickConnected(device, NULL);
 }