Minor fix in control key handling
authorAndreas Eversberg <jolly@eversberg.eu>
Sun, 25 Mar 2018 12:42:01 +0000 (14:42 +0200)
committerAndreas Eversberg <jolly@eversberg.eu>
Thu, 5 Apr 2018 16:00:13 +0000 (18:00 +0200)
src/mercenary/main.c

index d762ef4..553bae0 100644 (file)
@@ -505,63 +505,47 @@ static void keyboard_sdl(int down, SDL_Keycode sym)
                break;
        }
 
                break;
        }
 
-       if (ctrl) {
+       if (ctrl && down) {
                switch (sym) {
                case SDLK_v:
                switch (sym) {
                case SDLK_v:
-                       if (down) {
-                               config_video_filter ^= 1;
-                               print_info("video filter: %s\n", (config_video_filter) ? "on" : "off");
-                       }
+                       config_video_filter ^= 1;
+                       print_info("video filter: %s\n", (config_video_filter) ? "on" : "off");
                        break;
                case SDLK_a:
                        break;
                case SDLK_a:
-                       if (down) {
-                               config_audio_filter ^= 1;
-                               print_info("audio filter: %s\n", (config_audio_filter) ? "on" : "off");
-                       }
+                       config_audio_filter ^= 1;
+                       print_info("audio filter: %s\n", (config_audio_filter) ? "on" : "off");
                        break;
                case SDLK_s:
                        break;
                case SDLK_s:
-                       if (down) {
-                               config_amiga_speed ^= 1;
-                               print_info("amiga speed: %s\n", (config_amiga_speed) ? "original" : "full");
-                       }
+                       config_amiga_speed ^= 1;
+                       print_info("amiga speed: %s\n", (config_amiga_speed) ? "original" : "full");
                        break;
                case SDLK_r:
                        break;
                case SDLK_r:
-                       if (down) {
-                               config_render ^= 1;
-                               print_info("render: %s\n", (config_render) ? "opengl" : "original");
-                       }
+                       config_render ^= 1;
+                       print_info("render: %s\n", (config_render) ? "opengl" : "original");
                        break;
                case SDLK_b:
                        break;
                case SDLK_b:
-                       if (down) {
-                               if (config_benson_size == 0.5) {
-                                       config_benson_size = 1.0;
-                                       config_fov = FOV_NOVAGEN;
-                               } else {
-                                       config_benson_size = 0.5;
-                                       config_fov = FOV_JOLLY;
-                               }
-                               print_info("benson: %s\n", (config_benson_size == 0.5) ? "half" : "normal");
+                       if (config_benson_size == 0.5) {
+                               config_benson_size = 1.0;
+                               config_fov = FOV_NOVAGEN;
+                       } else {
+                               config_benson_size = 0.5;
+                               config_fov = FOV_JOLLY;
                        }
                        }
+                       print_info("benson: %s\n", (config_benson_size == 0.5) ? "half" : "normal");
                        break;
                case SDLK_c:
                        break;
                case SDLK_c:
-                       if (down) {
-                               if (config_ctrl_c)
-                                       quit = 1;
-                       }
+                       if (config_ctrl_c)
+                               quit = 1;
                        break;
                case SDLK_KP_PLUS:
                        break;
                case SDLK_KP_PLUS:
-                       if (down) {
-                               if (config_fov / 1.2 >= FOV_MIN)
-                                       config_fov /= 1.2;
-                               print_info("FOV: %.2f\n", config_fov);
-                       }
+                       if (config_fov / 1.2 >= FOV_MIN)
+                               config_fov /= 1.2;
+                       print_info("FOV: %.2f\n", config_fov);
                        break;
                case SDLK_KP_MINUS:
                        break;
                case SDLK_KP_MINUS:
-                       if (down) {
-                               if (config_fov * 1.2 <= FOV_MAX)
-                                       config_fov *= 1.2;
-                               print_info("FOV: %.2f\n", config_fov);
-                       }
+                       if (config_fov * 1.2 <= FOV_MAX)
+                               config_fov *= 1.2;
+                       print_info("FOV: %.2f\n", config_fov);
                        break;
                }
                /* do not pass keys to game while holding CTRL */
                        break;
                }
                /* do not pass keys to game while holding CTRL */