mirror of
https://github.com/DrBeef/Raze.git
synced 2024-11-15 00:41:55 +00:00
CON: Add getgamefuncbind
git-svn-id: https://svn.eduke32.com/eduke32@7993 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
cfd05db689
commit
9c3ec69c86
5 changed files with 94 additions and 0 deletions
|
@ -1129,6 +1129,41 @@ void CONFIG_WriteSetup(uint32_t flags)
|
|||
Bfflush(NULL);
|
||||
}
|
||||
|
||||
char const * CONFIG_GetGameFuncOnKeyboard(int gameFunc)
|
||||
{
|
||||
return KB_ScanCodeToString(ud.config.KeyboardKeys[gameFunc][0]);
|
||||
}
|
||||
|
||||
char const * CONFIG_GetGameFuncOnMouse(int gameFunc)
|
||||
{
|
||||
for (int j = 0; j < 2; ++j)
|
||||
for (int i = 0; i < joystick.numButtons; ++i)
|
||||
if (ud.config.JoystickFunctions[i][j] == gameFunc)
|
||||
return joyGetName(1, i);
|
||||
|
||||
for (int i = 0; i < joystick.numAxes; ++i)
|
||||
for (int j = 0; j < 2; ++j)
|
||||
if (ud.config.JoystickDigitalFunctions[i][j] == gameFunc)
|
||||
return joyGetName(0, i);
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
char const * CONFIG_GetGameFuncOnJoystick(int gameFunc)
|
||||
{
|
||||
for (int j = 0; j < 2; ++j)
|
||||
for (int i = 0; i < joystick.numButtons; ++i)
|
||||
if (ud.config.JoystickFunctions[i][j] == gameFunc)
|
||||
return joyGetName(1, i);
|
||||
|
||||
for (int i = 0; i < joystick.numAxes; ++i)
|
||||
for (int j = 0; j < 2; ++j)
|
||||
if (ud.config.JoystickDigitalFunctions[i][j] == gameFunc)
|
||||
return joyGetName(0, i);
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
static const char *CONFIG_GetMapEntryName(char m[], char const * const mapname)
|
||||
{
|
||||
strcpy(m, mapname);
|
||||
|
|
|
@ -45,4 +45,7 @@ int32_t CONFIG_AnalogNameToNum(const char *func);
|
|||
|
||||
void CONFIG_MapKey(int which, kb_scancode key1, kb_scancode oldkey1, kb_scancode key2, kb_scancode oldkey2);
|
||||
|
||||
const char * CONFIG_GetGameFuncOnKeyboard(int gameFunc);
|
||||
const char * CONFIG_GetGameFuncOnJoystick(int gameFunc);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -259,6 +259,7 @@ static tokenmap_t const vm_keywords[] =
|
|||
{ "getclosestcol", CON_GETCLOSESTCOL },
|
||||
{ "getcurraddress", CON_GETCURRADDRESS },
|
||||
{ "getflorzofslope", CON_GETFLORZOFSLOPE },
|
||||
{ "getgamefuncbind", CON_GETGAMEFUNCBIND },
|
||||
{ "getincangle", CON_GETINCANGLE },
|
||||
{ "getinput", CON_GETINPUT },
|
||||
{ "getkeyname", CON_GETKEYNAME },
|
||||
|
@ -3673,6 +3674,7 @@ DO_DEFSTATE:
|
|||
case CON_STOPACTORSOUND:
|
||||
case CON_SWAPTRACKSLOT:
|
||||
case CON_ZSHOOT:
|
||||
case CON_GETGAMEFUNCBIND:
|
||||
C_GetManyVars(2);
|
||||
continue;
|
||||
|
||||
|
|
|
@ -1125,6 +1125,7 @@ enum IterationTypes_t
|
|||
TRANSFORM(CON_GETCLOSESTCOL) DELIMITER \
|
||||
TRANSFORM(CON_GETCURRADDRESS) DELIMITER \
|
||||
TRANSFORM(CON_GETFLORZOFSLOPE) DELIMITER \
|
||||
TRANSFORM(CON_GETGAMEFUNCBIND) DELIMITER \
|
||||
TRANSFORM(CON_GETINCANGLE) DELIMITER \
|
||||
TRANSFORM(CON_GETINPUT) DELIMITER \
|
||||
TRANSFORM(CON_GETKEYNAME) DELIMITER \
|
||||
|
|
|
@ -3670,6 +3670,59 @@ badindex:
|
|||
dispatch();
|
||||
}
|
||||
|
||||
vInstruction(CON_GETGAMEFUNCBIND):
|
||||
insptr++;
|
||||
{
|
||||
int const quoteIndex = Gv_GetVar(*insptr++);
|
||||
int const gameFunc = Gv_GetVar(*insptr++);
|
||||
|
||||
VM_ASSERT((unsigned)quoteIndex < MAXQUOTES && apStrings[quoteIndex], "invalid quote %d\n", quoteIndex);
|
||||
VM_ASSERT((unsigned)gameFunc < NUMGAMEFUNCTIONS, "invalid function %d\n", gameFunc);
|
||||
|
||||
static char const s_KeyboardFormat[] = "[%s]";
|
||||
static char const s_JoystickFormat[] = "(%s)";
|
||||
static char const s_Unbound[] = "UNBOUND";
|
||||
|
||||
if (CONTROL_LastSeenInput == LastSeenInput::Joystick)
|
||||
{
|
||||
char const * joyname = CONFIG_GetGameFuncOnJoystick(gameFunc);
|
||||
if (joyname != nullptr && joyname[0] != '\0')
|
||||
{
|
||||
snprintf(apStrings[quoteIndex], MAXQUOTELEN, s_JoystickFormat, joyname);
|
||||
dispatch();
|
||||
}
|
||||
|
||||
char const * keyname = CONFIG_GetGameFuncOnKeyboard(gameFunc);
|
||||
if (keyname != nullptr && keyname[0] != '\0')
|
||||
{
|
||||
snprintf(apStrings[quoteIndex], MAXQUOTELEN, s_KeyboardFormat, keyname);
|
||||
dispatch();
|
||||
}
|
||||
|
||||
snprintf(apStrings[quoteIndex], MAXQUOTELEN, s_JoystickFormat, s_Unbound);
|
||||
}
|
||||
else
|
||||
{
|
||||
char const * keyname = CONFIG_GetGameFuncOnKeyboard(gameFunc);
|
||||
if (keyname != nullptr && keyname[0] != '\0')
|
||||
{
|
||||
snprintf(apStrings[quoteIndex], MAXQUOTELEN, s_KeyboardFormat, keyname);
|
||||
dispatch();
|
||||
}
|
||||
|
||||
char const * joyname = CONFIG_GetGameFuncOnJoystick(gameFunc);
|
||||
if (joyname != nullptr && joyname[0] != '\0')
|
||||
{
|
||||
snprintf(apStrings[quoteIndex], MAXQUOTELEN, s_JoystickFormat, joyname);
|
||||
dispatch();
|
||||
}
|
||||
|
||||
snprintf(apStrings[quoteIndex], MAXQUOTELEN, s_KeyboardFormat, s_Unbound);
|
||||
}
|
||||
|
||||
dispatch();
|
||||
}
|
||||
|
||||
vInstruction(CON_QSUBSTR):
|
||||
insptr++;
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue