]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
On Windows ignore repeat events for keys that don't need key repetition while pressed... terencehill/ignore_repeat_key_events
authorterencehill <piuntn@gmail.com>
Sun, 22 Sep 2024 08:09:37 +0000 (10:09 +0200)
committerterencehill <piuntn@gmail.com>
Sun, 22 Sep 2024 12:05:32 +0000 (14:05 +0200)
vid_sdl.c

index ea6fe26e0f900d626b686ac226442fd69d7d4385..2a0069898252ac12a6716494984cd4eba3b36365 100644 (file)
--- a/vid_sdl.c
+++ b/vid_sdl.c
@@ -1061,6 +1061,27 @@ void Sys_SDL_HandleEvents(void)
                                host.state = host_shutdown;
                                break;
                        case SDL_KEYDOWN:
+#ifdef WIN32
+                               if (event.key.repeat)
+                               {
+                                       // ignore repeat events for keys that don't need key repetition while pressed down
+                                       bool ignore = false;
+                                       switch(event.key.keysym.sym)
+                                       {
+                                               case SDLK_LCTRL: case SDLK_LSHIFT: case SDLK_LALT:
+                                               case SDLK_RCTRL: case SDLK_RSHIFT: case SDLK_RALT:
+                                               case SDLK_ESCAPE:     case SDLK_PAUSE:
+                                               case SDLK_CAPSLOCK:   case SDLK_INSERT:
+                                               case SDLK_SCROLLLOCK: case SDLK_NUMLOCKCLEAR:
+#ifdef DEBUGSDLEVENTS
+                                                       Con_DPrintf("SDL_Event: SDL_KEYDOWN %i  IGNORED\n", event.key.keysym.sym);
+#endif
+                                                       ignore = true;
+                                       }
+                                       if (ignore) break;
+                               }
+                               // fallthrough
+#endif
                        case SDL_KEYUP:
 #ifdef DEBUGSDLEVENTS
                                if (event.type == SDL_KEYDOWN)