From 4f08d1293d9a8d5814ec24b45be088d04247f5c8 Mon Sep 17 00:00:00 2001
From: fgsfds <pvt.fgsfds@gmail.com>
Date: Wed, 1 May 2019 20:21:21 +0300
Subject: [PATCH] worked around some bugs related to binds and input focus

---
 src/game/g_console.pas | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/game/g_console.pas b/src/game/g_console.pas
index 9a2bd99..6757bfc 100644
--- a/src/game/g_console.pas
+++ b/src/game/g_console.pas
@@ -1727,11 +1727,17 @@ end;
 procedure g_Console_ProcessBind (key: Integer; down: Boolean);
   var i: Integer;
 begin
-  if (not g_GUIGrabInput) and (not gChatShow) and (key >= 0) and (key < e_MaxInputKeys) and ((gInputBinds[key].down <> nil) or (gInputBinds[key].up <> nil)) then
+  if (key >= 0) and (key < e_MaxInputKeys) and ((gInputBinds[key].down <> nil) or (gInputBinds[key].up <> nil)) then
   begin
+    // down binds shouldn't be processed when there's no input focus
+    // however when the user releases a button the bind should still be processed
+    // to avoid "sticky" buttons
     if down then
-      for i := 0 to High(gInputBinds[key].down) do
-        g_Console_Process(gInputBinds[key].down[i], True)
+    begin
+      if (not g_GUIGrabInput) and (not gChatShow) and (not gConsoleShow) then
+        for i := 0 to High(gInputBinds[key].down) do
+          g_Console_Process(gInputBinds[key].down[i], True);
+    end
     else
       for i := 0 to High(gInputBinds[key].up) do
         g_Console_Process(gInputBinds[key].up[i], True)
-- 
2.29.2