sdl2 fullscreen toggle

This commit is contained in:
KikooDX 2022-03-11 12:35:04 +01:00
parent 3ff9240636
commit 44a2dbfc3d
1 changed files with 10 additions and 0 deletions

View File

@ -442,6 +442,7 @@ static const SDL_Scancode sc[LZYK_COUNT] = {
SDL_SCANCODE_LEFT, SDL_SCANCODE_RIGHT, SDL_SCANCODE_UP,
SDL_SCANCODE_DOWN, SDL_SCANCODE_Z, SDL_SCANCODE_X,
};
static const SDL_Scancode fullscreen_sc = SDL_SCANCODE_F11;
static const char *error = NULL;
static SDL_Window *window = NULL;
static SDL_Renderer *renderer = NULL;
@ -912,6 +913,15 @@ int LZY_PollEvent(LZY_Event *e) {
return 1;
}
}
if (sdl_e.key.keysym.scancode ==
fullscreen_sc) {
const unsigned int flag =
SDL_WINDOW_FULLSCREEN;
const unsigned int fullscreen =
SDL_GetWindowFlags(window) & flag;
SDL_SetWindowFullscreen(window,
!fullscreen);
}
}
return -1;
}