This commit is contained in:
ineedhelpbad 2023-12-21 06:02:30 -07:00 committed by GitHub
commit fba54a59b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 4 deletions

View File

@ -154,7 +154,7 @@ struct CreditsEntry sCreditsSequence[] = {
{ LEVEL_CASTLE_GROUNDS, 1, 1, -128, { 0, 906, -1200 }, NULL },
{ LEVEL_NONE, 0, 1, 0, { 0, 0, 0 }, NULL },
};
extern bool focus_Lost;
struct MarioState gMarioStates[1];
struct HudDisplay gHudDisplay;
s16 sCurrPlayMode;
@ -961,6 +961,7 @@ void basic_update(UNUSED s16 *arg) {
int gPressedStart = 0;
s32 play_mode_normal(void) {
if (gCurrDemoInput != NULL) {
print_intro_text();
if (gPlayer1Controller->buttonPressed & END_DEMO) {
@ -997,11 +998,12 @@ s32 play_mode_normal(void) {
set_play_mode(PLAY_MODE_CHANGE_LEVEL);
} else if (sTransitionTimer != 0) {
set_play_mode(PLAY_MODE_CHANGE_AREA);
} else if (pressed_pause()) {
} else if (pressed_pause() || focus_Lost) {
lower_background_noise(1);
cancel_rumble();
gCameraMovementFlags |= CAM_MOVE_PAUSE_SCREEN;
set_play_mode(PLAY_MODE_PAUSED);
focus_Lost = FALSE;
}
}

View File

@ -26,7 +26,7 @@
#else
# define FRAMERATE 30
#endif
bool focus_Lost = FALSE;
static int inverted_scancode_table[512];
static kb_callback_t kb_key_down = NULL;
@ -202,6 +202,11 @@ static void gfx_sdl_onkeyup(int scancode) {
static void gfx_sdl_handle_events(void) {
SDL_Event event;
while (SDL_PollEvent(&event)) {
if (event.type.event = SDL_WINDOWEVENT_FOCUS_LOST)
{
focus_Lost = TRUE;
}
switch (event.type) {
#ifndef TARGET_WEB
// Scancodes are broken in Emscripten SDL2: https://bugzilla.libsdl.org/show_bug.cgi?id=3259
@ -222,6 +227,7 @@ static void gfx_sdl_handle_events(void) {
case SDL_QUIT:
game_exit();
break;
}
}
}

View File

@ -42,7 +42,7 @@
#else
# define FRAMERATE 30
#endif
bool focus_Lost = FALSE;
static SDL_Window *wnd;
static SDL_GLContext ctx = NULL;
static int inverted_scancode_table[512];
@ -242,11 +242,13 @@ static void gfx_sdl_handle_events(void) {
// Scancodes are broken in Emscripten SDL2: https://bugzilla.libsdl.org/show_bug.cgi?id=3259
case SDL_KEYDOWN:
gfx_sdl_onkeydown(event.key.keysym.scancode);
break;
case SDL_KEYUP:
gfx_sdl_onkeyup(event.key.keysym.scancode);
break;
#endif
case SDL_WINDOWEVENT: // TODO: Check if this makes sense to be included in the Web build
if (!IS_FULLSCREEN()) {
switch (event.window.event) {
@ -260,12 +262,16 @@ static void gfx_sdl_handle_events(void) {
configWindow.w = event.window.data1;
configWindow.h = event.window.data2;
break;
case SDL_WINDOWEVENT_FOCUS_LOST:
focus_Lost = TRUE;
break;
}
}
break;
case SDL_QUIT:
game_exit();
break;
}
}