From cdfd4745d68315dcefbe2ab2f77bb3a1438dd3f3 Mon Sep 17 00:00:00 2001 From: Tomas Mudrunka Date: Thu, 16 Jul 2020 16:07:42 +0200 Subject: [PATCH] Keyboard shortcuts --- c/SDL2_putpixel_click/main.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/c/SDL2_putpixel_click/main.c b/c/SDL2_putpixel_click/main.c index 8032752..a1955ed 100644 --- a/c/SDL2_putpixel_click/main.c +++ b/c/SDL2_putpixel_click/main.c @@ -29,6 +29,8 @@ int main(void) { int running = 1; int mouseX, mouseY; + Uint32 fullscreen_status = 0; + while(running) { event.type = 0; if(SDL_PollEvent(&event)) { @@ -39,6 +41,16 @@ int main(void) { case SDL_KEYDOWN: //case SDL_KEYUP: printf("Key: %d\t%d\t%d\n", event.key.keysym.scancode, event.key.keysym.sym, event.key.keysym.mod ); + + if(event.key.keysym.scancode == SDL_SCANCODE_F && event.key.keysym.mod == KMOD_LCTRL) { + fullscreen_status = fullscreen_status ? 0 : SDL_WINDOW_FULLSCREEN_DESKTOP; + SDL_SetWindowFullscreen(window, fullscreen_status); + } + + if(event.key.keysym.scancode == SDL_SCANCODE_Q && event.key.keysym.mod == KMOD_LCTRL) { + running = 0; + } + break; case SDL_MOUSEBUTTONDOWN: //do whatever you want to do after a mouse button was pressed, -- 2.30.2