Skip to content

Commit 86e00bd

Browse files
committed
Update rcore_desktop_sdl.c
1 parent 95a8977 commit 86e00bd

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

src/platforms/rcore_desktop_sdl.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1723,15 +1723,11 @@ void PollInputEvents(void)
17231723
CORE.Input.Gamepad.axisState[nextAvailableSlot][GAMEPAD_AXIS_LEFT_TRIGGER] = -1.0f;
17241724
CORE.Input.Gamepad.axisState[nextAvailableSlot][GAMEPAD_AXIS_RIGHT_TRIGGER] = -1.0f;
17251725
memset(CORE.Input.Gamepad.name[nextAvailableSlot], 0, MAX_GAMEPAD_NAME_LENGTH);
1726-
if (SDL_GameControllerNameForIndex(nextAvailableSlot))
1727-
strncpy(CORE.Input.Gamepad.name[nextAvailableSlot], SDL_GameControllerNameForIndex(nextAvailableSlot), MAX_GAMEPAD_NAME_LENGTH - 1);
1728-
else
1729-
strncpy(CORE.Input.Gamepad.name[nextAvailableSlot], "Noname", 6);
1730-
}
1731-
else
1732-
{
1733-
TRACELOG(LOG_WARNING, "PLATFORM: Unable to open game controller [ERROR: %s]", SDL_GetError());
1726+
const char *controllerName = SDL_GameControllerNameForIndex(nextAvailableSlot);
1727+
if (controllerName != NULL) strncpy(CORE.Input.Gamepad.name[nextAvailableSlot], controllerName, MAX_GAMEPAD_NAME_LENGTH - 1);
1728+
else strncpy(CORE.Input.Gamepad.name[nextAvailableSlot], "noname", 6);
17341729
}
1730+
else TRACELOG(LOG_WARNING, "PLATFORM: Unable to open game controller [ERROR: %s]", SDL_GetError());
17351731
}
17361732
} break;
17371733
case SDL_JOYDEVICEREMOVED:

0 commit comments

Comments
 (0)