瀏覽代碼

Set the serial number to the Bluetooth MAC address for 8BitDo controllers

Sam Lantinga 11 月之前
父節點
當前提交
36936cbf37
共有 1 個文件被更改,包括 8 次插入0 次删除
  1. 8 0
      src/joystick/hidapi/SDL_hidapi_8bitdo.c

+ 8 - 0
src/joystick/hidapi/SDL_hidapi_8bitdo.c

@@ -179,6 +179,14 @@ static bool HIDAPI_Driver8BitDo_InitDevice(SDL_HIDAPI_Device *device)
                 ctx->sensors_supported = true;
                 ctx->rumble_supported = true;
                 ctx->powerstate_supported = true;
+
+                // Set the serial number to the Bluetooth MAC address
+                if (size >= 12 && data[10] != 0) {
+                    char serial[18];
+                    (void)SDL_snprintf(serial, sizeof(serial), "%.2x-%.2x-%.2x-%.2x-%.2x-%.2x",
+                                       data[10], data[9], data[8], data[7], data[6], data[5]);
+                    HIDAPI_SetDeviceSerial(device, serial);
+                }
                 break;
             }