Răsfoiți Sursa

examples: Disable quitting with the escape key in Emscripten builds

Cameron Cawley 1 lună în urmă
părinte
comite
dca1503f00

+ 2 - 0
examples/demo/01-snake/snake.c

@@ -214,10 +214,12 @@ void snake_step(SnakeContext *ctx)
 static SDL_AppResult handle_key_event_(SnakeContext *ctx, SDL_Keycode key_code)
 {
     switch (key_code) {
+#ifndef SDL_PLATFORM_EMSCRIPTEN
     /* Quit. */
     case SDLK_ESCAPE:
     case SDLK_Q:
         return SDL_APP_SUCCESS;
+#endif
     /* Restart the game as if the program was launched. */
     case SDLK_R:
         snake_initialize(ctx);

+ 2 - 0
examples/demo/02-woodeneye-008/woodeneye-008.c

@@ -434,7 +434,9 @@ SDL_AppResult SDL_AppEvent(void *appstate, SDL_Event *event)
         case SDL_EVENT_KEY_UP: {
             SDL_Scancode scancode = event->key.scancode;
             SDL_KeyboardID id = event->key.which;
+#ifndef SDL_PLATFORM_EMSCRIPTEN
             if (scancode == SDL_SCANCODE_ESCAPE) return SDL_APP_SUCCESS;
+#endif
             int index = whoseKeyboard(id, players, player_count);
             if (index >= 0) {
                 if (scancode == SDL_SCANCODE_W) players[index].wasd &= 30;

+ 1 - 1
examples/demo/04-bytepusher/bytepusher.c

@@ -346,7 +346,7 @@ SDL_AppResult SDL_AppEvent(void* appstate, SDL_Event* event) {
             break;
         
         case SDL_EVENT_KEY_DOWN:
-#ifndef __EMSCRIPTEN__
+#ifndef SDL_PLATFORM_EMSCRIPTEN
             if (event->key.key == SDLK_ESCAPE) {
                 return SDL_APP_SUCCESS;
             }