# HG changeset patch # User alfadur # Date 1511960079 -3600 # Node ID e5c461729fe34c820632747067bb1230cbee88ad # Parent b63ec501490bf694d577f165b6a35740c244b2f1 Fix chat input key being sometimes registered twice diff -r b63ec501490b -r e5c461729fe3 hedgewars/SDLh.pas --- a/hedgewars/SDLh.pas Sat Nov 25 11:28:44 2017 -0500 +++ b/hedgewars/SDLh.pas Wed Nov 29 13:54:39 2017 +0100 @@ -1112,6 +1112,7 @@ function SDL_SetHint(name, value: PChar): Boolean; cdecl; external SDLLibName; procedure SDL_StartTextInput; cdecl; external SDLLibName; procedure SDL_StopTextInput; cdecl; external SDLLibName; +procedure SDL_FlushEvent(eventType: LongWord); cdecl; external SDLLibName; function SDL_PeepEvents(event: PSDL_Event; numevents: LongInt; action: TSDL_eventaction; minType, maxType: LongWord): LongInt; cdecl; external SDLLibName; diff -r b63ec501490b -r e5c461729fe3 hedgewars/uChat.pas --- a/hedgewars/uChat.pas Sat Nov 25 11:28:44 2017 -0500 +++ b/hedgewars/uChat.pas Wed Nov 29 13:54:39 2017 +0100 @@ -1098,11 +1098,18 @@ end; procedure chChat(var s: shortstring); +var i: Integer; begin s:= s; // avoid compiler hint GameState:= gsChat; SDL_StopTextInput(); SDL_StartTextInput(); + //Make REALLY sure unexpected events are flushed (1 time is insufficient as of SDL 2.0.7) + for i := 1 to 2 do + begin + SDL_PumpEvents(); + SDL_FlushEvent(SDL_TEXTINPUT); + end; //SDL_EnableKeyRepeat(200,45); if length(s) = 0 then SetLine(InputStr, '', true)