Add SDL init call to initialize gamepad subsystem

This commit is contained in:
Lily Rose 2025-03-04 21:01:10 +11:00
parent 59832014df
commit c9a2ee83dc

7
main.c
View file

@ -45,12 +45,19 @@ SDL_AppResult SDL_AppInit(void **appstate, int argc, char *argv[]) {
(void) argc; (void) argc;
(void) argv; (void) argv;
if (!SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_EVENTS | SDL_INIT_GAMEPAD)) {
SDL_LogError(SDL_LOG_CATEGORY_ERROR, "Failed to initialize SDL: %s", SDL_GetError());
return SDL_APP_FAILURE;
}
if (!TTF_Init()) { if (!TTF_Init()) {
SDL_LogError(SDL_LOG_CATEGORY_ERROR, "Failed to initialize SDL TTF: %s", SDL_GetError());
return SDL_APP_FAILURE; return SDL_APP_FAILURE;
} }
AppState *state = SDL_calloc(1, sizeof(AppState)); AppState *state = SDL_calloc(1, sizeof(AppState));
if (!state) { if (!state) {
SDL_LogError(SDL_LOG_CATEGORY_ERROR, "Failed to allocate memory for application state: %s", SDL_GetError());
return SDL_APP_FAILURE; return SDL_APP_FAILURE;
} }
*appstate = state; *appstate = state;