mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-24 10:40:46 +00:00
- fixed the compile errors and consolidated the key binding CCMDs.
This commit is contained in:
parent
e7f75cbf4d
commit
f8203ac766
18 changed files with 312 additions and 722 deletions
|
@ -786,6 +786,7 @@ set (PCH_SOURCES
|
|||
common/gameconfigfile.cpp
|
||||
common/gamecvars.cpp
|
||||
common/gamecontrol.cpp
|
||||
common/inputstate.cpp
|
||||
|
||||
common/2d/v_2ddrawer.cpp
|
||||
common/2d/v_draw.cpp
|
||||
|
|
|
@ -616,7 +616,6 @@ void CPlayerMsg::ProcessKeys(void)
|
|||
Set(*CombatMacros[key-sc_F1]);
|
||||
Send();
|
||||
inputState.ClearKeyStatus(key);
|
||||
}
|
||||
break;
|
||||
case sc_BackSpace:
|
||||
if (ctrl)
|
||||
|
|
|
@ -476,207 +476,6 @@ void onvideomodechange(int32_t newmode)
|
|||
UpdateDacs(gLastPal, false);
|
||||
}
|
||||
|
||||
const char *const ConsoleButtons[] =
|
||||
{
|
||||
"mouse1", "mouse2", "mouse3", "mouse4", "mwheelup",
|
||||
"mwheeldn", "mouse5", "mouse6", "mouse7", "mouse8"
|
||||
};
|
||||
|
||||
static int osdcmd_bind(osdcmdptr_t parm)
|
||||
{
|
||||
char buffer[256];
|
||||
if (parm->numparms==1 && !Bstrcasecmp(parm->parms[0],"showkeys"))
|
||||
{
|
||||
for (auto & s : sctokeylut)
|
||||
OSD_Printf("%s\n", s.key);
|
||||
for (auto ConsoleButton : ConsoleButtons)
|
||||
OSD_Printf("%s\n",ConsoleButton);
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
|
||||
if (parm->numparms==0)
|
||||
{
|
||||
int j=0;
|
||||
|
||||
OSD_Printf("Current key bindings:\n");
|
||||
|
||||
for (int i=0; i<MAXBOUNDKEYS+MAXMOUSEBUTTONS; i++)
|
||||
if (CONTROL_KeyIsBound(i))
|
||||
{
|
||||
j++;
|
||||
OSD_Printf("%-9s %s\"%s\"\n", CONTROL_KeyBinds[i].key, CONTROL_KeyBinds[i].repeat?"":"norepeat ",
|
||||
CONTROL_KeyBinds[i].cmdstr);
|
||||
}
|
||||
|
||||
if (j == 0)
|
||||
OSD_Printf("No binds found.\n");
|
||||
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
|
||||
int i, j, repeat;
|
||||
|
||||
for (i=0; i < ARRAY_SSIZE(sctokeylut); i++)
|
||||
{
|
||||
if (!Bstrcasecmp(parm->parms[0], sctokeylut[i].key))
|
||||
break;
|
||||
}
|
||||
|
||||
// didn't find the key
|
||||
if (i == ARRAY_SSIZE(sctokeylut))
|
||||
{
|
||||
for (i=0; i<MAXMOUSEBUTTONS; i++)
|
||||
if (!Bstrcasecmp(parm->parms[0],ConsoleButtons[i]))
|
||||
break;
|
||||
|
||||
if (i >= MAXMOUSEBUTTONS)
|
||||
return OSDCMD_SHOWHELP;
|
||||
|
||||
if (parm->numparms < 2)
|
||||
{
|
||||
if (CONTROL_KeyBinds[MAXBOUNDKEYS + i].cmdstr && CONTROL_KeyBinds[MAXBOUNDKEYS + i ].key)
|
||||
OSD_Printf("%-9s %s\"%s\"\n", ConsoleButtons[i], CONTROL_KeyBinds[MAXBOUNDKEYS + i].repeat?"":"norepeat ",
|
||||
CONTROL_KeyBinds[MAXBOUNDKEYS + i].cmdstr);
|
||||
else OSD_Printf("%s is unbound\n", ConsoleButtons[i]);
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
|
||||
j = 1;
|
||||
|
||||
repeat = 1;
|
||||
if (!Bstrcasecmp(parm->parms[j],"norepeat"))
|
||||
{
|
||||
repeat = 0;
|
||||
j++;
|
||||
}
|
||||
|
||||
Bstrcpy(buffer,parm->parms[j++]);
|
||||
for (; j<parm->numparms; j++)
|
||||
{
|
||||
Bstrcat(buffer," ");
|
||||
Bstrcat(buffer,parm->parms[j++]);
|
||||
}
|
||||
|
||||
CONTROL_BindMouse(i, buffer, repeat, ConsoleButtons[i]);
|
||||
|
||||
if (!OSD_ParsingScript())
|
||||
OSD_Printf("%s\n",parm->raw);
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
|
||||
if (parm->numparms < 2)
|
||||
{
|
||||
if (CONTROL_KeyIsBound(sctokeylut[i].sc))
|
||||
OSD_Printf("%-9s %s\"%s\"\n", sctokeylut[i].key, CONTROL_KeyBinds[sctokeylut[i].sc].repeat?"":"norepeat ",
|
||||
CONTROL_KeyBinds[sctokeylut[i].sc].cmdstr);
|
||||
else OSD_Printf("%s is unbound\n", sctokeylut[i].key);
|
||||
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
|
||||
j = 1;
|
||||
|
||||
repeat = 1;
|
||||
if (!Bstrcasecmp(parm->parms[j],"norepeat"))
|
||||
{
|
||||
repeat = 0;
|
||||
j++;
|
||||
}
|
||||
|
||||
Bstrcpy(buffer,parm->parms[j++]);
|
||||
for (; j<parm->numparms; j++)
|
||||
{
|
||||
Bstrcat(buffer," ");
|
||||
Bstrcat(buffer,parm->parms[j++]);
|
||||
}
|
||||
|
||||
CONTROL_BindKey(sctokeylut[i].sc, buffer, repeat, sctokeylut[i].key);
|
||||
|
||||
char *cp = buffer;
|
||||
|
||||
// Populate the keyboard config menu based on the bind.
|
||||
// Take care of processing one-to-many bindings properly, too.
|
||||
static char const s_gamefunc_[] = "gamefunc_";
|
||||
int constexpr strlen_gamefunc_ = ARRAY_SIZE(s_gamefunc_) - 1;
|
||||
|
||||
while ((cp = Bstrstr(cp, s_gamefunc_)))
|
||||
{
|
||||
cp += strlen_gamefunc_;
|
||||
|
||||
char *semi = Bstrchr(cp, ';');
|
||||
|
||||
if (semi)
|
||||
*semi = 0;
|
||||
|
||||
j = CONFIG_FunctionNameToNum(cp);
|
||||
|
||||
if (semi)
|
||||
cp = semi+1;
|
||||
|
||||
if (j != -1)
|
||||
{
|
||||
KeyboardKeys[j][1] = KeyboardKeys[j][0];
|
||||
KeyboardKeys[j][0] = sctokeylut[i].sc;
|
||||
// CONTROL_MapKey(j, sctokeylut[i].sc, KeyboardKeys[j][0]);
|
||||
|
||||
if (j == gamefunc_Show_Console)
|
||||
OSD_CaptureKey(sctokeylut[i].sc);
|
||||
}
|
||||
}
|
||||
|
||||
if (!OSD_ParsingScript())
|
||||
OSD_Printf("%s\n",parm->raw);
|
||||
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
|
||||
static int osdcmd_unbindall(osdcmdptr_t UNUSED(parm))
|
||||
{
|
||||
UNREFERENCED_CONST_PARAMETER(parm);
|
||||
|
||||
for (int i = 0; i < MAXBOUNDKEYS; ++i)
|
||||
CONTROL_FreeKeyBind(i);
|
||||
|
||||
for (int i = 0; i < MAXMOUSEBUTTONS; ++i)
|
||||
CONTROL_FreeMouseBind(i);
|
||||
|
||||
for (auto &KeyboardKey : KeyboardKeys)
|
||||
KeyboardKey[0] = KeyboardKey[1] = 0xff;
|
||||
|
||||
if (!OSD_ParsingScript())
|
||||
OSD_Printf("unbound all controls\n");
|
||||
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
|
||||
static int osdcmd_unbind(osdcmdptr_t parm)
|
||||
{
|
||||
if (parm->numparms != 1)
|
||||
return OSDCMD_SHOWHELP;
|
||||
|
||||
for (auto ConsoleKey : sctokeylut)
|
||||
{
|
||||
if (ConsoleKey.key && !Bstrcasecmp(parm->parms[0], ConsoleKey.key))
|
||||
{
|
||||
CONTROL_FreeKeyBind(ConsoleKey.sc);
|
||||
OSD_Printf("unbound key %s\n", ConsoleKey.key);
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < MAXMOUSEBUTTONS; i++)
|
||||
{
|
||||
if (!Bstrcasecmp(parm->parms[0], ConsoleButtons[i]))
|
||||
{
|
||||
CONTROL_FreeMouseBind(i);
|
||||
OSD_Printf("unbound %s\n", ConsoleButtons[i]);
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
}
|
||||
|
||||
return OSDCMD_SHOWHELP;
|
||||
}
|
||||
|
||||
static int osdcmd_unbound(osdcmdptr_t parm)
|
||||
{
|
||||
if (parm->numparms != 1)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
|
||||
#pragma once
|
||||
#define sc_None 0
|
||||
#define sc_Bad 0xff
|
||||
#define sc_Comma 0x33
|
||||
|
|
|
@ -433,7 +433,7 @@ void FGameConfigFile::ArchiveGameData (const char *gamename)
|
|||
strcpy(subsection, "Bindings");
|
||||
if (SetSection(section, true))
|
||||
{
|
||||
for (int i = 0; i < MAXBOUNDKEYS + MAXMOUSEBUTTONS; i++)
|
||||
for (int i = 0; i < NUMKEYS + MAXMOUSEBUTTONS; i++)
|
||||
{
|
||||
if (CONTROL_KeyIsBound(i))
|
||||
{
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include "gameconfigfile.h"
|
||||
#include "gamecvars.h"
|
||||
#include "build.h"
|
||||
#include "inputstate.h"
|
||||
|
||||
InputState inputState;
|
||||
|
||||
|
@ -1111,3 +1112,206 @@ void CONFIG_WriteControllerSettings()
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
const char* const ConsoleButtons[] =
|
||||
{
|
||||
"mouse1", "mouse2", "mouse3", "mouse4", "mwheelup",
|
||||
"mwheeldn", "mouse5", "mouse6", "mouse7", "mouse8"
|
||||
};
|
||||
|
||||
int osdcmd_bind(osdcmdptr_t parm)
|
||||
{
|
||||
char tempbuf[256];
|
||||
|
||||
if (parm->numparms == 1 && !Bstrcasecmp(parm->parms[0], "showkeys"))
|
||||
{
|
||||
for (auto& s : sctokeylut)
|
||||
OSD_Printf("%s\n", s.key);
|
||||
for (auto ConsoleButton : ConsoleButtons)
|
||||
OSD_Printf("%s\n", ConsoleButton);
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
|
||||
if (parm->numparms == 0)
|
||||
{
|
||||
int j = 0;
|
||||
|
||||
OSD_Printf("Current key bindings:\n");
|
||||
|
||||
for (int i = 0; i < NUMKEYS + MAXMOUSEBUTTONS; i++)
|
||||
if (CONTROL_KeyIsBound(i))
|
||||
{
|
||||
j++;
|
||||
OSD_Printf("%-9s %s\"%s\"\n", CONTROL_KeyBinds[i].key, CONTROL_KeyBinds[i].repeat ? "" : "norepeat ",
|
||||
CONTROL_KeyBinds[i].cmdstr);
|
||||
}
|
||||
|
||||
if (j == 0)
|
||||
OSD_Printf("No binds found.\n");
|
||||
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
|
||||
int i, j, repeat;
|
||||
|
||||
for (i = 0; i < ARRAY_SSIZE(sctokeylut); i++)
|
||||
{
|
||||
if (!Bstrcasecmp(parm->parms[0], sctokeylut[i].key))
|
||||
break;
|
||||
}
|
||||
|
||||
// didn't find the key
|
||||
if (i == ARRAY_SSIZE(sctokeylut))
|
||||
{
|
||||
for (i = 0; i < MAXMOUSEBUTTONS; i++)
|
||||
if (!Bstrcasecmp(parm->parms[0], ConsoleButtons[i]))
|
||||
break;
|
||||
|
||||
if (i >= MAXMOUSEBUTTONS)
|
||||
return OSDCMD_SHOWHELP;
|
||||
|
||||
if (parm->numparms < 2)
|
||||
{
|
||||
if (CONTROL_KeyBinds[NUMKEYS + i].cmdstr && CONTROL_KeyBinds[NUMKEYS + i].key)
|
||||
OSD_Printf("%-9s %s\"%s\"\n", ConsoleButtons[i], CONTROL_KeyBinds[NUMKEYS + i].repeat ? "" : "norepeat ",
|
||||
CONTROL_KeyBinds[NUMKEYS + i].cmdstr);
|
||||
else OSD_Printf("%s is unbound\n", ConsoleButtons[i]);
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
|
||||
j = 1;
|
||||
|
||||
repeat = 1;
|
||||
if (!Bstrcasecmp(parm->parms[j], "norepeat"))
|
||||
{
|
||||
repeat = 0;
|
||||
j++;
|
||||
}
|
||||
|
||||
Bstrcpy(tempbuf, parm->parms[j++]);
|
||||
for (; j < parm->numparms; j++)
|
||||
{
|
||||
Bstrcat(tempbuf, " ");
|
||||
Bstrcat(tempbuf, parm->parms[j++]);
|
||||
}
|
||||
|
||||
CONTROL_BindMouse(i, tempbuf, repeat, ConsoleButtons[i]);
|
||||
|
||||
if (!OSD_ParsingScript())
|
||||
OSD_Printf("%s\n", parm->raw);
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
|
||||
if (parm->numparms < 2)
|
||||
{
|
||||
if (CONTROL_KeyIsBound(sctokeylut[i].sc))
|
||||
OSD_Printf("%-9s %s\"%s\"\n", sctokeylut[i].key, CONTROL_KeyBinds[sctokeylut[i].sc].repeat ? "" : "norepeat ",
|
||||
CONTROL_KeyBinds[sctokeylut[i].sc].cmdstr);
|
||||
else OSD_Printf("%s is unbound\n", sctokeylut[i].key);
|
||||
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
|
||||
j = 1;
|
||||
|
||||
repeat = 1;
|
||||
if (!Bstrcasecmp(parm->parms[j], "norepeat"))
|
||||
{
|
||||
repeat = 0;
|
||||
j++;
|
||||
}
|
||||
|
||||
Bstrcpy(tempbuf, parm->parms[j++]);
|
||||
for (; j < parm->numparms; j++)
|
||||
{
|
||||
Bstrcat(tempbuf, " ");
|
||||
Bstrcat(tempbuf, parm->parms[j++]);
|
||||
}
|
||||
|
||||
CONTROL_BindKey(sctokeylut[i].sc, tempbuf, repeat, sctokeylut[i].key);
|
||||
|
||||
char* cp = tempbuf;
|
||||
|
||||
// Populate the keyboard config menu based on the bind.
|
||||
// Take care of processing one-to-many bindings properly, too.
|
||||
static char const s_gamefunc_[] = "gamefunc_";
|
||||
int constexpr strlen_gamefunc_ = ARRAY_SIZE(s_gamefunc_) - 1;
|
||||
|
||||
while ((cp = Bstrstr(cp, s_gamefunc_)))
|
||||
{
|
||||
cp += strlen_gamefunc_;
|
||||
|
||||
char* semi = Bstrchr(cp, ';');
|
||||
|
||||
if (semi)
|
||||
*semi = 0;
|
||||
|
||||
j = CONFIG_FunctionNameToNum(cp);
|
||||
|
||||
if (semi)
|
||||
cp = semi + 1;
|
||||
|
||||
if (j != -1)
|
||||
{
|
||||
KeyboardKeys[j][1] = KeyboardKeys[j][0];
|
||||
KeyboardKeys[j][0] = sctokeylut[i].sc;
|
||||
// CONTROL_MapKey(j, sctokeylut[i].sc, KeyboardKeys[j][0]);
|
||||
|
||||
if (j == gamefunc_Show_Console)
|
||||
OSD_CaptureKey(sctokeylut[i].sc);
|
||||
}
|
||||
}
|
||||
|
||||
if (!OSD_ParsingScript())
|
||||
OSD_Printf("%s\n", parm->raw);
|
||||
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
|
||||
int osdcmd_unbindall(osdcmdptr_t UNUSED(parm))
|
||||
{
|
||||
UNREFERENCED_CONST_PARAMETER(parm);
|
||||
|
||||
for (int i = 0; i < NUMKEYS; ++i)
|
||||
CONTROL_FreeKeyBind(i);
|
||||
|
||||
for (int i = 0; i < MAXMOUSEBUTTONS; ++i)
|
||||
CONTROL_FreeMouseBind(i);
|
||||
|
||||
for (auto& KeyboardKey : KeyboardKeys)
|
||||
KeyboardKey[0] = KeyboardKey[1] = 0xff;
|
||||
|
||||
if (!OSD_ParsingScript())
|
||||
OSD_Printf("unbound all controls\n");
|
||||
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
|
||||
int osdcmd_unbind(osdcmdptr_t parm)
|
||||
{
|
||||
if (parm->numparms != 1)
|
||||
return OSDCMD_SHOWHELP;
|
||||
|
||||
for (auto& ConsoleKey : sctokeylut)
|
||||
{
|
||||
if (ConsoleKey.key && !Bstrcasecmp(parm->parms[0], ConsoleKey.key))
|
||||
{
|
||||
CONTROL_FreeKeyBind(ConsoleKey.sc);
|
||||
OSD_Printf("unbound key %s\n", ConsoleKey.key);
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < MAXMOUSEBUTTONS; i++)
|
||||
{
|
||||
if (!Bstrcasecmp(parm->parms[0], ConsoleButtons[i]))
|
||||
{
|
||||
CONTROL_FreeMouseBind(i);
|
||||
OSD_Printf("unbound %s\n", ConsoleButtons[i]);
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
}
|
||||
|
||||
return OSDCMD_SHOWHELP;
|
||||
}
|
||||
|
||||
|
|
|
@ -61,6 +61,10 @@ void CONFIG_SetGameControllerDefaultsClear();
|
|||
char const* CONFIG_GetGameFuncOnJoystick(int gameFunc);
|
||||
char const* CONFIG_GetGameFuncOnKeyboard(int gameFunc);
|
||||
|
||||
int osdcmd_bind(osdcmdptr_t parm);
|
||||
int osdcmd_unbindall(osdcmdptr_t);
|
||||
int osdcmd_unbind(osdcmdptr_t parm);
|
||||
|
||||
|
||||
extern FStringCVar* const CombatMacros[];
|
||||
void CONFIG_ReadCombatMacros();
|
||||
|
|
|
@ -1,18 +1,33 @@
|
|||
#pragma once
|
||||
|
||||
#include "keyboard.h"
|
||||
#include "control.h"
|
||||
#include <stdint.h>
|
||||
#include "tarray.h"
|
||||
#include "scancodes.h"
|
||||
|
||||
typedef uint8_t kb_scancode;
|
||||
|
||||
extern kb_scancode KB_LastScan;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
const char* key;
|
||||
char* cmdstr;
|
||||
char repeat;
|
||||
char laststate;
|
||||
}
|
||||
consolekeybind_t;
|
||||
|
||||
// This encapsulates the entire game-readable input state which previously was spread out across several files.
|
||||
|
||||
enum
|
||||
{
|
||||
NUMKEYS = 256,
|
||||
MAXMOUSEBUTTONS = 10,
|
||||
|
||||
};
|
||||
|
||||
extern consolekeybind_t CONTROL_KeyBinds[NUMKEYS + MAXMOUSEBUTTONS];
|
||||
|
||||
|
||||
// Order is that of EDuke32 by necessity because it exposes the key binds to scripting by index instead of by name.
|
||||
enum GameFunction_t
|
||||
|
@ -164,7 +179,7 @@ public:
|
|||
return KeyStatus[key];
|
||||
}
|
||||
|
||||
void SetKeyStatus(int key, int state)
|
||||
void SetKeyStatus(int key, int state = 1)
|
||||
{
|
||||
KeyStatus[key] = (uint8_t)state;
|
||||
}
|
||||
|
@ -186,7 +201,7 @@ public:
|
|||
|
||||
bool CtrlPressed()
|
||||
{
|
||||
KeyStatus[sc_LeftControl] || KeyStatus[sc_RightControl];
|
||||
return KeyStatus[sc_LeftControl] || KeyStatus[sc_RightControl];
|
||||
}
|
||||
|
||||
bool ShiftPressed()
|
||||
|
|
|
@ -204,21 +204,6 @@ typedef struct {
|
|||
struct {
|
||||
int32_t AutoAim;
|
||||
int32_t ShowWeapons;
|
||||
|
||||
// JBF 20031211: Store the input settings because
|
||||
// (currently) mact can't regurgitate them
|
||||
int32_t MouseFunctions[MAXMOUSEBUTTONS][2];
|
||||
int32_t MouseDigitalFunctions[MAXMOUSEAXES][2];
|
||||
int32_t MouseAnalogueAxes[MAXMOUSEAXES];
|
||||
int32_t MouseAnalogueScale[MAXMOUSEAXES];
|
||||
int32_t JoystickFunctions[MAXJOYBUTTONSANDHATS][2];
|
||||
int32_t JoystickDigitalFunctions[MAXJOYAXES][2];
|
||||
int32_t JoystickAnalogueAxes[MAXJOYAXES];
|
||||
int32_t JoystickAnalogueScale[MAXJOYAXES];
|
||||
int32_t JoystickAnalogueInvert[MAXJOYAXES];
|
||||
int32_t JoystickAnalogueDead[MAXJOYAXES];
|
||||
int32_t JoystickAnalogueSaturate[MAXJOYAXES];
|
||||
|
||||
int32_t setupread;
|
||||
|
||||
} config;
|
||||
|
|
|
@ -857,206 +857,6 @@ void onvideomodechange(int32_t newmode)
|
|||
g_crosshairSum = -1;
|
||||
}
|
||||
|
||||
const char *const ConsoleButtons[] =
|
||||
{
|
||||
"mouse1", "mouse2", "mouse3", "mouse4", "mwheelup",
|
||||
"mwheeldn", "mouse5", "mouse6", "mouse7", "mouse8"
|
||||
};
|
||||
|
||||
static int osdcmd_bind(osdcmdptr_t parm)
|
||||
{
|
||||
if (parm->numparms==1 && !Bstrcasecmp(parm->parms[0],"showkeys"))
|
||||
{
|
||||
for (auto & s : sctokeylut)
|
||||
OSD_Printf("%s\n", s.key);
|
||||
for (auto ConsoleButton : ConsoleButtons)
|
||||
OSD_Printf("%s\n",ConsoleButton);
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
|
||||
if (parm->numparms==0)
|
||||
{
|
||||
int j=0;
|
||||
|
||||
OSD_Printf("Current key bindings:\n");
|
||||
|
||||
for (int i=0; i<MAXBOUNDKEYS+MAXMOUSEBUTTONS; i++)
|
||||
if (CONTROL_KeyIsBound(i))
|
||||
{
|
||||
j++;
|
||||
OSD_Printf("%-9s %s\"%s\"\n", CONTROL_KeyBinds[i].key, CONTROL_KeyBinds[i].repeat?"":"norepeat ",
|
||||
CONTROL_KeyBinds[i].cmdstr);
|
||||
}
|
||||
|
||||
if (j == 0)
|
||||
OSD_Printf("No binds found.\n");
|
||||
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
|
||||
int i, j, repeat;
|
||||
|
||||
for (i=0; i < ARRAY_SSIZE(sctokeylut); i++)
|
||||
{
|
||||
if (!Bstrcasecmp(parm->parms[0], sctokeylut[i].key))
|
||||
break;
|
||||
}
|
||||
|
||||
// didn't find the key
|
||||
if (i == ARRAY_SSIZE(sctokeylut))
|
||||
{
|
||||
for (i=0; i<MAXMOUSEBUTTONS; i++)
|
||||
if (!Bstrcasecmp(parm->parms[0],ConsoleButtons[i]))
|
||||
break;
|
||||
|
||||
if (i >= MAXMOUSEBUTTONS)
|
||||
return OSDCMD_SHOWHELP;
|
||||
|
||||
if (parm->numparms < 2)
|
||||
{
|
||||
if (CONTROL_KeyBinds[MAXBOUNDKEYS + i].cmdstr && CONTROL_KeyBinds[MAXBOUNDKEYS + i ].key)
|
||||
OSD_Printf("%-9s %s\"%s\"\n", ConsoleButtons[i], CONTROL_KeyBinds[MAXBOUNDKEYS + i].repeat?"":"norepeat ",
|
||||
CONTROL_KeyBinds[MAXBOUNDKEYS + i].cmdstr);
|
||||
else OSD_Printf("%s is unbound\n", ConsoleButtons[i]);
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
|
||||
j = 1;
|
||||
|
||||
repeat = 1;
|
||||
if (!Bstrcasecmp(parm->parms[j],"norepeat"))
|
||||
{
|
||||
repeat = 0;
|
||||
j++;
|
||||
}
|
||||
|
||||
Bstrcpy(tempbuf,parm->parms[j++]);
|
||||
for (; j<parm->numparms; j++)
|
||||
{
|
||||
Bstrcat(tempbuf," ");
|
||||
Bstrcat(tempbuf,parm->parms[j++]);
|
||||
}
|
||||
|
||||
CONTROL_BindMouse(i, tempbuf, repeat, ConsoleButtons[i]);
|
||||
|
||||
if (!OSD_ParsingScript())
|
||||
OSD_Printf("%s\n",parm->raw);
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
|
||||
if (parm->numparms < 2)
|
||||
{
|
||||
if (CONTROL_KeyIsBound(sctokeylut[i].sc))
|
||||
OSD_Printf("%-9s %s\"%s\"\n", sctokeylut[i].key, CONTROL_KeyBinds[sctokeylut[i].sc].repeat?"":"norepeat ",
|
||||
CONTROL_KeyBinds[sctokeylut[i].sc].cmdstr);
|
||||
else OSD_Printf("%s is unbound\n", sctokeylut[i].key);
|
||||
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
|
||||
j = 1;
|
||||
|
||||
repeat = 1;
|
||||
if (!Bstrcasecmp(parm->parms[j],"norepeat"))
|
||||
{
|
||||
repeat = 0;
|
||||
j++;
|
||||
}
|
||||
|
||||
Bstrcpy(tempbuf,parm->parms[j++]);
|
||||
for (; j<parm->numparms; j++)
|
||||
{
|
||||
Bstrcat(tempbuf," ");
|
||||
Bstrcat(tempbuf,parm->parms[j++]);
|
||||
}
|
||||
|
||||
CONTROL_BindKey(sctokeylut[i].sc, tempbuf, repeat, sctokeylut[i].key);
|
||||
|
||||
char *cp = tempbuf;
|
||||
|
||||
// Populate the keyboard config menu based on the bind.
|
||||
// Take care of processing one-to-many bindings properly, too.
|
||||
static char const s_gamefunc_[] = "gamefunc_";
|
||||
int constexpr strlen_gamefunc_ = ARRAY_SIZE(s_gamefunc_) - 1;
|
||||
|
||||
while ((cp = Bstrstr(cp, s_gamefunc_)))
|
||||
{
|
||||
cp += strlen_gamefunc_;
|
||||
|
||||
char *semi = Bstrchr(cp, ';');
|
||||
|
||||
if (semi)
|
||||
*semi = 0;
|
||||
|
||||
j = CONFIG_FunctionNameToNum(cp);
|
||||
|
||||
if (semi)
|
||||
cp = semi+1;
|
||||
|
||||
if (j != -1)
|
||||
{
|
||||
KeyboardKeys[j][1] = KeyboardKeys[j][0];
|
||||
KeyboardKeys[j][0] = sctokeylut[i].sc;
|
||||
// CONTROL_MapKey(j, sctokeylut[i].sc, KeyboardKeys[j][0]);
|
||||
|
||||
if (j == gamefunc_Show_Console)
|
||||
OSD_CaptureKey(sctokeylut[i].sc);
|
||||
}
|
||||
}
|
||||
|
||||
if (!OSD_ParsingScript())
|
||||
OSD_Printf("%s\n",parm->raw);
|
||||
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
|
||||
static int osdcmd_unbindall(osdcmdptr_t UNUSED(parm))
|
||||
{
|
||||
UNREFERENCED_CONST_PARAMETER(parm);
|
||||
|
||||
for (int i = 0; i < MAXBOUNDKEYS; ++i)
|
||||
CONTROL_FreeKeyBind(i);
|
||||
|
||||
for (int i = 0; i < MAXMOUSEBUTTONS; ++i)
|
||||
CONTROL_FreeMouseBind(i);
|
||||
|
||||
for (auto &KeyboardKey : KeyboardKeys)
|
||||
KeyboardKey[0] = KeyboardKey[1] = 0xff;
|
||||
|
||||
if (!OSD_ParsingScript())
|
||||
OSD_Printf("unbound all controls\n");
|
||||
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
|
||||
static int osdcmd_unbind(osdcmdptr_t parm)
|
||||
{
|
||||
if (parm->numparms != 1)
|
||||
return OSDCMD_SHOWHELP;
|
||||
|
||||
for (auto & ConsoleKey : sctokeylut)
|
||||
{
|
||||
if (ConsoleKey.key && !Bstrcasecmp(parm->parms[0], ConsoleKey.key))
|
||||
{
|
||||
CONTROL_FreeKeyBind(ConsoleKey.sc);
|
||||
OSD_Printf("unbound key %s\n", ConsoleKey.key);
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < MAXMOUSEBUTTONS; i++)
|
||||
{
|
||||
if (!Bstrcasecmp(parm->parms[0], ConsoleButtons[i]))
|
||||
{
|
||||
CONTROL_FreeMouseBind(i);
|
||||
OSD_Printf("unbound %s\n", ConsoleButtons[i]);
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
}
|
||||
|
||||
return OSDCMD_SHOWHELP;
|
||||
}
|
||||
|
||||
static int osdcmd_unbound(osdcmdptr_t parm)
|
||||
{
|
||||
if (parm->numparms != 1)
|
||||
|
|
|
@ -207,20 +207,8 @@ void CONTROL_ClearGameControllerDigitalAxisNeg(int32_t axis);
|
|||
|
||||
////////// KEY/MOUSE BIND STUFF //////////
|
||||
|
||||
#define MAXBOUNDKEYS MAXKEYBOARDSCAN
|
||||
#define MAXMOUSEBUTTONS 10
|
||||
|
||||
typedef struct
|
||||
{
|
||||
const char *key;
|
||||
char *cmdstr;
|
||||
char repeat;
|
||||
char laststate;
|
||||
}
|
||||
consolekeybind_t;
|
||||
|
||||
// Direct use DEPRECATED:
|
||||
extern consolekeybind_t CONTROL_KeyBinds[MAXBOUNDKEYS+MAXMOUSEBUTTONS];
|
||||
extern bool CONTROL_BindsEnabled;
|
||||
|
||||
void CONTROL_ClearAllBinds(void);
|
||||
|
|
|
@ -33,8 +33,6 @@ Modifications for JonoF's port by Jonathon Fowler (jf@jonof.id.au)
|
|||
#include "baselayer.h" // for the keyboard stuff
|
||||
#include "scancodes.h"
|
||||
|
||||
typedef uint8_t kb_scancode;
|
||||
|
||||
// translation table for taking key names to scancodes and back again
|
||||
static struct
|
||||
{
|
||||
|
@ -58,8 +56,6 @@ static struct
|
|||
{ "Down", 0xd0 }, { "PgDn", 0xd1 }, { "Insert", 0xd2 }, { "Delete", 0xd3 },
|
||||
};
|
||||
|
||||
#define MAXKEYBOARDSCAN 256
|
||||
|
||||
extern kb_scancode KB_LastScan;
|
||||
|
||||
#define KB_GetLastScanCode() (KB_LastScan)
|
||||
|
|
|
@ -62,7 +62,7 @@ static int32_t(*ExtGetTime)(void);
|
|||
static uint8_t CONTROL_DoubleClickSpeed;
|
||||
|
||||
int32_t CONTROL_ButtonFlags[CONTROL_NUM_FLAGS];
|
||||
consolekeybind_t CONTROL_KeyBinds[MAXBOUNDKEYS + MAXMOUSEBUTTONS];
|
||||
consolekeybind_t CONTROL_KeyBinds[NUMKEYS + MAXMOUSEBUTTONS];
|
||||
bool CONTROL_BindsEnabled = 0;
|
||||
bool CONTROL_SmoothMouse = 0;
|
||||
|
||||
|
@ -71,7 +71,7 @@ bool CONTROL_SmoothMouse = 0;
|
|||
|
||||
void CONTROL_ClearAllBinds(void)
|
||||
{
|
||||
for (int i=0; i<MAXBOUNDKEYS; i++)
|
||||
for (int i=0; i<NUMKEYS; i++)
|
||||
CONTROL_FreeKeyBind(i);
|
||||
for (int i=0; i<MAXMOUSEBUTTONS; i++)
|
||||
CONTROL_FreeMouseBind(i);
|
||||
|
@ -84,7 +84,7 @@ void CONTROL_BindKey(int i, char const * const cmd, int repeat, char const * con
|
|||
|
||||
void CONTROL_BindMouse(int i, char const * const cmd, int repeat, char const * const keyname)
|
||||
{
|
||||
BIND(CONTROL_KeyBinds[MAXBOUNDKEYS + i], Xstrdup(cmd), repeat, keyname);
|
||||
BIND(CONTROL_KeyBinds[NUMKEYS + i], Xstrdup(cmd), repeat, keyname);
|
||||
}
|
||||
|
||||
void CONTROL_FreeKeyBind(int i)
|
||||
|
@ -94,7 +94,7 @@ void CONTROL_FreeKeyBind(int i)
|
|||
|
||||
void CONTROL_FreeMouseBind(int i)
|
||||
{
|
||||
BIND(CONTROL_KeyBinds[MAXBOUNDKEYS + i], NULL, 0, NULL);
|
||||
BIND(CONTROL_KeyBinds[NUMKEYS + i], NULL, 0, NULL);
|
||||
}
|
||||
|
||||
static void CONTROL_GetMouseDelta(ControlInfo * info)
|
||||
|
@ -643,7 +643,7 @@ static void CONTROL_ButtonFunctionState(int32_t *p1)
|
|||
|
||||
do
|
||||
{
|
||||
if (!CONTROL_KeyBinds[MAXBOUNDKEYS + i].cmdstr)
|
||||
if (!CONTROL_KeyBinds[NUMKEYS + i].cmdstr)
|
||||
{
|
||||
j = CONTROL_MouseButtonMapping[i].doubleclicked;
|
||||
if (j != KEYUNDEFINED)
|
||||
|
@ -657,12 +657,12 @@ static void CONTROL_ButtonFunctionState(int32_t *p1)
|
|||
if (!CONTROL_BindsEnabled)
|
||||
continue;
|
||||
|
||||
if (CONTROL_KeyBinds[MAXBOUNDKEYS + i].cmdstr && CONTROL_MouseButtonState[i])
|
||||
if (CONTROL_KeyBinds[NUMKEYS + i].cmdstr && CONTROL_MouseButtonState[i])
|
||||
{
|
||||
if (CONTROL_KeyBinds[MAXBOUNDKEYS + i].repeat || (CONTROL_KeyBinds[MAXBOUNDKEYS + i].laststate == 0))
|
||||
OSD_Dispatch(CONTROL_KeyBinds[MAXBOUNDKEYS + i].cmdstr);
|
||||
if (CONTROL_KeyBinds[NUMKEYS + i].repeat || (CONTROL_KeyBinds[NUMKEYS + i].laststate == 0))
|
||||
OSD_Dispatch(CONTROL_KeyBinds[NUMKEYS + i].cmdstr);
|
||||
}
|
||||
CONTROL_KeyBinds[MAXBOUNDKEYS + i].laststate = CONTROL_MouseButtonState[i];
|
||||
CONTROL_KeyBinds[NUMKEYS + i].laststate = CONTROL_MouseButtonState[i];
|
||||
}
|
||||
while (i--);
|
||||
}
|
||||
|
@ -752,7 +752,7 @@ void CONTROL_ProcessBinds(void)
|
|||
if (!CONTROL_BindsEnabled)
|
||||
return;
|
||||
|
||||
int i = MAXBOUNDKEYS-1;
|
||||
int i = NUMKEYS-1;
|
||||
|
||||
do
|
||||
{
|
||||
|
|
|
@ -713,206 +713,6 @@ void onvideomodechange(int32_t newmode)
|
|||
}
|
||||
|
||||
|
||||
const char *const ConsoleButtons[] =
|
||||
{
|
||||
"mouse1", "mouse2", "mouse3", "mouse4", "mwheelup",
|
||||
"mwheeldn", "mouse5", "mouse6", "mouse7", "mouse8"
|
||||
};
|
||||
|
||||
static int osdcmd_bind(osdcmdptr_t parm)
|
||||
{
|
||||
if (parm->numparms==1 && !Bstrcasecmp(parm->parms[0],"showkeys"))
|
||||
{
|
||||
for (int i=0; sctokeylut[i].key; i++)
|
||||
OSD_Printf("%s\n",sctokeylut[i].key);
|
||||
for (auto ConsoleButton : ConsoleButtons)
|
||||
OSD_Printf("%s\n",ConsoleButton);
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
|
||||
if (parm->numparms==0)
|
||||
{
|
||||
int j=0;
|
||||
|
||||
OSD_Printf("Current key bindings:\n");
|
||||
|
||||
for (int i=0; i<MAXBOUNDKEYS+MAXMOUSEBUTTONS; i++)
|
||||
if (CONTROL_KeyIsBound(i))
|
||||
{
|
||||
j++;
|
||||
OSD_Printf("%-9s %s\"%s\"\n", CONTROL_KeyBinds[i].key, CONTROL_KeyBinds[i].repeat?"":"norepeat ",
|
||||
CONTROL_KeyBinds[i].cmdstr);
|
||||
}
|
||||
|
||||
if (j == 0)
|
||||
OSD_Printf("No binds found.\n");
|
||||
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
|
||||
int i, j, repeat;
|
||||
|
||||
for (i=0; i < ARRAY_SSIZE(sctokeylut); i++)
|
||||
{
|
||||
if (!Bstrcasecmp(parm->parms[0], sctokeylut[i].key))
|
||||
break;
|
||||
}
|
||||
|
||||
// didn't find the key
|
||||
if (i == ARRAY_SSIZE(sctokeylut))
|
||||
{
|
||||
for (i=0; i<MAXMOUSEBUTTONS; i++)
|
||||
if (!Bstrcasecmp(parm->parms[0],ConsoleButtons[i]))
|
||||
break;
|
||||
|
||||
if (i >= MAXMOUSEBUTTONS)
|
||||
return OSDCMD_SHOWHELP;
|
||||
|
||||
if (parm->numparms < 2)
|
||||
{
|
||||
if (CONTROL_KeyBinds[MAXBOUNDKEYS + i].cmdstr && CONTROL_KeyBinds[MAXBOUNDKEYS + i ].key)
|
||||
OSD_Printf("%-9s %s\"%s\"\n", ConsoleButtons[i], CONTROL_KeyBinds[MAXBOUNDKEYS + i].repeat?"":"norepeat ",
|
||||
CONTROL_KeyBinds[MAXBOUNDKEYS + i].cmdstr);
|
||||
else OSD_Printf("%s is unbound\n", ConsoleButtons[i]);
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
|
||||
j = 1;
|
||||
|
||||
repeat = 1;
|
||||
if (!Bstrcasecmp(parm->parms[j],"norepeat"))
|
||||
{
|
||||
repeat = 0;
|
||||
j++;
|
||||
}
|
||||
|
||||
Bstrcpy(tempbuf,parm->parms[j++]);
|
||||
for (; j<parm->numparms; j++)
|
||||
{
|
||||
Bstrcat(tempbuf," ");
|
||||
Bstrcat(tempbuf,parm->parms[j++]);
|
||||
}
|
||||
|
||||
CONTROL_BindMouse(i, tempbuf, repeat, ConsoleButtons[i]);
|
||||
|
||||
if (!OSD_ParsingScript())
|
||||
OSD_Printf("%s\n",parm->raw);
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
|
||||
if (parm->numparms < 2)
|
||||
{
|
||||
if (CONTROL_KeyIsBound(sctokeylut[i].sc))
|
||||
OSD_Printf("%-9s %s\"%s\"\n", sctokeylut[i].key, CONTROL_KeyBinds[sctokeylut[i].sc].repeat?"":"norepeat ",
|
||||
CONTROL_KeyBinds[sctokeylut[i].sc].cmdstr);
|
||||
else OSD_Printf("%s is unbound\n", sctokeylut[i].key);
|
||||
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
|
||||
j = 1;
|
||||
|
||||
repeat = 1;
|
||||
if (!Bstrcasecmp(parm->parms[j],"norepeat"))
|
||||
{
|
||||
repeat = 0;
|
||||
j++;
|
||||
}
|
||||
|
||||
Bstrcpy(tempbuf,parm->parms[j++]);
|
||||
for (; j<parm->numparms; j++)
|
||||
{
|
||||
Bstrcat(tempbuf," ");
|
||||
Bstrcat(tempbuf,parm->parms[j++]);
|
||||
}
|
||||
|
||||
CONTROL_BindKey(sctokeylut[i].sc, tempbuf, repeat, sctokeylut[i].key);
|
||||
|
||||
char *cp = tempbuf;
|
||||
|
||||
// Populate the keyboard config menu based on the bind.
|
||||
// Take care of processing one-to-many bindings properly, too.
|
||||
static char const s_gamefunc_[] = "gamefunc_";
|
||||
int constexpr strlen_gamefunc_ = ARRAY_SIZE(s_gamefunc_) - 1;
|
||||
|
||||
while ((cp = Bstrstr(cp, s_gamefunc_)))
|
||||
{
|
||||
cp += strlen_gamefunc_;
|
||||
|
||||
char *semi = Bstrchr(cp, ';');
|
||||
|
||||
if (semi)
|
||||
*semi = 0;
|
||||
|
||||
j = CONFIG_FunctionNameToNum(cp);
|
||||
|
||||
if (semi)
|
||||
cp = semi+1;
|
||||
|
||||
if (j != -1)
|
||||
{
|
||||
KeyboardKeys[j][1] = KeyboardKeys[j][0];
|
||||
KeyboardKeys[j][0] = sctokeylut[i].sc;
|
||||
// CONTROL_MapKey(j, sctokeylut[i].sc, KeyboardKeys[j][0]);
|
||||
|
||||
if (j == gamefunc_Show_Console)
|
||||
OSD_CaptureKey(sctokeylut[i].sc);
|
||||
}
|
||||
}
|
||||
|
||||
if (!OSD_ParsingScript())
|
||||
OSD_Printf("%s\n",parm->raw);
|
||||
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
|
||||
static int osdcmd_unbindall(osdcmdptr_t UNUSED(parm))
|
||||
{
|
||||
UNREFERENCED_CONST_PARAMETER(parm);
|
||||
|
||||
for (int i = 0; i < MAXBOUNDKEYS; ++i)
|
||||
CONTROL_FreeKeyBind(i);
|
||||
|
||||
for (int i = 0; i < MAXMOUSEBUTTONS; ++i)
|
||||
CONTROL_FreeMouseBind(i);
|
||||
|
||||
for (auto &KeyboardKey : KeyboardKeys)
|
||||
KeyboardKey[0] = KeyboardKey[1] = 0xff;
|
||||
|
||||
if (!OSD_ParsingScript())
|
||||
OSD_Printf("unbound all controls\n");
|
||||
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
|
||||
static int osdcmd_unbind(osdcmdptr_t parm)
|
||||
{
|
||||
if (parm->numparms != 1)
|
||||
return OSDCMD_SHOWHELP;
|
||||
|
||||
for (auto ConsoleKey : sctokeylut)
|
||||
{
|
||||
if (ConsoleKey.key && !Bstrcasecmp(parm->parms[0], ConsoleKey.key))
|
||||
{
|
||||
CONTROL_FreeKeyBind(ConsoleKey.sc);
|
||||
OSD_Printf("unbound key %s\n", ConsoleKey.key);
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < MAXMOUSEBUTTONS; i++)
|
||||
{
|
||||
if (!Bstrcasecmp(parm->parms[0], ConsoleButtons[i]))
|
||||
{
|
||||
CONTROL_FreeMouseBind(i);
|
||||
OSD_Printf("unbound %s\n", ConsoleButtons[i]);
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
}
|
||||
|
||||
return OSDCMD_SHOWHELP;
|
||||
}
|
||||
|
||||
static int osdcmd_quicksave(osdcmdptr_t UNUSED(parm))
|
||||
{
|
||||
UNREFERENCED_CONST_PARAMETER(parm);
|
||||
|
|
|
@ -1058,7 +1058,7 @@ ResizeView(PLAYERp pp)
|
|||
{
|
||||
extern SWBOOL ScrollMode2D;
|
||||
|
||||
KEY_PRESSED(KEYSC_ESC) = 0;
|
||||
inputState.ClearKeyStatus(sc_Escape);
|
||||
dimensionmode = 3;
|
||||
ScrollMode2D = FALSE;
|
||||
SetRedrawScreen(pp);
|
||||
|
@ -1676,7 +1676,7 @@ void ScreenCaptureKeys(void)
|
|||
// screen capture
|
||||
if (KEY_PRESSED(KEYSC_F12))
|
||||
{
|
||||
KEY_PRESSED(KEYSC_F12) = 0;
|
||||
inputState.ClearKeyStatus(KEYSC_F12);
|
||||
PauseAction();
|
||||
videoCaptureScreenTGA("swcpxxxx.tga", KEY_PRESSED(KEYSC_LSHIFT) | KEY_PRESSED(KEYSC_RSHIFT));
|
||||
ResumeAction();
|
||||
|
|
|
@ -1560,7 +1560,7 @@ NewLevel(void)
|
|||
if (DemoModeMenuInit)
|
||||
{
|
||||
DemoModeMenuInit = FALSE;
|
||||
KEY_PRESSED(KEYSC_ESC) = TRUE;
|
||||
inputState.ClearKeyStatus(sc_Escape);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1620,10 +1620,7 @@ ResetKeys(void)
|
|||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < MAXKEYBOARDSCAN; i++)
|
||||
{
|
||||
KEY_PRESSED(i) = 0;
|
||||
}
|
||||
inputState.ClearAllKeyStatus();
|
||||
}
|
||||
|
||||
SWBOOL
|
||||
|
@ -1631,7 +1628,7 @@ KeyPressed(void)
|
|||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < MAXKEYBOARDSCAN; i++)
|
||||
for (i = 0; i < NUMKEYS; i++)
|
||||
{
|
||||
if (KEY_PRESSED(i))
|
||||
return TRUE;
|
||||
|
@ -2152,7 +2149,7 @@ MenuLevel(void)
|
|||
// go to ordering menu only if shareware
|
||||
if (FinishAnim)
|
||||
{
|
||||
KEY_PRESSED(KEYSC_ESC) = 1;
|
||||
inputState.ClearKeyStatus(sc_Escape);
|
||||
ControlPanelType = ct_ordermenu;
|
||||
FinishAnim = 0;
|
||||
}
|
||||
|
@ -2214,7 +2211,7 @@ MenuLevel(void)
|
|||
// force the use of menus at all time
|
||||
if (!UsingMenus && !ConPanel)
|
||||
{
|
||||
KEY_PRESSED(KEYSC_ESC) = TRUE;
|
||||
inputState.SetKeyStatus(sc_Escape);
|
||||
MNU_CheckForMenusAnyKey();
|
||||
}
|
||||
|
||||
|
@ -2232,7 +2229,7 @@ MenuLevel(void)
|
|||
|
||||
BorderAdjust = TRUE;
|
||||
//LoadGameOutsideMoveLoop = FALSE;
|
||||
KEY_PRESSED(KEYSC_ESC) = FALSE;
|
||||
inputState.ClearKeyStatus(sc_Escape);
|
||||
KB_ClearKeysDown();
|
||||
//ExitMenus();
|
||||
UsingMenus = FALSE;
|
||||
|
@ -2793,8 +2790,8 @@ StatScreen(PLAYERp mpp)
|
|||
while (KeyPressed()) ;
|
||||
}
|
||||
|
||||
KEY_PRESSED(KEYSC_SPACE) = 0;
|
||||
KEY_PRESSED(KEYSC_ENTER) = 0;
|
||||
inputState.ClearKeyStatus(KEYSC_SPACE);
|
||||
inputState.ClearKeyStatus(KEYSC_ENTER);
|
||||
|
||||
if (mus_enabled)
|
||||
{
|
||||
|
@ -4398,7 +4395,7 @@ FunctionKeys(PLAYERp pp)
|
|||
{
|
||||
if (rts_delay > 16 && fn_key && CommEnabled && !adult_lockout && !Global_PLock)
|
||||
{
|
||||
KEY_PRESSED(sc_F1 + fn_key - 1) = 0;
|
||||
inputState.ClearKeyStatus(sc_F1 + fn_key - 1);
|
||||
|
||||
rts_delay = 0;
|
||||
|
||||
|
@ -4423,7 +4420,8 @@ FunctionKeys(PLAYERp pp)
|
|||
{
|
||||
if (fn_key && CommEnabled)
|
||||
{
|
||||
KEY_PRESSED(sc_F1 + fn_key - 1) = 0;
|
||||
inputState.ClearKeyStatus(sc_Escape);
|
||||
inputState.ClearKeyStatus(sc_F1 + fn_key - 1);
|
||||
|
||||
if (CommEnabled)
|
||||
{
|
||||
|
@ -4452,10 +4450,10 @@ FunctionKeys(PLAYERp pp)
|
|||
// F2 save menu
|
||||
if (KEY_PRESSED(KEYSC_F2))
|
||||
{
|
||||
KEY_PRESSED(KEYSC_F2) = 0;
|
||||
inputState.ClearKeyStatus(KEYSC_F2);
|
||||
if (!TEST(pp->Flags, PF_DEAD))
|
||||
{
|
||||
KEY_PRESSED(KEYSC_ESC) = 1;
|
||||
inputState.SetKeyStatus(sc_Escape);
|
||||
ControlPanelType = ct_savemenu;
|
||||
}
|
||||
}
|
||||
|
@ -4463,10 +4461,10 @@ FunctionKeys(PLAYERp pp)
|
|||
// F3 load menu
|
||||
if (KEY_PRESSED(KEYSC_F3))
|
||||
{
|
||||
KEY_PRESSED(KEYSC_F3) = 0;
|
||||
inputState.ClearKeyStatus(KEYSC_F3);
|
||||
if (!TEST(pp->Flags, PF_DEAD))
|
||||
{
|
||||
KEY_PRESSED(KEYSC_ESC) = 1;
|
||||
inputState.SetKeyStatus(sc_Escape);
|
||||
ControlPanelType = ct_loadmenu;
|
||||
}
|
||||
}
|
||||
|
@ -4475,10 +4473,10 @@ FunctionKeys(PLAYERp pp)
|
|||
if (KEY_PRESSED(KEYSC_F6))
|
||||
{
|
||||
extern SWBOOL QuickSaveMode;
|
||||
KEY_PRESSED(KEYSC_F6) = 0;
|
||||
inputState.ClearKeyStatus(KEYSC_F6);
|
||||
if (!TEST(pp->Flags, PF_DEAD))
|
||||
{
|
||||
KEY_PRESSED(KEYSC_ESC) = 1;
|
||||
inputState.SetKeyStatus(sc_Escape);
|
||||
ControlPanelType = ct_savemenu;
|
||||
QuickSaveMode = TRUE;
|
||||
}
|
||||
|
@ -4487,7 +4485,7 @@ FunctionKeys(PLAYERp pp)
|
|||
// F9 quick load
|
||||
if (KEY_PRESSED(KEYSC_F9))
|
||||
{
|
||||
KEY_PRESSED(KEYSC_F9) = 0;
|
||||
inputState.ClearKeyStatus(KEYSC_F9);
|
||||
|
||||
if (!TEST(pp->Flags, PF_DEAD))
|
||||
{
|
||||
|
@ -4498,7 +4496,7 @@ FunctionKeys(PLAYERp pp)
|
|||
else
|
||||
{
|
||||
KB_ClearKeysDown();
|
||||
KEY_PRESSED(KEYSC_ESC) = 1;
|
||||
inputState.SetKeyStatus(sc_Escape);
|
||||
ControlPanelType = ct_quickloadmenu;
|
||||
}
|
||||
}
|
||||
|
@ -4510,8 +4508,8 @@ FunctionKeys(PLAYERp pp)
|
|||
// F4 sound menu
|
||||
if (KEY_PRESSED(KEYSC_F4))
|
||||
{
|
||||
KEY_PRESSED(KEYSC_F4) = 0;
|
||||
KEY_PRESSED(KEYSC_ESC) = 1;
|
||||
inputState.ClearKeyStatus(KEYSC_F4);
|
||||
inputState.SetKeyStatus(sc_Escape);
|
||||
ControlPanelType = ct_soundmenu;
|
||||
}
|
||||
|
||||
|
@ -4519,7 +4517,7 @@ FunctionKeys(PLAYERp pp)
|
|||
// F7 VIEW control
|
||||
if (KEY_PRESSED(KEYSC_F7))
|
||||
{
|
||||
KEY_PRESSED(KEYSC_F7) = 0;
|
||||
inputState.ClearKeyStatus(KEYSC_F7);
|
||||
|
||||
if (KEY_PRESSED(KEYSC_LSHIFT) || KEY_PRESSED(KEYSC_RSHIFT))
|
||||
{
|
||||
|
@ -4543,7 +4541,7 @@ FunctionKeys(PLAYERp pp)
|
|||
// F8 toggle messages
|
||||
if (KEY_PRESSED(KEYSC_F8))
|
||||
{
|
||||
KEY_PRESSED(KEYSC_F8) = 0;
|
||||
inputState.ClearKeyStatus(KEYSC_F8);
|
||||
|
||||
hud_messages = !hud_messages;
|
||||
|
||||
|
@ -4556,15 +4554,15 @@ FunctionKeys(PLAYERp pp)
|
|||
// F10 quit menu
|
||||
if (KEY_PRESSED(KEYSC_F10))
|
||||
{
|
||||
KEY_PRESSED(KEYSC_F10) = 0;
|
||||
KEY_PRESSED(KEYSC_ESC) = 1;
|
||||
inputState.ClearKeyStatus(KEYSC_F10);
|
||||
inputState.SetKeyStatus(sc_Escape);
|
||||
ControlPanelType = ct_quitmenu;
|
||||
}
|
||||
|
||||
// F11 gamma correction
|
||||
if (KEY_PRESSED(KEYSC_F11) > 0)
|
||||
{
|
||||
KEY_PRESSED(KEYSC_F11) = 0;
|
||||
inputState.ClearKeyStatus(KEYSC_F11);
|
||||
// Do this entirely in the video backend.
|
||||
}
|
||||
|
||||
|
@ -4578,7 +4576,7 @@ void PauseKey(PLAYERp pp)
|
|||
|
||||
if (KEY_PRESSED(sc_Pause) && !CommEnabled && !InputMode && !UsingMenus && !CheatInputMode && !ConPanel)
|
||||
{
|
||||
KEY_PRESSED(sc_Pause) = 0;
|
||||
inputState.ClearKeyStatus(sc_Pause);
|
||||
|
||||
PauseKeySet ^= 1;
|
||||
|
||||
|
@ -4612,7 +4610,7 @@ void PauseKey(PLAYERp pp)
|
|||
}
|
||||
else
|
||||
{
|
||||
KEY_PRESSED(KEYSC_ESC) = 1;
|
||||
inputState.SetKeyStatus(sc_Escape);
|
||||
ControlPanelType = ct_quickloadmenu;
|
||||
}
|
||||
}
|
||||
|
@ -4844,7 +4842,7 @@ void GetHelpInput(PLAYERp pp)
|
|||
{
|
||||
if (KEY_PRESSED(KEYSC_F1))
|
||||
{
|
||||
KEY_PRESSED(KEYSC_F1) = FALSE;
|
||||
inputState.ClearKeyStatus(KEYSC_F11);
|
||||
HelpPage = 0;
|
||||
HelpInputMode = TRUE;
|
||||
PanelUpdateMode = FALSE;
|
||||
|
@ -4857,7 +4855,7 @@ void GetHelpInput(PLAYERp pp)
|
|||
{
|
||||
if (KEY_PRESSED(KEYSC_ESC))
|
||||
{
|
||||
KEY_PRESSED(KEYSC_ESC) = 0;
|
||||
inputState.ClearKeyStatus(sc_Escape);
|
||||
KB_ClearKeysDown();
|
||||
PanelUpdateMode = TRUE;
|
||||
HelpInputMode = FALSE;
|
||||
|
@ -4869,13 +4867,14 @@ void GetHelpInput(PLAYERp pp)
|
|||
|
||||
if (KEY_PRESSED(KEYSC_SPACE) || KEY_PRESSED(KEYSC_ENTER) || KEY_PRESSED(KEYSC_PGDN) || KEY_PRESSED(KEYSC_DOWN) || KEY_PRESSED(KEYSC_RIGHT) || KEY_PRESSED(sc_kpad_3) || KEY_PRESSED(sc_kpad_2) || KEY_PRESSED(sc_kpad_6))
|
||||
{
|
||||
KEY_PRESSED(KEYSC_SPACE) = KEY_PRESSED(KEYSC_ENTER) = 0;
|
||||
KEY_PRESSED(KEYSC_PGDN) = 0;
|
||||
KEY_PRESSED(KEYSC_DOWN) = 0;
|
||||
KEY_PRESSED(KEYSC_RIGHT) = 0;
|
||||
KEY_PRESSED(sc_kpad_3) = 0;
|
||||
KEY_PRESSED(sc_kpad_2) = 0;
|
||||
KEY_PRESSED(sc_kpad_6) = 0;
|
||||
inputState.ClearKeyStatus(KEYSC_SPACE);
|
||||
inputState.ClearKeyStatus(KEYSC_ENTER);
|
||||
inputState.ClearKeyStatus(KEYSC_PGDN);
|
||||
inputState.ClearKeyStatus(KEYSC_DOWN);
|
||||
inputState.ClearKeyStatus(KEYSC_RIGHT);
|
||||
inputState.ClearKeyStatus(sc_kpad_3);
|
||||
inputState.ClearKeyStatus(sc_kpad_2);
|
||||
inputState.ClearKeyStatus(sc_kpad_6);
|
||||
|
||||
HelpPage++;
|
||||
if (HelpPage >= (int)SIZ(HelpPagePic))
|
||||
|
@ -4888,12 +4887,12 @@ void GetHelpInput(PLAYERp pp)
|
|||
|
||||
if (KEY_PRESSED(KEYSC_PGUP) || KEY_PRESSED(KEYSC_UP) || KEY_PRESSED(KEYSC_LEFT) || KEY_PRESSED(sc_kpad_9) || KEY_PRESSED(sc_kpad_8) || KEY_PRESSED(sc_kpad_4))
|
||||
{
|
||||
KEY_PRESSED(KEYSC_PGUP) = 0;
|
||||
KEY_PRESSED(KEYSC_UP) = 0;
|
||||
KEY_PRESSED(KEYSC_LEFT) = 0;
|
||||
KEY_PRESSED(sc_kpad_8) = 0;
|
||||
KEY_PRESSED(sc_kpad_9) = 0;
|
||||
KEY_PRESSED(sc_kpad_4) = 0;
|
||||
inputState.ClearKeyStatus(KEYSC_PGUP);
|
||||
inputState.ClearKeyStatus(KEYSC_UP);
|
||||
inputState.ClearKeyStatus(KEYSC_LEFT);
|
||||
inputState.ClearKeyStatus(sc_kpad_8);
|
||||
inputState.ClearKeyStatus(sc_kpad_9);
|
||||
inputState.ClearKeyStatus(sc_kpad_4);
|
||||
|
||||
HelpPage--;
|
||||
if (HelpPage < 0)
|
||||
|
@ -5167,7 +5166,7 @@ getinput(SW_PACKET *loc)
|
|||
else if (KEY_PRESSED(sc_Pause))
|
||||
{
|
||||
SET_LOC_KEY(loc->bits, SK_PAUSE, KEY_PRESSED(sc_Pause));
|
||||
KEY_PRESSED(sc_Pause) = 0;
|
||||
inputState.ClearKeyStatus(sc_Pause);
|
||||
}
|
||||
|
||||
SET_LOC_KEY(loc->bits, SK_CENTER_VIEW, BUTTON(gamefunc_Center_View));
|
||||
|
|
|
@ -728,7 +728,7 @@ SWBOOL MNU_KeySetupCustom(UserCall call, MenuItem *item)
|
|||
|
||||
if (KEY_PRESSED(KEYSC_ESC) || inpt.button1)
|
||||
{
|
||||
KEY_PRESSED(KEYSC_ESC) = FALSE;
|
||||
inputState.ClearKeyStatus(sc_Escape);
|
||||
cust_callback = NULL;
|
||||
CONTROL_ClearUserInput(&inpt);
|
||||
return TRUE;
|
||||
|
@ -1576,8 +1576,8 @@ MNU_OrderCustom(UserCall call, MenuItem *item)
|
|||
// Support a few other keys too
|
||||
if (KEY_PRESSED(KEYSC_SPACE)||KEY_PRESSED(KEYSC_ENTER))
|
||||
{
|
||||
KEY_PRESSED(KEYSC_SPACE) = FALSE;
|
||||
KEY_PRESSED(KEYSC_ENTER) = FALSE;
|
||||
inputState.ClearKeyStatus(KEYSC_SPACE);
|
||||
inputState.ClearKeyStatus(KEYSC_ENTER);
|
||||
tst_input.dir = dir_South;
|
||||
}
|
||||
}
|
||||
|
@ -1622,7 +1622,7 @@ MNU_OrderCustom(UserCall call, MenuItem *item)
|
|||
}
|
||||
else
|
||||
{
|
||||
KEY_PRESSED(KEYSC_ESC) = FALSE;
|
||||
inputState.ClearKeyStatus(sc_Escape);
|
||||
cust_callback = NULL;
|
||||
DidOrderSound = FALSE;
|
||||
on_screen = 0;
|
||||
|
@ -4395,7 +4395,7 @@ SetupMenu(void)
|
|||
MNU_SetupMenu();
|
||||
|
||||
// Clear the previous ESC key press
|
||||
KEY_PRESSED(KEYSC_ESC) = FALSE;
|
||||
inputState.ClearKeyStatus(sc_Escape);
|
||||
UsingMenus = TRUE;
|
||||
}
|
||||
}
|
||||
|
@ -4565,7 +4565,7 @@ MNU_CheckForMenus(void)
|
|||
{
|
||||
if ((KEY_PRESSED(KEYSC_ESC)) && dimensionmode == 3 && !ConPanel)
|
||||
{
|
||||
KEY_PRESSED(KEYSC_ESC) = 0;
|
||||
inputState.ClearKeyStatus(sc_Escape);
|
||||
KB_ClearKeysDown();
|
||||
// setup sliders/buttons
|
||||
MNU_InitMenus();
|
||||
|
|
|
@ -4118,7 +4118,7 @@ SWBOOL PlayerFlyKey(PLAYERp pp)
|
|||
key = KEY_PRESSED(KEYSC_J);
|
||||
|
||||
if (key)
|
||||
KEY_PRESSED(KEYSC_J) = 0;
|
||||
inputState.ClearKeyStatus(KEYSC_J);
|
||||
|
||||
return key;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue