]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge branch 'terencehill/hud_no_joypad_keys' into 'master'
authorMario <zacjardine@y7mail.com>
Wed, 8 Jun 2016 08:33:39 +0000 (08:33 +0000)
committerMario <zacjardine@y7mail.com>
Wed, 8 Jun 2016 08:33:39 +0000 (08:33 +0000)
Don't show joypad keys in the HUD if no joypad has been detected

See merge request !320

qcsrc/client/main.qc

index 2baa971b90ca854e65d6ed5298da0b6af6c7f28e..39c30f7d528aefe7cfef76adf106a5dc8fb8990c 100644 (file)
@@ -1187,16 +1187,21 @@ string getcommandkey(string text, string command)
        keys = db_get(binddb, command);
        if (keys == "")
        {
+               bool joy_detected = cvar("joy_detected");
                n = tokenize(findkeysforcommand(command, 0)); // uses '...' strings
                for(j = 0; j < n; ++j)
                {
                        k = stof(argv(j));
                        if(k != -1)
                        {
-                               if ("" == keys)
-                                       keys = keynumtostring(k);
+                               string key = keynumtostring(k);
+                               if(!joy_detected && substring(key, 0, 3) == "JOY")
+                                       continue;
+
+                               if (keys == "")
+                                       keys = key;
                                else
-                                       keys = strcat(keys, ", ", keynumtostring(k));
+                                       keys = strcat(keys, ", ", key);
 
                                ++l;
                                if (autocvar_hud_showbinds_limit > 0 && autocvar_hud_showbinds_limit <= l)