Browse Source

switch2: Move initialization after reading calibration

This removes the need to wait for initialization to finish
Vicki Pfau 4 months ago
parent
commit
ef99341691
1 changed files with 8 additions and 11 deletions
  1. 8 11
      src/joystick/hidapi/SDL_hidapi_switch2.c

+ 8 - 11
src/joystick/hidapi/SDL_hidapi_switch2.c

@@ -376,17 +376,6 @@ static bool HIDAPI_DriverSwitch2_InitUSB(SDL_HIDAPI_Device *device)
     };
     unsigned char calibration_data[0x50] = {0};
 
-    for (int i = 0; init_sequence[i].size; i++) {
-        res = SendBulkData(ctx, init_sequence[i].data, init_sequence[i].size);
-        if (res < 0) {
-            return SDL_SetError("Couldn't send initialization data: %d\n", res);
-        }
-        RecvBulkData(ctx, calibration_data, 0x40);
-    }
-
-    // Wait for initialization to complete
-    SDL_Delay(1);
-
     flash_read_command[12] = 0x80;
     res = SendBulkData(ctx, flash_read_command, sizeof(flash_read_command));
     if (res < 0) {
@@ -458,6 +447,14 @@ static bool HIDAPI_DriverSwitch2_InitUSB(SDL_HIDAPI_Device *device)
         }
     }
 
+    for (int i = 0; init_sequence[i].size; i++) {
+        res = SendBulkData(ctx, init_sequence[i].data, init_sequence[i].size);
+        if (res < 0) {
+            return SDL_SetError("Couldn't send initialization data: %d\n", res);
+        }
+        RecvBulkData(ctx, calibration_data, 0x40);
+    }
+
     return true;
 }