]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/hud/panel/quickmenu.qc
Merge branch 'terencehill/csqc_input_stuff' into 'master'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / hud / panel / quickmenu.qc
index f9568de1031ed9cdfee28172007353b9b5982e72..e9e7fe831e0e92e1f68078cc6774b50e9f6d89f6 100644 (file)
@@ -424,9 +424,6 @@ void QuickMenu_Page_ActiveEntry(int entry_num)
 bool QuickMenu_InputEvent(int bInputType, float nPrimary, float nSecondary)
 {
        TC(int, bInputType);
-       // we only care for keyboard events
-       if(bInputType == 2)
-               return false;
 
        if(!QuickMenu_IsOpened() || autocvar__hud_configure || mv_active)
                return false;
@@ -438,6 +435,12 @@ bool QuickMenu_InputEvent(int bInputType, float nPrimary, float nSecondary)
                return true;
        }
 
+       if(bInputType == 2)
+               return false;
+
+       // at this point bInputType can only be 0 or 1 (key pressed or released)
+       bool key_pressed = (bInputType == 0);
+
        // allow console bind to work
        string con_keys = findkeysforcommand("toggleconsole", 0);
        int keys = tokenize(con_keys); // findkeysforcommand returns data for this
@@ -449,12 +452,14 @@ bool QuickMenu_InputEvent(int bInputType, float nPrimary, float nSecondary)
                        hit_con_bind = true;
        }
 
-       if(bInputType == 0) {
+       if(key_pressed)
+       {
                if(nPrimary == K_ALT) hudShiftState |= S_ALT;
                if(nPrimary == K_CTRL) hudShiftState |= S_CTRL;
                if(nPrimary == K_SHIFT) hudShiftState |= S_SHIFT;
        }
-       else if(bInputType == 1) {
+       else
+       {
                if(nPrimary == K_ALT) hudShiftState -= (hudShiftState & S_ALT);
                if(nPrimary == K_CTRL) hudShiftState -= (hudShiftState & S_CTRL);
                if(nPrimary == K_SHIFT) hudShiftState -= (hudShiftState & S_SHIFT);
@@ -462,28 +467,28 @@ bool QuickMenu_InputEvent(int bInputType, float nPrimary, float nSecondary)
 
        if(nPrimary == K_ESCAPE)
        {
-               if (bInputType == 1)
+               if (!key_pressed)
                        return true;
                QuickMenu_Close();
        }
        else if(nPrimary >= '0' && nPrimary <= '9')
        {
-               if (bInputType == 1)
+               if (!key_pressed)
                        return true;
                QuickMenu_Page_ActiveEntry(stof(chr2str(nPrimary)));
        }
        if(nPrimary == K_MOUSE1)
        {
-               if(bInputType == 0) // key pressed
+               if(key_pressed)
                        mouseClicked |= S_MOUSE1;
-               else if(bInputType == 1) // key released
+               else
                        mouseClicked -= (mouseClicked & S_MOUSE1);
        }
        else if(nPrimary == K_MOUSE2)
        {
-               if(bInputType == 0) // key pressed
+               if(key_pressed)
                        mouseClicked |= S_MOUSE2;
-               else if(bInputType == 1) // key released
+               else
                        mouseClicked -= (mouseClicked & S_MOUSE2);
        }
        else if(hit_con_bind)