From 935f3ec50d1d557c3cba12d3f18c4df318dd1e56 Mon Sep 17 00:00:00 2001 From: helixhorned Date: Tue, 6 Nov 2012 23:06:40 +0000 Subject: [PATCH] When binding a key, take care of processing one-to-many binds properly in menu. This means that the "Keyboard Setup" should now properly reflect the bindings, except in the theoretical case of one gamefunc being bound more than two keys. (What was fixed is the one key to many gamefuncs case.) git-svn-id: https://svn.eduke32.com/eduke32@3126 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/source/osdcmds.c | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/polymer/eduke32/source/osdcmds.c b/polymer/eduke32/source/osdcmds.c index dfd82d443..65fc4c8fd 100644 --- a/polymer/eduke32/source/osdcmds.c +++ b/polymer/eduke32/source/osdcmds.c @@ -1012,16 +1012,32 @@ static int32_t osdcmd_bind(const osdfuncparm_t *parm) KeyBindings[ConsoleKeys[i].id].key=ConsoleKeys[i].name; - // populate the keyboard config menu based on the bind - if (!Bstrncasecmp(tempbuf, "gamefunc_", 9)) { - j = CONFIG_FunctionNameToNum(tempbuf+9); + char *cp = tempbuf; - if (j != -1) + // Populate the keyboard config menu based on the bind. + // Take care of processing one-to-many bindings properly, too. + while ((cp = Bstrstr(cp, "gamefunc_"))) { - ud.config.KeyboardKeys[j][1] = ud.config.KeyboardKeys[j][0]; - ud.config.KeyboardKeys[j][0] = ConsoleKeys[i].id; + char *semi; + + cp += 9; // skip the "gamefunc_" + + semi = Bstrchr(cp, ';'); + if (semi) + *semi = 0; + + j = CONFIG_FunctionNameToNum(cp); + + if (semi) + cp = semi+1; + + if (j != -1) + { + ud.config.KeyboardKeys[j][1] = ud.config.KeyboardKeys[j][0]; + ud.config.KeyboardKeys[j][0] = ConsoleKeys[i].id; // CONTROL_MapKey(j, ConsoleKeys[i].id, ud.config.KeyboardKeys[j][0]); + } } }