From ef99341691ad979d42e83cf4705eb107e90b2561 Mon Sep 17 00:00:00 2001
From: Vicki Pfau <[EMAIL REDACTED]>
Date: Fri, 10 Oct 2025 17:11:03 -0700
Subject: [PATCH] switch2: Move initialization after reading calibration
This removes the need to wait for initialization to finish
---
src/joystick/hidapi/SDL_hidapi_switch2.c | 19 ++++++++-----------
1 file changed, 8 insertions(+), 11 deletions(-)
diff --git a/src/joystick/hidapi/SDL_hidapi_switch2.c b/src/joystick/hidapi/SDL_hidapi_switch2.c
index ff3c2a30c05fa..9b59d37952093 100644
--- a/src/joystick/hidapi/SDL_hidapi_switch2.c
+++ b/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;
}