Commit b23cce282eae48a088f9bd4c69105810b844edb4

Zack Middleton 2019-06-19T06:43:04

Fix GameCube controller power level being reset to unknown HIDAPI_DriverGameCube_OpenJoystick() set power level to wired and then it was set to unknown in SDL_JoystickOpen().

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
diff --git a/src/joystick/SDL_joystick.c b/src/joystick/SDL_joystick.c
index a44b643..bd89a7c 100644
--- a/src/joystick/SDL_joystick.c
+++ b/src/joystick/SDL_joystick.c
@@ -323,6 +323,7 @@ SDL_JoystickOpen(int device_index)
     joystick->instance_id = instance_id;
     joystick->attached = SDL_TRUE;
     joystick->player_index = -1;
+    joystick->epowerlevel = SDL_JOYSTICK_POWER_UNKNOWN;
 
     if (driver->Open(joystick, device_index) < 0) {
         SDL_free(joystick);
@@ -360,7 +361,6 @@ SDL_JoystickOpen(int device_index)
         SDL_UnlockJoysticks();
         return NULL;
     }
-    joystick->epowerlevel = SDL_JOYSTICK_POWER_UNKNOWN;
 
     /* If this joystick is known to have all zero centered axes, skip the auto-centering code */
     if (SDL_JoystickAxesCenteredAtZero(joystick)) {