Fix issue where controls intentionally bound to no keys would be reset to default at startup

git-svn-id: https://svn.eduke32.com/eduke32@7442 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2019-03-20 11:24:25 +00:00 committed by Christoph Oelckers
parent fb36b256de
commit 3b271fb7bb
3 changed files with 27 additions and 3 deletions

View File

@ -504,7 +504,7 @@ static int osdfunc_listsymbols(osdcmdptr_t parm)
int maxwidth = 0;
for (auto symb=osd->symbols; symb!=NULL; symb=symb->next)
if (symb->func != OSD_UNALIASED)
if (symb->func != OSD_UNALIASED && symb->help != NULL)
maxwidth = max<int>(maxwidth, Bstrlen(symb->name));
if (maxwidth > 0)
@ -523,7 +523,7 @@ static int osdfunc_listsymbols(osdcmdptr_t parm)
for (auto symb=osd->symbols; symb!=NULL; symb=symb->next)
{
if (symb->func == OSD_UNALIASED || (parm->numparms == 1 && Bstrncmp(parm->parms[0], symb->name, parmlen)))
if (symb->func == OSD_UNALIASED || symb->help == NULL || (parm->numparms == 1 && Bstrncmp(parm->parms[0], symb->name, parmlen)))
continue;
int const var = hash_find(&h_cvars, symb->name);
@ -2014,7 +2014,7 @@ static osdsymbol_t * osd_findsymbol(const char * const pszName, osdsymbol_t *pSy
for (; pSymbol; pSymbol=pSymbol->next)
{
if (pSymbol->func != OSD_UNALIASED && !Bstrncasecmp(pszName, pSymbol->name, nameLen))
if (pSymbol->func != OSD_UNALIASED && pSymbol->help != NULL && !Bstrncasecmp(pszName, pSymbol->name, nameLen))
return pSymbol;
}

View File

@ -703,6 +703,16 @@ void CONFIG_WriteSettings(void) // save binds and aliases to <cfgname>_settings.
}
}
for (int i=0; i<NUMGAMEFUNCTIONS; ++i)
{
if (ud.config.KeyboardKeys[i][0] == 0xff || !ud.config.KeyboardKeys[i][0])
{
buildvfs_fputstr(fp, "unbound ");
buildvfs_fputstrptr(fp, CONFIG_FunctionNumToName(i));
buildvfs_fputstr(fp, "\n");
}
}
OSD_WriteAliases(fp);
if (g_crosshairSum != -1 && g_crosshairSum != DefaultCrosshairColors.r+(DefaultCrosshairColors.g<<8)+(DefaultCrosshairColors.b<<16))

View File

@ -1090,6 +1090,19 @@ static int osdcmd_unbind(osdcmdptr_t parm)
return OSDCMD_SHOWHELP;
}
static int osdcmd_unbound(osdcmdptr_t parm)
{
if (parm->numparms != 1)
return OSDCMD_OK;
int const gameFunc = CONFIG_FunctionNameToNum(parm->parms[0]);
if (gameFunc != -1)
ud.config.KeyboardKeys[gameFunc][0] = 0;
return OSDCMD_OK;
}
static int osdcmd_quicksave(osdcmdptr_t UNUSED(parm))
{
UNREFERENCED_CONST_PARAMETER(parm);
@ -1781,6 +1794,7 @@ int32_t registerosdcommands(void)
OSD_RegisterFunction("unbind","unbind <key>: unbinds a key", osdcmd_unbind);
OSD_RegisterFunction("unbindall","unbindall: unbinds all keys", osdcmd_unbindall);
OSD_RegisterFunction("unbound", NULL, osdcmd_unbound);
OSD_RegisterFunction("vidmode","vidmode <xdim> <ydim> <bpp> <fullscreen>: change the video mode",osdcmd_vidmode);
#ifdef USE_OPENGL