Keyboard shortcuts
authorTomas Mudrunka <tomas@mudrunka.cz>
Thu, 16 Jul 2020 14:07:42 +0000 (16:07 +0200)
committerTomas Mudrunka <tomas@mudrunka.cz>
Thu, 16 Jul 2020 14:07:42 +0000 (16:07 +0200)
c/SDL2_putpixel_click/main.c

index 8032752b1a90e8ea21871982cf8b4e3000fca75b..a1955edca17e074934f2dcc1e7c8c96621eb4d29 100644 (file)
@@ -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,
This page took 0.258093 seconds and 4 git commands to generate.