From: Tomas Mudrunka Date: Thu, 16 Jul 2020 14:07:42 +0000 (+0200) Subject: Keyboard shortcuts X-Git-Url: https://git.harvie.cz/?a=commitdiff_plain;h=cdfd4745d68315dcefbe2ab2f77bb3a1438dd3f3;p=mirrors%2FPrograms.git Keyboard shortcuts --- 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,