Fix spacing; tabs to 4 spaces

This commit is contained in:
DamianS-eng 2025-03-14 17:18:44 -04:00 committed by Sam Lantinga
parent 60857935ca
commit 3b90ce4995
1 changed files with 35 additions and 35 deletions

View File

@ -242,23 +242,23 @@ static SDL_AppResult handle_key_event_(SnakeContext *ctx, SDL_Scancode key_code)
}
static SDL_AppResult handle_hat_event_(SnakeContext *ctx, Uint8 hat) {
switch (hat) {
case SDL_HAT_RIGHT:
snake_redir(ctx, SNAKE_DIR_RIGHT);
break;
case SDL_HAT_UP:
snake_redir(ctx, SNAKE_DIR_UP);
break;
case SDL_HAT_LEFT:
snake_redir(ctx, SNAKE_DIR_LEFT);
break;
case SDL_HAT_DOWN:
snake_redir(ctx, SNAKE_DIR_DOWN);
break;
default:
break;
}
return SDL_APP_CONTINUE;
switch (hat) {
case SDL_HAT_RIGHT:
snake_redir(ctx, SNAKE_DIR_RIGHT);
break;
case SDL_HAT_UP:
snake_redir(ctx, SNAKE_DIR_UP);
break;
case SDL_HAT_LEFT:
snake_redir(ctx, SNAKE_DIR_LEFT);
break;
case SDL_HAT_DOWN:
snake_redir(ctx, SNAKE_DIR_DOWN);
break;
default:
break;
}
return SDL_APP_CONTINUE;
}
SDL_AppResult SDL_AppIterate(void *appstate)
@ -329,7 +329,7 @@ SDL_AppResult SDL_AppInit(void **appstate, int argc, char *argv[])
}
if (!SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK)) {
SDL_Log("Couldn't initialize SDL: %s", SDL_GetError());
SDL_Log("Couldn't initialize SDL: %s", SDL_GetError());
return SDL_APP_FAILURE;
}
@ -357,20 +357,20 @@ SDL_AppResult SDL_AppEvent(void *appstate, SDL_Event *event)
switch (event->type) {
case SDL_EVENT_QUIT:
return SDL_APP_SUCCESS;
case SDL_EVENT_JOYSTICK_ADDED:
if (joystick == NULL) {
joystick = SDL_OpenJoystick(event->jdevice.which);
if (!joystick) {
SDL_Log("Failed to open joystick ID %u: %s", (unsigned int) event->jdevice.which, SDL_GetError());
}
}
case SDL_EVENT_JOYSTICK_REMOVED:
if (joystick && (SDL_GetJoystickID(joystick) == event->jdevice.which)) {
SDL_CloseJoystick(joystick);
joystick = NULL;
}
case SDL_EVENT_JOYSTICK_HAT_MOTION:
return handle_hat_event_(ctx, event->jhat.value);
case SDL_EVENT_JOYSTICK_ADDED:
if (joystick == NULL) {
joystick = SDL_OpenJoystick(event->jdevice.which);
if (!joystick) {
SDL_Log("Failed to open joystick ID %u: %s", (unsigned int) event->jdevice.which, SDL_GetError());
}
}
case SDL_EVENT_JOYSTICK_REMOVED:
if (joystick && (SDL_GetJoystickID(joystick) == event->jdevice.which)) {
SDL_CloseJoystick(joystick);
joystick = NULL;
}
case SDL_EVENT_JOYSTICK_HAT_MOTION:
return handle_hat_event_(ctx, event->jhat.value);
case SDL_EVENT_KEY_DOWN:
return handle_key_event_(ctx, event->key.scancode);
}
@ -379,9 +379,9 @@ SDL_AppResult SDL_AppEvent(void *appstate, SDL_Event *event)
void SDL_AppQuit(void *appstate, SDL_AppResult result)
{
if (joystick) {
SDL_CloseJoystick(joystick);
}
if (joystick) {
SDL_CloseJoystick(joystick);
}
if (appstate != NULL) {
AppState *as = (AppState *)appstate;
SDL_DestroyRenderer(as->renderer);