diff --git a/src/sdl/i_gamepad.c b/src/sdl/i_gamepad.c
index c3150ac6e86ffb7acc0bbc8bc8649525633e1ff5..69f03d662e22be3dac9427e1495c342622326c34 100644
--- a/src/sdl/i_gamepad.c
+++ b/src/sdl/i_gamepad.c
@@ -534,17 +534,10 @@ void I_SetGamepadDigital(UINT8 which, boolean enable)
 
 static gamepad_t *Controller_GetFromID(SDL_JoystickID which, UINT8 *found)
 {
-	SDL_JoystickID joyid[NUM_GAMEPADS];
-
-	UINT8 i;
-
 	// Determine the joystick IDs for each current open controller
-	for (i = 0; i < NUM_GAMEPADS; i++)
-		joyid[i] = SDL_JoystickInstanceID(controllers[i].joydev);
-
-	for (i = 0; i < NUM_GAMEPADS; i++)
+	for (UINT8 i = 0; i < NUM_GAMEPADS; i++)
 	{
-		if (which == joyid[i])
+		if (which == SDL_JoystickInstanceID(controllers[i].joydev))
 		{
 			(*found) = i;
 			return &gamepads[i];