mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-26 03:30:46 +00:00
After parsing the cfg, fill in the default bindings for any control functions that are completely missing, with function unbound and key unused by anything else.
git-svn-id: https://svn.eduke32.com/eduke32@7212 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
ca1494262c
commit
073987fa42
3 changed files with 30 additions and 10 deletions
|
@ -116,24 +116,42 @@ const char *CONFIG_AnalogNumToName(int32_t func)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CONFIG_SetDefaultKeys(const char (*keyptr)[MAXGAMEFUNCLEN])
|
void CONFIG_SetDefaultKeys(const char (*keyptr)[MAXGAMEFUNCLEN], bool lazy/*=false*/)
|
||||||
|
{
|
||||||
|
if (!lazy)
|
||||||
{
|
{
|
||||||
Bmemset(ud.config.KeyboardKeys, 0xff, sizeof(ud.config.KeyboardKeys));
|
Bmemset(ud.config.KeyboardKeys, 0xff, sizeof(ud.config.KeyboardKeys));
|
||||||
|
|
||||||
CONTROL_ClearAllBinds();
|
CONTROL_ClearAllBinds();
|
||||||
|
}
|
||||||
|
|
||||||
for (size_t i=0; i < ARRAY_SIZE(gamefunctions); ++i)
|
for (int i=0; i < ARRAY_SSIZE(gamefunctions); ++i)
|
||||||
{
|
{
|
||||||
if (gamefunctions[i][0] == '\0')
|
if (gamefunctions[i][0] == '\0')
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
ud.config.KeyboardKeys[i][0] = KB_StringToScanCode(keyptr[i<<1]);
|
auto &key = ud.config.KeyboardKeys[i];
|
||||||
ud.config.KeyboardKeys[i][1] = KB_StringToScanCode(keyptr[(i<<1)+1]);
|
|
||||||
|
int const default0 = KB_StringToScanCode(keyptr[i<<1]);
|
||||||
|
int const default1 = KB_StringToScanCode(keyptr[(i<<1)+1]);
|
||||||
|
|
||||||
|
// skip the function if the default key is already used
|
||||||
|
// or the function is assigned to another key
|
||||||
|
if (lazy && (CONTROL_KeyIsBound(default0) || key[0] != 0xff))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
key[0] = default0;
|
||||||
|
key[1] = default1;
|
||||||
|
|
||||||
|
if (key[0])
|
||||||
|
CONTROL_FreeKeyBind(key[0]);
|
||||||
|
|
||||||
|
if (key[1])
|
||||||
|
CONTROL_FreeKeyBind(key[1]);
|
||||||
|
|
||||||
if (i == gamefunc_Show_Console)
|
if (i == gamefunc_Show_Console)
|
||||||
OSD_CaptureKey(ud.config.KeyboardKeys[i][0]);
|
OSD_CaptureKey(key[0]);
|
||||||
else
|
else
|
||||||
CONFIG_MapKey(i, ud.config.KeyboardKeys[i][0], 0, ud.config.KeyboardKeys[i][1], 0);
|
CONFIG_MapKey(i, key[0], 0, key[1], 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ void CONFIG_WriteSetup(uint32_t flags);
|
||||||
void CONFIG_SetDefaults(void);
|
void CONFIG_SetDefaults(void);
|
||||||
void CONFIG_SetupMouse(void);
|
void CONFIG_SetupMouse(void);
|
||||||
void CONFIG_SetupJoystick(void);
|
void CONFIG_SetupJoystick(void);
|
||||||
void CONFIG_SetDefaultKeys(const char (*keyptr)[MAXGAMEFUNCLEN]);
|
void CONFIG_SetDefaultKeys(const char (*keyptr)[MAXGAMEFUNCLEN], bool lazy=false);
|
||||||
|
|
||||||
int32_t CONFIG_GetMapBestTime(char const *mapname, uint8_t const *mapmd4);
|
int32_t CONFIG_GetMapBestTime(char const *mapname, uint8_t const *mapmd4);
|
||||||
int CONFIG_SetMapBestTime(uint8_t const *mapmd4, int32_t tm);
|
int CONFIG_SetMapBestTime(uint8_t const *mapmd4, int32_t tm);
|
||||||
|
|
|
@ -6519,6 +6519,8 @@ int app_main(int argc, char const * const * argv)
|
||||||
OSD_Exec(tempbuf);
|
OSD_Exec(tempbuf);
|
||||||
OSD_Exec("autoexec.cfg");
|
OSD_Exec("autoexec.cfg");
|
||||||
|
|
||||||
|
CONFIG_SetDefaultKeys(keydefaults, true);
|
||||||
|
|
||||||
system_getcvars();
|
system_getcvars();
|
||||||
|
|
||||||
if (g_networkMode != NET_DEDICATED_SERVER)
|
if (g_networkMode != NET_DEDICATED_SERVER)
|
||||||
|
|
Loading…
Reference in a new issue