Skip to content

Commit

Permalink
Update rcore_desktop_sdl.c
Browse files Browse the repository at this point in the history
Removed hardcoded values
  • Loading branch information
hanaxars authored Jan 17, 2025
1 parent dcc7bd1 commit 444eda2
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/platforms/rcore_desktop_sdl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1670,8 +1670,8 @@ void PollInputEvents(void)
CORE.Input.Gamepad.axisCount[jid] = SDL_JoystickNumAxes(SDL_GameControllerGetJoystick(platform.gamepad[jid]));
CORE.Input.Gamepad.axisState[jid][GAMEPAD_AXIS_LEFT_TRIGGER] = -1.0f;
CORE.Input.Gamepad.axisState[jid][GAMEPAD_AXIS_RIGHT_TRIGGER] = -1.0f;
strncpy(CORE.Input.Gamepad.name[jid], SDL_GameControllerNameForIndex(jid), 63);
CORE.Input.Gamepad.name[jid][63] = '\0';
strncpy(CORE.Input.Gamepad.name[jid], SDL_GameControllerNameForIndex(jid), sizeof(CORE.Input.Gamepad.name[jid]) - 1);
CORE.Input.Gamepad.name[jid][sizeof(CORE.Input.Gamepad.name[jid]) - 1] = '\0';
}
else
{
Expand All @@ -1688,7 +1688,7 @@ void PollInputEvents(void)
SDL_GameControllerClose(platform.gamepad[jid]);
platform.gamepad[jid] = SDL_GameControllerOpen(0);
CORE.Input.Gamepad.ready[jid] = false;
memset(CORE.Input.Gamepad.name[jid], 0, 64);
memset(CORE.Input.Gamepad.name[jid], 0, sizeof(CORE.Input.Gamepad.name[jid]));
}
} break;
case SDL_CONTROLLERBUTTONDOWN:
Expand Down Expand Up @@ -1977,8 +1977,8 @@ int InitPlatform(void)
CORE.Input.Gamepad.axisCount[i] = SDL_JoystickNumAxes(SDL_GameControllerGetJoystick(platform.gamepad[i]));
CORE.Input.Gamepad.axisState[i][GAMEPAD_AXIS_LEFT_TRIGGER] = -1.0f;
CORE.Input.Gamepad.axisState[i][GAMEPAD_AXIS_RIGHT_TRIGGER] = -1.0f;
strncpy(CORE.Input.Gamepad.name[i], SDL_GameControllerNameForIndex(i), 63);
CORE.Input.Gamepad.name[i][63] = '\0';
strncpy(CORE.Input.Gamepad.name[i], SDL_GameControllerNameForIndex(i), sizeof(CORE.Input.Gamepad.name[jid]) - 1);
CORE.Input.Gamepad.name[i][sizeof(CORE.Input.Gamepad.name[jid]) - 1] = '\0';
}
else TRACELOG(LOG_WARNING, "PLATFORM: Unable to open game controller [ERROR: %s]", SDL_GetError());
}
Expand Down

0 comments on commit 444eda2

Please sign in to comment.