File tree Expand file tree Collapse file tree 1 file changed +4
-8
lines changed
Expand file tree Collapse file tree 1 file changed +4
-8
lines changed Original file line number Diff line number Diff 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 :
You can’t perform that action at this time.
0 commit comments