From fcdab6a7778ef94f58e7007526ab84b93232d087 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Wed, 11 Mar 2009 00:17:31 +0000 Subject: [PATCH] - Added sdl_nokeyrepeat to disable key repeating in the menus and console on Linux. SVN r1470 (trunk) --- docs/rh-log.txt | 2 ++ src/sdl/i_input.cpp | 28 ++++++++++++++++++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/docs/rh-log.txt b/docs/rh-log.txt index 7340d557e0..bb64a33b8c 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,4 +1,6 @@ March 10, 2009 +- Added sdl_nokeyrepeat to disable key repeating in the menus and console + on Linux. - Added support for zip/pk3 files with LZMA and bzip2 compression to ZDoom. - Added more output to zipdir and a -q option to turn it off. - Added -u option to zipdir to only recompress those files in a zip that have diff --git a/src/sdl/i_input.cpp b/src/sdl/i_input.cpp index 249c71fcfb..572d381e6c 100644 --- a/src/sdl/i_input.cpp +++ b/src/sdl/i_input.cpp @@ -29,6 +29,7 @@ extern int paused; CVAR (Bool, use_mouse, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) CVAR (Bool, m_noprescale, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) CVAR (Bool, m_filter, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) +CVAR (Bool, sdl_nokeyrepeat, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) float JoyAxes[6]; //static int JoyActive; @@ -200,6 +201,10 @@ static void InitKeySymMap () static void I_CheckGUICapture () { bool wantCapt; + bool repeat; + int oldrepeat, interval; + + SDL_GetKeyRepeat(&oldrepeat, &interval); if (menuactive == MENU_Off) { @@ -217,15 +222,34 @@ static void I_CheckGUICapture () { FlushDIKState (); memset (DownState, 0, sizeof(DownState)); - SDL_EnableKeyRepeat (SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); + repeat = !sdl_nokeyrepeat; SDL_EnableUNICODE (1); } else { - SDL_EnableKeyRepeat (0, 0); + repeat = false; SDL_EnableUNICODE (0); } } + if (wantCapt) + { + repeat = !sdl_nokeyrepeat; + } + else + { + repeat = false; + } + if (repeat != (oldrepeat != 0)) + { + if (repeat) + { + SDL_EnableKeyRepeat (SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); + } + else + { + SDL_EnableKeyRepeat (0, 0); + } + } } static void CenterMouse ()