Add SDL init call to initialize gamepad subsystem
This commit is contained in:
parent
59832014df
commit
c9a2ee83dc
1 changed files with 7 additions and 0 deletions
7
main.c
7
main.c
|
@ -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;
|
||||||
|
|
Loading…
Reference in a new issue