mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-24 10:40:46 +00:00
- it compiles again (safety commit)
This commit is contained in:
parent
73e64ff0b2
commit
eb049abc3a
22 changed files with 198 additions and 662 deletions
|
@ -38,6 +38,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
#include "levels.h"
|
||||
#include "map2d.h"
|
||||
#include "view.h"
|
||||
#include "d_event.h"
|
||||
|
||||
BEGIN_BLD_NS
|
||||
|
||||
|
@ -118,7 +119,7 @@ void ctrlGetInput(void)
|
|||
return;
|
||||
}
|
||||
|
||||
CONTROL_ProcessBinds();
|
||||
D_ProcessEvents();
|
||||
|
||||
if (in_aimmode)
|
||||
g_MyAimMode = 0;
|
||||
|
|
|
@ -1214,21 +1214,8 @@ bool CGameMenuItemKeyList::Event(CGameMenuEvent &event)
|
|||
{
|
||||
if (KB_KeyWaiting())
|
||||
KB_GetCh();
|
||||
char key1, key2;
|
||||
extern uint8_t KeyboardKeys[NUMGAMEFUNCTIONS][2];
|
||||
key1 = KeyboardKeys[nFocus][0];
|
||||
key2 = KeyboardKeys[nFocus][1];
|
||||
if (key1 > 0 && key2 != KB_LastScan)
|
||||
key2 = key1;
|
||||
key1 = KB_LastScan;
|
||||
if (key1 == key2)
|
||||
key2 = 0;
|
||||
uint8_t oldKey[2];
|
||||
oldKey[0] = KeyboardKeys[nFocus][0];
|
||||
oldKey[1] = KeyboardKeys[nFocus][1];
|
||||
KeyboardKeys[nFocus][0] = key1;
|
||||
KeyboardKeys[nFocus][1] = key2;
|
||||
CONFIG_MapKey(nFocus, key1, oldKey[0], key2, oldKey[1]);
|
||||
|
||||
Bindings.SetBind(KB_LastScan, CONFIG_FunctionNumToName(nFocus));
|
||||
KB_FlushKeyboardQueue();
|
||||
KB_FlushKeyboardQueueScans();
|
||||
KB_ClearKeysDown();
|
||||
|
@ -1267,12 +1254,7 @@ bool CGameMenuItemKeyList::Event(CGameMenuEvent &event)
|
|||
return false;
|
||||
case kMenuEventBackSpace:
|
||||
case kMenuEventDelete:
|
||||
uint8_t oldKey[2];
|
||||
oldKey[0] = KeyboardKeys[nFocus][0];
|
||||
oldKey[1] = KeyboardKeys[nFocus][1];
|
||||
KeyboardKeys[nFocus][0] = 0;
|
||||
KeyboardKeys[nFocus][1] = 0;
|
||||
CONFIG_MapKey(nFocus, 0, oldKey[0], 0, oldKey[1]);
|
||||
Bindings.UnbindACommand(CONFIG_FunctionNumToName(nFocus));
|
||||
return false;
|
||||
case kMenuEventScrollUp:
|
||||
if (nFocus-nTopDelta > 0)
|
||||
|
|
|
@ -1982,17 +1982,6 @@ void PreDrawControlMouse(CGameMenuItem *pItem)
|
|||
|
||||
void SetMouseButton(CGameMenuItemZCycle *pItem)
|
||||
{
|
||||
for (int i = 0; i < MENUMOUSEFUNCTIONS; i++)
|
||||
{
|
||||
if (pItem == pItemOptionsControlMouseButton[i])
|
||||
{
|
||||
int nFunc = nGamefuncsValues[pItem->m_nFocus];
|
||||
MouseFunctions[MenuMouseDataIndex[i][0]][MenuMouseDataIndex[i][1]] = nFunc;
|
||||
CONTROL_MapButton(nFunc, MenuMouseDataIndex[i][0], MenuMouseDataIndex[i][1], controldevice_mouse);
|
||||
CONTROL_FreeMouseBind(MenuMouseDataIndex[i][0]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SetupMouseButtonMenu(CGameMenuItemChain *pItem)
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
#include "control.h"
|
||||
#include "gamecontrol.h"
|
||||
#include "m_crc32.h"
|
||||
#include "c_commandline.h"
|
||||
#include "c_bind.h"
|
||||
|
||||
#include "vfs.h"
|
||||
|
||||
|
@ -1869,178 +1871,17 @@ static osdsymbol_t * osd_findexactsymbol(const char *pszName)
|
|||
return (symbolNum >= 0) ? osd->symbptrs[symbolNum] : NULL;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
FCommandLine args(parm->raw);
|
||||
Bindings.PerformBind(args, "Bind");
|
||||
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
|
||||
int osdcmd_unbindall(osdcmdptr_t UNUSED(parm))
|
||||
int osdcmd_unbindall(osdcmdptr_t)
|
||||
{
|
||||
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");
|
||||
|
||||
C_UnbindAll();
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
|
||||
|
@ -2049,27 +1890,8 @@ 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;
|
||||
Bindings.UnbindKey(parm->parms[0]);
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -49,14 +49,13 @@
|
|||
#include "printf.h"
|
||||
#include "v_text.h"
|
||||
#include "d_event.h"
|
||||
#include "sc_man.h"
|
||||
#include "gamecontrol.h"
|
||||
|
||||
|
||||
const char *KeyNames[NUM_KEYS] =
|
||||
{
|
||||
// This array is dependant on the particular keyboard input
|
||||
// codes generated in i_input.c. If they change there, they
|
||||
// also need to change here. In this case, we use the
|
||||
// DirectInput codes and assume a qwerty keyboard layout.
|
||||
// We use the DirectInput codes and assume a qwerty keyboard layout.
|
||||
// See <dinput.h> for the DIK_* codes
|
||||
|
||||
nullptr, "Escape", "1", "2", "3", "4", "5", "6", //00
|
||||
|
@ -618,20 +617,20 @@ CCMD (defaultbind)
|
|||
//
|
||||
//=============================================================================
|
||||
|
||||
CCMD (rebind)
|
||||
CCMD(rebind)
|
||||
{
|
||||
FKeyBindings *bindings;
|
||||
FKeyBindings* bindings;
|
||||
|
||||
if (key == 0)
|
||||
{
|
||||
Printf ("Rebind cannot be used from the console\n");
|
||||
Printf("Rebind cannot be used from the console\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (key & KEY_DBLCLICKED)
|
||||
{
|
||||
bindings = &DoubleBindings;
|
||||
key &= KEY_DBLCLICKED-1;
|
||||
key &= KEY_DBLCLICKED - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -651,54 +650,83 @@ CCMD (rebind)
|
|||
//
|
||||
//=============================================================================
|
||||
|
||||
void C_BindDefaults ()
|
||||
void ReadBindings(int lump)
|
||||
{
|
||||
#if 0
|
||||
int lump, lastlump = 0;
|
||||
FScanner sc(lump);
|
||||
|
||||
while ((lump = Wads.FindLump("DEFBINDS", &lastlump)) != -1)
|
||||
while (sc.GetString())
|
||||
{
|
||||
FScanner sc(lump);
|
||||
FKeyBindings* dest = &Bindings;
|
||||
int key;
|
||||
|
||||
while (sc.GetString())
|
||||
// bind destination is optional and is the same as the console command
|
||||
if (sc.Compare("bind"))
|
||||
{
|
||||
FKeyBindings *dest = &Bindings;
|
||||
int key;
|
||||
|
||||
// bind destination is optional and is the same as the console command
|
||||
if (sc.Compare("bind"))
|
||||
{
|
||||
sc.MustGetString();
|
||||
}
|
||||
else if (sc.Compare("doublebind"))
|
||||
{
|
||||
dest = &DoubleBindings;
|
||||
sc.MustGetString();
|
||||
}
|
||||
else if (sc.Compare("mapbind"))
|
||||
{
|
||||
dest = &AutomapBindings;
|
||||
sc.MustGetString();
|
||||
}
|
||||
key = GetConfigKeyFromName(sc.String);
|
||||
sc.MustGetString();
|
||||
dest->SetBind(key, sc.String);
|
||||
}
|
||||
else if (sc.Compare("doublebind"))
|
||||
{
|
||||
dest = &DoubleBindings;
|
||||
sc.MustGetString();
|
||||
}
|
||||
else if (sc.Compare("mapbind"))
|
||||
{
|
||||
dest = &AutomapBindings;
|
||||
sc.MustGetString();
|
||||
}
|
||||
key = GetConfigKeyFromName(sc.String);
|
||||
sc.MustGetString();
|
||||
dest->SetBind(key, sc.String);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void CONFIG_SetDefaultKeys(const char* baseconfig)
|
||||
{
|
||||
auto lump = fileSystem.GetFile(baseconfig);
|
||||
ReadBindings(lump);
|
||||
int lastlump = 0;
|
||||
|
||||
while ((lump = fileSystem.Iterate("defbinds.txt", &lastlump)) != -1)
|
||||
{
|
||||
ReadBindings(lump);
|
||||
}
|
||||
}
|
||||
|
||||
void C_BindDefaults()
|
||||
{
|
||||
CONFIG_SetDefaultKeys(cl_defaultconfiguration == 1 ? "demolition/origbinds.txt" : cl_defaultconfiguration == 2 ? "demolition/leftbinds.txt" : "demolition/defbinds.txt");
|
||||
}
|
||||
|
||||
#if 0
|
||||
CCMD(binddefaults)
|
||||
{
|
||||
C_BindDefaults ();
|
||||
C_BindDefaults();
|
||||
}
|
||||
#endif
|
||||
|
||||
void C_SetDefaultBindings ()
|
||||
void C_SetDefaultBindings()
|
||||
{
|
||||
C_UnbindAll ();
|
||||
C_BindDefaults ();
|
||||
C_UnbindAll();
|
||||
C_BindDefaults();
|
||||
}
|
||||
|
||||
// this is horrible!
|
||||
const char* KB_ScanCodeToString(int scancode)
|
||||
{
|
||||
if (scancode >= 0 && scancode < NUM_KEYS)
|
||||
return KeyNames[scancode];
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
int KB_StringToScanCode(const char* string)
|
||||
{
|
||||
for (int i = 0; i < NUM_KEYS; i++)
|
||||
{
|
||||
if (KeyNames[i] && !stricmp(string, KeyNames[i])) return i;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void AddCommandString (const char *copy, int keynum);
|
||||
|
|
|
@ -90,6 +90,10 @@ bool C_DoKey (event_t *ev, FKeyBindings *binds, FKeyBindings *doublebinds);
|
|||
void C_SetDefaultBindings ();
|
||||
void C_UnbindAll ();
|
||||
|
||||
const char* KB_ScanCodeToString(int scancode); // convert scancode into a string
|
||||
int KB_StringToScanCode(const char* string); // convert a string into a scancode
|
||||
|
||||
|
||||
extern const char *KeyNames[];
|
||||
|
||||
struct FKeyAction
|
||||
|
|
|
@ -59,6 +59,7 @@ struct event_t
|
|||
// Called by IO functions when input is detected.
|
||||
void D_PostEvent (const event_t* ev);
|
||||
void D_RemoveNextCharEvent();
|
||||
void D_ProcessEvents(void);
|
||||
|
||||
|
||||
//
|
||||
|
|
|
@ -53,6 +53,7 @@ enum EKeyCodes
|
|||
KEY_PGUP = 0xc9, // DIK_PRIOR
|
||||
KEY_PGDN = 0xd1, // DIK_NEXT
|
||||
|
||||
KEY_FIRSTMOUSEBUTTON = 0x100,
|
||||
KEY_MOUSE1 = 0x100,
|
||||
KEY_MOUSE2 = 0x101,
|
||||
KEY_MOUSE3 = 0x102,
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
#include "gameconfigfile.h"
|
||||
#include "c_cvars.h"
|
||||
//#include "c_dispatch.h"
|
||||
//#include "c_bind.h"
|
||||
#include "c_bind.h"
|
||||
#include "m_argv.h"
|
||||
#include "cmdlib.h"
|
||||
//#include "version.h"
|
||||
|
@ -432,7 +432,6 @@ void FGameConfigFile::ArchiveGameData (const char *gamename)
|
|||
ClearCurrentSection ();
|
||||
C_ArchiveCVars (this, CVAR_ARCHIVE|CVAR_AUTO);
|
||||
|
||||
#if 0
|
||||
strncpy (subsection, "ConsoleAliases", sublen);
|
||||
SetSection (section, true);
|
||||
ClearCurrentSection ();
|
||||
|
@ -442,43 +441,16 @@ void FGameConfigFile::ArchiveGameData (const char *gamename)
|
|||
|
||||
strcpy (subsection, "Bindings");
|
||||
SetSection (section, true);
|
||||
//Bindings.ArchiveBindings (this);
|
||||
Bindings.ArchiveBindings (this);
|
||||
|
||||
strncpy (subsection, "DoubleBindings", sublen);
|
||||
SetSection (section, true);
|
||||
//DoubleBindings.ArchiveBindings (this);
|
||||
DoubleBindings.ArchiveBindings (this);
|
||||
|
||||
strncpy (subsection, "AutomapBindings", sublen);
|
||||
SetSection (section, true);
|
||||
//AutomapBindings.ArchiveBindings (this);
|
||||
#else
|
||||
strcpy(subsection, "Bindings");
|
||||
if (SetSection(section, true))
|
||||
{
|
||||
for (int i = 0; i < NUMKEYS + MAXMOUSEBUTTONS; i++)
|
||||
{
|
||||
if (CONTROL_KeyIsBound(i))
|
||||
{
|
||||
SetValueForKey(CONTROL_KeyBinds[i].key, CONTROL_KeyBinds[i].cmdstr);
|
||||
}
|
||||
}
|
||||
}
|
||||
AutomapBindings.ArchiveBindings (this);
|
||||
|
||||
#if 0 // This somehow does not work. The Build console sucks.
|
||||
strncpy(subsection, "ConsoleAliases", sublen);
|
||||
if (SetSection(section, true))
|
||||
{
|
||||
for (auto& symb : osd->symbptrs)
|
||||
{
|
||||
if (symb == NULL || symb->name == nullptr ||symb->help == nullptr)
|
||||
break;
|
||||
|
||||
if (symb->func == (void*)OSD_ALIAS)
|
||||
SetValueForKey(symb->name, symb->help);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void FGameConfigFile::ArchiveGlobalData ()
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include "m_argv.h"
|
||||
#include "rts.h"
|
||||
#include "printf.h"
|
||||
#include "c_bind.h"
|
||||
|
||||
InputState inputState;
|
||||
void SetClipshapes();
|
||||
|
@ -535,119 +536,6 @@ void CONFIG_DeleteButtonName(int num)
|
|||
GF_NumToAlias[num] = "";
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// wrapper for CONTROL_MapKey(), generates key bindings to reflect changes to keyboard setup
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void CONFIG_MapKey(int which, kb_scancode key1, kb_scancode oldkey1, kb_scancode key2, kb_scancode oldkey2)
|
||||
{
|
||||
int const keys[] = { key1, key2, oldkey1, oldkey2 };
|
||||
|
||||
if (which == gamefunc_Show_Console)
|
||||
OSD_CaptureKey(key1);
|
||||
|
||||
for (int k = 0; (unsigned)k < ARRAY_SIZE(keys); k++)
|
||||
{
|
||||
if (keys[k] == 0xff || !keys[k])
|
||||
continue;
|
||||
|
||||
int match = 0;
|
||||
|
||||
for (; sctokeylut[match].key; match++)
|
||||
{
|
||||
if (keys[k] == sctokeylut[match].sc)
|
||||
break;
|
||||
}
|
||||
|
||||
FString tempbuf;
|
||||
|
||||
for (int i = NUMGAMEFUNCTIONS - 1; i >= 0; i--)
|
||||
{
|
||||
if (KeyboardKeys[i][0] == keys[k] || KeyboardKeys[i][1] == keys[k])
|
||||
{
|
||||
tempbuf.AppendFormat("gamefunc_%s; ", CONFIG_FunctionNumToName(i));
|
||||
}
|
||||
}
|
||||
|
||||
auto len = tempbuf.Len();
|
||||
|
||||
if (len >= 2)
|
||||
{
|
||||
tempbuf.Truncate(len - 2); // cut off the trailing "; "
|
||||
CONTROL_BindKey(keys[k], tempbuf, 1, sctokeylut[match].key ? sctokeylut[match].key : "<?>");
|
||||
}
|
||||
else
|
||||
{
|
||||
CONTROL_FreeKeyBind(keys[k]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void CONFIG_SetDefaultKeys(const char *defbinds, bool lazy/*=false*/)
|
||||
{
|
||||
FScanner sc;
|
||||
|
||||
sc.Open(defbinds);
|
||||
|
||||
if (!lazy)
|
||||
{
|
||||
memset(KeyboardKeys, 0xff, sizeof(KeyboardKeys));
|
||||
CONTROL_ClearAllBinds();
|
||||
}
|
||||
|
||||
while (sc.GetToken())
|
||||
{
|
||||
sc.TokenMustBe(TK_StringConst);
|
||||
int num = CONFIG_FunctionNameToNum(sc.String);
|
||||
int default0 = -1;
|
||||
int default1 = -1;
|
||||
|
||||
if (sc.CheckToken(','))
|
||||
{
|
||||
sc.MustGetToken(TK_StringConst);
|
||||
default0 = KB_StringToScanCode(sc.String);
|
||||
if (sc.CheckToken(','))
|
||||
{
|
||||
sc.MustGetToken(TK_StringConst);
|
||||
default1 = KB_StringToScanCode(sc.String);
|
||||
}
|
||||
if (num >= 0 && num < NUMGAMEFUNCTIONS)
|
||||
{
|
||||
auto& key = KeyboardKeys[num];
|
||||
#if 0
|
||||
// skip the function if the default key is already used
|
||||
// or the function is assigned to another key
|
||||
if (lazy && (key[0] != 0xff || (CONTROL_KeyIsBound(default0) && Bstrlen(CONTROL_KeyBinds[default0].cmdstr) > strlen_gamefunc_
|
||||
&& CONFIG_FunctionNameToNum(CONTROL_KeyBinds[default0].cmdstr + strlen_gamefunc_) >= 0)))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
key[0] = default0;
|
||||
key[1] = default1;
|
||||
|
||||
if (key[0]) CONTROL_FreeKeyBind(key[0]);
|
||||
if (key[1]) CONTROL_FreeKeyBind(key[1]);
|
||||
|
||||
if (num == gamefunc_Show_Console)
|
||||
OSD_CaptureKey(key[0]);
|
||||
else
|
||||
CONFIG_MapKey(num, key[0], 0, key[1], 0);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
|
@ -1246,39 +1134,50 @@ void CONFIG_SetGameControllerDefaultsPro()
|
|||
digitalAxis.apply();
|
||||
}
|
||||
|
||||
char const* CONFIG_GetGameFuncOnKeyboard(int gameFunc)
|
||||
FString CONFIG_GetGameFuncOnKeyboard(int gameFunc)
|
||||
{
|
||||
const char* string0 = KB_ScanCodeToString(KeyboardKeys[gameFunc][0]);
|
||||
return string0[0] == '\0' ? KB_ScanCodeToString(KeyboardKeys[gameFunc][1]) : string0;
|
||||
auto binding = CONFIG_FunctionNumToRealName(gameFunc);
|
||||
auto keys = Bindings.GetKeysForCommand(binding);
|
||||
for(auto key : keys)
|
||||
{
|
||||
if (key < KEY_FIRSTMOUSEBUTTON)
|
||||
{
|
||||
auto scan = KB_ScanCodeToString(key);
|
||||
if (scan) return scan;
|
||||
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
char const* CONFIG_GetGameFuncOnMouse(int gameFunc)
|
||||
FString CONFIG_GetGameFuncOnMouse(int gameFunc)
|
||||
{
|
||||
for (int j = 0; j < 2; ++j)
|
||||
for (int i = 0; i < joystick.numButtons; ++i)
|
||||
if (JoystickFunctions[i][j] == gameFunc)
|
||||
return joyGetName(1, i);
|
||||
|
||||
for (int i = 0; i < joystick.numAxes; ++i)
|
||||
for (int j = 0; j < 2; ++j)
|
||||
if (JoystickDigitalFunctions[i][j] == gameFunc)
|
||||
return joyGetName(0, i);
|
||||
auto binding = CONFIG_FunctionNumToRealName(gameFunc);
|
||||
auto keys = Bindings.GetKeysForCommand(binding);
|
||||
for (auto key : keys)
|
||||
{
|
||||
if (key >= KEY_FIRSTMOUSEBUTTON && key < KEY_FIRSTJOYBUTTON)
|
||||
{
|
||||
auto scan = KB_ScanCodeToString(key);
|
||||
if (scan) return scan;
|
||||
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
char const* CONFIG_GetGameFuncOnJoystick(int gameFunc)
|
||||
{
|
||||
for (int j = 0; j < 2; ++j)
|
||||
for (int i = 0; i < joystick.numButtons; ++i)
|
||||
if (JoystickFunctions[i][j] == gameFunc)
|
||||
return joyGetName(1, i);
|
||||
|
||||
for (int i = 0; i < joystick.numAxes; ++i)
|
||||
for (int j = 0; j < 2; ++j)
|
||||
if (JoystickDigitalFunctions[i][j] == gameFunc)
|
||||
return joyGetName(0, i);
|
||||
|
||||
auto binding = CONFIG_FunctionNumToRealName(gameFunc);
|
||||
auto keys = Bindings.GetKeysForCommand(binding);
|
||||
for (auto key : keys)
|
||||
{
|
||||
if (key >= KEY_FIRSTJOYBUTTON)
|
||||
{
|
||||
auto scan = KB_ScanCodeToString(key);
|
||||
if (scan) return scan;
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
|
@ -1287,31 +1186,29 @@ FString CONFIG_GetBoundKeyForLastInput(int gameFunc)
|
|||
{
|
||||
if (CONTROL_LastSeenInput == LastSeenInput::Joystick)
|
||||
{
|
||||
char const* joyname = CONFIG_GetGameFuncOnJoystick(gameFunc);
|
||||
if (joyname != nullptr && joyname[0] != '\0')
|
||||
FString name = CONFIG_GetGameFuncOnJoystick(gameFunc);
|
||||
if (name.IsNotEmpty())
|
||||
{
|
||||
return joyname;
|
||||
}
|
||||
|
||||
char const* keyname = CONFIG_GetGameFuncOnKeyboard(gameFunc);
|
||||
if (keyname != nullptr && keyname[0] != '\0')
|
||||
{
|
||||
return keyname;
|
||||
return name;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
char const* keyname = CONFIG_GetGameFuncOnKeyboard(gameFunc);
|
||||
if (keyname != nullptr && keyname[0] != '\0')
|
||||
{
|
||||
return keyname;
|
||||
}
|
||||
|
||||
char const* joyname = CONFIG_GetGameFuncOnJoystick(gameFunc);
|
||||
if (joyname != nullptr && joyname[0] != '\0')
|
||||
{
|
||||
return joyname;
|
||||
}
|
||||
FString name = CONFIG_GetGameFuncOnKeyboard(gameFunc);
|
||||
if (name.IsNotEmpty())
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
name = CONFIG_GetGameFuncOnMouse(gameFunc);
|
||||
if (name.IsNotEmpty())
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
name = CONFIG_GetGameFuncOnJoystick(gameFunc);
|
||||
if (name.IsNotEmpty())
|
||||
{
|
||||
return name;
|
||||
}
|
||||
return "UNBOUND";
|
||||
}
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
#include "inputstate.h"
|
||||
#include "gamecvars.h"
|
||||
|
||||
EXTERN_CVAR(Int, cl_defaultconfiguration)
|
||||
|
||||
extern FString currentGame;
|
||||
extern FString LumpFilter;
|
||||
class FArgs;
|
||||
|
@ -17,7 +19,7 @@ void D_AddWildFile(TArray<FString>& wadfiles, const char* value);
|
|||
extern uint8_t KeyboardKeys[NUMGAMEFUNCTIONS][2];
|
||||
|
||||
int CONFIG_Init();
|
||||
void CONFIG_SetDefaultKeys(const char *defbinds, bool lazy=false);
|
||||
void CONFIG_SetDefaultKeys(const char *defbinds);
|
||||
int32_t CONFIG_FunctionNameToNum(const char* func);
|
||||
const char* CONFIG_FunctionNumToName(int32_t func);
|
||||
const char* CONFIG_FunctionNumToRealName(int32_t func);
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include <stdint.h>
|
||||
#include "tarray.h"
|
||||
#include "scancodes.h"
|
||||
#include "c_bind.h"
|
||||
|
||||
typedef uint8_t kb_scancode;
|
||||
|
||||
|
@ -26,7 +27,6 @@ enum
|
|||
|
||||
};
|
||||
|
||||
extern consolekeybind_t CONTROL_KeyBinds[NUMKEYS + MAXMOUSEBUTTONS];
|
||||
extern int32_t CONTROL_ButtonFlags[NUMKEYS];
|
||||
extern bool CONTROL_BindsEnabled;
|
||||
|
||||
|
@ -241,7 +241,7 @@ inline void KB_ClearKeyDown(int scan)
|
|||
|
||||
inline bool KB_UnBoundKeyPressed(int scan)
|
||||
{
|
||||
return (inputState.GetKeyStatus(scan) != 0 && !CONTROL_KeyBinds[scan].cmdstr);
|
||||
return (inputState.GetKeyStatus(scan) != 0 && Bindings.GetBind(scan) == nullptr);
|
||||
}
|
||||
|
||||
inline void KB_ClearKeysDown(void)
|
||||
|
|
|
@ -156,6 +156,26 @@ void FScanner::Open (const char *name)
|
|||
PrepareScript();
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// FScanner :: Open
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
FScanner::FScanner(int lump)
|
||||
{
|
||||
if ((unsigned)lump >= fileSystem.GetNumEntries())
|
||||
{
|
||||
I_Error("Invalid file index %d\n", lump);
|
||||
}
|
||||
Close();
|
||||
auto data = fileSystem.GetFileData(lump, 1);
|
||||
ScriptBuffer = data;
|
||||
ScriptName = fileSystem.GetFileName(lump);
|
||||
LumpNum = lump;
|
||||
PrepareScript();
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// FScanner :: OpenFile
|
||||
|
|
|
@ -3652,24 +3652,13 @@ badindex:
|
|||
{
|
||||
int const quoteIndex = Gv_GetVar(*insptr++);
|
||||
int const gameFunc = Gv_GetVar(*insptr++);
|
||||
int const funcPos = 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);
|
||||
|
||||
if (funcPos < 2)
|
||||
Bstrcpy(tempbuf, KB_ScanCodeToString(KeyboardKeys[gameFunc][funcPos]));
|
||||
else
|
||||
{
|
||||
Bstrcpy(tempbuf, KB_ScanCodeToString(KeyboardKeys[gameFunc][0]));
|
||||
|
||||
if (!*tempbuf)
|
||||
Bstrcpy(tempbuf, KB_ScanCodeToString(KeyboardKeys[gameFunc][1]));
|
||||
}
|
||||
|
||||
if (*tempbuf)
|
||||
Bstrcpy(apStrings[quoteIndex], tempbuf);
|
||||
int funcPos = 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);
|
||||
|
||||
auto bindings = Bindings.GetKeysForCommand(CONFIG_FunctionNumToRealName(gameFunc));
|
||||
if ((unsigned)funcPos >= bindings.Size()) funcPos = 0;
|
||||
Bstrcpy(apStrings[quoteIndex], KB_ScanCodeToString(bindings[funcPos]));
|
||||
dispatch();
|
||||
}
|
||||
|
||||
|
|
|
@ -2864,12 +2864,7 @@ static void Menu_PreInput(MenuEntry_t *entry)
|
|||
case MENU_KEYBOARDKEYS:
|
||||
if (KB_KeyPressed(sc_Delete))
|
||||
{
|
||||
auto column = (MenuCustom2Col_t*)entry->entry;
|
||||
char key[2];
|
||||
key[0] = KeyboardKeys[M_KEYBOARDKEYS.currentEntry][0];
|
||||
key[1] = KeyboardKeys[M_KEYBOARDKEYS.currentEntry][1];
|
||||
*column->column[M_KEYBOARDKEYS.currentColumn] = 0xff;
|
||||
CONFIG_MapKey(M_KEYBOARDKEYS.currentEntry, KeyboardKeys[M_KEYBOARDKEYS.currentEntry][0], key[0], KeyboardKeys[M_KEYBOARDKEYS.currentEntry][1], key[1]);
|
||||
Bindings.UnbindACommand(CONFIG_FunctionNumToName(M_KEYBOARDKEYS.currentEntry));
|
||||
S_PlaySound(KICK_HIT);
|
||||
KB_ClearKeyDown(sc_Delete);
|
||||
}
|
||||
|
@ -2925,16 +2920,9 @@ static int32_t Menu_PreCustom2ColScreen(MenuEntry_t *entry)
|
|||
int32_t sc = KB_GetLastScanCode();
|
||||
if (sc != sc_None)
|
||||
{
|
||||
char key[2];
|
||||
key[0] = KeyboardKeys[M_KEYBOARDKEYS.currentEntry][0];
|
||||
key[1] = KeyboardKeys[M_KEYBOARDKEYS.currentEntry][1];
|
||||
|
||||
S_PlaySound(PISTOL_BODYHIT);
|
||||
|
||||
*column->column[M_KEYBOARDKEYS.currentColumn] = KB_GetLastScanCode();
|
||||
|
||||
CONFIG_MapKey(M_KEYBOARDKEYS.currentEntry, KeyboardKeys[M_KEYBOARDKEYS.currentEntry][0], key[0], KeyboardKeys[M_KEYBOARDKEYS.currentEntry][1], key[1]);
|
||||
|
||||
*column->column[M_KEYBOARDKEYS.currentColumn] = sc;
|
||||
Bindings.SetBind(sc, CONFIG_FunctionNumToName(M_KEYBOARDKEYS.currentEntry));
|
||||
KB_ClearKeyDown(sc);
|
||||
|
||||
return -1;
|
||||
|
@ -3335,11 +3323,8 @@ static int32_t Menu_EntryOptionModify(MenuEntry_t *entry, int32_t newOption)
|
|||
switch (g_currentMenu)
|
||||
{
|
||||
case MENU_MOUSEBTNS:
|
||||
CONTROL_MapButton(newOption, MenuMouseDataIndex[M_MOUSEBTNS.currentEntry][0], MenuMouseDataIndex[M_MOUSEBTNS.currentEntry][1], controldevice_mouse);
|
||||
CONTROL_FreeMouseBind(MenuMouseDataIndex[M_MOUSEBTNS.currentEntry][0]);
|
||||
break;
|
||||
case MENU_JOYSTICKBTNS:
|
||||
CONTROL_MapButton(newOption, M_JOYSTICKBTNS.currentEntry>>1, M_JOYSTICKBTNS.currentEntry&1, controldevice_joystick);
|
||||
break;
|
||||
case MENU_JOYSTICKAXIS:
|
||||
{
|
||||
|
|
|
@ -27,6 +27,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
#include "enet.h"
|
||||
#include "sjson.h"
|
||||
#include "gamecvars.h"
|
||||
#include "d_event.h"
|
||||
#include "i_specialpaths.h"
|
||||
|
||||
BEGIN_DUKE_NS
|
||||
|
@ -2906,7 +2907,7 @@ void P_GetInput(int const playerNum)
|
|||
return;
|
||||
}
|
||||
|
||||
CONTROL_ProcessBinds();
|
||||
D_ProcessEvents();
|
||||
|
||||
if (in_aimmode)
|
||||
g_MyAimMode = BUTTON(gamefunc_Mouse_Aiming);
|
||||
|
|
|
@ -205,23 +205,6 @@ void CONTROL_ClearGameControllerDigitalAxisNeg(int32_t axis);
|
|||
////////// KEY/MOUSE BIND STUFF //////////
|
||||
|
||||
|
||||
// Direct use DEPRECATED:
|
||||
extern bool CONTROL_BindsEnabled;
|
||||
|
||||
void CONTROL_ClearAllBinds(void);
|
||||
void CONTROL_BindKey(int i, char const * cmd, int repeat, char const * keyname);
|
||||
void CONTROL_BindMouse(int i, char const * cmd, int repeat, char const * keyname);
|
||||
void CONTROL_FreeKeyBind(int i);
|
||||
void CONTROL_FreeMouseBind(int i);
|
||||
|
||||
static inline int CONTROL_KeyIsBound(int const key)
|
||||
{
|
||||
auto &bind = CONTROL_KeyBinds[key];
|
||||
return bind.cmdstr && bind.key;
|
||||
}
|
||||
|
||||
void CONTROL_ProcessBinds(void);
|
||||
|
||||
#define CONTROL_GetUserInput(...)
|
||||
#define CONTROL_ClearUserInput(...)
|
||||
|
||||
|
|
|
@ -33,29 +33,6 @@ Modifications for JonoF's port by Jonathon Fowler (jf@jonof.id.au)
|
|||
#include "baselayer.h" // for the keyboard stuff
|
||||
#include "scancodes.h"
|
||||
|
||||
// translation table for taking key names to scancodes and back again
|
||||
static struct
|
||||
{
|
||||
const char *key;
|
||||
kb_scancode sc;
|
||||
} CONSTEXPR sctokeylut[] = {
|
||||
{ "Escape", 0x1 }, { "1", 0x2 }, { "2", 0x3 }, { "3", 0x4 }, { "4", 0x5 }, { "5", 0x6 }, { "6", 0x7 },
|
||||
{ "7", 0x8 }, { "8", 0x9 }, { "9", 0xa }, { "0", 0xb }, { "-", 0xc }, { "Equal", 0xd }, { "BakSpc", 0xe },
|
||||
{ "Tab", 0xf }, { "Q", 0x10 }, { "W", 0x11 }, { "E", 0x12 }, { "R", 0x13 }, { "T", 0x14 }, { "Y", 0x15 },
|
||||
{ "U", 0x16 }, { "I", 0x17 }, { "O", 0x18 }, { "P", 0x19 }, { "LeftBrk", 0x1a }, { "RightBrk", 0x1b }, { "Enter", 0x1c },
|
||||
{ "LCtrl", 0x1d }, { "A", 0x1e }, { "S", 0x1f }, { "D", 0x20 }, { "F", 0x21 }, { "G", 0x22 }, { "H", 0x23 },
|
||||
{ "J", 0x24 }, { "K", 0x25 }, { "L", 0x26 }, { "Semi", 0x27 }, { "'", 0x28 }, { "`", 0x29 }, { "LShift", 0x2a },
|
||||
{ "Backslash", 0x2b }, { "Z", 0x2c }, { "X", 0x2d }, { "C", 0x2e }, { "V", 0x2f }, { "B", 0x30 }, { "N", 0x31 },
|
||||
{ "M", 0x32 }, { ",", 0x33 }, { ".", 0x34 }, { "/", 0x35 }, { "RShift", 0x36 }, { "Kpad*", 0x37 }, { "LAlt", 0x38 },
|
||||
{ "Space", 0x39 }, { "CapLck", 0x3a }, { "F1", 0x3b }, { "F2", 0x3c }, { "F3", 0x3d }, { "F4", 0x3e }, { "F5", 0x3f },
|
||||
{ "F6", 0x40 }, { "F7", 0x41 }, { "F8", 0x42 }, { "F9", 0x43 }, { "F10", 0x44 }, { "NumLck", 0x45 }, { "ScrLck", 0x46 },
|
||||
{ "Kpad7", 0x47 }, { "Kpad8", 0x48 }, { "Kpad9", 0x49 }, { "Kpad-", 0x4a }, { "Kpad4", 0x4b }, { "Kpad5", 0x4c }, { "Kpad6", 0x4d },
|
||||
{ "Kpad+", 0x4e }, { "Kpad1", 0x4f }, { "Kpad2", 0x50 }, { "Kpad3", 0x51 }, { "Kpad0", 0x52 }, { "Kpad.", 0x53 }, { "LessThan", 0x56 },
|
||||
{ "F11", 0x57 }, { "F12", 0x58 }, { "KpdEnt", 0x9c }, { "RCtrl", 0x9d }, { "Kpad/", 0xb5 }, { "RAlt", 0xb8 }, { "PrtScn", 0xb7 },
|
||||
{ "Pause", 0xc5 }, { "Home", 0xc7 }, { "Up", 0xc8 }, { "PgUp", 0xc9 }, { "Left", 0xcb }, { "Right", 0xcd }, { "End", 0xcf },
|
||||
{ "Down", 0xd0 }, { "PgDn", 0xd1 }, { "Insert", 0xd2 }, { "Delete", 0xd3 },
|
||||
};
|
||||
|
||||
extern kb_scancode KB_LastScan;
|
||||
|
||||
#define KB_GetLastScanCode() (KB_LastScan)
|
||||
|
@ -80,7 +57,7 @@ static inline void KB_KeyEvent(int32_t scancode, int32_t keypressed)
|
|||
|
||||
void KB_Startup(void);
|
||||
void KB_Shutdown(void);
|
||||
const char * KB_ScanCodeToString( kb_scancode scancode ); // convert scancode into a string
|
||||
kb_scancode KB_StringToScanCode( const char * string ); // convert a string into a scancode
|
||||
const char * KB_ScanCodeToString( int scancode ); // convert scancode into a string
|
||||
int KB_StringToScanCode( const char * string ); // convert a string into a scancode
|
||||
|
||||
#endif
|
||||
|
|
|
@ -60,40 +60,10 @@ static int32_t(*ExtGetTime)(void);
|
|||
static uint8_t CONTROL_DoubleClickSpeed;
|
||||
|
||||
int32_t CONTROL_ButtonFlags[NUMKEYS];
|
||||
consolekeybind_t CONTROL_KeyBinds[NUMKEYS + MAXMOUSEBUTTONS];
|
||||
bool CONTROL_BindsEnabled = 0;
|
||||
bool CONTROL_SmoothMouse = 0;
|
||||
|
||||
#define CONTROL_CheckRange(which) ((unsigned)which >= (unsigned)NUMKEYS)
|
||||
#define BIND(x, s, r, k) do { Xfree(x.cmdstr); x.cmdstr = s; x.repeat = r; x.key = k; } while (0)
|
||||
|
||||
void CONTROL_ClearAllBinds(void)
|
||||
{
|
||||
for (int i=0; i<NUMKEYS; i++)
|
||||
CONTROL_FreeKeyBind(i);
|
||||
for (int i=0; i<MAXMOUSEBUTTONS; i++)
|
||||
CONTROL_FreeMouseBind(i);
|
||||
}
|
||||
|
||||
void CONTROL_BindKey(int i, char const * const cmd, int repeat, char const * const keyname)
|
||||
{
|
||||
BIND(CONTROL_KeyBinds[i], Xstrdup(cmd), repeat, keyname);
|
||||
}
|
||||
|
||||
void CONTROL_BindMouse(int i, char const * const cmd, int repeat, char const * const keyname)
|
||||
{
|
||||
BIND(CONTROL_KeyBinds[NUMKEYS + i], Xstrdup(cmd), repeat, keyname);
|
||||
}
|
||||
|
||||
void CONTROL_FreeKeyBind(int i)
|
||||
{
|
||||
BIND(CONTROL_KeyBinds[i], NULL, 0, NULL);
|
||||
}
|
||||
|
||||
void CONTROL_FreeMouseBind(int i)
|
||||
{
|
||||
BIND(CONTROL_KeyBinds[NUMKEYS + i], NULL, 0, NULL);
|
||||
}
|
||||
|
||||
static void CONTROL_GetMouseDelta(ControlInfo * info)
|
||||
{
|
||||
|
@ -555,36 +525,6 @@ static void CONTROL_AxisFunctionState(int32_t *p1)
|
|||
|
||||
static void CONTROL_ButtonFunctionState(int32_t *p1)
|
||||
{
|
||||
if (CONTROL_NumMouseButtons)
|
||||
{
|
||||
int i = CONTROL_NumMouseButtons-1, j;
|
||||
|
||||
do
|
||||
{
|
||||
if (!CONTROL_KeyBinds[NUMKEYS + i].cmdstr)
|
||||
{
|
||||
j = CONTROL_MouseButtonMapping[i].doubleclicked;
|
||||
if (j != KEYUNDEFINED)
|
||||
p1[j] |= CONTROL_MouseButtonClickedState[i];
|
||||
|
||||
j = CONTROL_MouseButtonMapping[i].singleclicked;
|
||||
if (j != KEYUNDEFINED)
|
||||
p1[j] |= CONTROL_MouseButtonState[i];
|
||||
}
|
||||
|
||||
if (!CONTROL_BindsEnabled)
|
||||
continue;
|
||||
|
||||
if (CONTROL_KeyBinds[NUMKEYS + i].cmdstr && CONTROL_MouseButtonState[i])
|
||||
{
|
||||
if (CONTROL_KeyBinds[NUMKEYS + i].repeat || (CONTROL_KeyBinds[NUMKEYS + i].laststate == 0))
|
||||
OSD_Dispatch(CONTROL_KeyBinds[NUMKEYS + i].cmdstr);
|
||||
}
|
||||
CONTROL_KeyBinds[NUMKEYS + i].laststate = CONTROL_MouseButtonState[i];
|
||||
}
|
||||
while (i--);
|
||||
}
|
||||
|
||||
if (CONTROL_NumJoyButtons)
|
||||
{
|
||||
int i=CONTROL_NumJoyButtons-1, j;
|
||||
|
@ -645,30 +585,6 @@ void CONTROL_ClearGameControllerDigitalAxisNeg(int32_t axis)
|
|||
CONTROL_JoyAxes[axis].digitalClearedN = 1;
|
||||
}
|
||||
|
||||
void CONTROL_ProcessBinds(void)
|
||||
{
|
||||
if (!CONTROL_BindsEnabled)
|
||||
return;
|
||||
|
||||
int i = NUMKEYS-1;
|
||||
|
||||
do
|
||||
{
|
||||
if (CONTROL_KeyBinds[i].cmdstr)
|
||||
{
|
||||
auto const keyPressed = KB_KeyPressed(i);
|
||||
|
||||
if (keyPressed && (CONTROL_KeyBinds[i].repeat || (CONTROL_KeyBinds[i].laststate == 0)))
|
||||
{
|
||||
CONTROL_LastSeenInput = LastSeenInput::Keyboard;
|
||||
OSD_Dispatch(CONTROL_KeyBinds[i].cmdstr);
|
||||
}
|
||||
|
||||
CONTROL_KeyBinds[i].laststate = keyPressed;
|
||||
}
|
||||
}
|
||||
while (i--);
|
||||
}
|
||||
|
||||
static void CONTROL_GetFunctionInput(void)
|
||||
{
|
||||
|
@ -738,8 +654,6 @@ void CONTROL_Shutdown(void)
|
|||
if (!CONTROL_Started)
|
||||
return;
|
||||
|
||||
CONTROL_ClearAllBinds();
|
||||
|
||||
MOUSE_Shutdown();
|
||||
uninitinput();
|
||||
|
||||
|
|
|
@ -39,24 +39,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
|
||||
kb_scancode KB_LastScan;
|
||||
|
||||
// this is horrible!
|
||||
const char *KB_ScanCodeToString(kb_scancode scancode)
|
||||
{
|
||||
for (auto &s : sctokeylut)
|
||||
if (s.sc == scancode)
|
||||
return s.key;
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
kb_scancode KB_StringToScanCode(const char * string)
|
||||
{
|
||||
for (auto &s : sctokeylut)
|
||||
if (!Bstrcasecmp(s.key, string))
|
||||
return s.sc;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void KB_Startup(void) { keySetCallback(KB_KeyEvent); }
|
||||
void KB_Shutdown(void) { keySetCallback((void (*)(int32_t, int32_t))NULL); }
|
||||
|
|
|
@ -3241,13 +3241,8 @@ static void Menu_PreInput(MenuEntry_t *entry)
|
|||
case MENU_KEYBOARDKEYS:
|
||||
if (KB_KeyPressed(sc_Delete))
|
||||
{
|
||||
auto *column = (MenuCustom2Col_t*)entry->entry;
|
||||
char key[2];
|
||||
key[0] = KeyboardKeys[M_KEYBOARDKEYS.currentEntry][0];
|
||||
key[1] = KeyboardKeys[M_KEYBOARDKEYS.currentEntry][1];
|
||||
*column->column[M_KEYBOARDKEYS.currentColumn] = 0xff;
|
||||
CONFIG_MapKey(M_KEYBOARDKEYS.currentEntry, KeyboardKeys[M_KEYBOARDKEYS.currentEntry][0], key[0], KeyboardKeys[M_KEYBOARDKEYS.currentEntry][1], key[1]);
|
||||
S_PlaySound(RR ? 335 : KICK_HIT);
|
||||
Bindings.UnbindACommand(CONFIG_FunctionNumToName(M_KEYBOARDKEYS.currentEntry));
|
||||
S_PlaySound(RR ? 335 : KICK_HIT);
|
||||
KB_ClearKeyDown(sc_Delete);
|
||||
}
|
||||
break;
|
||||
|
@ -3300,23 +3295,16 @@ static int32_t Menu_PreCustom2ColScreen(MenuEntry_t *entry)
|
|||
auto *column = (MenuCustom2Col_t*)entry->entry;
|
||||
|
||||
int32_t sc = KB_GetLastScanCode();
|
||||
if (sc != sc_None)
|
||||
{
|
||||
char key[2];
|
||||
key[0] = KeyboardKeys[M_KEYBOARDKEYS.currentEntry][0];
|
||||
key[1] = KeyboardKeys[M_KEYBOARDKEYS.currentEntry][1];
|
||||
if (sc != sc_None)
|
||||
{
|
||||
S_PlaySound(PISTOL_BODYHIT);
|
||||
*column->column[M_KEYBOARDKEYS.currentColumn] = sc;
|
||||
Bindings.SetBind(sc, CONFIG_FunctionNumToName(M_KEYBOARDKEYS.currentEntry));
|
||||
KB_ClearKeyDown(sc);
|
||||
|
||||
S_PlaySound(RR ? 341 : PISTOL_BODYHIT);
|
||||
|
||||
*column->column[M_KEYBOARDKEYS.currentColumn] = KB_GetLastScanCode();
|
||||
|
||||
CONFIG_MapKey(M_KEYBOARDKEYS.currentEntry, KeyboardKeys[M_KEYBOARDKEYS.currentEntry][0], key[0], KeyboardKeys[M_KEYBOARDKEYS.currentEntry][1], key[1]);
|
||||
|
||||
KB_ClearKeyDown(sc);
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -3715,8 +3703,6 @@ static int32_t Menu_EntryOptionModify(MenuEntry_t *entry, int32_t newOption)
|
|||
switch (g_currentMenu)
|
||||
{
|
||||
case MENU_MOUSEBTNS:
|
||||
CONTROL_MapButton(newOption, MenuMouseDataIndex[M_MOUSEBTNS.currentEntry][0], MenuMouseDataIndex[M_MOUSEBTNS.currentEntry][1], controldevice_mouse);
|
||||
CONTROL_FreeMouseBind(MenuMouseDataIndex[M_MOUSEBTNS.currentEntry][0]);
|
||||
break;
|
||||
case MENU_MOUSEADVANCED:
|
||||
{
|
||||
|
@ -3726,7 +3712,6 @@ static int32_t Menu_EntryOptionModify(MenuEntry_t *entry, int32_t newOption)
|
|||
}
|
||||
break;
|
||||
case MENU_JOYSTICKBTNS:
|
||||
CONTROL_MapButton(newOption, M_JOYSTICKBTNS.currentEntry>>1, M_JOYSTICKBTNS.currentEntry&1, controldevice_joystick);
|
||||
break;
|
||||
case MENU_JOYSTICKAXIS:
|
||||
{
|
||||
|
|
|
@ -24,6 +24,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
#include "duke3d.h"
|
||||
#include "demo.h"
|
||||
#include "enet.h"
|
||||
#include "d_event.h"
|
||||
|
||||
BEGIN_RR_NS
|
||||
|
||||
|
@ -2755,7 +2756,7 @@ void P_GetInput(int playerNum)
|
|||
return;
|
||||
}
|
||||
|
||||
CONTROL_ProcessBinds();
|
||||
D_ProcessEvents();
|
||||
|
||||
if (in_aimmode)
|
||||
g_MyAimMode = BUTTON(gamefunc_Mouse_Aiming);
|
||||
|
@ -3061,7 +3062,7 @@ void P_GetInputMotorcycle(int playerNum)
|
|||
return;
|
||||
}
|
||||
|
||||
CONTROL_ProcessBinds();
|
||||
D_ProcessEvents();
|
||||
|
||||
if (in_aimmode)
|
||||
g_MyAimMode = BUTTON(gamefunc_Mouse_Aiming);
|
||||
|
@ -3359,7 +3360,7 @@ void P_GetInputBoat(int playerNum)
|
|||
return;
|
||||
}
|
||||
|
||||
CONTROL_ProcessBinds();
|
||||
D_ProcessEvents();
|
||||
|
||||
if (in_aimmode)
|
||||
g_MyAimMode = BUTTON(gamefunc_Mouse_Aiming);
|
||||
|
|
Loading…
Reference in a new issue