mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-08-25 16:11:40 +00:00
examples: Disable quitting with the escape key in Emscripten builds
This commit is contained in:
committed by
Sam Lantinga
parent
741668ab12
commit
dca1503f00
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user