- added ZDoom's CCMD code.

Not tested yet.
This commit is contained in:
Christoph Oelckers 2019-11-04 23:01:50 +01:00
parent bbf0a73471
commit 570696fc09
36 changed files with 2165 additions and 841 deletions

View file

@ -782,7 +782,9 @@ set (PCH_SOURCES
common/console/c_cvars.cpp common/console/c_cvars.cpp
common/console/c_bind.cpp common/console/c_bind.cpp
common/console/c_buttons.cpp
common/console/c_commandline.cpp common/console/c_commandline.cpp
common/console/c_dispatch.cpp
common/console/d_event.cpp common/console/d_event.cpp
common/utility/i_time.cpp common/utility/i_time.cpp

View file

@ -809,17 +809,17 @@ void LocalKeys(void)
bool alt = inputState.AltPressed(); bool alt = inputState.AltPressed();
bool ctrl = inputState.CtrlPressed(); bool ctrl = inputState.CtrlPressed();
bool shift = inputState.ShiftPressed(); bool shift = inputState.ShiftPressed();
if (inputState.BUTTON(gamefunc_See_Chase_View) && !alt && !shift) if (buttonMap.ButtonDown(gamefunc_See_Chase_View) && !alt && !shift)
{ {
inputState.ClearButton(gamefunc_See_Chase_View); buttonMap.ClearButton(gamefunc_See_Chase_View);
if (gViewPos > VIEWPOS_0) if (gViewPos > VIEWPOS_0)
gViewPos = VIEWPOS_0; gViewPos = VIEWPOS_0;
else else
gViewPos = VIEWPOS_1; gViewPos = VIEWPOS_1;
} }
if (inputState.BUTTON(gamefunc_See_Coop_View)) if (buttonMap.ButtonDown(gamefunc_See_Coop_View))
{ {
inputState.ClearButton(gamefunc_See_Coop_View); buttonMap.ClearButton(gamefunc_See_Coop_View);
if (gGameOptions.nGameType == 1) if (gGameOptions.nGameType == 1)
{ {
gViewIndex = connectpoint2[gViewIndex]; gViewIndex = connectpoint2[gViewIndex];
@ -873,7 +873,7 @@ void LocalKeys(void)
} }
inputState.keyFlushScans(); inputState.keyFlushScans();
inputState.ClearKeyStatus(key); inputState.ClearKeyStatus(key);
inputState.ClearButton(gamefunc_See_Chase_View); buttonMap.ClearButton(gamefunc_See_Chase_View);
return; return;
} }
switch (key) switch (key)

View file

@ -124,13 +124,13 @@ void ctrlGetInput(void)
if (in_aimmode) if (in_aimmode)
g_MyAimMode = 0; g_MyAimMode = 0;
if (inputState.BUTTON(gamefunc_Mouse_Aiming)) if (buttonMap.ButtonDown(gamefunc_Mouse_Aiming))
{ {
if (in_aimmode) if (in_aimmode)
g_MyAimMode = 1; g_MyAimMode = 1;
else else
{ {
inputState.ClearButton(gamefunc_Mouse_Aiming); buttonMap.ClearButton(gamefunc_Mouse_Aiming);
g_MyAimMode = !g_MyAimMode; g_MyAimMode = !g_MyAimMode;
if (g_MyAimMode) if (g_MyAimMode)
{ {
@ -175,16 +175,16 @@ void ctrlGetInput(void)
gInput.keyFlags.quit = 1; gInput.keyFlags.quit = 1;
if (gGameStarted && gInputMode != kInputMessage && gInputMode != kInputMenu if (gGameStarted && gInputMode != kInputMessage && gInputMode != kInputMenu
&& inputState.BUTTON(gamefunc_Send_Message)) && buttonMap.ButtonDown(gamefunc_Send_Message))
{ {
inputState.ClearButton(gamefunc_Send_Message); buttonMap.ClearButton(gamefunc_Send_Message);
inputState.keyFlushScans(); inputState.keyFlushScans();
gInputMode = kInputMessage; gInputMode = kInputMessage;
} }
if (inputState.BUTTON(gamefunc_AutoRun)) if (buttonMap.ButtonDown(gamefunc_AutoRun))
{ {
inputState.ClearButton(gamefunc_AutoRun); buttonMap.ClearButton(gamefunc_AutoRun);
gAutoRun = !gAutoRun; gAutoRun = !gAutoRun;
if (gAutoRun) if (gAutoRun)
viewSetMessage("Auto run ON"); viewSetMessage("Auto run ON");
@ -192,24 +192,24 @@ void ctrlGetInput(void)
viewSetMessage("Auto run OFF"); viewSetMessage("Auto run OFF");
} }
if (inputState.BUTTON(gamefunc_Map_Toggle)) if (buttonMap.ButtonDown(gamefunc_Map_Toggle))
{ {
inputState.ClearButton(gamefunc_Map_Toggle); buttonMap.ClearButton(gamefunc_Map_Toggle);
viewToggle(gViewMode); viewToggle(gViewMode);
} }
if (inputState.BUTTON(gamefunc_Map_Follow_Mode)) if (buttonMap.ButtonDown(gamefunc_Map_Follow_Mode))
{ {
inputState.ClearButton(gamefunc_Map_Follow_Mode); buttonMap.ClearButton(gamefunc_Map_Follow_Mode);
gFollowMap = !gFollowMap; gFollowMap = !gFollowMap;
gViewMap.FollowMode(gFollowMap); gViewMap.FollowMode(gFollowMap);
} }
if (inputState.BUTTON(gamefunc_Shrink_Screen)) if (buttonMap.ButtonDown(gamefunc_Shrink_Screen))
{ {
if (gViewMode == 3) if (gViewMode == 3)
{ {
inputState.ClearButton(gamefunc_Shrink_Screen); buttonMap.ClearButton(gamefunc_Shrink_Screen);
G_ChangeHudLayout(-1); G_ChangeHudLayout(-1);
} }
if (gViewMode == 2 || gViewMode == 4) if (gViewMode == 2 || gViewMode == 4)
@ -219,11 +219,11 @@ void ctrlGetInput(void)
} }
} }
if (inputState.BUTTON(gamefunc_Enlarge_Screen)) if (buttonMap.ButtonDown(gamefunc_Enlarge_Screen))
{ {
if (gViewMode == 3) if (gViewMode == 3)
{ {
inputState.ClearButton(gamefunc_Enlarge_Screen); buttonMap.ClearButton(gamefunc_Enlarge_Screen);
G_ChangeHudLayout(1); G_ChangeHudLayout(1);
} }
if (gViewMode == 2 || gViewMode == 4) if (gViewMode == 2 || gViewMode == 4)
@ -233,165 +233,165 @@ void ctrlGetInput(void)
} }
} }
if (inputState.BUTTON(gamefunc_Toggle_Crosshair)) if (buttonMap.ButtonDown(gamefunc_Toggle_Crosshair))
{ {
inputState.ClearButton(gamefunc_Toggle_Crosshair); buttonMap.ClearButton(gamefunc_Toggle_Crosshair);
cl_crosshair = !cl_crosshair; cl_crosshair = !cl_crosshair;
} }
if (inputState.BUTTON(gamefunc_Next_Weapon)) if (buttonMap.ButtonDown(gamefunc_Next_Weapon))
{ {
inputState.ClearButton(gamefunc_Next_Weapon); buttonMap.ClearButton(gamefunc_Next_Weapon);
gInput.keyFlags.nextWeapon = 1; gInput.keyFlags.nextWeapon = 1;
} }
if (inputState.BUTTON(gamefunc_Previous_Weapon)) if (buttonMap.ButtonDown(gamefunc_Previous_Weapon))
{ {
inputState.ClearButton(gamefunc_Previous_Weapon); buttonMap.ClearButton(gamefunc_Previous_Weapon);
gInput.keyFlags.prevWeapon = 1; gInput.keyFlags.prevWeapon = 1;
} }
if (inputState.BUTTON(gamefunc_Show_Opponents_Weapon)) if (buttonMap.ButtonDown(gamefunc_Show_Opponents_Weapon))
{ {
inputState.ClearButton(gamefunc_Show_Opponents_Weapon); buttonMap.ClearButton(gamefunc_Show_Opponents_Weapon);
cl_showweapon = (cl_showweapon + 1) & 3; cl_showweapon = (cl_showweapon + 1) & 3;
} }
if (inputState.BUTTON(gamefunc_Jump)) if (buttonMap.ButtonDown(gamefunc_Jump))
gInput.buttonFlags.jump = 1; gInput.buttonFlags.jump = 1;
if (inputState.BUTTON(gamefunc_Crouch)) if (buttonMap.ButtonDown(gamefunc_Crouch))
gInput.buttonFlags.crouch = 1; gInput.buttonFlags.crouch = 1;
if (inputState.BUTTON(gamefunc_Fire)) if (buttonMap.ButtonDown(gamefunc_Fire))
gInput.buttonFlags.shoot = 1; gInput.buttonFlags.shoot = 1;
if (inputState.BUTTON(gamefunc_Alt_Fire)) if (buttonMap.ButtonDown(gamefunc_Alt_Fire))
gInput.buttonFlags.shoot2 = 1; gInput.buttonFlags.shoot2 = 1;
if (inputState.BUTTON(gamefunc_Open)) if (buttonMap.ButtonDown(gamefunc_Open))
{ {
inputState.ClearButton(gamefunc_Open); buttonMap.ClearButton(gamefunc_Open);
gInput.keyFlags.action = 1; gInput.keyFlags.action = 1;
} }
gInput.buttonFlags.lookUp = inputState.BUTTON(gamefunc_Look_Up); gInput.buttonFlags.lookUp = buttonMap.ButtonDown(gamefunc_Look_Up);
gInput.buttonFlags.lookDown = inputState.BUTTON(gamefunc_Look_Down); gInput.buttonFlags.lookDown = buttonMap.ButtonDown(gamefunc_Look_Down);
if (gInput.buttonFlags.lookUp || gInput.buttonFlags.lookDown) if (gInput.buttonFlags.lookUp || gInput.buttonFlags.lookDown)
gInput.keyFlags.lookCenter = 1; gInput.keyFlags.lookCenter = 1;
else else
{ {
gInput.buttonFlags.lookUp = inputState.BUTTON(gamefunc_Aim_Up); gInput.buttonFlags.lookUp = buttonMap.ButtonDown(gamefunc_Aim_Up);
gInput.buttonFlags.lookDown = inputState.BUTTON(gamefunc_Aim_Down); gInput.buttonFlags.lookDown = buttonMap.ButtonDown(gamefunc_Aim_Down);
} }
if (inputState.BUTTON(gamefunc_Aim_Center)) if (buttonMap.ButtonDown(gamefunc_Aim_Center))
{ {
inputState.ClearButton(gamefunc_Aim_Center); buttonMap.ClearButton(gamefunc_Aim_Center);
gInput.keyFlags.lookCenter = 1; gInput.keyFlags.lookCenter = 1;
} }
gInput.keyFlags.spin180 = inputState.BUTTON(gamefunc_Turn_Around); gInput.keyFlags.spin180 = buttonMap.ButtonDown(gamefunc_Turn_Around);
if (inputState.BUTTON(gamefunc_Inventory_Left)) if (buttonMap.ButtonDown(gamefunc_Inventory_Left))
{ {
inputState.ClearButton(gamefunc_Inventory_Left); buttonMap.ClearButton(gamefunc_Inventory_Left);
gInput.keyFlags.prevItem = 1; gInput.keyFlags.prevItem = 1;
} }
if (inputState.BUTTON(gamefunc_Inventory_Right)) if (buttonMap.ButtonDown(gamefunc_Inventory_Right))
{ {
inputState.ClearButton(gamefunc_Inventory_Right); buttonMap.ClearButton(gamefunc_Inventory_Right);
gInput.keyFlags.nextItem = 1; gInput.keyFlags.nextItem = 1;
} }
if (inputState.BUTTON(gamefunc_Inventory_Use)) if (buttonMap.ButtonDown(gamefunc_Inventory_Use))
{ {
inputState.ClearButton(gamefunc_Inventory_Use); buttonMap.ClearButton(gamefunc_Inventory_Use);
gInput.keyFlags.useItem = 1; gInput.keyFlags.useItem = 1;
} }
if (inputState.BUTTON(gamefunc_BeastVision)) if (buttonMap.ButtonDown(gamefunc_BeastVision))
{ {
inputState.ClearButton(gamefunc_BeastVision); buttonMap.ClearButton(gamefunc_BeastVision);
gInput.useFlags.useBeastVision = 1; gInput.useFlags.useBeastVision = 1;
} }
if (inputState.BUTTON(gamefunc_CrystalBall)) if (buttonMap.ButtonDown(gamefunc_CrystalBall))
{ {
inputState.ClearButton(gamefunc_CrystalBall); buttonMap.ClearButton(gamefunc_CrystalBall);
gInput.useFlags.useCrystalBall = 1; gInput.useFlags.useCrystalBall = 1;
} }
if (inputState.BUTTON(gamefunc_JumpBoots)) if (buttonMap.ButtonDown(gamefunc_JumpBoots))
{ {
inputState.ClearButton(gamefunc_JumpBoots); buttonMap.ClearButton(gamefunc_JumpBoots);
gInput.useFlags.useJumpBoots = 1; gInput.useFlags.useJumpBoots = 1;
} }
if (inputState.BUTTON(gamefunc_MedKit)) if (buttonMap.ButtonDown(gamefunc_MedKit))
{ {
inputState.ClearButton(gamefunc_MedKit); buttonMap.ClearButton(gamefunc_MedKit);
gInput.useFlags.useMedKit = 1; gInput.useFlags.useMedKit = 1;
} }
for (int i = 0; i < 10; i++) for (int i = 0; i < 10; i++)
{ {
if (inputState.BUTTON(gamefunc_Weapon_1 + i)) if (buttonMap.ButtonDown(gamefunc_Weapon_1 + i))
{ {
inputState.ClearButton(gamefunc_Weapon_1 + i); buttonMap.ClearButton(gamefunc_Weapon_1 + i);
gInput.newWeapon = 1 + i; gInput.newWeapon = 1 + i;
} }
} }
if (inputState.BUTTON(gamefunc_ProximityBombs)) if (buttonMap.ButtonDown(gamefunc_ProximityBombs))
{ {
inputState.ClearButton(gamefunc_ProximityBombs); buttonMap.ClearButton(gamefunc_ProximityBombs);
gInput.newWeapon = 11; gInput.newWeapon = 11;
} }
if (inputState.BUTTON(gamefunc_RemoteBombs)) if (buttonMap.ButtonDown(gamefunc_RemoteBombs))
{ {
inputState.ClearButton(gamefunc_RemoteBombs); buttonMap.ClearButton(gamefunc_RemoteBombs);
gInput.newWeapon = 12; gInput.newWeapon = 12;
} }
if (inputState.BUTTON(gamefunc_Holster_Weapon)) if (buttonMap.ButtonDown(gamefunc_Holster_Weapon))
{ {
inputState.ClearButton(gamefunc_Holster_Weapon); buttonMap.ClearButton(gamefunc_Holster_Weapon);
gInput.keyFlags.holsterWeapon = 1; gInput.keyFlags.holsterWeapon = 1;
} }
char run = G_CheckAutorun(inputState.BUTTON(gamefunc_Run)); char run = G_CheckAutorun(buttonMap.ButtonDown(gamefunc_Run));
char run2 = false; // What??? inputState.BUTTON(gamefunc_Run); char run2 = false; // What??? buttonMap.ButtonDown(gamefunc_Run);
gInput.syncFlags.run = run; gInput.syncFlags.run = run;
if (inputState.BUTTON(gamefunc_Move_Forward)) if (buttonMap.ButtonDown(gamefunc_Move_Forward))
forward += (1+run)<<10; forward += (1+run)<<10;
if (inputState.BUTTON(gamefunc_Move_Backward)) if (buttonMap.ButtonDown(gamefunc_Move_Backward))
forward -= (1+run)<<10; forward -= (1+run)<<10;
char turnLeft = 0, turnRight = 0; char turnLeft = 0, turnRight = 0;
if (inputState.BUTTON(gamefunc_Strafe)) if (buttonMap.ButtonDown(gamefunc_Strafe))
{ {
if (inputState.BUTTON(gamefunc_Turn_Left)) if (buttonMap.ButtonDown(gamefunc_Turn_Left))
strafe += (1 + run) << 10; strafe += (1 + run) << 10;
if (inputState.BUTTON(gamefunc_Turn_Right)) if (buttonMap.ButtonDown(gamefunc_Turn_Right))
strafe -= (1 + run) << 10; strafe -= (1 + run) << 10;
} }
else else
{ {
if (inputState.BUTTON(gamefunc_Strafe_Left)) if (buttonMap.ButtonDown(gamefunc_Strafe_Left))
strafe += (1 + run) << 10; strafe += (1 + run) << 10;
if (inputState.BUTTON(gamefunc_Strafe_Right)) if (buttonMap.ButtonDown(gamefunc_Strafe_Right))
strafe -= (1 + run) << 10; strafe -= (1 + run) << 10;
if (inputState.BUTTON(gamefunc_Turn_Left)) if (buttonMap.ButtonDown(gamefunc_Turn_Left))
turnLeft = 1; turnLeft = 1;
if (inputState.BUTTON(gamefunc_Turn_Right)) if (buttonMap.ButtonDown(gamefunc_Turn_Right))
turnRight = 1; turnRight = 1;
} }
@ -408,7 +408,7 @@ void ctrlGetInput(void)
if ((run2 || run) && iTurnCount > 24) if ((run2 || run) && iTurnCount > 24)
turn <<= 1; turn <<= 1;
if (inputState.BUTTON(gamefunc_Strafe)) if (buttonMap.ButtonDown(gamefunc_Strafe))
strafe = ClipRange(strafe - info.mousex, -2048, 2048); strafe = ClipRange(strafe - info.mousex, -2048, 2048);
else else
turn = fix16_clamp(turn + fix16_div(fix16_from_int(info.mousex), F16(32)), F16(-1024)>>2, F16(1024)>>2); turn = fix16_clamp(turn + fix16_div(fix16_from_int(info.mousex), F16(32)), F16(-1024)>>2, F16(1024)>>2);

View file

@ -1128,9 +1128,9 @@ void CGameMenuItemKeyList::Draw(void)
bool bClick = false; bool bClick = false;
for (int i = 0; i < nRows; i++, y += height, k++) for (int i = 0; i < nRows; i++, y += height, k++)
{ {
auto keys = Bindings.GetKeysForCommand(CONFIG_FunctionNumToName(k)); auto keys = Bindings.GetKeysForCommand(buttonMap.GetButtonName(k));
FString text = C_NameKeys(keys.Data(), std::min(keys.Size(), 2u)); FString text = C_NameKeys(keys.Data(), std::min(keys.Size(), 2u));
sprintf(buffer, "%s", CONFIG_FunctionNumToName(k)); sprintf(buffer, "%s", buttonMap.GetButtonName(k));
if (k == nFocus) if (k == nFocus)
{ {
@ -1192,7 +1192,7 @@ bool CGameMenuItemKeyList::Event(CGameMenuEvent &event)
if (inputState.keyBufferWaiting()) if (inputState.keyBufferWaiting())
inputState.keyGetChar(); inputState.keyGetChar();
Bindings.SetBind(inputState.GetLastScanCode(), CONFIG_FunctionNumToName(nFocus)); Bindings.SetBind(inputState.GetLastScanCode(), buttonMap.GetButtonName(nFocus));
inputState.keyFlushChars(); inputState.keyFlushChars();
inputState.keyFlushScans(); inputState.keyFlushScans();
inputState.ClearKeysDown(); inputState.ClearKeysDown();
@ -1231,7 +1231,7 @@ bool CGameMenuItemKeyList::Event(CGameMenuEvent &event)
return false; return false;
case kMenuEventBackSpace: case kMenuEventBackSpace:
case kMenuEventDelete: case kMenuEventDelete:
Bindings.UnbindACommand(CONFIG_FunctionNumToName(nFocus)); Bindings.UnbindACommand(buttonMap.GetButtonName(nFocus));
return false; return false;
case kMenuEventScrollUp: case kMenuEventScrollUp:
if (nFocus-nTopDelta > 0) if (nFocus-nTopDelta > 0)

View file

@ -1314,7 +1314,7 @@ void SetupMenus(void)
int k = 1; int k = 1;
for (int i = 0; i < NUMGAMEFUNCTIONS; ++i) for (int i = 0; i < NUMGAMEFUNCTIONS; ++i)
{ {
MenuGameFuncs[i] = CONFIG_FunctionNumToName(i); MenuGameFuncs[i] = buttonMap.GetButtonName(i);
MenuGameFuncs[i].Substitute('_', ' '); MenuGameFuncs[i].Substitute('_', ' ');
if (MenuGameFuncs[i][0] != '\0') if (MenuGameFuncs[i][0] != '\0')
@ -1987,19 +1987,7 @@ void SetMouseButton(CGameMenuItemZCycle *pItem)
void SetupMouseButtonMenu(CGameMenuItemChain *pItem) void SetupMouseButtonMenu(CGameMenuItemChain *pItem)
{ {
UNREFERENCED_PARAMETER(pItem); UNREFERENCED_PARAMETER(pItem);
for (int i = 0; i < MENUMOUSEFUNCTIONS; i++) // This functionality no longer exists as a separate item.
{
auto pItem = pItemOptionsControlMouseButton[i];
pItem->m_nFocus = 0;
for (int j = 0; j < NUMGAMEFUNCTIONS+1; j++)
{
if (MouseFunctions[MenuMouseDataIndex[i][0]][MenuMouseDataIndex[i][1]] == nGamefuncsValues[j])
{
pItem->m_nFocus = j;
break;
}
}
}
} }
void SetupNetworkMenu(void) void SetupNetworkMenu(void)

View file

@ -50,7 +50,7 @@ CCheatMgr gCheatMgr;
void sub_5A928(void) void sub_5A928(void)
{ {
for (int i = 0; i < NUMGAMEFUNCTIONS-1; i++) for (int i = 0; i < NUMGAMEFUNCTIONS-1; i++)
inputState.ClearButton(i); buttonMap.ClearButton(i);
} }
void sub_5A944(int key) void sub_5A944(int key)
@ -608,7 +608,7 @@ void CPlayerMsg::ProcessKeys(void)
case sc_F8: case sc_F8:
case sc_F9: case sc_F9:
case sc_F10: case sc_F10:
inputState.ClearButton(gamefunc_See_Chase_View); buttonMap.ClearButton(gamefunc_See_Chase_View);
Set(*CombatMacros[key-sc_F1]); Set(*CombatMacros[key-sc_F1]);
Send(); Send();
inputState.ClearKeyStatus(key); inputState.ClearKeyStatus(key);

View file

@ -38,6 +38,7 @@
#include "keydef.h" #include "keydef.h"
#include "c_commandline.h" #include "c_commandline.h"
#include "c_bind.h" #include "c_bind.h"
#include "c_dispatch.h"
//#include "g_level.h" //#include "g_level.h"
//#include "hu_stuff.h" //#include "hu_stuff.h"
#include "configfile.h" #include "configfile.h"
@ -803,21 +804,3 @@ bool C_DoKey (event_t *ev, FKeyBindings *binds, FKeyBindings *doublebinds)
} }
return false; return false;
} }
#include "osd.h"
void AddCommandString(const char* copy, int keynum)
{
// For the time being this still needs a bit of glue code to work as expected.
if (*copy == '+')
{
auto num = CONFIG_FunctionNameToNum(copy + 1);
if (num >= 0) inputState.UpdateButton(num, true);
}
else if (*copy == '-')
{
auto num = CONFIG_FunctionNameToNum(copy + 1);
if (num >= 0) inputState.UpdateButton(num, false);
}
else OSD_Dispatch(copy);
}

View file

@ -0,0 +1,351 @@
/*
** c_dispatch.cpp
** Functions for executing console commands and aliases
**
**---------------------------------------------------------------------------
** Copyright 1998-2007 Randy Heit
** Copyright 2019 Christoph Oelckers
** All rights reserved.
**
** Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions
** are met:
**
** 1. Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** 2. Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in the
** documentation and/or other materials provided with the distribution.
** 3. The name of the author may not be used to endorse or promote products
** derived from this software without specific prior written permission.
**
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**---------------------------------------------------------------------------
**
*/
#include "c_buttons.h"
#include "printf.h"
#include "cmdlib.h"
#include "c_dispatch.h"
ButtonMap buttonMap;
struct ButtonDesc
{
int index;
const char *name;
};
static const ButtonDesc gamefuncs[] = {
{ gamefunc_Move_Forward, "Move_Forward"},
{ gamefunc_Move_Backward, "Move_Backward"},
{ gamefunc_Turn_Left, "Turn_Left"},
{ gamefunc_Turn_Right, "Turn_Right"},
{ gamefunc_Strafe, "Strafe"},
{ gamefunc_Fire, "Fire"},
{ gamefunc_Open, "Open"},
{ gamefunc_Run, "Run"},
{ gamefunc_Alt_Fire, "Alt_Fire"},
{ gamefunc_Jump, "Jump"},
{ gamefunc_Crouch, "Crouch"},
{ gamefunc_Look_Up, "Look_Up"},
{ gamefunc_Look_Down, "Look_Down"},
{ gamefunc_Look_Left, "Look_Left"},
{ gamefunc_Look_Right, "Look_Right"},
{ gamefunc_Strafe_Left, "Strafe_Left"},
{ gamefunc_Strafe_Right, "Strafe_Right"},
{ gamefunc_Aim_Up, "Aim_Up"},
{ gamefunc_Aim_Down, "Aim_Down"},
{ gamefunc_Weapon_1, "Weapon_1"},
{ gamefunc_Weapon_2, "Weapon_2"},
{ gamefunc_Weapon_3, "Weapon_3"},
{ gamefunc_Weapon_4, "Weapon_4"},
{ gamefunc_Weapon_5, "Weapon_5"},
{ gamefunc_Weapon_6, "Weapon_6"},
{ gamefunc_Weapon_7, "Weapon_7"},
{ gamefunc_Weapon_8, "Weapon_8"},
{ gamefunc_Weapon_9, "Weapon_9"},
{ gamefunc_Weapon_10, "Weapon_10"},
{ gamefunc_Inventory, "Inventory"},
{ gamefunc_Inventory_Left, "Inventory_Left"},
{ gamefunc_Inventory_Right, "Inventory_Right"},
{ gamefunc_Holo_Duke, "Holo_Duke"},
{ gamefunc_Jetpack, "Jetpack"},
{ gamefunc_NightVision, "NightVision"},
{ gamefunc_MedKit, "MedKit"},
{ gamefunc_TurnAround, "TurnAround"},
{ gamefunc_SendMessage, "SendMessage"},
{ gamefunc_Map, "Map"},
{ gamefunc_Shrink_Screen, "Shrink_Screen"},
{ gamefunc_Enlarge_Screen, "Enlarge_Screen"},
{ gamefunc_Center_View, "Center_View"},
{ gamefunc_Holster_Weapon, "Holster_Weapon"},
{ gamefunc_Show_Opponents_Weapon, "Show_Opponents_Weapon"},
{ gamefunc_Map_Follow_Mode, "Map_Follow_Mode"},
{ gamefunc_See_Coop_View, "See_Coop_View"},
{ gamefunc_Mouse_Aiming, "Mouse_Aiming"},
{ gamefunc_Toggle_Crosshair, "Toggle_Crosshair"},
{ gamefunc_Steroids, "Steroids"},
{ gamefunc_Quick_Kick, "Quick_Kick"},
{ gamefunc_Next_Weapon, "Next_Weapon"},
{ gamefunc_Previous_Weapon, "Previous_Weapon"},
{ gamefunc_Show_Console, "Show_Console"},
{ gamefunc_Show_DukeMatch_Scores, "Show_DukeMatch_Scores"},
{ gamefunc_Dpad_Select, "Dpad_Select"},
{ gamefunc_Dpad_Aiming, "Dpad_Aiming"},
{ gamefunc_AutoRun, "AutoRun"},
{ gamefunc_Last_Weapon, "Last_Used_Weapon"},
{ gamefunc_Quick_Save, "Quick_Save"},
{ gamefunc_Quick_Load, "Quick_Load"},
{ gamefunc_Alt_Weapon, "Alt_Weapon"},
{ gamefunc_Third_Person_View, "Third_Person_View"},
{ gamefunc_Toggle_Crouch, "Toggle_Crouch"},
{ gamefunc_See_Chase_View, "See_Chase_View"}, // the following were added by Blood
{ gamefunc_Turn_Around, "Turn_Around"},
{ gamefunc_Aim_Center, "Aim_Center"},
{ gamefunc_Tilt_Left, "Tilt_Left"},
{ gamefunc_Tilt_Right, "Tilt_Right"},
{ gamefunc_Send_Message, "Send_Message"},
{ gamefunc_BeastVision, "BeastVision"},
{ gamefunc_CrystalBall, "CrystalBall"},
{ gamefunc_JumpBoots, "JumpBoots"},
{ gamefunc_ProximityBombs, "ProximityBombs"},
{ gamefunc_RemoteBombs, "RemoteBombs"},
{ gamefunc_Smoke_Bomb, "Smoke_Bomb" },
{ gamefunc_Gas_Bomb, "Gas_Bomb" },
{ gamefunc_Flash_Bomb, "Flash_Bomb" },
{ gamefunc_Caltrops, "Calitrops" },
};
//=============================================================================
//
//
//
//=============================================================================
ButtonMap::ButtonMap()
{
for(auto &gf : gamefuncs)
{
NameToNum.Insert(gf.name, gf.index);
NumToAlias[gf.index] = NumToName[gf.index] = gf.name;
}
}
//=============================================================================
//
//
//
//=============================================================================
int ButtonMap::ListActionCommands (const char *pattern)
{
char matcher[32];
int count = 0;
for (int i = 0; i < NumButtons(); i++)
{
if (NumToAlias[i].IsEmpty()) continue; // do not list buttons that were removed from the alias list
if (pattern == NULL || CheckWildcards (pattern,
(snprintf (matcher, countof(matcher), "+%s", NumToName[i].GetChars()), matcher)))
{
Printf ("+%s\n", NumToName[i]);
count++;
}
if (pattern == NULL || CheckWildcards (pattern,
(snprintf (matcher, countof(matcher), "-%s", NumToName[i].GetChars()), matcher)))
{
Printf ("-%s\n", NumToName[i]);
count++;
}
}
return count;
}
//=============================================================================
//
//
//
//=============================================================================
int ButtonMap::FindButtonIndex (const char *key) const
{
if (!key) return -1;
FName name(key, true);
if (name == NAME_None) return -1;
auto res = NameToNum.CheckKey(name);
if (!res) return -1;
return *res;
}
//=============================================================================
//
//
//
//=============================================================================
void ButtonMap::ResetButtonTriggers ()
{
for (auto &button : Buttons)
{
button.ResetTriggers ();
}
}
//=============================================================================
//
//
//
//=============================================================================
void ButtonMap::ResetButtonStates ()
{
for (auto &button : Buttons)
{
button.ReleaseKey (0);
button.ResetTriggers ();
}
}
//=============================================================================
//
//
//
//=============================================================================
void ButtonMap::SetButtonAlias(int num, const char *text)
{
if ((unsigned)num >= (unsigned)NUMGAMEFUNCTIONS)
return;
NumToAlias[num] = text;
NameToNum.Insert(text, num);
}
//=============================================================================
//
//
//
//=============================================================================
void ButtonMap::ClearButtonAlias(int num)
{
if ((unsigned)num >= (unsigned)NUMGAMEFUNCTIONS)
return;
NumToAlias[num] = "";
}
//=============================================================================
//
//
//
//=============================================================================
bool FButtonStatus::PressKey (int keynum)
{
int i, open;
keynum &= KEY_DBLCLICKED-1;
if (keynum == 0)
{ // Issued from console instead of a key, so force on
Keys[0] = 0xffff;
for (i = MAX_KEYS-1; i > 0; --i)
{
Keys[i] = 0;
}
}
else
{
for (i = MAX_KEYS-1, open = -1; i >= 0; --i)
{
if (Keys[i] == 0)
{
open = i;
}
else if (Keys[i] == keynum)
{ // Key is already down; do nothing
return false;
}
}
if (open < 0)
{ // No free key slots, so do nothing
Printf ("More than %u keys pressed for a single action!\n", MAX_KEYS);
return false;
}
Keys[open] = keynum;
}
uint8_t wasdown = bDown;
bDown = bWentDown = true;
// Returns true if this key caused the button to go down.
return !wasdown;
}
//=============================================================================
//
//
//
//=============================================================================
bool FButtonStatus::ReleaseKey (int keynum)
{
int i, numdown, match;
uint8_t wasdown = bDown;
keynum &= KEY_DBLCLICKED-1;
if (keynum == 0)
{ // Issued from console instead of a key, so force off
for (i = MAX_KEYS-1; i >= 0; --i)
{
Keys[i] = 0;
}
bWentUp = true;
bDown = false;
}
else
{
for (i = MAX_KEYS-1, numdown = 0, match = -1; i >= 0; --i)
{
if (Keys[i] != 0)
{
++numdown;
if (Keys[i] == keynum)
{
match = i;
}
}
}
if (match < 0)
{ // Key was not down; do nothing
return false;
}
Keys[match] = 0;
bWentUp = true;
if (--numdown == 0)
{
bDown = false;
}
}
// Returns true if releasing this key caused the button to go up.
return wasdown && !bDown;
}

View file

@ -0,0 +1,182 @@
#pragma once
#include <stdint.h>
#include "tarray.h"
#include "zstring.h"
#include "name.h"
// Order is that of EDuke32 by necessity because it exposes the key binds to scripting by index instead of by name.
enum GameFunction_t
{
gamefunc_Move_Forward,
gamefunc_Move_Backward,
gamefunc_Turn_Left,
gamefunc_Turn_Right,
gamefunc_Strafe,
gamefunc_Fire,
gamefunc_Open,
gamefunc_Run,
gamefunc_Alt_Fire,
gamefunc_Jump,
gamefunc_Crouch,
gamefunc_Look_Up,
gamefunc_Look_Down,
gamefunc_Look_Left,
gamefunc_Look_Right,
gamefunc_Strafe_Left,
gamefunc_Strafe_Right,
gamefunc_Aim_Up,
gamefunc_Aim_Down,
gamefunc_Weapon_1,
gamefunc_Weapon_2,
gamefunc_Weapon_3,
gamefunc_Weapon_4,
gamefunc_Weapon_5,
gamefunc_Weapon_6,
gamefunc_Weapon_7,
gamefunc_Weapon_8,
gamefunc_Weapon_9,
gamefunc_Weapon_10,
gamefunc_Inventory,
gamefunc_Inventory_Use = gamefunc_Inventory,
gamefunc_Inventory_Left,
gamefunc_Inventory_Right,
gamefunc_Holo_Duke,
gamefunc_Jetpack,
gamefunc_NightVision,
gamefunc_Night_Vision = gamefunc_NightVision,
gamefunc_MedKit,
gamefunc_Med_Kit = gamefunc_MedKit,
gamefunc_TurnAround,
gamefunc_SendMessage,
gamefunc_Map,
gamefunc_Map_Toggle = gamefunc_Map,
gamefunc_Shrink_Screen,
gamefunc_Enlarge_Screen,
gamefunc_Center_View,
gamefunc_Holster_Weapon,
gamefunc_Show_Opponents_Weapon,
gamefunc_Map_Follow_Mode,
gamefunc_See_Coop_View,
gamefunc_See_Co_Op_View = gamefunc_See_Coop_View,
gamefunc_Mouse_Aiming,
gamefunc_Toggle_Crosshair,
gamefunc_Steroids,
gamefunc_Quick_Kick,
gamefunc_Next_Weapon,
gamefunc_Previous_Weapon,
gamefunc_Show_Console,
gamefunc_Show_DukeMatch_Scores,
gamefunc_Dpad_Select,
gamefunc_Dpad_Aiming,
gamefunc_AutoRun,
gamefunc_Last_Weapon,
gamefunc_Quick_Save,
gamefunc_Quick_Load,
gamefunc_Alt_Weapon,
gamefunc_Third_Person_View,
gamefunc_Toggle_Crouch,
gamefunc_See_Chase_View, // this was added by Blood
gamefunc_Turn_Around,
gamefunc_Aim_Center,
gamefunc_Tilt_Left,
gamefunc_Tilt_Right,
gamefunc_Send_Message,
gamefunc_BeastVision,
gamefunc_CrystalBall,
gamefunc_JumpBoots,
gamefunc_ProximityBombs,
gamefunc_RemoteBombs,
gamefunc_Smoke_Bomb, // and these by ShadowWarrior (todo: There's quite a bit of potential for consolidation here - is it worth it?)
gamefunc_Gas_Bomb,
gamefunc_Flash_Bomb,
gamefunc_Caltrops,
NUMGAMEFUNCTIONS
};
// Actions
struct FButtonStatus
{
enum { MAX_KEYS = 6 }; // Maximum number of keys that can press this button
uint16_t Keys[MAX_KEYS];
bool bDown; // Button is down right now
bool bWentDown; // Button went down this tic
bool bWentUp; // Button went up this tic
bool PressKey (int keynum); // Returns true if this key caused the button to be pressed.
bool ReleaseKey (int keynum); // Returns true if this key is no longer pressed.
void ResetTriggers () { bWentDown = bWentUp = false; }
void Reset () { bDown = bWentDown = bWentUp = false; }
};
class ButtonMap
{
FButtonStatus Buttons[NUMGAMEFUNCTIONS];
FString NumToName[NUMGAMEFUNCTIONS]; // The internal name of the button
FString NumToAlias[NUMGAMEFUNCTIONS]; // The display name which can be altered by scripts.
TMap<FName, int> NameToNum;
public:
ButtonMap();
constexpr int NumButtons() const
{
return NUMGAMEFUNCTIONS;
}
int FindButtonIndex(const char* func) const;
FButtonStatus *FindButton(const char *func)
{
int index = FindButtonIndex(func);
return index > -1? &Buttons[index] : nullptr;
}
const char* GetButtonName(int32_t func) const
{
if ((unsigned)func >= (unsigned)NumButtons())
return nullptr;
return NumToName[func];
}
const char* GetButtonAlias(int32_t func) const
{
if ((unsigned)func >= (unsigned)NumButtons())
return nullptr;
return NumToAlias[func];
}
void SetButtonAlias(int num, const char* text);
void ClearButtonAlias(int num);
void ResetButtonTriggers (); // Call ResetTriggers for all buttons
void ResetButtonStates (); // Same as above, but also clear bDown
int ListActionCommands(const char* pattern);
bool ButtonDown(int x) const
{
return Buttons[x].bDown;
}
bool ButtonPressed(int x) const
{
return Buttons[x].bWentDown;
}
bool ButtonReleased(int x) const
{
return Buttons[x].bWentUp;
}
void ClearButton(int x)
{
Buttons[x].Reset();
}
};
extern ButtonMap buttonMap;

View file

@ -1,3 +1,4 @@
#pragma once
/* /*
** c_dispatch.h ** c_dispatch.h
** **
@ -31,12 +32,9 @@
** **
*/ */
#ifndef __C_DISPATCH_H__
#define __C_DISPATCH_H__
class FConfigFile; class FConfigFile;
const int KEY_DBLCLICKED = 0x8000;
// Class that can parse command lines // Class that can parse command lines
class FCommandLine class FCommandLine
{ {
@ -56,5 +54,3 @@ private:
bool noescapes; bool noescapes;
}; };
#endif //__C_DISPATCH_H__

View file

@ -41,8 +41,8 @@
#include "c_console.h" #include "c_console.h"
#include "gamecvars.h" #include "gamecvars.h"
//#include "cmdlib.h" #include "cmdlib.h"
//#include "c_dispatch.h" #include "c_dispatch.h"
//#include "g_game.h" //#include "g_game.h"
//#include "d_player.h" //#include "d_player.h"
@ -1419,7 +1419,6 @@ void C_ArchiveCVars (FConfigFile *f, uint32_t filter)
} }
} }
#if 0
EXTERN_CVAR(Bool, sv_cheats); EXTERN_CVAR(Bool, sv_cheats);
void FBaseCVar::CmdSet (const char *newval) void FBaseCVar::CmdSet (const char *newval)
@ -1543,7 +1542,7 @@ void FBaseCVar::ListVars (const char *filter, bool plain)
else else
{ {
++count; ++count;
Printf ("%c%c%c%c%c %s = %s\n", Printf ("%c%c%c %s = %s\n",
flags & CVAR_ARCHIVE ? 'A' : ' ', flags & CVAR_ARCHIVE ? 'A' : ' ',
flags & CVAR_USERINFO ? 'U' : flags & CVAR_USERINFO ? 'U' :
flags & CVAR_SERVERINFO ? 'S' : flags & CVAR_SERVERINFO ? 'S' :
@ -1551,8 +1550,6 @@ void FBaseCVar::ListVars (const char *filter, bool plain)
flags & CVAR_NOSET ? '-' : flags & CVAR_NOSET ? '-' :
flags & CVAR_LATCH ? 'L' : flags & CVAR_LATCH ? 'L' :
flags & CVAR_UNSETTABLE ? '*' : ' ', flags & CVAR_UNSETTABLE ? '*' : ' ',
flags & CVAR_MOD ? 'M' : ' ',
flags & CVAR_IGNORE ? 'X' : ' ',
var->GetName(), var->GetName(),
var->GetHumanString()); var->GetHumanString());
} }
@ -1596,4 +1593,3 @@ CCMD (archivecvar)
} }
} }
} }
#endif

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,146 @@
/*
** c_dispatch.h
**
**---------------------------------------------------------------------------
** Copyright 1998-2006 Randy Heit
** All rights reserved.
**
** Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions
** are met:
**
** 1. Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** 2. Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in the
** documentation and/or other materials provided with the distribution.
** 3. The name of the author may not be used to endorse or promote products
** derived from this software without specific prior written permission.
**
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**---------------------------------------------------------------------------
**
*/
#ifndef __C_DISPATCH_H__
#define __C_DISPATCH_H__
#include "printf.h"
#include "zstring.h"
#include "c_commandline.h"
class FConfigFile;
// Contains the contents of an exec'ed file
struct FExecList
{
TArray<FString> Commands;
void AddCommand(const char *cmd, const char *file = NULL);
void ExecCommands() const;
};
extern bool CheckCheatmode (bool printmsg = true);
FExecList *C_ParseCmdLineParams(FExecList *exec);
// Add commands to the console as if they were typed in. Can handle wait
// and semicolon-separated commands. This function may modify the source
// string, but the string will be restored to its original state before
// returning. Therefore, commands passed must not be in read-only memory.
void AddCommandString (const char *text, int keynum=0);
void C_RunDelayedCommands();
void C_ClearDelayedCommands();
// Process a single console command. Does not handle wait.
void C_DoCommand (const char *cmd, int keynum=0);
FExecList *C_ParseExecFile(const char *file, FExecList *source);
bool C_ExecFile(const char *file);
// Write out alias commands to a file for all current aliases.
void C_ArchiveAliases (FConfigFile *f);
void C_SetAlias (const char *name, const char *cmd);
void C_ClearAliases ();
// build a single string out of multiple strings
FString BuildString (int argc, FString *argv);
typedef void (*CCmdRun) (FCommandLine &argv, void *instigator, int key);
class FConsoleCommand
{
public:
FConsoleCommand (const char *name, CCmdRun RunFunc);
virtual ~FConsoleCommand ();
virtual bool IsAlias ();
void PrintCommand () { Printf ("%s\n", m_Name); }
virtual void Run (FCommandLine &args, void *instigator, int key);
static FConsoleCommand* FindByName (const char* name);
FConsoleCommand *m_Next, **m_Prev;
FString m_Name;
enum { HASH_SIZE = 251 }; // Is this prime?
protected:
FConsoleCommand ();
bool AddToHash (FConsoleCommand **table);
CCmdRun m_RunFunc;
};
#define CCMD(n) \
void Cmd_##n (FCommandLine &, void *, int key); \
FConsoleCommand Cmd_##n##_Ref (#n, Cmd_##n); \
void Cmd_##n (FCommandLine &argv, void *who, int key)
const int KEY_DBLCLICKED = 0x8000;
class FConsoleAlias : public FConsoleCommand
{
public:
FConsoleAlias (const char *name, const char *command, bool noSave);
~FConsoleAlias ();
void Run (FCommandLine &args, void *instigator, int key);
bool IsAlias ();
void PrintAlias ();
void Archive (FConfigFile *f);
void Realias (const char *command, bool noSave);
void SafeDelete ();
protected:
FString m_Command[2]; // Slot 0 is saved to the ini, slot 1 is not.
bool bDoSubstitution;
bool bRunning;
bool bKill;
};
class FUnsafeConsoleAlias : public FConsoleAlias
{
public:
FUnsafeConsoleAlias (const char *name, const char *command)
: FConsoleAlias (name, command, true)
{
}
virtual void Run (FCommandLine &args, void *instigator, int key) override;
};
void execLogfile(const char *fn, bool append = false);
#endif //__C_DISPATCH_H__

View file

@ -24,123 +24,13 @@ int ShowStartupWindow(TArray<GrpEntry> &);
void InitFileSystem(TArray<GrpEntry>&); void InitFileSystem(TArray<GrpEntry>&);
int globalShadeDiv; int globalShadeDiv;
struct GameFuncNameDesc
{
int index;
const char *name;
};
static const GameFuncNameDesc gamefuncs[] = {
{ gamefunc_Move_Forward, "Move_Forward"},
{ gamefunc_Move_Backward, "Move_Backward"},
{ gamefunc_Turn_Left, "Turn_Left"},
{ gamefunc_Turn_Right, "Turn_Right"},
{ gamefunc_Strafe, "Strafe"},
{ gamefunc_Fire, "Fire"},
{ gamefunc_Open, "Open"},
{ gamefunc_Run, "Run"},
{ gamefunc_Alt_Fire, "Alt_Fire"},
{ gamefunc_Jump, "Jump"},
{ gamefunc_Crouch, "Crouch"},
{ gamefunc_Look_Up, "Look_Up"},
{ gamefunc_Look_Down, "Look_Down"},
{ gamefunc_Look_Left, "Look_Left"},
{ gamefunc_Look_Right, "Look_Right"},
{ gamefunc_Strafe_Left, "Strafe_Left"},
{ gamefunc_Strafe_Right, "Strafe_Right"},
{ gamefunc_Aim_Up, "Aim_Up"},
{ gamefunc_Aim_Down, "Aim_Down"},
{ gamefunc_Weapon_1, "Weapon_1"},
{ gamefunc_Weapon_2, "Weapon_2"},
{ gamefunc_Weapon_3, "Weapon_3"},
{ gamefunc_Weapon_4, "Weapon_4"},
{ gamefunc_Weapon_5, "Weapon_5"},
{ gamefunc_Weapon_6, "Weapon_6"},
{ gamefunc_Weapon_7, "Weapon_7"},
{ gamefunc_Weapon_8, "Weapon_8"},
{ gamefunc_Weapon_9, "Weapon_9"},
{ gamefunc_Weapon_10, "Weapon_10"},
{ gamefunc_Inventory, "Inventory"},
{ gamefunc_Inventory_Left, "Inventory_Left"},
{ gamefunc_Inventory_Right, "Inventory_Right"},
{ gamefunc_Holo_Duke, "Holo_Duke"},
{ gamefunc_Jetpack, "Jetpack"},
{ gamefunc_NightVision, "NightVision"},
{ gamefunc_MedKit, "MedKit"},
{ gamefunc_TurnAround, "TurnAround"},
{ gamefunc_SendMessage, "SendMessage"},
{ gamefunc_Map, "Map"},
{ gamefunc_Shrink_Screen, "Shrink_Screen"},
{ gamefunc_Enlarge_Screen, "Enlarge_Screen"},
{ gamefunc_Center_View, "Center_View"},
{ gamefunc_Holster_Weapon, "Holster_Weapon"},
{ gamefunc_Show_Opponents_Weapon, "Show_Opponents_Weapon"},
{ gamefunc_Map_Follow_Mode, "Map_Follow_Mode"},
{ gamefunc_See_Coop_View, "See_Coop_View"},
{ gamefunc_Mouse_Aiming, "Mouse_Aiming"},
{ gamefunc_Toggle_Crosshair, "Toggle_Crosshair"},
{ gamefunc_Steroids, "Steroids"},
{ gamefunc_Quick_Kick, "Quick_Kick"},
{ gamefunc_Next_Weapon, "Next_Weapon"},
{ gamefunc_Previous_Weapon, "Previous_Weapon"},
{ gamefunc_Show_Console, "Show_Console"},
{ gamefunc_Show_DukeMatch_Scores, "Show_DukeMatch_Scores"},
{ gamefunc_Dpad_Select, "Dpad_Select"},
{ gamefunc_Dpad_Aiming, "Dpad_Aiming"},
{ gamefunc_AutoRun, "AutoRun"},
{ gamefunc_Last_Weapon, "Last_Used_Weapon"},
{ gamefunc_Quick_Save, "Quick_Save"},
{ gamefunc_Quick_Load, "Quick_Load"},
{ gamefunc_Alt_Weapon, "Alt_Weapon"},
{ gamefunc_Third_Person_View, "Third_Person_View"},
{ gamefunc_Toggle_Crouch, "Toggle_Crouch"},
{ gamefunc_See_Chase_View, "See_Chase_View"}, // the following were added by Blood
{ gamefunc_Turn_Around, "Turn_Around"},
{ gamefunc_Aim_Center, "Aim_Center"},
{ gamefunc_Tilt_Left, "Tilt_Left"},
{ gamefunc_Tilt_Right, "Tilt_Right"},
{ gamefunc_Send_Message, "Send_Message"},
{ gamefunc_BeastVision, "BeastVision"},
{ gamefunc_CrystalBall, "CrystalBall"},
{ gamefunc_JumpBoots, "JumpBoots"},
{ gamefunc_ProximityBombs, "ProximityBombs"},
{ gamefunc_RemoteBombs, "RemoteBombs"},
{ gamefunc_Smoke_Bomb, "Smoke_Bomb" },
{ gamefunc_Gas_Bomb, "Gas_Bomb" },
{ gamefunc_Flash_Bomb, "Flash_Bomb" },
{ gamefunc_Caltrops, "Calitrops" },
};
FString currentGame; FString currentGame;
FString LumpFilter; FString LumpFilter;
static TMap<FName, int> GF_NameToNum;
static FString GF_NumToName[NUMGAMEFUNCTIONS]; // This one will preserve the original name for writing to the config (which must be loaded before CON scripts can hack around with the alias array.)
static FString GF_NumToAlias[NUMGAMEFUNCTIONS]; // This is for CON scripts to hack apart.
uint8_t KeyboardKeys[NUMGAMEFUNCTIONS][2];
CVAR(Int, cl_defaultconfiguration, 2, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) CVAR(Int, cl_defaultconfiguration, 2, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
//==========================================================================
//
//
//
//==========================================================================
void SetupButtonFunctions()
{
unsigned index = 0;
for (auto& func : GF_NumToAlias)
{
if (func[0] == '\0')
continue;
}
}
UserConfig userConfig; UserConfig userConfig;
@ -435,22 +325,13 @@ int CONFIG_Init()
CheckFrontend(g_gameType); CheckFrontend(g_gameType);
int index = 0; int index = 0;
for(auto &gf : gamefuncs)
{
GF_NameToNum.Insert(gf.name, gf.index);
GF_NumToAlias[gf.index] = GF_NumToName[gf.index] = gf.name;
index += 2;
}
InitFileSystem(usedgroups); InitFileSystem(usedgroups);
CONTROL_ClearAssignments(); CONTROL_ClearAssignments();
CONFIG_InitMouseAndController(); CONFIG_InitMouseAndController();
CONFIG_SetGameControllerDefaultsStandard(); CONFIG_SetGameControllerDefaultsStandard();
CONFIG_SetDefaultKeys(cl_defaultconfiguration == 1 ? "demolition/origbinds.txt" : cl_defaultconfiguration == 2 ? "demolition/leftbinds.txt" : "demolition/defbinds.txt"); CONFIG_SetDefaultKeys(cl_defaultconfiguration == 1 ? "demolition/origbinds.txt" : cl_defaultconfiguration == 2 ? "demolition/leftbinds.txt" : "demolition/defbinds.txt");
SetupButtonFunctions();
G_ReadConfig(currentGame); G_ReadConfig(currentGame);
if (!GameConfig->IsInitialized()) if (!GameConfig->IsInitialized())
{ {
@ -467,54 +348,6 @@ int CONFIG_Init()
return gi->app_main(); return gi->app_main();
} }
//==========================================================================
//
//
//
//==========================================================================
int32_t CONFIG_FunctionNameToNum(const char *func)
{
if (!func) return -1;
FName name(func, true);
if (name == NAME_None) return -1;
auto res = GF_NameToNum.CheckKey(name);
if (!res) return -1;
return *res;
}
const char *CONFIG_FunctionNumToName(int32_t func)
{
if ((unsigned)func >= (unsigned)NUMGAMEFUNCTIONS)
return NULL;
return GF_NumToAlias[func];
}
const char *CONFIG_FunctionNumToRealName(int32_t func)
{
if ((unsigned)func >= (unsigned)NUMGAMEFUNCTIONS)
return NULL;
return GF_NumToName[func];
}
void CONFIG_ReplaceButtonName(int num, const char *text)
{
if ((unsigned)num >= (unsigned)NUMGAMEFUNCTIONS)
return;
GF_NumToAlias[num] = text;
GF_NameToNum.Insert(text, num);
}
void CONFIG_DeleteButtonName(int num)
{
if ((unsigned)num >= (unsigned)NUMGAMEFUNCTIONS)
return;
GF_NumToAlias[num] = "";
}
//========================================================================== //==========================================================================
// //
// //
@ -586,7 +419,6 @@ int CONFIG_SetMapBestTime(uint8_t const* const mapmd4, int32_t tm)
// //
//========================================================================== //==========================================================================
int32_t MouseFunctions[MAXMOUSEBUTTONS][2];
int32_t MouseDigitalFunctions[MAXMOUSEAXES][2]; int32_t MouseDigitalFunctions[MAXMOUSEAXES][2];
int32_t MouseAnalogueAxes[MAXMOUSEAXES]; int32_t MouseAnalogueAxes[MAXMOUSEAXES];
int32_t MouseAnalogueScale[MAXMOUSEAXES]; int32_t MouseAnalogueScale[MAXMOUSEAXES];
@ -756,19 +588,6 @@ void CONFIG_SetupMouse(void)
FString section = currentGame + ".MouseSettings"; FString section = currentGame + ".MouseSettings";
if (!GameConfig->SetSection(section)) return; if (!GameConfig->SetSection(section)) return;
for (int i = 0; i < MAXMOUSEBUTTONS; i++)
{
section.Format("MouseButton%d", i);
val = GameConfig->GetValueForKey(section);
if (val)
MouseFunctions[i][0] = CONFIG_FunctionNameToNum(val);
section.Format("MouseButtonClicked%d", i);
val = GameConfig->GetValueForKey(section);
if (val)
MouseFunctions[i][1] = CONFIG_FunctionNameToNum(val);
}
// map over the axes // map over the axes
for (int i = 0; i < MAXMOUSEAXES; i++) for (int i = 0; i < MAXMOUSEAXES; i++)
{ {
@ -780,12 +599,12 @@ void CONFIG_SetupMouse(void)
section.Format("MouseDigitalAxes%d_0", i); section.Format("MouseDigitalAxes%d_0", i);
val = GameConfig->GetValueForKey(section); val = GameConfig->GetValueForKey(section);
if (val) if (val)
MouseDigitalFunctions[i][0] = CONFIG_FunctionNameToNum(val); MouseDigitalFunctions[i][0] = buttonMap.FindButtonIndex(val);
section.Format("MouseDigitalAxes%d_1", i); section.Format("MouseDigitalAxes%d_1", i);
val = GameConfig->GetValueForKey(section); val = GameConfig->GetValueForKey(section);
if (val) if (val)
MouseDigitalFunctions[i][1] = CONFIG_FunctionNameToNum(val); MouseDigitalFunctions[i][1] = buttonMap.FindButtonIndex(val);
section.Format("MouseAnalogScale%d", i); section.Format("MouseAnalogScale%d", i);
val = GameConfig->GetValueForKey(section); val = GameConfig->GetValueForKey(section);
@ -793,11 +612,6 @@ void CONFIG_SetupMouse(void)
MouseAnalogueScale[i] = (int32_t)strtoull(val, nullptr, 0); MouseAnalogueScale[i] = (int32_t)strtoull(val, nullptr, 0);
} }
for (int i = 0; i < MAXMOUSEBUTTONS; i++)
{
CONTROL_MapButton(MouseFunctions[i][0], i, 0, controldevice_mouse);
CONTROL_MapButton(MouseFunctions[i][1], i, 1, controldevice_mouse);
}
for (int i = 0; i < MAXMOUSEAXES; i++) for (int i = 0; i < MAXMOUSEAXES; i++)
{ {
CONTROL_MapAnalogAxis(i, MouseAnalogueAxes[i], controldevice_mouse); CONTROL_MapAnalogAxis(i, MouseAnalogueAxes[i], controldevice_mouse);
@ -820,12 +634,12 @@ void CONFIG_SetupJoystick(void)
section.Format("ControllerButton%d", i); section.Format("ControllerButton%d", i);
val = GameConfig->GetValueForKey(section); val = GameConfig->GetValueForKey(section);
if (val) if (val)
JoystickFunctions[i][0] = CONFIG_FunctionNameToNum(val); JoystickFunctions[i][0] = buttonMap.FindButtonIndex(val);
section.Format("ControllerButtonClicked%d", i); section.Format("ControllerButtonClicked%d", i);
val = GameConfig->GetValueForKey(section); val = GameConfig->GetValueForKey(section);
if (val) if (val)
JoystickFunctions[i][1] = CONFIG_FunctionNameToNum(val); JoystickFunctions[i][1] = buttonMap.FindButtonIndex(val);
} }
// map over the axes // map over the axes
@ -839,12 +653,12 @@ void CONFIG_SetupJoystick(void)
section.Format("ControllerDigitalAxes%d_0", i); section.Format("ControllerDigitalAxes%d_0", i);
val = GameConfig->GetValueForKey(section); val = GameConfig->GetValueForKey(section);
if (val) if (val)
JoystickDigitalFunctions[i][0] = CONFIG_FunctionNameToNum(val); JoystickDigitalFunctions[i][0] = buttonMap.FindButtonIndex(val);
section.Format("ControllerDigitalAxes%d_1", i); section.Format("ControllerDigitalAxes%d_1", i);
val = GameConfig->GetValueForKey(section); val = GameConfig->GetValueForKey(section);
if (val) if (val)
JoystickDigitalFunctions[i][1] = CONFIG_FunctionNameToNum(val); JoystickDigitalFunctions[i][1] = buttonMap.FindButtonIndex(val);
section.Format("ControllerAnalogScale%d", i); section.Format("ControllerAnalogScale%d", i);
val = GameConfig->GetValueForKey(section); val = GameConfig->GetValueForKey(section);
@ -1115,7 +929,7 @@ void CONFIG_SetGameControllerDefaultsPro()
FString CONFIG_GetGameFuncOnKeyboard(int gameFunc) FString CONFIG_GetGameFuncOnKeyboard(int gameFunc)
{ {
auto binding = CONFIG_FunctionNumToRealName(gameFunc); auto binding = buttonMap.GetButtonAlias(gameFunc);
auto keys = Bindings.GetKeysForCommand(binding); auto keys = Bindings.GetKeysForCommand(binding);
for(auto key : keys) for(auto key : keys)
{ {
@ -1131,7 +945,7 @@ FString CONFIG_GetGameFuncOnKeyboard(int gameFunc)
FString CONFIG_GetGameFuncOnMouse(int gameFunc) FString CONFIG_GetGameFuncOnMouse(int gameFunc)
{ {
auto binding = CONFIG_FunctionNumToRealName(gameFunc); auto binding = buttonMap.GetButtonAlias(gameFunc);
auto keys = Bindings.GetKeysForCommand(binding); auto keys = Bindings.GetKeysForCommand(binding);
for (auto key : keys) for (auto key : keys)
{ {
@ -1147,7 +961,7 @@ FString CONFIG_GetGameFuncOnMouse(int gameFunc)
char const* CONFIG_GetGameFuncOnJoystick(int gameFunc) char const* CONFIG_GetGameFuncOnJoystick(int gameFunc)
{ {
auto binding = CONFIG_FunctionNumToRealName(gameFunc); auto binding = buttonMap.GetButtonAlias(gameFunc);
auto keys = Bindings.GetKeysForCommand(binding); auto keys = Bindings.GetKeysForCommand(binding);
for (auto key : keys) for (auto key : keys)
{ {
@ -1195,27 +1009,17 @@ FString CONFIG_GetBoundKeyForLastInput(int gameFunc)
void CONFIG_InitMouseAndController() void CONFIG_InitMouseAndController()
{ {
memset(MouseFunctions, -1, sizeof(MouseFunctions));
memset(MouseDigitalFunctions, -1, sizeof(MouseDigitalFunctions)); memset(MouseDigitalFunctions, -1, sizeof(MouseDigitalFunctions));
memset(JoystickFunctions, -1, sizeof(JoystickFunctions)); memset(JoystickFunctions, -1, sizeof(JoystickFunctions));
memset(JoystickDigitalFunctions, -1, sizeof(JoystickDigitalFunctions)); memset(JoystickDigitalFunctions, -1, sizeof(JoystickDigitalFunctions));
for (int i = 0; i < MAXMOUSEBUTTONS; i++)
{
MouseFunctions[i][0] = CONFIG_FunctionNameToNum(mousedefaults[i]);
CONTROL_MapButton(MouseFunctions[i][0], i, 0, controldevice_mouse);
if (i >= 4) continue;
MouseFunctions[i][1] = CONFIG_FunctionNameToNum(mouseclickeddefaults[i]);
CONTROL_MapButton(MouseFunctions[i][1], i, 1, controldevice_mouse);
}
for (int i = 0; i < MAXMOUSEAXES; i++) for (int i = 0; i < MAXMOUSEAXES; i++)
{ {
MouseAnalogueScale[i] = DEFAULTMOUSEANALOGUESCALE; MouseAnalogueScale[i] = DEFAULTMOUSEANALOGUESCALE;
CONTROL_SetAnalogAxisScale(i, MouseAnalogueScale[i], controldevice_mouse); CONTROL_SetAnalogAxisScale(i, MouseAnalogueScale[i], controldevice_mouse);
MouseDigitalFunctions[i][0] = CONFIG_FunctionNameToNum(mousedigitaldefaults[i * 2]); MouseDigitalFunctions[i][0] = buttonMap.FindButtonIndex(mousedigitaldefaults[i * 2]);
MouseDigitalFunctions[i][1] = CONFIG_FunctionNameToNum(mousedigitaldefaults[i * 2 + 1]); MouseDigitalFunctions[i][1] = buttonMap.FindButtonIndex(mousedigitaldefaults[i * 2 + 1]);
CONTROL_MapDigitalAxis(i, MouseDigitalFunctions[i][0], 0, controldevice_mouse); CONTROL_MapDigitalAxis(i, MouseDigitalFunctions[i][0], 0, controldevice_mouse);
CONTROL_MapDigitalAxis(i, MouseDigitalFunctions[i][1], 1, controldevice_mouse); CONTROL_MapDigitalAxis(i, MouseDigitalFunctions[i][1], 1, controldevice_mouse);
@ -1243,23 +1047,6 @@ void CONFIG_WriteControllerSettings()
{ {
FString section = currentGame + ".MouseSettings"; FString section = currentGame + ".MouseSettings";
GameConfig->SetSection(section); GameConfig->SetSection(section);
for (int i = 0; i < MAXMOUSEBUTTONS; i++)
{
if (CONFIG_FunctionNumToName(MouseFunctions[i][0]))
{
buf.Format("MouseButton%d", i);
GameConfig->SetValueForKey(buf, CONFIG_FunctionNumToName(MouseFunctions[i][0]));
}
if (i >= (MAXMOUSEBUTTONS - 2)) continue;
if (CONFIG_FunctionNumToName(MouseFunctions[i][1]))
{
buf.Format("MouseButtonClicked%d", i);
GameConfig->SetValueForKey(buf, CONFIG_FunctionNumToName(MouseFunctions[i][1]));
}
}
for (int i = 0; i < MAXMOUSEAXES; i++) for (int i = 0; i < MAXMOUSEAXES; i++)
{ {
if (CONFIG_AnalogNumToName(MouseAnalogueAxes[i])) if (CONFIG_AnalogNumToName(MouseAnalogueAxes[i]))
@ -1268,16 +1055,16 @@ void CONFIG_WriteControllerSettings()
GameConfig->SetValueForKey(buf, CONFIG_AnalogNumToName(MouseAnalogueAxes[i])); GameConfig->SetValueForKey(buf, CONFIG_AnalogNumToName(MouseAnalogueAxes[i]));
} }
if (CONFIG_FunctionNumToName(MouseDigitalFunctions[i][0])) if (buttonMap.GetButtonName(MouseDigitalFunctions[i][0]))
{ {
buf.Format("MouseDigitalAxes%d_0", i); buf.Format("MouseDigitalAxes%d_0", i);
GameConfig->SetValueForKey(buf, CONFIG_FunctionNumToName(MouseDigitalFunctions[i][0])); GameConfig->SetValueForKey(buf, buttonMap.GetButtonName(MouseDigitalFunctions[i][0]));
} }
if (CONFIG_FunctionNumToName(MouseDigitalFunctions[i][1])) if (buttonMap.GetButtonName(MouseDigitalFunctions[i][1]))
{ {
buf.Format("MouseDigitalAxes%d_1", i); buf.Format("MouseDigitalAxes%d_1", i);
GameConfig->SetValueForKey(buf, CONFIG_FunctionNumToName(MouseDigitalFunctions[i][1])); GameConfig->SetValueForKey(buf, buttonMap.GetButtonName(MouseDigitalFunctions[i][1]));
} }
buf.Format("MouseAnalogScale%d", i); buf.Format("MouseAnalogScale%d", i);
@ -1291,16 +1078,16 @@ void CONFIG_WriteControllerSettings()
GameConfig->SetSection(section); GameConfig->SetSection(section);
for (int dummy = 0; dummy < MAXJOYBUTTONSANDHATS; dummy++) for (int dummy = 0; dummy < MAXJOYBUTTONSANDHATS; dummy++)
{ {
if (CONFIG_FunctionNumToName(JoystickFunctions[dummy][0])) if (buttonMap.GetButtonName(JoystickFunctions[dummy][0]))
{ {
buf.Format("ControllerButton%d", dummy); buf.Format("ControllerButton%d", dummy);
GameConfig->SetValueForKey(buf, CONFIG_FunctionNumToName(JoystickFunctions[dummy][0])); GameConfig->SetValueForKey(buf, buttonMap.GetButtonName(JoystickFunctions[dummy][0]));
} }
if (CONFIG_FunctionNumToName(JoystickFunctions[dummy][1])) if (buttonMap.GetButtonName(JoystickFunctions[dummy][1]))
{ {
buf.Format("ControllerButtonClicked%d", dummy); buf.Format("ControllerButtonClicked%d", dummy);
GameConfig->SetValueForKey(buf, CONFIG_FunctionNumToName(JoystickFunctions[dummy][1])); GameConfig->SetValueForKey(buf, buttonMap.GetButtonName(JoystickFunctions[dummy][1]));
} }
} }
for (int dummy = 0; dummy < MAXJOYAXES; dummy++) for (int dummy = 0; dummy < MAXJOYAXES; dummy++)
@ -1311,16 +1098,16 @@ void CONFIG_WriteControllerSettings()
GameConfig->SetValueForKey(buf, CONFIG_AnalogNumToName(JoystickAnalogueAxes[dummy])); GameConfig->SetValueForKey(buf, CONFIG_AnalogNumToName(JoystickAnalogueAxes[dummy]));
} }
if (CONFIG_FunctionNumToName(JoystickDigitalFunctions[dummy][0])) if (buttonMap.GetButtonName(JoystickDigitalFunctions[dummy][0]))
{ {
buf.Format("ControllerDigitalAxes%d_0", dummy); buf.Format("ControllerDigitalAxes%d_0", dummy);
GameConfig->SetValueForKey(buf, CONFIG_FunctionNumToName(JoystickDigitalFunctions[dummy][0])); GameConfig->SetValueForKey(buf, buttonMap.GetButtonName(JoystickDigitalFunctions[dummy][0]));
} }
if (CONFIG_FunctionNumToName(JoystickDigitalFunctions[dummy][1])) if (buttonMap.GetButtonName(JoystickDigitalFunctions[dummy][1]))
{ {
buf.Format("ControllerDigitalAxes%d_1", dummy); buf.Format("ControllerDigitalAxes%d_1", dummy);
GameConfig->SetValueForKey(buf, CONFIG_FunctionNumToName(JoystickDigitalFunctions[dummy][1])); GameConfig->SetValueForKey(buf, buttonMap.GetButtonName(JoystickDigitalFunctions[dummy][1]));
} }
buf.Format("ControllerAnalogScale%d", dummy); buf.Format("ControllerAnalogScale%d", dummy);

View file

@ -18,11 +18,6 @@ void D_AddWildFile(TArray<FString>& wadfiles, const char* value);
int CONFIG_Init(); int CONFIG_Init();
void CONFIG_SetDefaultKeys(const char *defbinds); 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);
void CONFIG_ReplaceButtonName(int num, const char* text);
void CONFIG_DeleteButtonName(int num);
// I am not sure if anything below will survive for long... // I am not sure if anything below will survive for long...
@ -39,7 +34,6 @@ void CONFIG_DeleteButtonName(int num);
#define DEFAULTJOYSTICKANALOGUESATURATE 9500 #define DEFAULTJOYSTICKANALOGUESATURATE 9500
extern int32_t MouseFunctions[MAXMOUSEBUTTONS][2];
extern int32_t MouseDigitalFunctions[MAXMOUSEAXES][2]; extern int32_t MouseDigitalFunctions[MAXMOUSEAXES][2];
extern int32_t MouseAnalogueAxes[MAXMOUSEAXES]; extern int32_t MouseAnalogueAxes[MAXMOUSEAXES];
extern int32_t MouseAnalogueScale[MAXMOUSEAXES]; extern int32_t MouseAnalogueScale[MAXMOUSEAXES];

View file

@ -4,6 +4,7 @@
#include "tarray.h" #include "tarray.h"
#include "scancodes.h" #include "scancodes.h"
#include "c_bind.h" #include "c_bind.h"
#include "c_buttons.h"
#include "d_event.h" #include "d_event.h"
#include "osd.h" #include "osd.h"
@ -29,7 +30,6 @@ enum
MAXMOUSEBUTTONS = 10, MAXMOUSEBUTTONS = 10,
}; };
extern int32_t CONTROL_ButtonFlags[NUMKEYS];
extern bool CONTROL_BindsEnabled; extern bool CONTROL_BindsEnabled;
extern vec2_t g_mousePos; extern vec2_t g_mousePos;
@ -40,96 +40,6 @@ extern bool g_mouseInsideWindow;
extern bool g_mouseLockedToWindow; extern bool g_mouseLockedToWindow;
// Order is that of EDuke32 by necessity because it exposes the key binds to scripting by index instead of by name.
enum GameFunction_t
{
gamefunc_Move_Forward,
gamefunc_Move_Backward,
gamefunc_Turn_Left,
gamefunc_Turn_Right,
gamefunc_Strafe,
gamefunc_Fire,
gamefunc_Open,
gamefunc_Run,
gamefunc_Alt_Fire,
gamefunc_Jump,
gamefunc_Crouch,
gamefunc_Look_Up,
gamefunc_Look_Down,
gamefunc_Look_Left,
gamefunc_Look_Right,
gamefunc_Strafe_Left,
gamefunc_Strafe_Right,
gamefunc_Aim_Up,
gamefunc_Aim_Down,
gamefunc_Weapon_1,
gamefunc_Weapon_2,
gamefunc_Weapon_3,
gamefunc_Weapon_4,
gamefunc_Weapon_5,
gamefunc_Weapon_6,
gamefunc_Weapon_7,
gamefunc_Weapon_8,
gamefunc_Weapon_9,
gamefunc_Weapon_10,
gamefunc_Inventory,
gamefunc_Inventory_Use = gamefunc_Inventory,
gamefunc_Inventory_Left,
gamefunc_Inventory_Right,
gamefunc_Holo_Duke,
gamefunc_Jetpack,
gamefunc_NightVision,
gamefunc_Night_Vision = gamefunc_NightVision,
gamefunc_MedKit,
gamefunc_Med_Kit = gamefunc_MedKit,
gamefunc_TurnAround,
gamefunc_SendMessage,
gamefunc_Map,
gamefunc_Map_Toggle = gamefunc_Map,
gamefunc_Shrink_Screen,
gamefunc_Enlarge_Screen,
gamefunc_Center_View,
gamefunc_Holster_Weapon,
gamefunc_Show_Opponents_Weapon,
gamefunc_Map_Follow_Mode,
gamefunc_See_Coop_View,
gamefunc_See_Co_Op_View = gamefunc_See_Coop_View,
gamefunc_Mouse_Aiming,
gamefunc_Toggle_Crosshair,
gamefunc_Steroids,
gamefunc_Quick_Kick,
gamefunc_Next_Weapon,
gamefunc_Previous_Weapon,
gamefunc_Show_Console,
gamefunc_Show_DukeMatch_Scores,
gamefunc_Dpad_Select,
gamefunc_Dpad_Aiming,
gamefunc_AutoRun,
gamefunc_Last_Weapon,
gamefunc_Quick_Save,
gamefunc_Quick_Load,
gamefunc_Alt_Weapon,
gamefunc_Third_Person_View,
gamefunc_Toggle_Crouch,
gamefunc_See_Chase_View, // this was added by Blood
gamefunc_Turn_Around,
gamefunc_Aim_Center,
gamefunc_Tilt_Left,
gamefunc_Tilt_Right,
gamefunc_Send_Message,
gamefunc_BeastVision,
gamefunc_CrystalBall,
gamefunc_JumpBoots,
gamefunc_ProximityBombs,
gamefunc_RemoteBombs,
gamefunc_Smoke_Bomb, // and these by ShadowWarrior (todo: There's quite a bit of potential for consolidation here - is it worth it?)
gamefunc_Gas_Bomb,
gamefunc_Flash_Bomb,
gamefunc_Caltrops,
NUMGAMEFUNCTIONS
};
enum EMouseBits enum EMouseBits
{ {
@ -157,16 +67,7 @@ class InputState
{ {
KEYFIFOSIZ = 64, KEYFIFOSIZ = 64,
}; };
// NOTE: This entire thing is mostly a band-aid to wrap something around MACT so that replacing it with a true event-driven system later
// won't result in a total disaster. None of this is meant to live for long because the input method at use here is fundamentally flawed
// because it does not track what triggered the button.
struct ButtonStateFlags
{
bool ButtonActive; // Button currently reports being active to the client
bool ButtonCleared; // Button has been cleared by the client, i.e. do not set to active until no input for this button is active anymore.
};
ButtonStateFlags ButtonState[NUMGAMEFUNCTIONS];
uint8_t KeyStatus[NUMKEYS]; uint8_t KeyStatus[NUMKEYS];
char g_keyFIFO[KEYFIFOSIZ]; char g_keyFIFO[KEYFIFOSIZ];
@ -182,35 +83,6 @@ class InputState
uint8_t g_mouseClickState; uint8_t g_mouseClickState;
public: public:
bool BUTTON(int x)
{
return ButtonState[x].ButtonActive;
}
// Receive a status update
void UpdateButton(int x, bool set)
{
auto &b = ButtonState[x];
if (!b.ButtonCleared) b.ButtonActive = set;
else if (!set) b.ButtonCleared = false;
}
void ClearButton(int x)
{
ButtonState[x].ButtonActive = false;
//ButtonState[x].ButtonCleared = true;
}
void ClearAllButtons()
{
for (auto & b : ButtonState)
{
b.ButtonActive = false;
//b.ButtonCleared = true;
}
}
uint8_t GetKeyStatus(int key) uint8_t GetKeyStatus(int key)
{ {
return KeyStatus[key]; return KeyStatus[key];

View file

@ -907,10 +907,10 @@ nextdemo_nomenu:
{ {
ControlInfo noshareinfo; ControlInfo noshareinfo;
CONTROL_GetInput(&noshareinfo); CONTROL_GetInput(&noshareinfo);
if (inputState.BUTTON(gamefunc_SendMessage)) if (buttonMap.ButtonDown(gamefunc_SendMessage))
{ {
inputState.keyFlushChars(); inputState.keyFlushChars();
inputState.ClearButton(gamefunc_SendMessage); buttonMap.ClearButton(gamefunc_SendMessage);
g_player[myconnectindex].ps->gm = MODE_TYPE; g_player[myconnectindex].ps->gm = MODE_TYPE;
typebuf[0] = 0; typebuf[0] = 0;
} }

View file

@ -4524,9 +4524,9 @@ void G_HandleLocalKeys(void)
if (!ALT_IS_PRESSED && ud.overhead_on == 0 && (myplayer.gm & MODE_TYPE) == 0) if (!ALT_IS_PRESSED && ud.overhead_on == 0 && (myplayer.gm & MODE_TYPE) == 0)
{ {
if (inputState.BUTTON(gamefunc_Enlarge_Screen)) if (buttonMap.ButtonDown(gamefunc_Enlarge_Screen))
{ {
inputState.ClearButton(gamefunc_Enlarge_Screen); buttonMap.ClearButton(gamefunc_Enlarge_Screen);
if (!SHIFTS_IS_PRESSED) if (!SHIFTS_IS_PRESSED)
{ {
@ -4543,9 +4543,9 @@ void G_HandleLocalKeys(void)
G_UpdateScreenArea(); G_UpdateScreenArea();
} }
if (inputState.BUTTON(gamefunc_Shrink_Screen)) if (buttonMap.ButtonDown(gamefunc_Shrink_Screen))
{ {
inputState.ClearButton(gamefunc_Shrink_Screen); buttonMap.ClearButton(gamefunc_Shrink_Screen);
if (!SHIFTS_IS_PRESSED) if (!SHIFTS_IS_PRESSED)
{ {
@ -4566,31 +4566,31 @@ void G_HandleLocalKeys(void)
if (myplayer.cheat_phase == 1 || (myplayer.gm & (MODE_MENU|MODE_TYPE))) if (myplayer.cheat_phase == 1 || (myplayer.gm & (MODE_MENU|MODE_TYPE)))
return; return;
if (inputState.BUTTON(gamefunc_See_Coop_View) && (GTFLAGS(GAMETYPE_COOPVIEW) || ud.recstat == 2)) if (buttonMap.ButtonDown(gamefunc_See_Coop_View) && (GTFLAGS(GAMETYPE_COOPVIEW) || ud.recstat == 2))
{ {
inputState.ClearButton(gamefunc_See_Coop_View); buttonMap.ClearButton(gamefunc_See_Coop_View);
screenpeek = connectpoint2[screenpeek]; screenpeek = connectpoint2[screenpeek];
if (screenpeek == -1) screenpeek = 0; if (screenpeek == -1) screenpeek = 0;
g_restorePalette = -1; g_restorePalette = -1;
} }
if ((g_netServer || ud.multimode > 1) && inputState.BUTTON(gamefunc_Show_Opponents_Weapon)) if ((g_netServer || ud.multimode > 1) && buttonMap.ButtonDown(gamefunc_Show_Opponents_Weapon))
{ {
inputState.ClearButton(gamefunc_Show_Opponents_Weapon); buttonMap.ClearButton(gamefunc_Show_Opponents_Weapon);
ud.config.ShowWeapons = ud.showweapons = 1-ud.showweapons; ud.config.ShowWeapons = ud.showweapons = 1-ud.showweapons;
P_DoQuote(QUOTE_WEAPON_MODE_OFF-ud.showweapons, &myplayer); P_DoQuote(QUOTE_WEAPON_MODE_OFF-ud.showweapons, &myplayer);
} }
if (inputState.BUTTON(gamefunc_Toggle_Crosshair)) if (buttonMap.ButtonDown(gamefunc_Toggle_Crosshair))
{ {
inputState.ClearButton(gamefunc_Toggle_Crosshair); buttonMap.ClearButton(gamefunc_Toggle_Crosshair);
cl_crosshair = !cl_crosshair; cl_crosshair = !cl_crosshair;
P_DoQuote(QUOTE_CROSSHAIR_OFF-cl_crosshair, &myplayer); P_DoQuote(QUOTE_CROSSHAIR_OFF-cl_crosshair, &myplayer);
} }
if (ud.overhead_on && inputState.BUTTON(gamefunc_Map_Follow_Mode)) if (ud.overhead_on && buttonMap.ButtonDown(gamefunc_Map_Follow_Mode))
{ {
inputState.ClearButton(gamefunc_Map_Follow_Mode); buttonMap.ClearButton(gamefunc_Map_Follow_Mode);
ud.scrollmode = 1-ud.scrollmode; ud.scrollmode = 1-ud.scrollmode;
if (ud.scrollmode) if (ud.scrollmode)
{ {
@ -4739,10 +4739,10 @@ void G_HandleLocalKeys(void)
if (!ALT_IS_PRESSED && !SHIFTS_IS_PRESSED && !WIN_IS_PRESSED) if (!ALT_IS_PRESSED && !SHIFTS_IS_PRESSED && !WIN_IS_PRESSED)
{ {
if ((g_netServer || ud.multimode > 1) && inputState.BUTTON(gamefunc_SendMessage)) if ((g_netServer || ud.multimode > 1) && buttonMap.ButtonDown(gamefunc_SendMessage))
{ {
inputState.keyFlushChars(); inputState.keyFlushChars();
inputState.ClearButton(gamefunc_SendMessage); buttonMap.ClearButton(gamefunc_SendMessage);
myplayer.gm |= MODE_TYPE; myplayer.gm |= MODE_TYPE;
typebuf[0] = 0; typebuf[0] = 0;
} }
@ -4839,9 +4839,9 @@ FAKE_F3:
P_DoQuote(QUOTE_MUSIC, g_player[myconnectindex].ps); P_DoQuote(QUOTE_MUSIC, g_player[myconnectindex].ps);
} }
if ((inputState.BUTTON(gamefunc_Quick_Save) || g_doQuickSave == 1) && (myplayer.gm & MODE_GAME)) if ((buttonMap.ButtonDown(gamefunc_Quick_Save) || g_doQuickSave == 1) && (myplayer.gm & MODE_GAME))
{ {
inputState.ClearButton(gamefunc_Quick_Save); buttonMap.ClearButton(gamefunc_Quick_Save);
g_doQuickSave = 0; g_doQuickSave = 0;
@ -4876,9 +4876,9 @@ FAKE_F3:
} }
} }
if (inputState.BUTTON(gamefunc_Third_Person_View)) if (buttonMap.ButtonDown(gamefunc_Third_Person_View))
{ {
inputState.ClearButton(gamefunc_Third_Person_View); buttonMap.ClearButton(gamefunc_Third_Person_View);
myplayer.over_shoulder_on = !myplayer.over_shoulder_on; myplayer.over_shoulder_on = !myplayer.over_shoulder_on;
@ -4898,9 +4898,9 @@ FAKE_F3:
ud.fta_on = fta; ud.fta_on = fta;
} }
if ((inputState.BUTTON(gamefunc_Quick_Load) || g_doQuickSave == 2) && (myplayer.gm & MODE_GAME)) if ((buttonMap.ButtonDown(gamefunc_Quick_Load) || g_doQuickSave == 2) && (myplayer.gm & MODE_GAME))
{ {
inputState.ClearButton(gamefunc_Quick_Load); buttonMap.ClearButton(gamefunc_Quick_Load);
g_doQuickSave = 0; g_doQuickSave = 0;
@ -4951,10 +4951,10 @@ FAKE_F3:
int const timerOffset = ((int) totalclock - nonsharedtimer); int const timerOffset = ((int) totalclock - nonsharedtimer);
nonsharedtimer += timerOffset; nonsharedtimer += timerOffset;
if (inputState.BUTTON(gamefunc_Enlarge_Screen)) if (buttonMap.ButtonDown(gamefunc_Enlarge_Screen))
myplayer.zoom += mulscale6(timerOffset, max<int>(myplayer.zoom, 256)); myplayer.zoom += mulscale6(timerOffset, max<int>(myplayer.zoom, 256));
if (inputState.BUTTON(gamefunc_Shrink_Screen)) if (buttonMap.ButtonDown(gamefunc_Shrink_Screen))
myplayer.zoom -= mulscale6(timerOffset, max<int>(myplayer.zoom, 256)); myplayer.zoom -= mulscale6(timerOffset, max<int>(myplayer.zoom, 256));
myplayer.zoom = clamp(myplayer.zoom, 48, 2048); myplayer.zoom = clamp(myplayer.zoom, 48, 2048);
@ -4970,16 +4970,16 @@ FAKE_F3:
G_UpdateScreenArea(); G_UpdateScreenArea();
} }
if (inputState.BUTTON(gamefunc_AutoRun)) if (buttonMap.ButtonDown(gamefunc_AutoRun))
{ {
inputState.ClearButton(gamefunc_AutoRun); buttonMap.ClearButton(gamefunc_AutoRun);
cl_autorun= 1-cl_autorun; cl_autorun= 1-cl_autorun;
P_DoQuote(QUOTE_RUN_MODE_OFF + cl_autorun, &myplayer); P_DoQuote(QUOTE_RUN_MODE_OFF + cl_autorun, &myplayer);
} }
if (inputState.BUTTON(gamefunc_Map)) if (buttonMap.ButtonDown(gamefunc_Map))
{ {
inputState.ClearButton(gamefunc_Map); buttonMap.ClearButton(gamefunc_Map);
if (ud.last_overhead != ud.overhead_on && ud.last_overhead) if (ud.last_overhead != ud.overhead_on && ud.last_overhead)
{ {
ud.overhead_on = ud.last_overhead; ud.overhead_on = ud.last_overhead;

View file

@ -2198,7 +2198,7 @@ void C_InitQuotes(void)
apStrings[QUOTE_DEAD] = 0; apStrings[QUOTE_DEAD] = 0;
#else #else
// WTF ?!? // WTF ?!?
char const * const OpenGameFunc = CONFIG_FunctionNumToName(gamefunc_Open); char const * const OpenGameFunc = buttonMap.GetButtonName(gamefunc_Open);
C_ReplaceQuoteSubstring(QUOTE_DEAD, "SPACE", OpenGameFunc); C_ReplaceQuoteSubstring(QUOTE_DEAD, "SPACE", OpenGameFunc);
C_ReplaceQuoteSubstring(QUOTE_DEAD, "OPEN", OpenGameFunc); C_ReplaceQuoteSubstring(QUOTE_DEAD, "OPEN", OpenGameFunc);
C_ReplaceQuoteSubstring(QUOTE_DEAD, "USE", OpenGameFunc); C_ReplaceQuoteSubstring(QUOTE_DEAD, "USE", OpenGameFunc);
@ -5090,7 +5090,7 @@ repeatcase:
} }
} }
build.Push(0); build.Push(0);
CONFIG_ReplaceButtonName(j, build.Data()); buttonMap.SetButtonAlias(j, build.Data());
} }
continue; continue;
@ -5109,7 +5109,7 @@ repeatcase:
continue; continue;
} }
CONFIG_DeleteButtonName(j); buttonMap.ClearButtonAlias(j);
continue; continue;
case CON_DEFINESKILLNAME: case CON_DEFINESKILLNAME:

View file

@ -3656,7 +3656,7 @@ badindex:
VM_ASSERT((unsigned)quoteIndex < MAXQUOTES && apStrings[quoteIndex], "invalid quote %d\n", quoteIndex); VM_ASSERT((unsigned)quoteIndex < MAXQUOTES && apStrings[quoteIndex], "invalid quote %d\n", quoteIndex);
VM_ASSERT((unsigned)gameFunc < NUMGAMEFUNCTIONS, "invalid function %d\n", gameFunc); VM_ASSERT((unsigned)gameFunc < NUMGAMEFUNCTIONS, "invalid function %d\n", gameFunc);
auto bindings = Bindings.GetKeysForCommand(CONFIG_FunctionNumToRealName(gameFunc)); auto bindings = Bindings.GetKeysForCommand(buttonMap.GetButtonAlias(gameFunc));
if ((unsigned)funcPos >= bindings.Size()) funcPos = 0; if ((unsigned)funcPos >= bindings.Size()) funcPos = 0;
Bstrcpy(apStrings[quoteIndex], KB_ScanCodeToString(bindings[funcPos])); Bstrcpy(apStrings[quoteIndex], KB_ScanCodeToString(bindings[funcPos]));
dispatch(); dispatch();

View file

@ -1643,7 +1643,7 @@ void Menu_Init(void)
k = 1; k = 1;
for (i = 0; i < NUMGAMEFUNCTIONS; ++i) for (i = 0; i < NUMGAMEFUNCTIONS; ++i)
{ {
MenuGameFuncs[i] = CONFIG_FunctionNumToName(i); MenuGameFuncs[i] = buttonMap.GetButtonName(i);
MenuGameFuncs[i].Substitute('_', ' '); MenuGameFuncs[i].Substitute('_', ' ');
if (MenuGameFuncs[i][0] != '\0') if (MenuGameFuncs[i][0] != '\0')
@ -1836,7 +1836,8 @@ void Menu_Init(void)
ME_MOUSESETUPBTNS[i].name = MenuMouseNames[i]; ME_MOUSESETUPBTNS[i].name = MenuMouseNames[i];
ME_MOUSESETUPBTNS[i].entry = &MEO_MOUSESETUPBTNS[i]; ME_MOUSESETUPBTNS[i].entry = &MEO_MOUSESETUPBTNS[i];
MEO_MOUSESETUPBTNS[i] = MEO_MOUSEJOYSETUPBTNS_TEMPLATE; MEO_MOUSESETUPBTNS[i] = MEO_MOUSEJOYSETUPBTNS_TEMPLATE;
MEO_MOUSESETUPBTNS[i].data = &MouseFunctions[MenuMouseDataIndex[i][0]][MenuMouseDataIndex[i][1]]; static int32_t sink;
MEO_MOUSESETUPBTNS[i].data = &sink;
} }
for (i = 0; i < 2*joystick.numButtons + 8*joystick.numHats; ++i) for (i = 0; i < 2*joystick.numButtons + 8*joystick.numHats; ++i)
{ {
@ -2863,7 +2864,7 @@ static void Menu_PreInput(MenuEntry_t *entry)
case MENU_KEYBOARDKEYS: case MENU_KEYBOARDKEYS:
if (inputState.GetKeyStatus(sc_Delete)) if (inputState.GetKeyStatus(sc_Delete))
{ {
Bindings.UnbindACommand(CONFIG_FunctionNumToName(M_KEYBOARDKEYS.currentEntry)); Bindings.UnbindACommand(buttonMap.GetButtonName(M_KEYBOARDKEYS.currentEntry));
S_PlaySound(KICK_HIT); S_PlaySound(KICK_HIT);
inputState.ClearKeyStatus(sc_Delete); inputState.ClearKeyStatus(sc_Delete);
} }
@ -2920,7 +2921,7 @@ static int32_t Menu_PreCustom2ColScreen(MenuEntry_t *entry)
if (sc != sc_None) if (sc != sc_None)
{ {
S_PlaySound(PISTOL_BODYHIT); S_PlaySound(PISTOL_BODYHIT);
Bindings.SetBind(sc, CONFIG_FunctionNumToName(M_KEYBOARDKEYS.currentEntry)); Bindings.SetBind(sc, buttonMap.GetButtonName(M_KEYBOARDKEYS.currentEntry));
inputState.ClearKeyStatus(sc); inputState.ClearKeyStatus(sc);
return -1; return -1;
@ -4884,7 +4885,7 @@ static int32_t M_RunMenu_Menu(Menu_t *cm, MenuMenu_t *menu, MenuEntry_t *current
const int32_t columny = origin.y + y_upper + y - menu->scrollPos; const int32_t columny = origin.y + y_upper + y - menu->scrollPos;
// Beware of hack job! // Beware of hack job!
auto keys = Bindings.GetKeysForCommand(CONFIG_FunctionNumToName(object->buttonindex)); auto keys = Bindings.GetKeysForCommand(buttonMap.GetButtonName(object->buttonindex));
FString text1; FString text1;
FString text2; FString text2;
if (keys.Size() > 0) text1 = C_NameKeys(&keys[0], 1); if (keys.Size() > 0) text1 = C_NameKeys(&keys[0], 1);

View file

@ -2910,11 +2910,11 @@ void P_GetInput(int const playerNum)
D_ProcessEvents(); D_ProcessEvents();
if (in_aimmode) if (in_aimmode)
g_MyAimMode = inputState.BUTTON(gamefunc_Mouse_Aiming); g_MyAimMode = buttonMap.ButtonDown(gamefunc_Mouse_Aiming);
else else
{ {
g_oldAimStat = g_myAimStat; g_oldAimStat = g_myAimStat;
g_myAimStat = inputState.BUTTON(gamefunc_Mouse_Aiming); g_myAimStat = buttonMap.ButtonDown(gamefunc_Mouse_Aiming);
if (g_myAimStat > g_oldAimStat) if (g_myAimStat > g_oldAimStat)
{ {
@ -2947,7 +2947,7 @@ void P_GetInput(int const playerNum)
} }
// JBF: Run key behaviour is selectable // JBF: Run key behaviour is selectable
int const playerRunning = G_CheckAutorun(inputState.BUTTON(gamefunc_Run)); int const playerRunning = G_CheckAutorun(buttonMap.ButtonDown(gamefunc_Run));
int const turnAmount = playerRunning ? (NORMALTURN << 1) : NORMALTURN; int const turnAmount = playerRunning ? (NORMALTURN << 1) : NORMALTURN;
constexpr int const analogTurnAmount = (NORMALTURN << 1); constexpr int const analogTurnAmount = (NORMALTURN << 1);
int const keyMove = playerRunning ? (NORMALKEYMOVE << 1) : NORMALKEYMOVE; int const keyMove = playerRunning ? (NORMALKEYMOVE << 1) : NORMALKEYMOVE;
@ -2955,7 +2955,7 @@ void P_GetInput(int const playerNum)
input_t input {}; input_t input {};
if (inputState.BUTTON(gamefunc_Strafe)) if (buttonMap.ButtonDown(gamefunc_Strafe))
{ {
static int strafeyaw; static int strafeyaw;
@ -2981,12 +2981,12 @@ void P_GetInput(int const playerNum)
input.svel -= info.dx * keyMove / analogExtent; input.svel -= info.dx * keyMove / analogExtent;
input.fvel -= info.dz * keyMove / analogExtent; input.fvel -= info.dz * keyMove / analogExtent;
if (inputState.BUTTON(gamefunc_Strafe)) if (buttonMap.ButtonDown(gamefunc_Strafe))
{ {
if (inputState.BUTTON(gamefunc_Turn_Left) && !(pPlayer->movement_lock&4)) if (buttonMap.ButtonDown(gamefunc_Turn_Left) && !(pPlayer->movement_lock&4))
input.svel -= -keyMove; input.svel -= -keyMove;
if (inputState.BUTTON(gamefunc_Turn_Right) && !(pPlayer->movement_lock&8)) if (buttonMap.ButtonDown(gamefunc_Turn_Right) && !(pPlayer->movement_lock&8))
input.svel -= keyMove; input.svel -= keyMove;
} }
else else
@ -2997,12 +2997,12 @@ void P_GetInput(int const playerNum)
lastInputClock = (int32_t) totalclock; lastInputClock = (int32_t) totalclock;
if (inputState.BUTTON(gamefunc_Turn_Left)) if (buttonMap.ButtonDown(gamefunc_Turn_Left))
{ {
turnHeldTime += elapsedTics; turnHeldTime += elapsedTics;
input.q16avel -= fix16_from_int((turnHeldTime >= TURBOTURNTIME) ? (turnAmount << 1) : (PREAMBLETURN << 1)); input.q16avel -= fix16_from_int((turnHeldTime >= TURBOTURNTIME) ? (turnAmount << 1) : (PREAMBLETURN << 1));
} }
else if (inputState.BUTTON(gamefunc_Turn_Right)) else if (buttonMap.ButtonDown(gamefunc_Turn_Right))
{ {
turnHeldTime += elapsedTics; turnHeldTime += elapsedTics;
input.q16avel += fix16_from_int((turnHeldTime >= TURBOTURNTIME) ? (turnAmount << 1) : (PREAMBLETURN << 1)); input.q16avel += fix16_from_int((turnHeldTime >= TURBOTURNTIME) ? (turnAmount << 1) : (PREAMBLETURN << 1));
@ -3011,16 +3011,16 @@ void P_GetInput(int const playerNum)
turnHeldTime=0; turnHeldTime=0;
} }
if (inputState.BUTTON(gamefunc_Strafe_Left) && !(pPlayer->movement_lock & 4)) if (buttonMap.ButtonDown(gamefunc_Strafe_Left) && !(pPlayer->movement_lock & 4))
input.svel += keyMove; input.svel += keyMove;
if (inputState.BUTTON(gamefunc_Strafe_Right) && !(pPlayer->movement_lock & 8)) if (buttonMap.ButtonDown(gamefunc_Strafe_Right) && !(pPlayer->movement_lock & 8))
input.svel += -keyMove; input.svel += -keyMove;
if (inputState.BUTTON(gamefunc_Move_Forward) && !(pPlayer->movement_lock & 1)) if (buttonMap.ButtonDown(gamefunc_Move_Forward) && !(pPlayer->movement_lock & 1))
input.fvel += keyMove; input.fvel += keyMove;
if (inputState.BUTTON(gamefunc_Move_Backward) && !(pPlayer->movement_lock & 2)) if (buttonMap.ButtonDown(gamefunc_Move_Backward) && !(pPlayer->movement_lock & 2))
input.fvel += -keyMove; input.fvel += -keyMove;
input.fvel = clamp(input.fvel, -MAXVEL, MAXVEL); input.fvel = clamp(input.fvel, -MAXVEL, MAXVEL);
@ -3033,90 +3033,90 @@ void P_GetInput(int const playerNum)
for (weaponSelection = gamefunc_Weapon_10; weaponSelection >= gamefunc_Weapon_1; --weaponSelection) for (weaponSelection = gamefunc_Weapon_10; weaponSelection >= gamefunc_Weapon_1; --weaponSelection)
{ {
if (inputState.BUTTON(weaponSelection)) if (buttonMap.ButtonDown(weaponSelection))
{ {
weaponSelection -= (gamefunc_Weapon_1 - 1); weaponSelection -= (gamefunc_Weapon_1 - 1);
break; break;
} }
} }
if (inputState.BUTTON(gamefunc_Last_Weapon)) if (buttonMap.ButtonDown(gamefunc_Last_Weapon))
weaponSelection = 14; weaponSelection = 14;
else if (inputState.BUTTON(gamefunc_Alt_Weapon)) else if (buttonMap.ButtonDown(gamefunc_Alt_Weapon))
weaponSelection = 13; weaponSelection = 13;
else if (inputState.BUTTON(gamefunc_Next_Weapon) || (inputState.BUTTON(gamefunc_Dpad_Select) && input.fvel > 0)) else if (buttonMap.ButtonDown(gamefunc_Next_Weapon) || (buttonMap.ButtonDown(gamefunc_Dpad_Select) && input.fvel > 0))
weaponSelection = 12; weaponSelection = 12;
else if (inputState.BUTTON(gamefunc_Previous_Weapon) || (inputState.BUTTON(gamefunc_Dpad_Select) && input.fvel < 0)) else if (buttonMap.ButtonDown(gamefunc_Previous_Weapon) || (buttonMap.ButtonDown(gamefunc_Dpad_Select) && input.fvel < 0))
weaponSelection = 11; weaponSelection = 11;
else if (weaponSelection == gamefunc_Weapon_1-1) else if (weaponSelection == gamefunc_Weapon_1-1)
weaponSelection = 0; weaponSelection = 0;
localInput.bits = (weaponSelection << SK_WEAPON_BITS) | (inputState.BUTTON(gamefunc_Fire) << SK_FIRE); localInput.bits = (weaponSelection << SK_WEAPON_BITS) | (buttonMap.ButtonDown(gamefunc_Fire) << SK_FIRE);
localInput.bits |= (inputState.BUTTON(gamefunc_Open) << SK_OPEN); localInput.bits |= (buttonMap.ButtonDown(gamefunc_Open) << SK_OPEN);
int const sectorLotag = pPlayer->cursectnum != -1 ? sector[pPlayer->cursectnum].lotag : 0; int const sectorLotag = pPlayer->cursectnum != -1 ? sector[pPlayer->cursectnum].lotag : 0;
int const crouchable = sectorLotag != 2 && (sectorLotag != 1 || pPlayer->spritebridge); int const crouchable = sectorLotag != 2 && (sectorLotag != 1 || pPlayer->spritebridge);
if (pPlayer->cheat_phase == 0 && inputState.BUTTON(gamefunc_Toggle_Crouch)) if (pPlayer->cheat_phase == 0 && buttonMap.ButtonDown(gamefunc_Toggle_Crouch))
{ {
pPlayer->crouch_toggle = !pPlayer->crouch_toggle && crouchable; pPlayer->crouch_toggle = !pPlayer->crouch_toggle && crouchable;
if (crouchable) if (crouchable)
inputState.ClearButton(gamefunc_Toggle_Crouch); buttonMap.ClearButton(gamefunc_Toggle_Crouch);
} }
if (inputState.BUTTON(gamefunc_Crouch) || inputState.BUTTON(gamefunc_Jump) || pPlayer->jetpack_on || (!crouchable && pPlayer->on_ground)) if (buttonMap.ButtonDown(gamefunc_Crouch) || buttonMap.ButtonDown(gamefunc_Jump) || pPlayer->jetpack_on || (!crouchable && pPlayer->on_ground))
pPlayer->crouch_toggle = 0; pPlayer->crouch_toggle = 0;
int const crouching = inputState.BUTTON(gamefunc_Crouch) || inputState.BUTTON(gamefunc_Toggle_Crouch) || pPlayer->crouch_toggle; int const crouching = buttonMap.ButtonDown(gamefunc_Crouch) || buttonMap.ButtonDown(gamefunc_Toggle_Crouch) || pPlayer->crouch_toggle;
localInput.bits |= (inputState.BUTTON(gamefunc_Jump) << SK_JUMP) | (crouching << SK_CROUCH); localInput.bits |= (buttonMap.ButtonDown(gamefunc_Jump) << SK_JUMP) | (crouching << SK_CROUCH);
localInput.bits |= (inputState.BUTTON(gamefunc_Aim_Up) || (inputState.BUTTON(gamefunc_Dpad_Aiming) && input.fvel > 0)) << SK_AIM_UP; localInput.bits |= (buttonMap.ButtonDown(gamefunc_Aim_Up) || (buttonMap.ButtonDown(gamefunc_Dpad_Aiming) && input.fvel > 0)) << SK_AIM_UP;
localInput.bits |= (inputState.BUTTON(gamefunc_Aim_Down) || (inputState.BUTTON(gamefunc_Dpad_Aiming) && input.fvel < 0)) << SK_AIM_DOWN; localInput.bits |= (buttonMap.ButtonDown(gamefunc_Aim_Down) || (buttonMap.ButtonDown(gamefunc_Dpad_Aiming) && input.fvel < 0)) << SK_AIM_DOWN;
localInput.bits |= (inputState.BUTTON(gamefunc_Center_View) << SK_CENTER_VIEW); localInput.bits |= (buttonMap.ButtonDown(gamefunc_Center_View) << SK_CENTER_VIEW);
localInput.bits |= (inputState.BUTTON(gamefunc_Look_Left) << SK_LOOK_LEFT) | (inputState.BUTTON(gamefunc_Look_Right) << SK_LOOK_RIGHT); localInput.bits |= (buttonMap.ButtonDown(gamefunc_Look_Left) << SK_LOOK_LEFT) | (buttonMap.ButtonDown(gamefunc_Look_Right) << SK_LOOK_RIGHT);
localInput.bits |= (inputState.BUTTON(gamefunc_Look_Up) << SK_LOOK_UP) | (inputState.BUTTON(gamefunc_Look_Down) << SK_LOOK_DOWN); localInput.bits |= (buttonMap.ButtonDown(gamefunc_Look_Up) << SK_LOOK_UP) | (buttonMap.ButtonDown(gamefunc_Look_Down) << SK_LOOK_DOWN);
localInput.bits |= (playerRunning << SK_RUN); localInput.bits |= (playerRunning << SK_RUN);
localInput.bits |= (inputState.BUTTON(gamefunc_Inventory_Left) || (inputState.BUTTON(gamefunc_Dpad_Select) && (input.svel > 0 || input.q16avel < 0))) << SK_INV_LEFT; localInput.bits |= (buttonMap.ButtonDown(gamefunc_Inventory_Left) || (buttonMap.ButtonDown(gamefunc_Dpad_Select) && (input.svel > 0 || input.q16avel < 0))) << SK_INV_LEFT;
localInput.bits |= (inputState.BUTTON(gamefunc_Inventory_Right) || (inputState.BUTTON(gamefunc_Dpad_Select) && (input.svel < 0 || input.q16avel > 0))) << SK_INV_RIGHT; localInput.bits |= (buttonMap.ButtonDown(gamefunc_Inventory_Right) || (buttonMap.ButtonDown(gamefunc_Dpad_Select) && (input.svel < 0 || input.q16avel > 0))) << SK_INV_RIGHT;
localInput.bits |= (inputState.BUTTON(gamefunc_Inventory) << SK_INVENTORY); localInput.bits |= (buttonMap.ButtonDown(gamefunc_Inventory) << SK_INVENTORY);
localInput.bits |= (inputState.BUTTON(gamefunc_Steroids) << SK_STEROIDS) | (inputState.BUTTON(gamefunc_NightVision) << SK_NIGHTVISION); localInput.bits |= (buttonMap.ButtonDown(gamefunc_Steroids) << SK_STEROIDS) | (buttonMap.ButtonDown(gamefunc_NightVision) << SK_NIGHTVISION);
localInput.bits |= (inputState.BUTTON(gamefunc_MedKit) << SK_MEDKIT) | (inputState.BUTTON(gamefunc_Holo_Duke) << SK_HOLODUKE); localInput.bits |= (buttonMap.ButtonDown(gamefunc_MedKit) << SK_MEDKIT) | (buttonMap.ButtonDown(gamefunc_Holo_Duke) << SK_HOLODUKE);
localInput.bits |= (inputState.BUTTON(gamefunc_Jetpack) << SK_JETPACK); localInput.bits |= (buttonMap.ButtonDown(gamefunc_Jetpack) << SK_JETPACK);
localInput.bits |= inputState.BUTTON(gamefunc_Holster_Weapon) << SK_HOLSTER; localInput.bits |= buttonMap.ButtonDown(gamefunc_Holster_Weapon) << SK_HOLSTER;
localInput.bits |= inputState.BUTTON(gamefunc_Quick_Kick) << SK_QUICK_KICK; localInput.bits |= buttonMap.ButtonDown(gamefunc_Quick_Kick) << SK_QUICK_KICK;
localInput.bits |= inputState.BUTTON(gamefunc_TurnAround) << SK_TURNAROUND; localInput.bits |= buttonMap.ButtonDown(gamefunc_TurnAround) << SK_TURNAROUND;
localInput.bits |= (g_MyAimMode << SK_AIMMODE); localInput.bits |= (g_MyAimMode << SK_AIMMODE);
localInput.bits |= (g_gameQuit << SK_GAMEQUIT); localInput.bits |= (g_gameQuit << SK_GAMEQUIT);
localInput.bits |= inputState.GetKeyStatus(sc_Pause) << SK_PAUSE; localInput.bits |= inputState.GetKeyStatus(sc_Pause) << SK_PAUSE;
localInput.bits |= ((uint32_t)inputState.GetKeyStatus(sc_Escape)) << SK_ESCAPE; localInput.bits |= ((uint32_t)inputState.GetKeyStatus(sc_Escape)) << SK_ESCAPE;
if (inputState.BUTTON(gamefunc_Dpad_Select)) if (buttonMap.ButtonDown(gamefunc_Dpad_Select))
{ {
input.fvel = 0; input.fvel = 0;
input.svel = 0; input.svel = 0;
input.q16avel = 0; input.q16avel = 0;
} }
else if (inputState.BUTTON(gamefunc_Dpad_Aiming)) else if (buttonMap.ButtonDown(gamefunc_Dpad_Aiming))
input.fvel = 0; input.fvel = 0;
if (PWEAPON(playerNum, pPlayer->curr_weapon, Flags) & WEAPON_SEMIAUTO && inputState.BUTTON(gamefunc_Fire)) if (PWEAPON(playerNum, pPlayer->curr_weapon, Flags) & WEAPON_SEMIAUTO && buttonMap.ButtonDown(gamefunc_Fire))
inputState.ClearButton(gamefunc_Fire); buttonMap.ClearButton(gamefunc_Fire);
localInput.extbits = (inputState.BUTTON(gamefunc_Move_Forward) || (input.fvel > 0)); localInput.extbits = (buttonMap.ButtonDown(gamefunc_Move_Forward) || (input.fvel > 0));
localInput.extbits |= (inputState.BUTTON(gamefunc_Move_Backward) || (input.fvel < 0)) << 1; localInput.extbits |= (buttonMap.ButtonDown(gamefunc_Move_Backward) || (input.fvel < 0)) << 1;
localInput.extbits |= (inputState.BUTTON(gamefunc_Strafe_Left) || (input.svel > 0)) << 2; localInput.extbits |= (buttonMap.ButtonDown(gamefunc_Strafe_Left) || (input.svel > 0)) << 2;
localInput.extbits |= (inputState.BUTTON(gamefunc_Strafe_Right) || (input.svel < 0)) << 3; localInput.extbits |= (buttonMap.ButtonDown(gamefunc_Strafe_Right) || (input.svel < 0)) << 3;
localInput.extbits |= inputState.BUTTON(gamefunc_Turn_Left)<<4; localInput.extbits |= buttonMap.ButtonDown(gamefunc_Turn_Left)<<4;
localInput.extbits |= inputState.BUTTON(gamefunc_Turn_Right)<<5; localInput.extbits |= buttonMap.ButtonDown(gamefunc_Turn_Right)<<5;
localInput.extbits |= inputState.BUTTON(gamefunc_Alt_Fire)<<6; localInput.extbits |= buttonMap.ButtonDown(gamefunc_Alt_Fire)<<6;
if (ud.scrollmode && ud.overhead_on) if (ud.scrollmode && ud.overhead_on)
{ {
@ -5144,7 +5144,7 @@ void P_ProcessInput(int playerNum)
pPlayer->jumping_toggle = 2; pPlayer->jumping_toggle = 2;
if (myconnectindex == playerNum) if (myconnectindex == playerNum)
inputState.ClearButton(gamefunc_Jump); buttonMap.ClearButton(gamefunc_Jump);
} }
} }
} }

View file

@ -1210,7 +1210,7 @@ void G_DisplayRest(int32_t smoothratio)
gametext_center(70, "Press F1 to Accept, F2 to Decline"); gametext_center(70, "Press F1 to Accept, F2 to Decline");
} }
if (inputState.BUTTON(gamefunc_Show_DukeMatch_Scores)) if (buttonMap.ButtonDown(gamefunc_Show_DukeMatch_Scores))
G_ShowScores(); G_ShowScores();
if (g_Debug) if (g_Debug)

View file

@ -590,8 +590,6 @@ static void CONTROL_GetFunctionInput(void)
{ {
CONTROL_ButtonFunctionState(CONTROL_ButtonFlags); CONTROL_ButtonFunctionState(CONTROL_ButtonFlags);
CONTROL_AxisFunctionState(CONTROL_ButtonFlags); CONTROL_AxisFunctionState(CONTROL_ButtonFlags);
memset(CONTROL_ButtonFlags, 0, sizeof(CONTROL_ButtonFlags));
} }
void CONTROL_GetInput(ControlInfo *info) void CONTROL_GetInput(ControlInfo *info)

View file

@ -45,7 +45,7 @@ void I_ClearAllInput(void)
inputState.ClearKeysDown(); inputState.ClearKeysDown();
inputState.MouseClearAllButtonss(); inputState.MouseClearAllButtonss();
JOYSTICK_ClearAllButtons(); JOYSTICK_ClearAllButtons();
inputState.ClearAllButtons(); buttonMap.ResetButtonStates();
} }
@ -101,9 +101,9 @@ int32_t I_GeneralTrigger(void)
return return
I_AdvanceTrigger() I_AdvanceTrigger()
|| I_ReturnTrigger() || I_ReturnTrigger()
|| inputState.BUTTON(gamefunc_Open) || buttonMap.ButtonDown(gamefunc_Open)
//|| MOUSEINACTIVECONDITIONAL(inputState.BUTTON(gamefunc_Fire)) //|| MOUSEINACTIVECONDITIONAL(buttonMap.ButtonDown(gamefunc_Fire))
|| inputState.BUTTON(gamefunc_Crouch) || buttonMap.ButtonDown(gamefunc_Crouch)
|| (JOYSTICK_GetGameControllerButtons()&(1<<GAMECONTROLLER_BUTTON_START)); || (JOYSTICK_GetGameControllerButtons()&(1<<GAMECONTROLLER_BUTTON_START));
} }
@ -111,9 +111,9 @@ void I_GeneralTriggerClear(void)
{ {
I_AdvanceTriggerClear(); I_AdvanceTriggerClear();
I_ReturnTriggerClear(); I_ReturnTriggerClear();
inputState.ClearButton(gamefunc_Open); buttonMap.ClearButton(gamefunc_Open);
inputState.ClearButton(gamefunc_Fire); buttonMap.ClearButton(gamefunc_Fire);
inputState.ClearButton(gamefunc_Crouch); buttonMap.ClearButton(gamefunc_Crouch);
JOYSTICK_ClearGameControllerButton(1<<GAMECONTROLLER_BUTTON_START); JOYSTICK_ClearGameControllerButton(1<<GAMECONTROLLER_BUTTON_START);
} }
@ -139,7 +139,7 @@ int32_t I_MenuUp(void)
inputState.GetKeyStatus(sc_UpArrow) inputState.GetKeyStatus(sc_UpArrow)
|| inputState.GetKeyStatus(sc_kpad_8) || inputState.GetKeyStatus(sc_kpad_8)
|| (inputState.MouseGetButtons()&WHEELUP_MOUSE) || (inputState.MouseGetButtons()&WHEELUP_MOUSE)
|| inputState.BUTTON(gamefunc_Move_Forward) || buttonMap.ButtonDown(gamefunc_Move_Forward)
|| (JOYSTICK_GetHat(0)&HAT_UP) || (JOYSTICK_GetHat(0)&HAT_UP)
|| (JOYSTICK_GetGameControllerButtons()&(1<<GAMECONTROLLER_BUTTON_DPAD_UP)) || (JOYSTICK_GetGameControllerButtons()&(1<<GAMECONTROLLER_BUTTON_DPAD_UP))
|| CONTROL_GetGameControllerDigitalAxisNeg(GAMECONTROLLER_AXIS_LEFTY); || CONTROL_GetGameControllerDigitalAxisNeg(GAMECONTROLLER_AXIS_LEFTY);
@ -150,7 +150,7 @@ void I_MenuUpClear(void)
inputState.ClearKeyStatus(sc_UpArrow); inputState.ClearKeyStatus(sc_UpArrow);
inputState.ClearKeyStatus(sc_kpad_8); inputState.ClearKeyStatus(sc_kpad_8);
inputState.MouseClearButton(WHEELUP_MOUSE); inputState.MouseClearButton(WHEELUP_MOUSE);
inputState.ClearButton(gamefunc_Move_Forward); buttonMap.ClearButton(gamefunc_Move_Forward);
JOYSTICK_ClearHat(0); JOYSTICK_ClearHat(0);
JOYSTICK_ClearGameControllerButton(1<<GAMECONTROLLER_BUTTON_DPAD_UP); JOYSTICK_ClearGameControllerButton(1<<GAMECONTROLLER_BUTTON_DPAD_UP);
CONTROL_ClearGameControllerDigitalAxisNeg(GAMECONTROLLER_AXIS_LEFTY); CONTROL_ClearGameControllerDigitalAxisNeg(GAMECONTROLLER_AXIS_LEFTY);
@ -163,7 +163,7 @@ int32_t I_MenuDown(void)
inputState.GetKeyStatus(sc_DownArrow) inputState.GetKeyStatus(sc_DownArrow)
|| inputState.GetKeyStatus(sc_kpad_2) || inputState.GetKeyStatus(sc_kpad_2)
|| (inputState.MouseGetButtons()&WHEELDOWN_MOUSE) || (inputState.MouseGetButtons()&WHEELDOWN_MOUSE)
|| inputState.BUTTON(gamefunc_Move_Backward) || buttonMap.ButtonDown(gamefunc_Move_Backward)
|| (JOYSTICK_GetHat(0)&HAT_DOWN) || (JOYSTICK_GetHat(0)&HAT_DOWN)
|| (JOYSTICK_GetGameControllerButtons()&(1<<GAMECONTROLLER_BUTTON_DPAD_DOWN)) || (JOYSTICK_GetGameControllerButtons()&(1<<GAMECONTROLLER_BUTTON_DPAD_DOWN))
|| CONTROL_GetGameControllerDigitalAxisPos(GAMECONTROLLER_AXIS_LEFTY); || CONTROL_GetGameControllerDigitalAxisPos(GAMECONTROLLER_AXIS_LEFTY);
@ -175,7 +175,7 @@ void I_MenuDownClear(void)
inputState.ClearKeyStatus(sc_kpad_2); inputState.ClearKeyStatus(sc_kpad_2);
inputState.ClearKeyStatus(sc_PgDn); inputState.ClearKeyStatus(sc_PgDn);
inputState.MouseClearButton(WHEELDOWN_MOUSE); inputState.MouseClearButton(WHEELDOWN_MOUSE);
inputState.ClearButton(gamefunc_Move_Backward); buttonMap.ClearButton(gamefunc_Move_Backward);
JOYSTICK_ClearHat(0); JOYSTICK_ClearHat(0);
JOYSTICK_ClearGameControllerButton(1<<GAMECONTROLLER_BUTTON_DPAD_DOWN); JOYSTICK_ClearGameControllerButton(1<<GAMECONTROLLER_BUTTON_DPAD_DOWN);
CONTROL_ClearGameControllerDigitalAxisPos(GAMECONTROLLER_AXIS_LEFTY); CONTROL_ClearGameControllerDigitalAxisPos(GAMECONTROLLER_AXIS_LEFTY);
@ -188,8 +188,8 @@ int32_t I_MenuLeft(void)
inputState.GetKeyStatus(sc_LeftArrow) inputState.GetKeyStatus(sc_LeftArrow)
|| inputState.GetKeyStatus(sc_kpad_4) || inputState.GetKeyStatus(sc_kpad_4)
|| (inputState.ShiftPressed() && inputState.GetKeyStatus(sc_Tab)) || (inputState.ShiftPressed() && inputState.GetKeyStatus(sc_Tab))
|| inputState.BUTTON(gamefunc_Turn_Left) || buttonMap.ButtonDown(gamefunc_Turn_Left)
|| inputState.BUTTON(gamefunc_Strafe_Left) || buttonMap.ButtonDown(gamefunc_Strafe_Left)
|| (JOYSTICK_GetHat(0)&HAT_LEFT) || (JOYSTICK_GetHat(0)&HAT_LEFT)
|| (JOYSTICK_GetGameControllerButtons()&(1<<GAMECONTROLLER_BUTTON_DPAD_LEFT)) || (JOYSTICK_GetGameControllerButtons()&(1<<GAMECONTROLLER_BUTTON_DPAD_LEFT))
|| CONTROL_GetGameControllerDigitalAxisNeg(GAMECONTROLLER_AXIS_LEFTX); || CONTROL_GetGameControllerDigitalAxisNeg(GAMECONTROLLER_AXIS_LEFTX);
@ -200,8 +200,8 @@ void I_MenuLeftClear(void)
inputState.ClearKeyStatus(sc_LeftArrow); inputState.ClearKeyStatus(sc_LeftArrow);
inputState.ClearKeyStatus(sc_kpad_4); inputState.ClearKeyStatus(sc_kpad_4);
inputState.ClearKeyStatus(sc_Tab); inputState.ClearKeyStatus(sc_Tab);
inputState.ClearButton(gamefunc_Turn_Left); buttonMap.ClearButton(gamefunc_Turn_Left);
inputState.ClearButton(gamefunc_Strafe_Left); buttonMap.ClearButton(gamefunc_Strafe_Left);
JOYSTICK_ClearHat(0); JOYSTICK_ClearHat(0);
JOYSTICK_ClearGameControllerButton(1<<GAMECONTROLLER_BUTTON_DPAD_LEFT); JOYSTICK_ClearGameControllerButton(1<<GAMECONTROLLER_BUTTON_DPAD_LEFT);
CONTROL_ClearGameControllerDigitalAxisNeg(GAMECONTROLLER_AXIS_LEFTX); CONTROL_ClearGameControllerDigitalAxisNeg(GAMECONTROLLER_AXIS_LEFTX);
@ -214,8 +214,8 @@ int32_t I_MenuRight(void)
inputState.GetKeyStatus(sc_RightArrow) inputState.GetKeyStatus(sc_RightArrow)
|| inputState.GetKeyStatus(sc_kpad_6) || inputState.GetKeyStatus(sc_kpad_6)
|| (!inputState.ShiftPressed() && inputState.GetKeyStatus(sc_Tab)) || (!inputState.ShiftPressed() && inputState.GetKeyStatus(sc_Tab))
|| inputState.BUTTON(gamefunc_Turn_Right) || buttonMap.ButtonDown(gamefunc_Turn_Right)
|| inputState.BUTTON(gamefunc_Strafe_Right) || buttonMap.ButtonDown(gamefunc_Strafe_Right)
|| (inputState.MouseGetButtons()&MIDDLE_MOUSE) || (inputState.MouseGetButtons()&MIDDLE_MOUSE)
|| (JOYSTICK_GetHat(0)&HAT_RIGHT) || (JOYSTICK_GetHat(0)&HAT_RIGHT)
|| (JOYSTICK_GetGameControllerButtons()&(1<<GAMECONTROLLER_BUTTON_DPAD_RIGHT)) || (JOYSTICK_GetGameControllerButtons()&(1<<GAMECONTROLLER_BUTTON_DPAD_RIGHT))
@ -228,8 +228,8 @@ void I_MenuRightClear(void)
inputState.ClearKeyStatus(sc_RightArrow); inputState.ClearKeyStatus(sc_RightArrow);
inputState.ClearKeyStatus(sc_kpad_6); inputState.ClearKeyStatus(sc_kpad_6);
inputState.ClearKeyStatus(sc_Tab); inputState.ClearKeyStatus(sc_Tab);
inputState.ClearButton(gamefunc_Turn_Right); buttonMap.ClearButton(gamefunc_Turn_Right);
inputState.ClearButton(gamefunc_Strafe_Right); buttonMap.ClearButton(gamefunc_Strafe_Right);
inputState.MouseClearButton(MIDDLE_MOUSE); inputState.MouseClearButton(MIDDLE_MOUSE);
JOYSTICK_ClearHat(0); JOYSTICK_ClearHat(0);
JOYSTICK_ClearGameControllerButton(1<<GAMECONTROLLER_BUTTON_DPAD_RIGHT); JOYSTICK_ClearGameControllerButton(1<<GAMECONTROLLER_BUTTON_DPAD_RIGHT);

View file

@ -915,10 +915,10 @@ nextdemo_nomenu:
{ {
ControlInfo noshareinfo; ControlInfo noshareinfo;
CONTROL_GetInput(&noshareinfo); CONTROL_GetInput(&noshareinfo);
if (inputState.BUTTON(gamefunc_SendMessage)) if (buttonMap.ButtonDown(gamefunc_SendMessage))
{ {
inputState.keyFlushChars(); inputState.keyFlushChars();
inputState.ClearButton(gamefunc_SendMessage); buttonMap.ClearButton(gamefunc_SendMessage);
g_player[myconnectindex].ps->gm = MODE_TYPE; g_player[myconnectindex].ps->gm = MODE_TYPE;
typebuf[0] = 0; typebuf[0] = 0;
} }

View file

@ -6045,9 +6045,9 @@ void G_HandleLocalKeys(void)
if (!ALT_IS_PRESSED && ud.overhead_on == 0 && (g_player[myconnectindex].ps->gm & MODE_TYPE) == 0) if (!ALT_IS_PRESSED && ud.overhead_on == 0 && (g_player[myconnectindex].ps->gm & MODE_TYPE) == 0)
{ {
if (inputState.BUTTON(gamefunc_Enlarge_Screen)) if (buttonMap.ButtonDown(gamefunc_Enlarge_Screen))
{ {
inputState.ClearButton(gamefunc_Enlarge_Screen); buttonMap.ClearButton(gamefunc_Enlarge_Screen);
if (!SHIFTS_IS_PRESSED) if (!SHIFTS_IS_PRESSED)
{ {
@ -6064,9 +6064,9 @@ void G_HandleLocalKeys(void)
G_UpdateScreenArea(); G_UpdateScreenArea();
} }
if (inputState.BUTTON(gamefunc_Shrink_Screen)) if (buttonMap.ButtonDown(gamefunc_Shrink_Screen))
{ {
inputState.ClearButton(gamefunc_Shrink_Screen); buttonMap.ClearButton(gamefunc_Shrink_Screen);
if (!SHIFTS_IS_PRESSED) if (!SHIFTS_IS_PRESSED)
{ {
@ -6087,31 +6087,31 @@ void G_HandleLocalKeys(void)
if (g_player[myconnectindex].ps->cheat_phase == 1 || (g_player[myconnectindex].ps->gm&(MODE_MENU|MODE_TYPE))) if (g_player[myconnectindex].ps->cheat_phase == 1 || (g_player[myconnectindex].ps->gm&(MODE_MENU|MODE_TYPE)))
return; return;
if (inputState.BUTTON(gamefunc_See_Coop_View) && (GTFLAGS(GAMETYPE_COOPVIEW) || ud.recstat == 2)) if (buttonMap.ButtonDown(gamefunc_See_Coop_View) && (GTFLAGS(GAMETYPE_COOPVIEW) || ud.recstat == 2))
{ {
inputState.ClearButton(gamefunc_See_Coop_View); buttonMap.ClearButton(gamefunc_See_Coop_View);
screenpeek = connectpoint2[screenpeek]; screenpeek = connectpoint2[screenpeek];
if (screenpeek == -1) screenpeek = 0; if (screenpeek == -1) screenpeek = 0;
g_restorePalette = -1; g_restorePalette = -1;
} }
if ((g_netServer || ud.multimode > 1) && inputState.BUTTON(gamefunc_Show_Opponents_Weapon)) if ((g_netServer || ud.multimode > 1) && buttonMap.ButtonDown(gamefunc_Show_Opponents_Weapon))
{ {
inputState.ClearButton(gamefunc_Show_Opponents_Weapon); buttonMap.ClearButton(gamefunc_Show_Opponents_Weapon);
ud.config.ShowOpponentWeapons = ud.showweapons = 1-ud.showweapons; ud.config.ShowOpponentWeapons = ud.showweapons = 1-ud.showweapons;
P_DoQuote(QUOTE_WEAPON_MODE_OFF-ud.showweapons,g_player[screenpeek].ps); P_DoQuote(QUOTE_WEAPON_MODE_OFF-ud.showweapons,g_player[screenpeek].ps);
} }
if (inputState.BUTTON(gamefunc_Toggle_Crosshair)) if (buttonMap.ButtonDown(gamefunc_Toggle_Crosshair))
{ {
inputState.ClearButton(gamefunc_Toggle_Crosshair); buttonMap.ClearButton(gamefunc_Toggle_Crosshair);
cl_crosshair = !cl_crosshair; cl_crosshair = !cl_crosshair;
P_DoQuote(QUOTE_CROSSHAIR_OFF-cl_crosshair,g_player[screenpeek].ps); P_DoQuote(QUOTE_CROSSHAIR_OFF-cl_crosshair,g_player[screenpeek].ps);
} }
if (ud.overhead_on && inputState.BUTTON(gamefunc_Map_Follow_Mode)) if (ud.overhead_on && buttonMap.ButtonDown(gamefunc_Map_Follow_Mode))
{ {
inputState.ClearButton(gamefunc_Map_Follow_Mode); buttonMap.ClearButton(gamefunc_Map_Follow_Mode);
ud.scrollmode = 1-ud.scrollmode; ud.scrollmode = 1-ud.scrollmode;
if (ud.scrollmode) if (ud.scrollmode)
{ {
@ -6257,10 +6257,10 @@ void G_HandleLocalKeys(void)
if (!ALT_IS_PRESSED && !SHIFTS_IS_PRESSED && !WIN_IS_PRESSED) if (!ALT_IS_PRESSED && !SHIFTS_IS_PRESSED && !WIN_IS_PRESSED)
{ {
if ((g_netServer || ud.multimode > 1) && inputState.BUTTON(gamefunc_SendMessage)) if ((g_netServer || ud.multimode > 1) && buttonMap.ButtonDown(gamefunc_SendMessage))
{ {
inputState.keyFlushChars(); inputState.keyFlushChars();
inputState.ClearButton(gamefunc_SendMessage); buttonMap.ClearButton(gamefunc_SendMessage);
g_player[myconnectindex].ps->gm |= MODE_TYPE; g_player[myconnectindex].ps->gm |= MODE_TYPE;
typebuf[0] = 0; typebuf[0] = 0;
} }
@ -6357,9 +6357,9 @@ FAKE_F3:
P_DoQuote(QUOTE_MUSIC, g_player[myconnectindex].ps); P_DoQuote(QUOTE_MUSIC, g_player[myconnectindex].ps);
} }
if ((inputState.BUTTON(gamefunc_Quick_Save) || g_doQuickSave == 1) && (!RRRA || ud.player_skill != 4) && (!RR || RRRA || ud.player_skill != 5) && (g_player[myconnectindex].ps->gm&MODE_GAME)) if ((buttonMap.ButtonDown(gamefunc_Quick_Save) || g_doQuickSave == 1) && (!RRRA || ud.player_skill != 4) && (!RR || RRRA || ud.player_skill != 5) && (g_player[myconnectindex].ps->gm&MODE_GAME))
{ {
inputState.ClearButton(gamefunc_Quick_Save); buttonMap.ClearButton(gamefunc_Quick_Save);
g_doQuickSave = 0; g_doQuickSave = 0;
@ -6394,9 +6394,9 @@ FAKE_F3:
} }
} }
if (inputState.BUTTON(gamefunc_Third_Person_View)) if (buttonMap.ButtonDown(gamefunc_Third_Person_View))
{ {
inputState.ClearButton(gamefunc_Third_Person_View); buttonMap.ClearButton(gamefunc_Third_Person_View);
if (!RRRA || (!g_player[myconnectindex].ps->on_motorcycle && !g_player[myconnectindex].ps->on_boat)) if (!RRRA || (!g_player[myconnectindex].ps->on_motorcycle && !g_player[myconnectindex].ps->on_boat))
{ {
@ -6419,9 +6419,9 @@ FAKE_F3:
ud.fta_on = fta; ud.fta_on = fta;
} }
if ((inputState.BUTTON(gamefunc_Quick_Load) || g_doQuickSave == 2) && (!RRRA || ud.player_skill != 4) && (!RR || RRRA || ud.player_skill != 5) && (g_player[myconnectindex].ps->gm&MODE_GAME)) if ((buttonMap.ButtonDown(gamefunc_Quick_Load) || g_doQuickSave == 2) && (!RRRA || ud.player_skill != 4) && (!RR || RRRA || ud.player_skill != 5) && (g_player[myconnectindex].ps->gm&MODE_GAME))
{ {
inputState.ClearButton(gamefunc_Quick_Load); buttonMap.ClearButton(gamefunc_Quick_Load);
g_doQuickSave = 0; g_doQuickSave = 0;
@ -6472,10 +6472,10 @@ FAKE_F3:
int const timerOffset = ((int) totalclock - nonsharedtimer); int const timerOffset = ((int) totalclock - nonsharedtimer);
nonsharedtimer += timerOffset; nonsharedtimer += timerOffset;
if (inputState.BUTTON(gamefunc_Enlarge_Screen)) if (buttonMap.ButtonDown(gamefunc_Enlarge_Screen))
g_player[myconnectindex].ps->zoom += mulscale6(timerOffset, max<int>(g_player[myconnectindex].ps->zoom, 256)); g_player[myconnectindex].ps->zoom += mulscale6(timerOffset, max<int>(g_player[myconnectindex].ps->zoom, 256));
if (inputState.BUTTON(gamefunc_Shrink_Screen)) if (buttonMap.ButtonDown(gamefunc_Shrink_Screen))
g_player[myconnectindex].ps->zoom -= mulscale6(timerOffset, max<int>(g_player[myconnectindex].ps->zoom, 256)); g_player[myconnectindex].ps->zoom -= mulscale6(timerOffset, max<int>(g_player[myconnectindex].ps->zoom, 256));
g_player[myconnectindex].ps->zoom = clamp(g_player[myconnectindex].ps->zoom, 48, 2048); g_player[myconnectindex].ps->zoom = clamp(g_player[myconnectindex].ps->zoom, 48, 2048);
@ -6491,16 +6491,16 @@ FAKE_F3:
G_UpdateScreenArea(); G_UpdateScreenArea();
} }
if (inputState.BUTTON(gamefunc_AutoRun)) if (buttonMap.ButtonDown(gamefunc_AutoRun))
{ {
inputState.ClearButton(gamefunc_AutoRun); buttonMap.ClearButton(gamefunc_AutoRun);
cl_autorun = !cl_autorun; cl_autorun = !cl_autorun;
P_DoQuote(QUOTE_RUN_MODE_OFF+cl_autorun,g_player[myconnectindex].ps); P_DoQuote(QUOTE_RUN_MODE_OFF+cl_autorun,g_player[myconnectindex].ps);
} }
if (inputState.BUTTON(gamefunc_Map)) if (buttonMap.ButtonDown(gamefunc_Map))
{ {
inputState.ClearButton(gamefunc_Map); buttonMap.ClearButton(gamefunc_Map);
if (ud.last_overhead != ud.overhead_on && ud.last_overhead) if (ud.last_overhead != ud.overhead_on && ud.last_overhead)
{ {
ud.overhead_on = ud.last_overhead; ud.overhead_on = ud.last_overhead;

View file

@ -935,7 +935,7 @@ void C_InitQuotes(void)
#ifdef EDUKE32_TOUCH_DEVICES #ifdef EDUKE32_TOUCH_DEVICES
apStrings[QUOTE_DEAD] = 0; apStrings[QUOTE_DEAD] = 0;
#else #else
char const * OpenGameFunc = CONFIG_FunctionNumToName(gamefunc_Open); char const * OpenGameFunc = buttonMap.GetButtonName(gamefunc_Open);
C_ReplaceQuoteSubstring(QUOTE_DEAD, "SPACE", OpenGameFunc); C_ReplaceQuoteSubstring(QUOTE_DEAD, "SPACE", OpenGameFunc);
C_ReplaceQuoteSubstring(QUOTE_DEAD, "OPEN", OpenGameFunc); C_ReplaceQuoteSubstring(QUOTE_DEAD, "OPEN", OpenGameFunc);
C_ReplaceQuoteSubstring(QUOTE_DEAD, "USE", OpenGameFunc); C_ReplaceQuoteSubstring(QUOTE_DEAD, "USE", OpenGameFunc);

View file

@ -1568,7 +1568,7 @@ void Menu_Init(void)
k = 1; k = 1;
for (i = 0; i < NUMGAMEFUNCTIONS; ++i) for (i = 0; i < NUMGAMEFUNCTIONS; ++i)
{ {
MenuGameFuncs[i] = CONFIG_FunctionNumToName(i); MenuGameFuncs[i] = buttonMap.GetButtonName(i);
MenuGameFuncs[i].Substitute('_', ' '); MenuGameFuncs[i].Substitute('_', ' ');
} }
if (RR) if (RR)
@ -1715,8 +1715,9 @@ void Menu_Init(void)
ME_MOUSESETUPBTNS[i].name = MenuMouseNames[i]; ME_MOUSESETUPBTNS[i].name = MenuMouseNames[i];
ME_MOUSESETUPBTNS[i].entry = &MEO_MOUSESETUPBTNS[i]; ME_MOUSESETUPBTNS[i].entry = &MEO_MOUSESETUPBTNS[i];
MEO_MOUSESETUPBTNS[i] = MEO_MOUSEJOYSETUPBTNS_TEMPLATE; MEO_MOUSESETUPBTNS[i] = MEO_MOUSEJOYSETUPBTNS_TEMPLATE;
MEO_MOUSESETUPBTNS[i].data = &MouseFunctions[MenuMouseDataIndex[i][0]][MenuMouseDataIndex[i][1]]; static int32_t sink;
} MEO_MOUSESETUPBTNS[i].data = &sink;
}
for (i = 0; i < 2*joystick.numButtons + 8*joystick.numHats; ++i) for (i = 0; i < 2*joystick.numButtons + 8*joystick.numHats; ++i)
{ {
if (i < 2*joystick.numButtons) if (i < 2*joystick.numButtons)
@ -3225,7 +3226,7 @@ static void Menu_PreInput(MenuEntry_t *entry)
case MENU_KEYBOARDKEYS: case MENU_KEYBOARDKEYS:
if (inputState.GetKeyStatus(sc_Delete)) if (inputState.GetKeyStatus(sc_Delete))
{ {
Bindings.UnbindACommand(CONFIG_FunctionNumToName(M_KEYBOARDKEYS.currentEntry)); Bindings.UnbindACommand(buttonMap.GetButtonName(M_KEYBOARDKEYS.currentEntry));
S_PlaySound(RR ? 335 : KICK_HIT); S_PlaySound(RR ? 335 : KICK_HIT);
inputState.ClearKeyStatus(sc_Delete); inputState.ClearKeyStatus(sc_Delete);
} }
@ -3283,7 +3284,7 @@ static int32_t Menu_PreCustom2ColScreen(MenuEntry_t *entry)
{ {
S_PlaySound(PISTOL_BODYHIT); S_PlaySound(PISTOL_BODYHIT);
*column->column[M_KEYBOARDKEYS.currentColumn] = sc; *column->column[M_KEYBOARDKEYS.currentColumn] = sc;
Bindings.SetBind(sc, CONFIG_FunctionNumToName(M_KEYBOARDKEYS.currentEntry)); Bindings.SetBind(sc, buttonMap.GetButtonName(M_KEYBOARDKEYS.currentEntry));
inputState.ClearKeyStatus(sc); inputState.ClearKeyStatus(sc);
return -1; return -1;

View file

@ -2759,11 +2759,11 @@ void P_GetInput(int playerNum)
D_ProcessEvents(); D_ProcessEvents();
if (in_aimmode) if (in_aimmode)
g_MyAimMode = inputState.BUTTON(gamefunc_Mouse_Aiming); g_MyAimMode = buttonMap.ButtonDown(gamefunc_Mouse_Aiming);
else else
{ {
g_oldAimStat = g_myAimStat; g_oldAimStat = g_myAimStat;
g_myAimStat = inputState.BUTTON(gamefunc_Mouse_Aiming); g_myAimStat = buttonMap.ButtonDown(gamefunc_Mouse_Aiming);
if (g_myAimStat > g_oldAimStat) if (g_myAimStat > g_oldAimStat)
{ {
@ -2797,7 +2797,7 @@ void P_GetInput(int playerNum)
// JBF: Run key behaviour is selectable // JBF: Run key behaviour is selectable
int const playerRunning = G_CheckAutorun(inputState.BUTTON(gamefunc_Run)); int const playerRunning = G_CheckAutorun(buttonMap.ButtonDown(gamefunc_Run));
int const turnAmount = playerRunning ? (NORMALTURN << 1) : NORMALTURN; int const turnAmount = playerRunning ? (NORMALTURN << 1) : NORMALTURN;
constexpr int const analogTurnAmount = (NORMALTURN << 1); constexpr int const analogTurnAmount = (NORMALTURN << 1);
int const keyMove = playerRunning ? (NORMALKEYMOVE << 1) : NORMALKEYMOVE; int const keyMove = playerRunning ? (NORMALKEYMOVE << 1) : NORMALKEYMOVE;
@ -2805,7 +2805,7 @@ void P_GetInput(int playerNum)
input_t input {}; input_t input {};
if (inputState.BUTTON(gamefunc_Strafe)) if (buttonMap.ButtonDown(gamefunc_Strafe))
{ {
static int strafeyaw; static int strafeyaw;
@ -2831,12 +2831,12 @@ void P_GetInput(int playerNum)
input.svel -= info.dx * keyMove / analogExtent; input.svel -= info.dx * keyMove / analogExtent;
input.fvel -= info.dz * keyMove / analogExtent; input.fvel -= info.dz * keyMove / analogExtent;
if (inputState.BUTTON(gamefunc_Strafe)) if (buttonMap.ButtonDown(gamefunc_Strafe))
{ {
if (inputState.BUTTON(gamefunc_Turn_Left) && !(pPlayer->movement_lock&4)) if (buttonMap.ButtonDown(gamefunc_Turn_Left) && !(pPlayer->movement_lock&4))
input.svel -= -keyMove; input.svel -= -keyMove;
if (inputState.BUTTON(gamefunc_Turn_Right) && !(pPlayer->movement_lock&8)) if (buttonMap.ButtonDown(gamefunc_Turn_Right) && !(pPlayer->movement_lock&8))
input.svel -= keyMove; input.svel -= keyMove;
} }
else else
@ -2847,12 +2847,12 @@ void P_GetInput(int playerNum)
lastInputClock = (int32_t) totalclock; lastInputClock = (int32_t) totalclock;
if (inputState.BUTTON(gamefunc_Turn_Left)) if (buttonMap.ButtonDown(gamefunc_Turn_Left))
{ {
turnHeldTime += elapsedTics; turnHeldTime += elapsedTics;
input.q16avel -= fix16_from_int((turnHeldTime >= TURBOTURNTIME) ? (turnAmount << 1) : (PREAMBLETURN << 1)); input.q16avel -= fix16_from_int((turnHeldTime >= TURBOTURNTIME) ? (turnAmount << 1) : (PREAMBLETURN << 1));
} }
else if (inputState.BUTTON(gamefunc_Turn_Right)) else if (buttonMap.ButtonDown(gamefunc_Turn_Right))
{ {
turnHeldTime += elapsedTics; turnHeldTime += elapsedTics;
input.q16avel += fix16_from_int((turnHeldTime >= TURBOTURNTIME) ? (turnAmount << 1) : (PREAMBLETURN << 1)); input.q16avel += fix16_from_int((turnHeldTime >= TURBOTURNTIME) ? (turnAmount << 1) : (PREAMBLETURN << 1));
@ -2861,24 +2861,24 @@ void P_GetInput(int playerNum)
turnHeldTime=0; turnHeldTime=0;
} }
if (inputState.BUTTON(gamefunc_Strafe_Left) && !(pPlayer->movement_lock & 4)) if (buttonMap.ButtonDown(gamefunc_Strafe_Left) && !(pPlayer->movement_lock & 4))
input.svel += keyMove; input.svel += keyMove;
if (inputState.BUTTON(gamefunc_Strafe_Right) && !(pPlayer->movement_lock & 8)) if (buttonMap.ButtonDown(gamefunc_Strafe_Right) && !(pPlayer->movement_lock & 8))
input.svel += -keyMove; input.svel += -keyMove;
if (RR) if (RR)
{ {
/*if (inputState.BUTTON(gamefunc_Quick_Kick)) /*if (buttonMap.ButtonDown(gamefunc_Quick_Kick))
{ {
localInput.bits |= inputState.BUTTON(gamefunc_Move_Forward)<<SK_AIM_UP; localInput.bits |= buttonMap.ButtonDown(gamefunc_Move_Forward)<<SK_AIM_UP;
localInput.bits |= inputState.BUTTON(gamefunc_Move_Backward)<<SK_AIM_DOWN; localInput.bits |= buttonMap.ButtonDown(gamefunc_Move_Backward)<<SK_AIM_DOWN;
} }
else*/ else*/
{ {
if (pPlayer->drink_amt >= 66 && pPlayer->drink_amt <= 87) if (pPlayer->drink_amt >= 66 && pPlayer->drink_amt <= 87)
{ {
if (inputState.BUTTON(gamefunc_Move_Forward)) if (buttonMap.ButtonDown(gamefunc_Move_Forward))
{ {
input.fvel += keyMove; input.fvel += keyMove;
if (pPlayer->drink_amt & 1) if (pPlayer->drink_amt & 1)
@ -2887,7 +2887,7 @@ void P_GetInput(int playerNum)
input.svel -= keyMove; input.svel -= keyMove;
} }
if (inputState.BUTTON(gamefunc_Move_Backward)) if (buttonMap.ButtonDown(gamefunc_Move_Backward))
{ {
input.fvel += -keyMove; input.fvel += -keyMove;
if (pPlayer->drink_amt & 1) if (pPlayer->drink_amt & 1)
@ -2898,20 +2898,20 @@ void P_GetInput(int playerNum)
} }
else else
{ {
if (inputState.BUTTON(gamefunc_Move_Forward)) if (buttonMap.ButtonDown(gamefunc_Move_Forward))
input.fvel += keyMove; input.fvel += keyMove;
if (inputState.BUTTON(gamefunc_Move_Backward)) if (buttonMap.ButtonDown(gamefunc_Move_Backward))
input.fvel += -keyMove; input.fvel += -keyMove;
} }
} }
} }
else else
{ {
if (inputState.BUTTON(gamefunc_Move_Forward) && !(g_player[playerNum].ps->movement_lock & 1)) if (buttonMap.ButtonDown(gamefunc_Move_Forward) && !(g_player[playerNum].ps->movement_lock & 1))
input.fvel += keyMove; input.fvel += keyMove;
if (inputState.BUTTON(gamefunc_Move_Backward) && !(g_player[playerNum].ps->movement_lock & 2)) if (buttonMap.ButtonDown(gamefunc_Move_Backward) && !(g_player[playerNum].ps->movement_lock & 2))
input.fvel += -keyMove; input.fvel += -keyMove;
} }
@ -2925,65 +2925,65 @@ void P_GetInput(int playerNum)
for (weaponSelection = gamefunc_Weapon_10; weaponSelection >= gamefunc_Weapon_1; --weaponSelection) for (weaponSelection = gamefunc_Weapon_10; weaponSelection >= gamefunc_Weapon_1; --weaponSelection)
{ {
if (inputState.BUTTON(weaponSelection)) if (buttonMap.ButtonDown(weaponSelection))
{ {
weaponSelection -= (gamefunc_Weapon_1 - 1); weaponSelection -= (gamefunc_Weapon_1 - 1);
break; break;
} }
} }
if (inputState.BUTTON(gamefunc_Last_Weapon)) if (buttonMap.ButtonDown(gamefunc_Last_Weapon))
weaponSelection = 14; weaponSelection = 14;
else if (inputState.BUTTON(gamefunc_Alt_Weapon)) else if (buttonMap.ButtonDown(gamefunc_Alt_Weapon))
weaponSelection = 13; weaponSelection = 13;
else if (inputState.BUTTON(gamefunc_Next_Weapon) || (inputState.BUTTON(gamefunc_Dpad_Select) && input.fvel > 0)) else if (buttonMap.ButtonDown(gamefunc_Next_Weapon) || (buttonMap.ButtonDown(gamefunc_Dpad_Select) && input.fvel > 0))
weaponSelection = 12; weaponSelection = 12;
else if (inputState.BUTTON(gamefunc_Previous_Weapon) || (inputState.BUTTON(gamefunc_Dpad_Select) && input.fvel < 0)) else if (buttonMap.ButtonDown(gamefunc_Previous_Weapon) || (buttonMap.ButtonDown(gamefunc_Dpad_Select) && input.fvel < 0))
weaponSelection = 11; weaponSelection = 11;
else if (weaponSelection == gamefunc_Weapon_1-1) else if (weaponSelection == gamefunc_Weapon_1-1)
weaponSelection = 0; weaponSelection = 0;
localInput.bits = (weaponSelection << SK_WEAPON_BITS) | (inputState.BUTTON(gamefunc_Fire) << SK_FIRE); localInput.bits = (weaponSelection << SK_WEAPON_BITS) | (buttonMap.ButtonDown(gamefunc_Fire) << SK_FIRE);
localInput.bits |= (inputState.BUTTON(gamefunc_Open) << SK_OPEN); localInput.bits |= (buttonMap.ButtonDown(gamefunc_Open) << SK_OPEN);
int const sectorLotag = pPlayer->cursectnum != -1 ? sector[pPlayer->cursectnum].lotag : 0; int const sectorLotag = pPlayer->cursectnum != -1 ? sector[pPlayer->cursectnum].lotag : 0;
int const crouchable = sectorLotag != 2 && (sectorLotag != 1 || pPlayer->spritebridge); int const crouchable = sectorLotag != 2 && (sectorLotag != 1 || pPlayer->spritebridge);
if (inputState.BUTTON(gamefunc_Toggle_Crouch)) if (buttonMap.ButtonDown(gamefunc_Toggle_Crouch))
{ {
pPlayer->crouch_toggle = !pPlayer->crouch_toggle && crouchable; pPlayer->crouch_toggle = !pPlayer->crouch_toggle && crouchable;
if (crouchable) if (crouchable)
inputState.ClearButton(gamefunc_Toggle_Crouch); buttonMap.ClearButton(gamefunc_Toggle_Crouch);
} }
if (inputState.BUTTON(gamefunc_Crouch) || inputState.BUTTON(gamefunc_Jump) || pPlayer->jetpack_on || (!crouchable && pPlayer->on_ground)) if (buttonMap.ButtonDown(gamefunc_Crouch) || buttonMap.ButtonDown(gamefunc_Jump) || pPlayer->jetpack_on || (!crouchable && pPlayer->on_ground))
pPlayer->crouch_toggle = 0; pPlayer->crouch_toggle = 0;
int const crouching = inputState.BUTTON(gamefunc_Crouch) || inputState.BUTTON(gamefunc_Toggle_Crouch) || pPlayer->crouch_toggle; int const crouching = buttonMap.ButtonDown(gamefunc_Crouch) || buttonMap.ButtonDown(gamefunc_Toggle_Crouch) || pPlayer->crouch_toggle;
localInput.bits |= (inputState.BUTTON(gamefunc_Jump) << SK_JUMP) | (crouching << SK_CROUCH); localInput.bits |= (buttonMap.ButtonDown(gamefunc_Jump) << SK_JUMP) | (crouching << SK_CROUCH);
localInput.bits |= (inputState.BUTTON(gamefunc_Aim_Up) || (inputState.BUTTON(gamefunc_Dpad_Aiming) && input.fvel > 0)) << SK_AIM_UP; localInput.bits |= (buttonMap.ButtonDown(gamefunc_Aim_Up) || (buttonMap.ButtonDown(gamefunc_Dpad_Aiming) && input.fvel > 0)) << SK_AIM_UP;
localInput.bits |= (inputState.BUTTON(gamefunc_Aim_Down) || (inputState.BUTTON(gamefunc_Dpad_Aiming) && input.fvel < 0)) << SK_AIM_DOWN; localInput.bits |= (buttonMap.ButtonDown(gamefunc_Aim_Down) || (buttonMap.ButtonDown(gamefunc_Dpad_Aiming) && input.fvel < 0)) << SK_AIM_DOWN;
localInput.bits |= (inputState.BUTTON(gamefunc_Center_View) << SK_CENTER_VIEW); localInput.bits |= (buttonMap.ButtonDown(gamefunc_Center_View) << SK_CENTER_VIEW);
localInput.bits |= (inputState.BUTTON(gamefunc_Look_Left) << SK_LOOK_LEFT) | (inputState.BUTTON(gamefunc_Look_Right) << SK_LOOK_RIGHT); localInput.bits |= (buttonMap.ButtonDown(gamefunc_Look_Left) << SK_LOOK_LEFT) | (buttonMap.ButtonDown(gamefunc_Look_Right) << SK_LOOK_RIGHT);
localInput.bits |= (inputState.BUTTON(gamefunc_Look_Up) << SK_LOOK_UP) | (inputState.BUTTON(gamefunc_Look_Down) << SK_LOOK_DOWN); localInput.bits |= (buttonMap.ButtonDown(gamefunc_Look_Up) << SK_LOOK_UP) | (buttonMap.ButtonDown(gamefunc_Look_Down) << SK_LOOK_DOWN);
localInput.bits |= (playerRunning << SK_RUN); localInput.bits |= (playerRunning << SK_RUN);
localInput.bits |= (inputState.BUTTON(gamefunc_Inventory_Left) || (inputState.BUTTON(gamefunc_Dpad_Select) && (input.svel > 0 || input.q16avel < 0))) << SK_INV_LEFT; localInput.bits |= (buttonMap.ButtonDown(gamefunc_Inventory_Left) || (buttonMap.ButtonDown(gamefunc_Dpad_Select) && (input.svel > 0 || input.q16avel < 0))) << SK_INV_LEFT;
localInput.bits |= (inputState.BUTTON(gamefunc_Inventory_Right) || (inputState.BUTTON(gamefunc_Dpad_Select) && (input.svel < 0 || input.q16avel > 0))) << SK_INV_RIGHT; localInput.bits |= (buttonMap.ButtonDown(gamefunc_Inventory_Right) || (buttonMap.ButtonDown(gamefunc_Dpad_Select) && (input.svel < 0 || input.q16avel > 0))) << SK_INV_RIGHT;
localInput.bits |= (inputState.BUTTON(gamefunc_Inventory) << SK_INVENTORY); localInput.bits |= (buttonMap.ButtonDown(gamefunc_Inventory) << SK_INVENTORY);
localInput.bits |= (inputState.BUTTON(gamefunc_Steroids) << SK_STEROIDS) | (inputState.BUTTON(gamefunc_NightVision) << SK_NIGHTVISION); localInput.bits |= (buttonMap.ButtonDown(gamefunc_Steroids) << SK_STEROIDS) | (buttonMap.ButtonDown(gamefunc_NightVision) << SK_NIGHTVISION);
localInput.bits |= (inputState.BUTTON(gamefunc_MedKit) << SK_MEDKIT) | (inputState.BUTTON(gamefunc_Holo_Duke) << SK_HOLODUKE); localInput.bits |= (buttonMap.ButtonDown(gamefunc_MedKit) << SK_MEDKIT) | (buttonMap.ButtonDown(gamefunc_Holo_Duke) << SK_HOLODUKE);
localInput.bits |= (inputState.BUTTON(gamefunc_Jetpack) << SK_JETPACK); localInput.bits |= (buttonMap.ButtonDown(gamefunc_Jetpack) << SK_JETPACK);
localInput.bits |= inputState.BUTTON(gamefunc_Holster_Weapon) << SK_HOLSTER; localInput.bits |= buttonMap.ButtonDown(gamefunc_Holster_Weapon) << SK_HOLSTER;
localInput.bits |= inputState.BUTTON(gamefunc_Quick_Kick) << SK_QUICK_KICK; localInput.bits |= buttonMap.ButtonDown(gamefunc_Quick_Kick) << SK_QUICK_KICK;
localInput.bits |= inputState.BUTTON(gamefunc_TurnAround) << SK_TURNAROUND; localInput.bits |= buttonMap.ButtonDown(gamefunc_TurnAround) << SK_TURNAROUND;
localInput.bits |= (g_MyAimMode << SK_AIMMODE); localInput.bits |= (g_MyAimMode << SK_AIMMODE);
localInput.bits |= (g_gameQuit << SK_GAMEQUIT); localInput.bits |= (g_gameQuit << SK_GAMEQUIT);
@ -3000,21 +3000,21 @@ void P_GetInput(int playerNum)
localInput.bits |= 1 << SK_LOOK_DOWN; localInput.bits |= 1 << SK_LOOK_DOWN;
} }
if (inputState.BUTTON(gamefunc_Dpad_Select)) if (buttonMap.ButtonDown(gamefunc_Dpad_Select))
{ {
input.fvel = 0; input.fvel = 0;
input.svel = 0; input.svel = 0;
input.q16avel = 0; input.q16avel = 0;
} }
else if (inputState.BUTTON(gamefunc_Dpad_Aiming)) else if (buttonMap.ButtonDown(gamefunc_Dpad_Aiming))
input.fvel = 0; input.fvel = 0;
localInput.extbits = (inputState.BUTTON(gamefunc_Move_Forward) || (input.fvel > 0)); localInput.extbits = (buttonMap.ButtonDown(gamefunc_Move_Forward) || (input.fvel > 0));
localInput.extbits |= (inputState.BUTTON(gamefunc_Move_Backward) || (input.fvel < 0)) << 1; localInput.extbits |= (buttonMap.ButtonDown(gamefunc_Move_Backward) || (input.fvel < 0)) << 1;
localInput.extbits |= (inputState.BUTTON(gamefunc_Strafe_Left) || (input.svel > 0)) << 2; localInput.extbits |= (buttonMap.ButtonDown(gamefunc_Strafe_Left) || (input.svel > 0)) << 2;
localInput.extbits |= (inputState.BUTTON(gamefunc_Strafe_Right) || (input.svel < 0)) << 3; localInput.extbits |= (buttonMap.ButtonDown(gamefunc_Strafe_Right) || (input.svel < 0)) << 3;
localInput.extbits |= inputState.BUTTON(gamefunc_Turn_Left)<<4; localInput.extbits |= buttonMap.ButtonDown(gamefunc_Turn_Left)<<4;
localInput.extbits |= inputState.BUTTON(gamefunc_Turn_Right)<<5; localInput.extbits |= buttonMap.ButtonDown(gamefunc_Turn_Right)<<5;
if (ud.scrollmode && ud.overhead_on) if (ud.scrollmode && ud.overhead_on)
{ {
@ -3065,11 +3065,11 @@ void P_GetInputMotorcycle(int playerNum)
D_ProcessEvents(); D_ProcessEvents();
if (in_aimmode) if (in_aimmode)
g_MyAimMode = inputState.BUTTON(gamefunc_Mouse_Aiming); g_MyAimMode = buttonMap.ButtonDown(gamefunc_Mouse_Aiming);
else else
{ {
g_oldAimStat = g_myAimStat; g_oldAimStat = g_myAimStat;
g_myAimStat = inputState.BUTTON(gamefunc_Mouse_Aiming); g_myAimStat = buttonMap.ButtonDown(gamefunc_Mouse_Aiming);
if (g_myAimStat > g_oldAimStat) if (g_myAimStat > g_oldAimStat)
{ {
@ -3102,7 +3102,7 @@ void P_GetInputMotorcycle(int playerNum)
} }
// JBF: Run key behaviour is selectable // JBF: Run key behaviour is selectable
int const playerRunning = G_CheckAutorun(inputState.BUTTON(gamefunc_Run)); int const playerRunning = G_CheckAutorun(buttonMap.ButtonDown(gamefunc_Run));
constexpr int const analogTurnAmount = (NORMALTURN << 1); constexpr int const analogTurnAmount = (NORMALTURN << 1);
int const keyMove = playerRunning ? (NORMALKEYMOVE << 1) : NORMALKEYMOVE; int const keyMove = playerRunning ? (NORMALKEYMOVE << 1) : NORMALKEYMOVE;
constexpr int const analogExtent = 32767; // KEEPINSYNC sdlayer.cpp constexpr int const analogExtent = 32767; // KEEPINSYNC sdlayer.cpp
@ -3128,40 +3128,40 @@ void P_GetInputMotorcycle(int playerNum)
pPlayer->crouch_toggle = 0; pPlayer->crouch_toggle = 0;
localInput.bits = inputState.BUTTON(gamefunc_Fire) << SK_FIRE; localInput.bits = buttonMap.ButtonDown(gamefunc_Fire) << SK_FIRE;
localInput.bits |= inputState.BUTTON(gamefunc_Steroids) << SK_STEROIDS; localInput.bits |= buttonMap.ButtonDown(gamefunc_Steroids) << SK_STEROIDS;
localInput.bits |= inputState.BUTTON(gamefunc_NightVision) << SK_NIGHTVISION; localInput.bits |= buttonMap.ButtonDown(gamefunc_NightVision) << SK_NIGHTVISION;
localInput.bits |= inputState.BUTTON(gamefunc_MedKit) << SK_MEDKIT; localInput.bits |= buttonMap.ButtonDown(gamefunc_MedKit) << SK_MEDKIT;
localInput.bits |= (inputState.BUTTON(gamefunc_Inventory_Left) || localInput.bits |= (buttonMap.ButtonDown(gamefunc_Inventory_Left) ||
(inputState.BUTTON(gamefunc_Dpad_Select) && (input.svel > 0 || input.q16avel < 0))) << SK_INV_LEFT; (buttonMap.ButtonDown(gamefunc_Dpad_Select) && (input.svel > 0 || input.q16avel < 0))) << SK_INV_LEFT;
localInput.bits |= inputState.GetKeyStatus(sc_Pause) << SK_PAUSE; localInput.bits |= inputState.GetKeyStatus(sc_Pause) << SK_PAUSE;
localInput.bits |= inputState.BUTTON(gamefunc_Holo_Duke) << SK_HOLODUKE; localInput.bits |= buttonMap.ButtonDown(gamefunc_Holo_Duke) << SK_HOLODUKE;
localInput.bits |= inputState.BUTTON(gamefunc_Jetpack) << SK_JETPACK; localInput.bits |= buttonMap.ButtonDown(gamefunc_Jetpack) << SK_JETPACK;
localInput.bits |= (g_gameQuit << SK_GAMEQUIT); localInput.bits |= (g_gameQuit << SK_GAMEQUIT);
localInput.bits |= (inputState.BUTTON(gamefunc_Inventory_Right) || localInput.bits |= (buttonMap.ButtonDown(gamefunc_Inventory_Right) ||
(inputState.BUTTON(gamefunc_Dpad_Select) && (input.svel < 0 || input.q16avel > 0))) << SK_INV_RIGHT; (buttonMap.ButtonDown(gamefunc_Dpad_Select) && (input.svel < 0 || input.q16avel > 0))) << SK_INV_RIGHT;
localInput.bits |= inputState.BUTTON(gamefunc_Open) << SK_OPEN; localInput.bits |= buttonMap.ButtonDown(gamefunc_Open) << SK_OPEN;
localInput.bits |= inputState.BUTTON(gamefunc_Inventory) << SK_INVENTORY; localInput.bits |= buttonMap.ButtonDown(gamefunc_Inventory) << SK_INVENTORY;
localInput.bits |= ((uint32_t)inputState.GetKeyStatus(sc_Escape)) << SK_ESCAPE; localInput.bits |= ((uint32_t)inputState.GetKeyStatus(sc_Escape)) << SK_ESCAPE;
if (inputState.BUTTON(gamefunc_Dpad_Select)) if (buttonMap.ButtonDown(gamefunc_Dpad_Select))
{ {
input.fvel = 0; input.fvel = 0;
input.svel = 0; input.svel = 0;
input.q16avel = 0; input.q16avel = 0;
} }
if (inputState.BUTTON(gamefunc_Dpad_Aiming)) if (buttonMap.ButtonDown(gamefunc_Dpad_Aiming))
input.fvel = 0; input.fvel = 0;
localInput.extbits = (inputState.BUTTON(gamefunc_Move_Forward) || (input.fvel > 0)); localInput.extbits = (buttonMap.ButtonDown(gamefunc_Move_Forward) || (input.fvel > 0));
localInput.extbits |= (inputState.BUTTON(gamefunc_Move_Backward) || (input.fvel < 0)) << 1; localInput.extbits |= (buttonMap.ButtonDown(gamefunc_Move_Backward) || (input.fvel < 0)) << 1;
localInput.extbits |= (inputState.BUTTON(gamefunc_Strafe_Left) || (input.svel > 0)) << 2; localInput.extbits |= (buttonMap.ButtonDown(gamefunc_Strafe_Left) || (input.svel > 0)) << 2;
localInput.extbits |= (inputState.BUTTON(gamefunc_Strafe_Right) || (input.svel < 0)) << 3; localInput.extbits |= (buttonMap.ButtonDown(gamefunc_Strafe_Right) || (input.svel < 0)) << 3;
int const turn = input.q16avel / 32; int const turn = input.q16avel / 32;
int turnLeft = inputState.BUTTON(gamefunc_Turn_Left) || inputState.BUTTON(gamefunc_Strafe_Left); int turnLeft = buttonMap.ButtonDown(gamefunc_Turn_Left) || buttonMap.ButtonDown(gamefunc_Strafe_Left);
int turnRight = inputState.BUTTON(gamefunc_Turn_Right) || inputState.BUTTON(gamefunc_Strafe_Right); int turnRight = buttonMap.ButtonDown(gamefunc_Turn_Right) || buttonMap.ButtonDown(gamefunc_Strafe_Right);
int avelScale = F16((turnLeft || turnRight) ? 1 : 0); int avelScale = F16((turnLeft || turnRight) ? 1 : 0);
if (turn) if (turn)
{ {
@ -3176,9 +3176,9 @@ void P_GetInputMotorcycle(int playerNum)
if (!pPlayer->moto_underwater) if (!pPlayer->moto_underwater)
{ {
localInput.bits |= (inputState.BUTTON(gamefunc_Move_Forward) || inputState.BUTTON(gamefunc_Strafe)) << SK_JUMP; localInput.bits |= (buttonMap.ButtonDown(gamefunc_Move_Forward) || buttonMap.ButtonDown(gamefunc_Strafe)) << SK_JUMP;
localInput.bits |= inputState.BUTTON(gamefunc_Move_Backward) << SK_AIM_UP; localInput.bits |= buttonMap.ButtonDown(gamefunc_Move_Backward) << SK_AIM_UP;
localInput.bits |= inputState.BUTTON(gamefunc_Run) << SK_CROUCH; localInput.bits |= buttonMap.ButtonDown(gamefunc_Run) << SK_CROUCH;
} }
localInput.bits |= turnLeft << SK_AIM_DOWN; localInput.bits |= turnLeft << SK_AIM_DOWN;
@ -3188,7 +3188,7 @@ void P_GetInputMotorcycle(int playerNum)
static int32_t lastInputClock = 0; // MED static int32_t lastInputClock = 0; // MED
int32_t const elapsedTics = (int32_t) totalclock - lastInputClock; int32_t const elapsedTics = (int32_t) totalclock - lastInputClock;
int const moveBack = inputState.BUTTON(gamefunc_Move_Backward) && pPlayer->moto_speed <= 0; int const moveBack = buttonMap.ButtonDown(gamefunc_Move_Backward) && pPlayer->moto_speed <= 0;
if (pPlayer->moto_speed == 0 || !pPlayer->on_ground) if (pPlayer->moto_speed == 0 || !pPlayer->on_ground)
{ {
@ -3363,11 +3363,11 @@ void P_GetInputBoat(int playerNum)
D_ProcessEvents(); D_ProcessEvents();
if (in_aimmode) if (in_aimmode)
g_MyAimMode = inputState.BUTTON(gamefunc_Mouse_Aiming); g_MyAimMode = buttonMap.ButtonDown(gamefunc_Mouse_Aiming);
else else
{ {
g_oldAimStat = g_myAimStat; g_oldAimStat = g_myAimStat;
g_myAimStat = inputState.BUTTON(gamefunc_Mouse_Aiming); g_myAimStat = buttonMap.ButtonDown(gamefunc_Mouse_Aiming);
if (g_myAimStat > g_oldAimStat) if (g_myAimStat > g_oldAimStat)
{ {
@ -3400,7 +3400,7 @@ void P_GetInputBoat(int playerNum)
} }
// JBF: Run key behaviour is selectable // JBF: Run key behaviour is selectable
int const playerRunning = G_CheckAutorun(inputState.BUTTON(gamefunc_Run)); int const playerRunning = G_CheckAutorun(buttonMap.ButtonDown(gamefunc_Run));
constexpr int const analogTurnAmount = (NORMALTURN << 1); constexpr int const analogTurnAmount = (NORMALTURN << 1);
int const keyMove = playerRunning ? (NORMALKEYMOVE << 1) : NORMALKEYMOVE; int const keyMove = playerRunning ? (NORMALKEYMOVE << 1) : NORMALKEYMOVE;
constexpr int const analogExtent = 32767; // KEEPINSYNC sdlayer.cpp constexpr int const analogExtent = 32767; // KEEPINSYNC sdlayer.cpp
@ -3426,40 +3426,40 @@ void P_GetInputBoat(int playerNum)
pPlayer->crouch_toggle = 0; pPlayer->crouch_toggle = 0;
localInput.bits = inputState.BUTTON(gamefunc_Fire) << SK_FIRE; localInput.bits = buttonMap.ButtonDown(gamefunc_Fire) << SK_FIRE;
localInput.bits |= inputState.BUTTON(gamefunc_Steroids) << SK_STEROIDS; localInput.bits |= buttonMap.ButtonDown(gamefunc_Steroids) << SK_STEROIDS;
localInput.bits |= inputState.BUTTON(gamefunc_NightVision) << SK_NIGHTVISION; localInput.bits |= buttonMap.ButtonDown(gamefunc_NightVision) << SK_NIGHTVISION;
localInput.bits |= inputState.BUTTON(gamefunc_MedKit) << SK_MEDKIT; localInput.bits |= buttonMap.ButtonDown(gamefunc_MedKit) << SK_MEDKIT;
localInput.bits |= (inputState.BUTTON(gamefunc_Inventory_Left) || localInput.bits |= (buttonMap.ButtonDown(gamefunc_Inventory_Left) ||
(inputState.BUTTON(gamefunc_Dpad_Select) && (input.svel > 0 || input.q16avel < 0))) << SK_INV_LEFT; (buttonMap.ButtonDown(gamefunc_Dpad_Select) && (input.svel > 0 || input.q16avel < 0))) << SK_INV_LEFT;
localInput.bits |= inputState.GetKeyStatus(sc_Pause) << SK_PAUSE; localInput.bits |= inputState.GetKeyStatus(sc_Pause) << SK_PAUSE;
localInput.bits |= inputState.BUTTON(gamefunc_Holo_Duke) << SK_HOLODUKE; localInput.bits |= buttonMap.ButtonDown(gamefunc_Holo_Duke) << SK_HOLODUKE;
localInput.bits |= inputState.BUTTON(gamefunc_Jetpack) << SK_JETPACK; localInput.bits |= buttonMap.ButtonDown(gamefunc_Jetpack) << SK_JETPACK;
localInput.bits |= (g_gameQuit << SK_GAMEQUIT); localInput.bits |= (g_gameQuit << SK_GAMEQUIT);
localInput.bits |= (inputState.BUTTON(gamefunc_Inventory_Right) || localInput.bits |= (buttonMap.ButtonDown(gamefunc_Inventory_Right) ||
(inputState.BUTTON(gamefunc_Dpad_Select) && (input.svel < 0 || input.q16avel > 0))) << SK_INV_RIGHT; (buttonMap.ButtonDown(gamefunc_Dpad_Select) && (input.svel < 0 || input.q16avel > 0))) << SK_INV_RIGHT;
localInput.bits |= inputState.BUTTON(gamefunc_Open) << SK_OPEN; localInput.bits |= buttonMap.ButtonDown(gamefunc_Open) << SK_OPEN;
localInput.bits |= inputState.BUTTON(gamefunc_Inventory) << SK_INVENTORY; localInput.bits |= buttonMap.ButtonDown(gamefunc_Inventory) << SK_INVENTORY;
localInput.bits |= ((uint32_t)inputState.GetKeyStatus(sc_Escape)) << SK_ESCAPE; localInput.bits |= ((uint32_t)inputState.GetKeyStatus(sc_Escape)) << SK_ESCAPE;
if (inputState.BUTTON(gamefunc_Dpad_Select)) if (buttonMap.ButtonDown(gamefunc_Dpad_Select))
{ {
input.fvel = 0; input.fvel = 0;
input.svel = 0; input.svel = 0;
input.q16avel = 0; input.q16avel = 0;
} }
if (inputState.BUTTON(gamefunc_Dpad_Aiming)) if (buttonMap.ButtonDown(gamefunc_Dpad_Aiming))
input.fvel = 0; input.fvel = 0;
localInput.extbits = (inputState.BUTTON(gamefunc_Move_Forward) || (input.fvel > 0)); localInput.extbits = (buttonMap.ButtonDown(gamefunc_Move_Forward) || (input.fvel > 0));
localInput.extbits |= (inputState.BUTTON(gamefunc_Move_Backward) || (input.fvel < 0)) << 1; localInput.extbits |= (buttonMap.ButtonDown(gamefunc_Move_Backward) || (input.fvel < 0)) << 1;
localInput.extbits |= (inputState.BUTTON(gamefunc_Strafe_Left) || (input.svel > 0)) << 2; localInput.extbits |= (buttonMap.ButtonDown(gamefunc_Strafe_Left) || (input.svel > 0)) << 2;
localInput.extbits |= (inputState.BUTTON(gamefunc_Strafe_Right) || (input.svel < 0)) << 3; localInput.extbits |= (buttonMap.ButtonDown(gamefunc_Strafe_Right) || (input.svel < 0)) << 3;
int const turn = input.q16avel / 32; int const turn = input.q16avel / 32;
int turnLeft = inputState.BUTTON(gamefunc_Turn_Left) || inputState.BUTTON(gamefunc_Strafe_Left); int turnLeft = buttonMap.ButtonDown(gamefunc_Turn_Left) || buttonMap.ButtonDown(gamefunc_Strafe_Left);
int turnRight = inputState.BUTTON(gamefunc_Turn_Right) || inputState.BUTTON(gamefunc_Strafe_Right); int turnRight = buttonMap.ButtonDown(gamefunc_Turn_Right) || buttonMap.ButtonDown(gamefunc_Strafe_Right);
int avelScale = F16((turnLeft || turnRight) ? 1 : 0); int avelScale = F16((turnLeft || turnRight) ? 1 : 0);
if (turn) if (turn)
{ {
@ -3472,9 +3472,9 @@ void P_GetInputBoat(int playerNum)
input.svel = input.fvel = input.q16avel = input.q16horz = 0; input.svel = input.fvel = input.q16avel = input.q16horz = 0;
localInput.bits |= (inputState.BUTTON(gamefunc_Move_Forward) || inputState.BUTTON(gamefunc_Strafe)) << SK_JUMP; localInput.bits |= (buttonMap.ButtonDown(gamefunc_Move_Forward) || buttonMap.ButtonDown(gamefunc_Strafe)) << SK_JUMP;
localInput.bits |= inputState.BUTTON(gamefunc_Move_Backward) << SK_AIM_UP; localInput.bits |= buttonMap.ButtonDown(gamefunc_Move_Backward) << SK_AIM_UP;
localInput.bits |= inputState.BUTTON(gamefunc_Run) << SK_CROUCH; localInput.bits |= buttonMap.ButtonDown(gamefunc_Run) << SK_CROUCH;
localInput.bits |= turnLeft << SK_AIM_DOWN; localInput.bits |= turnLeft << SK_AIM_DOWN;
localInput.bits |= turnRight << SK_LOOK_LEFT; localInput.bits |= turnRight << SK_LOOK_LEFT;

View file

@ -1220,7 +1220,7 @@ void G_DisplayRest(int32_t smoothratio)
gametext_center(70, "Press F1 to Accept, F2 to Decline"); gametext_center(70, "Press F1 to Accept, F2 to Decline");
} }
if (inputState.BUTTON(gamefunc_Show_DukeMatch_Scores)) if (buttonMap.ButtonDown(gamefunc_Show_DukeMatch_Scores))
G_ShowScores(); G_ShowScores();
if (g_Debug) if (g_Debug)

View file

@ -471,9 +471,9 @@ DemoPlayBack(void)
else else
{ {
if (inputState.BUTTON(gamefunc_See_Coop_View)) if (buttonMap.ButtonDown(gamefunc_See_Coop_View))
{ {
inputState.ClearButton(gamefunc_See_Coop_View); buttonMap.ClearButton(gamefunc_See_Coop_View);
screenpeek = connectpoint2[screenpeek]; screenpeek = connectpoint2[screenpeek];
@ -497,16 +497,16 @@ DemoPlayBack(void)
// if a key is pressed, start recording from the point the key // if a key is pressed, start recording from the point the key
// was pressed // was pressed
if (inputState.BUTTON(gamefunc_Move_Forward) || if (buttonMap.ButtonDown(gamefunc_Move_Forward) ||
inputState.BUTTON(gamefunc_Move_Backward) || buttonMap.ButtonDown(gamefunc_Move_Backward) ||
inputState.BUTTON(gamefunc_Turn_Left) || buttonMap.ButtonDown(gamefunc_Turn_Left) ||
inputState.BUTTON(gamefunc_Turn_Right) || buttonMap.ButtonDown(gamefunc_Turn_Right) ||
inputState.BUTTON(gamefunc_Fire) || buttonMap.ButtonDown(gamefunc_Fire) ||
inputState.BUTTON(gamefunc_Open) || buttonMap.ButtonDown(gamefunc_Open) ||
inputState.BUTTON(gamefunc_Jump) || buttonMap.ButtonDown(gamefunc_Jump) ||
inputState.BUTTON(gamefunc_Crouch) || buttonMap.ButtonDown(gamefunc_Crouch) ||
inputState.BUTTON(gamefunc_Look_Up) || buttonMap.ButtonDown(gamefunc_Look_Up) ||
inputState.BUTTON(gamefunc_Look_Down)) buttonMap.ButtonDown(gamefunc_Look_Down))
{ {
DemoBackupBuffer(); DemoBackupBuffer();
@ -517,7 +517,7 @@ DemoPlayBack(void)
} }
} }
if (inputState.BUTTON(gamefunc_See_Co_Op_View)) if (buttonMap.ButtonDown(gamefunc_See_Co_Op_View))
{ {
screenpeek += 1; screenpeek += 1;
if (screenpeek > numplayers-1) if (screenpeek > numplayers-1)

View file

@ -1066,16 +1066,16 @@ ResizeView(PLAYERp pp)
} }
else else
{ {
if (inputState.BUTTON(gamefunc_Shrink_Screen)) // && if (buttonMap.ButtonDown(gamefunc_Shrink_Screen)) // &&
{ {
inputState.ClearButton(gamefunc_Shrink_Screen); buttonMap.ClearButton(gamefunc_Shrink_Screen);
SetBorder(pp, gs.BorderNum + 1); SetBorder(pp, gs.BorderNum + 1);
SetRedrawScreen(pp); SetRedrawScreen(pp);
} }
if (inputState.BUTTON(gamefunc_Enlarge_Screen)) // && if (buttonMap.ButtonDown(gamefunc_Enlarge_Screen)) // &&
{ {
inputState.ClearButton(gamefunc_Enlarge_Screen); buttonMap.ClearButton(gamefunc_Enlarge_Screen);
SetBorder(pp, gs.BorderNum - 1); SetBorder(pp, gs.BorderNum - 1);
SetRedrawScreen(pp); SetRedrawScreen(pp);
} }

View file

@ -3438,11 +3438,11 @@ SinglePlayInput(PLAYERp pp)
int pnum = myconnectindex; int pnum = myconnectindex;
uint8_t* kp; uint8_t* kp;
if (inputState.BUTTON(gamefunc_See_Co_Op_View) && !UsingMenus && !ConPanel && dimensionmode == 3) if (buttonMap.ButtonDown(gamefunc_See_Co_Op_View) && !UsingMenus && !ConPanel && dimensionmode == 3)
{ {
short oldscreenpeek = screenpeek; short oldscreenpeek = screenpeek;
inputState.ClearButton(gamefunc_See_Co_Op_View); buttonMap.ClearButton(gamefunc_See_Co_Op_View);
screenpeek = connectpoint2[screenpeek]; screenpeek = connectpoint2[screenpeek];
@ -3839,9 +3839,9 @@ void GetMessageInput(PLAYERp pp)
if (!MessageInputMode && !ConInputMode) if (!MessageInputMode && !ConInputMode)
{ {
if (inputState.BUTTON(gamefunc_SendMessage)) if (buttonMap.ButtonDown(gamefunc_SendMessage))
{ {
inputState.ClearButton(gamefunc_SendMessage); buttonMap.ClearButton(gamefunc_SendMessage);
inputState.keyFlushChars(); inputState.keyFlushChars();
MessageInputMode = TRUE; MessageInputMode = TRUE;
InputMode = TRUE; InputMode = TRUE;
@ -3876,7 +3876,7 @@ void GetMessageInput(PLAYERp pp)
InputMode = FALSE; InputMode = FALSE;
inputState.ClearKeysDown(); inputState.ClearKeysDown();
inputState.keyFlushChars(); inputState.keyFlushChars();
inputState.ClearButton(gamefunc_Inventory); buttonMap.ClearButton(gamefunc_Inventory);
} }
else else
{ {
@ -3910,11 +3910,11 @@ SEND_MESSAGE:
InputMode = FALSE; InputMode = FALSE;
inputState.ClearKeysDown(); inputState.ClearKeysDown();
inputState.keyFlushChars(); inputState.keyFlushChars();
inputState.ClearButton(gamefunc_Inventory); buttonMap.ClearButton(gamefunc_Inventory);
CON_ProcessUserCommand(); // Check to see if it's a cheat or command CON_ProcessUserCommand(); // Check to see if it's a cheat or command
for (i = 0; i < NUMGAMEFUNCTIONS; i++) for (i = 0; i < NUMGAMEFUNCTIONS; i++)
inputState.ClearButton(i); buttonMap.ClearButton(i);
// Put who sent this // Put who sent this
sprintf(ds,"%s: %s",pp->PlayerName,MessageInputString); sprintf(ds,"%s: %s",pp->PlayerName,MessageInputString);
@ -4006,7 +4006,7 @@ void GetConInput(PLAYERp pp)
InputMode = FALSE; InputMode = FALSE;
inputState.ClearKeysDown(); inputState.ClearKeysDown();
inputState.keyFlushChars(); inputState.keyFlushChars();
inputState.ClearButton(gamefunc_Inventory); buttonMap.ClearButton(gamefunc_Inventory);
memset(MessageInputString, '\0', sizeof(MessageInputString)); memset(MessageInputString, '\0', sizeof(MessageInputString));
} }
else else
@ -4014,7 +4014,7 @@ void GetConInput(PLAYERp pp)
InputMode = FALSE; InputMode = FALSE;
inputState.ClearKeysDown(); inputState.ClearKeysDown();
inputState.keyFlushChars(); inputState.keyFlushChars();
inputState.ClearButton(gamefunc_Inventory); buttonMap.ClearButton(gamefunc_Inventory);
CON_ConMessage("%s", MessageInputString); CON_ConMessage("%s", MessageInputString);
CON_ProcessUserCommand(); // Check to see if it's a cheat or command CON_ProcessUserCommand(); // Check to see if it's a cheat or command
@ -4162,13 +4162,13 @@ getinput(SW_PACKET *loc)
if (in_aimmode) if (in_aimmode)
g_MyAimMode = 0; g_MyAimMode = 0;
if (inputState.BUTTON(gamefunc_Mouse_Aiming)) if (buttonMap.ButtonDown(gamefunc_Mouse_Aiming))
{ {
if (in_aimmode) if (in_aimmode)
g_MyAimMode = 1; g_MyAimMode = 1;
else else
{ {
inputState.ClearButton(gamefunc_Mouse_Aiming); buttonMap.ClearButton(gamefunc_Mouse_Aiming);
g_MyAimMode = !g_MyAimMode; g_MyAimMode = !g_MyAimMode;
if (g_MyAimMode) if (g_MyAimMode)
{ {
@ -4200,9 +4200,9 @@ getinput(SW_PACKET *loc)
} }
// MAP KEY // MAP KEY
if (inputState.BUTTON(gamefunc_Map)) if (buttonMap.ButtonDown(gamefunc_Map))
{ {
inputState.ClearButton(gamefunc_Map); buttonMap.ClearButton(gamefunc_Map);
// Init follow coords // Init follow coords
Follow_posx = pp->posx; Follow_posx = pp->posx;
@ -4225,9 +4225,9 @@ getinput(SW_PACKET *loc)
// Toggle follow map mode on/off // Toggle follow map mode on/off
if (dimensionmode == 5 || dimensionmode == 6) if (dimensionmode == 5 || dimensionmode == 6)
{ {
if (inputState.BUTTON(gamefunc_Map_Follow_Mode)) if (buttonMap.ButtonDown(gamefunc_Map_Follow_Mode))
{ {
inputState.ClearButton(gamefunc_Map_Follow_Mode); buttonMap.ClearButton(gamefunc_Map_Follow_Mode);
ScrollMode2D = !ScrollMode2D; ScrollMode2D = !ScrollMode2D;
Follow_posx = pp->posx; Follow_posx = pp->posx;
Follow_posy = pp->posy; Follow_posy = pp->posy;
@ -4244,11 +4244,11 @@ getinput(SW_PACKET *loc)
if (MenuInputMode || UsingMenus || ScrollMode2D || InputMode) if (MenuInputMode || UsingMenus || ScrollMode2D || InputMode)
return; return;
SET_LOC_KEY(loc->bits, SK_SPACE_BAR, ((!!inputState.GetKeyStatus(KEYSC_SPACE)) | inputState.BUTTON(gamefunc_Open))); SET_LOC_KEY(loc->bits, SK_SPACE_BAR, ((!!inputState.GetKeyStatus(KEYSC_SPACE)) | buttonMap.ButtonDown(gamefunc_Open)));
running = G_CheckAutorun(inputState.BUTTON(gamefunc_Run)); running = G_CheckAutorun(buttonMap.ButtonDown(gamefunc_Run));
if (inputState.BUTTON(gamefunc_Strafe) && !pp->sop) if (buttonMap.ButtonDown(gamefunc_Strafe) && !pp->sop)
svel = -info.dyaw; svel = -info.dyaw;
else else
{ {
@ -4286,16 +4286,16 @@ getinput(SW_PACKET *loc)
keymove = NORMALKEYMOVE; keymove = NORMALKEYMOVE;
} }
if (inputState.BUTTON(gamefunc_Strafe) && !pp->sop) if (buttonMap.ButtonDown(gamefunc_Strafe) && !pp->sop)
{ {
if (inputState.BUTTON(gamefunc_Turn_Left)) if (buttonMap.ButtonDown(gamefunc_Turn_Left))
svel -= -keymove; svel -= -keymove;
if (inputState.BUTTON(gamefunc_Turn_Right)) if (buttonMap.ButtonDown(gamefunc_Turn_Right))
svel -= keymove; svel -= keymove;
} }
else else
{ {
if (inputState.BUTTON(gamefunc_Turn_Left)) if (buttonMap.ButtonDown(gamefunc_Turn_Left))
{ {
turnheldtime += synctics; turnheldtime += synctics;
if (turnheldtime >= TURBOTURNTIME) if (turnheldtime >= TURBOTURNTIME)
@ -4303,7 +4303,7 @@ getinput(SW_PACKET *loc)
else else
angvel -= PREAMBLETURN; angvel -= PREAMBLETURN;
} }
else if (inputState.BUTTON(gamefunc_Turn_Right)) else if (buttonMap.ButtonDown(gamefunc_Turn_Right))
{ {
turnheldtime += synctics; turnheldtime += synctics;
if (turnheldtime >= TURBOTURNTIME) if (turnheldtime >= TURBOTURNTIME)
@ -4317,13 +4317,13 @@ getinput(SW_PACKET *loc)
} }
} }
if (inputState.BUTTON(gamefunc_Strafe_Left) && !pp->sop) if (buttonMap.ButtonDown(gamefunc_Strafe_Left) && !pp->sop)
svel += keymove; svel += keymove;
if (inputState.BUTTON(gamefunc_Strafe_Right) && !pp->sop) if (buttonMap.ButtonDown(gamefunc_Strafe_Right) && !pp->sop)
svel += -keymove; svel += -keymove;
if (inputState.BUTTON(gamefunc_Move_Forward)) if (buttonMap.ButtonDown(gamefunc_Move_Forward))
{ {
vel += keymove; vel += keymove;
//DSPRINTF(ds,"vel key %d",vel); //DSPRINTF(ds,"vel key %d",vel);
@ -4335,7 +4335,7 @@ getinput(SW_PACKET *loc)
//DebugWriteString(ds); //DebugWriteString(ds);
} }
if (inputState.BUTTON(gamefunc_Move_Backward)) if (buttonMap.ButtonDown(gamefunc_Move_Backward))
vel += -keymove; vel += -keymove;
@ -4378,36 +4378,36 @@ getinput(SW_PACKET *loc)
inputState.ClearKeyStatus(sc_Pause); inputState.ClearKeyStatus(sc_Pause);
} }
SET_LOC_KEY(loc->bits, SK_CENTER_VIEW, inputState.BUTTON(gamefunc_Center_View)); SET_LOC_KEY(loc->bits, SK_CENTER_VIEW, buttonMap.ButtonDown(gamefunc_Center_View));
SET_LOC_KEY(loc->bits, SK_RUN, inputState.BUTTON(gamefunc_Run)); SET_LOC_KEY(loc->bits, SK_RUN, buttonMap.ButtonDown(gamefunc_Run));
SET_LOC_KEY(loc->bits, SK_SHOOT, inputState.BUTTON(gamefunc_Fire)); SET_LOC_KEY(loc->bits, SK_SHOOT, buttonMap.ButtonDown(gamefunc_Fire));
// actually snap // actually snap
SET_LOC_KEY(loc->bits, SK_SNAP_UP, inputState.BUTTON(gamefunc_Aim_Up)); SET_LOC_KEY(loc->bits, SK_SNAP_UP, buttonMap.ButtonDown(gamefunc_Aim_Up));
SET_LOC_KEY(loc->bits, SK_SNAP_DOWN, inputState.BUTTON(gamefunc_Aim_Down)); SET_LOC_KEY(loc->bits, SK_SNAP_DOWN, buttonMap.ButtonDown(gamefunc_Aim_Down));
// actually just look // actually just look
SET_LOC_KEY(loc->bits, SK_LOOK_UP, inputState.BUTTON(gamefunc_Look_Up)); SET_LOC_KEY(loc->bits, SK_LOOK_UP, buttonMap.ButtonDown(gamefunc_Look_Up));
SET_LOC_KEY(loc->bits, SK_LOOK_DOWN, inputState.BUTTON(gamefunc_Look_Down)); SET_LOC_KEY(loc->bits, SK_LOOK_DOWN, buttonMap.ButtonDown(gamefunc_Look_Down));
for (i = 0; i < MAX_WEAPONS_KEYS; i++) for (i = 0; i < MAX_WEAPONS_KEYS; i++)
{ {
if (inputState.BUTTON(gamefunc_Weapon_1 + i)) if (buttonMap.ButtonDown(gamefunc_Weapon_1 + i))
{ {
SET(loc->bits, i + 1); SET(loc->bits, i + 1);
break; break;
} }
} }
if (inputState.BUTTON(gamefunc_Next_Weapon)) if (buttonMap.ButtonDown(gamefunc_Next_Weapon))
{ {
USERp u = User[pp->PlayerSprite]; USERp u = User[pp->PlayerSprite];
short next_weapon = u->WeaponNum + 1; short next_weapon = u->WeaponNum + 1;
short start_weapon; short start_weapon;
inputState.ClearButton(gamefunc_Next_Weapon); buttonMap.ClearButton(gamefunc_Next_Weapon);
start_weapon = u->WeaponNum + 1; start_weapon = u->WeaponNum + 1;
@ -4441,13 +4441,13 @@ getinput(SW_PACKET *loc)
} }
if (inputState.BUTTON(gamefunc_Previous_Weapon)) if (buttonMap.ButtonDown(gamefunc_Previous_Weapon))
{ {
USERp u = User[pp->PlayerSprite]; USERp u = User[pp->PlayerSprite];
short prev_weapon = u->WeaponNum - 1; short prev_weapon = u->WeaponNum - 1;
short start_weapon; short start_weapon;
inputState.ClearButton(gamefunc_Previous_Weapon); buttonMap.ClearButton(gamefunc_Previous_Weapon);
start_weapon = u->WeaponNum - 1; start_weapon = u->WeaponNum - 1;
@ -4479,42 +4479,42 @@ getinput(SW_PACKET *loc)
} }
inv_hotkey = 0; inv_hotkey = 0;
if (inputState.BUTTON(gamefunc_Med_Kit)) if (buttonMap.ButtonDown(gamefunc_Med_Kit))
inv_hotkey = INVENTORY_MEDKIT+1; inv_hotkey = INVENTORY_MEDKIT+1;
if (inputState.BUTTON(gamefunc_Smoke_Bomb)) if (buttonMap.ButtonDown(gamefunc_Smoke_Bomb))
inv_hotkey = INVENTORY_CLOAK+1; inv_hotkey = INVENTORY_CLOAK+1;
if (inputState.BUTTON(gamefunc_Night_Vision)) if (buttonMap.ButtonDown(gamefunc_Night_Vision))
inv_hotkey = INVENTORY_NIGHT_VISION+1; inv_hotkey = INVENTORY_NIGHT_VISION+1;
if (inputState.BUTTON(gamefunc_Gas_Bomb)) if (buttonMap.ButtonDown(gamefunc_Gas_Bomb))
inv_hotkey = INVENTORY_CHEMBOMB+1; inv_hotkey = INVENTORY_CHEMBOMB+1;
if (inputState.BUTTON(gamefunc_Flash_Bomb) && dimensionmode == 3) if (buttonMap.ButtonDown(gamefunc_Flash_Bomb) && dimensionmode == 3)
inv_hotkey = INVENTORY_FLASHBOMB+1; inv_hotkey = INVENTORY_FLASHBOMB+1;
if (inputState.BUTTON(gamefunc_Caltrops)) if (buttonMap.ButtonDown(gamefunc_Caltrops))
inv_hotkey = INVENTORY_CALTROPS+1; inv_hotkey = INVENTORY_CALTROPS+1;
SET(loc->bits, inv_hotkey<<SK_INV_HOTKEY_BIT0); SET(loc->bits, inv_hotkey<<SK_INV_HOTKEY_BIT0);
SET_LOC_KEY(loc->bits, SK_INV_USE, inputState.BUTTON(gamefunc_Inventory)); SET_LOC_KEY(loc->bits, SK_INV_USE, buttonMap.ButtonDown(gamefunc_Inventory));
SET_LOC_KEY(loc->bits, SK_OPERATE, inputState.BUTTON(gamefunc_Open)); SET_LOC_KEY(loc->bits, SK_OPERATE, buttonMap.ButtonDown(gamefunc_Open));
SET_LOC_KEY(loc->bits, SK_JUMP, inputState.BUTTON(gamefunc_Jump)); SET_LOC_KEY(loc->bits, SK_JUMP, buttonMap.ButtonDown(gamefunc_Jump));
SET_LOC_KEY(loc->bits, SK_CRAWL, inputState.BUTTON(gamefunc_Crouch)); SET_LOC_KEY(loc->bits, SK_CRAWL, buttonMap.ButtonDown(gamefunc_Crouch));
SET_LOC_KEY(loc->bits, SK_TURN_180, inputState.BUTTON(gamefunc_TurnAround)); SET_LOC_KEY(loc->bits, SK_TURN_180, buttonMap.ButtonDown(gamefunc_TurnAround));
SET_LOC_KEY(loc->bits, SK_INV_LEFT, inputState.BUTTON(gamefunc_Inventory_Left)); SET_LOC_KEY(loc->bits, SK_INV_LEFT, buttonMap.ButtonDown(gamefunc_Inventory_Left));
SET_LOC_KEY(loc->bits, SK_INV_RIGHT, inputState.BUTTON(gamefunc_Inventory_Right)); SET_LOC_KEY(loc->bits, SK_INV_RIGHT, buttonMap.ButtonDown(gamefunc_Inventory_Right));
SET_LOC_KEY(loc->bits, SK_HIDE_WEAPON, inputState.BUTTON(gamefunc_Holster_Weapon)); SET_LOC_KEY(loc->bits, SK_HIDE_WEAPON, buttonMap.ButtonDown(gamefunc_Holster_Weapon));
// need BUTTON // need BUTTON
SET_LOC_KEY(loc->bits, SK_CRAWL_LOCK, inputState.GetKeyStatus(KEYSC_NUM)); SET_LOC_KEY(loc->bits, SK_CRAWL_LOCK, inputState.GetKeyStatus(KEYSC_NUM));
if (gNet.MultiGameType == MULTI_GAME_COOPERATIVE) if (gNet.MultiGameType == MULTI_GAME_COOPERATIVE)
{ {
if (inputState.BUTTON(gamefunc_See_Co_Op_View)) if (buttonMap.ButtonDown(gamefunc_See_Co_Op_View))
{ {
inputState.ClearButton(gamefunc_See_Co_Op_View); buttonMap.ClearButton(gamefunc_See_Co_Op_View);
screenpeek = connectpoint2[screenpeek]; screenpeek = connectpoint2[screenpeek];
@ -4551,9 +4551,9 @@ getinput(SW_PACKET *loc)
FunctionKeys(pp); FunctionKeys(pp);
if (inputState.BUTTON(gamefunc_Toggle_Crosshair)) if (buttonMap.ButtonDown(gamefunc_Toggle_Crosshair))
{ {
inputState.ClearButton(gamefunc_Toggle_Crosshair); buttonMap.ClearButton(gamefunc_Toggle_Crosshair);
pToggleCrosshair(pp); pToggleCrosshair(pp);
} }
} }

View file

@ -705,7 +705,7 @@ SWBOOL MNU_KeySetupCustom(UserCall call, MenuItem *item)
for (i=0; i<(int)SIZ(strs); i++) for (i=0; i<(int)SIZ(strs); i++)
{ {
w = 0; w = 0;
auto c = CONFIG_FunctionNumToName(currentkey); auto c = buttonMap.GetButtonName(currentkey);
sprintf(ds,strs[i],c,col[currentcol]); sprintf(ds,strs[i],c,col[currentcol]);
for (j=0; ds[j]; j++) if (ds[j] == '_') ds[j] = ' '; for (j=0; ds[j]; j++) if (ds[j] == '_') ds[j] = ' ';
MNU_MeasureString(ds, &w, &h); MNU_MeasureString(ds, &w, &h);
@ -738,7 +738,7 @@ SWBOOL MNU_KeySetupCustom(UserCall call, MenuItem *item)
inputState.ClearKeyStatus(sc_Delete); inputState.ClearKeyStatus(sc_Delete);
if (currentkey != gamefunc_Show_Console) if (currentkey != gamefunc_Show_Console)
{ {
//Bindings.UnbindACommand(CONFIG_FunctionNumToName(M_KEYBOARDKEYS.currentEntry)); //Bindings.UnbindACommand(buttonMap.GetButtonName(M_KEYBOARDKEYS.currentEntry));
} }
} }
else if (inputState.GetKeyStatus(sc_Home)) else if (inputState.GetKeyStatus(sc_Home))
@ -797,7 +797,7 @@ SWBOOL MNU_KeySetupCustom(UserCall call, MenuItem *item)
for (i = topitem; i <= botitem; i++) for (i = topitem; i <= botitem; i++)
{ {
auto c = CONFIG_FunctionNumToName(i); auto c = buttonMap.GetButtonName(i);
for (j = 0; c[j]; j++) for (j = 0; c[j]; j++)
{ {
if (c[j] == '_') ds[j] = ' '; if (c[j] == '_') ds[j] = ' ';
@ -922,7 +922,7 @@ static int MNU_SelectButtonFunction(const char *buttonname, int *currentfunc)
} }
else else
{ {
auto c = CONFIG_FunctionNumToName(i-1); auto c = buttonMap.GetButtonName(i-1);
for (j = 0; c[j]; j++) for (j = 0; c[j]; j++)
{ {
if (c[j] == '_') ds[j] = ' '; if (c[j] == '_') ds[j] = ' ';
@ -1047,7 +1047,7 @@ static SWBOOL MNU_SetMouseButtonFunctions(MenuItem_p item)
} }
else else
{ {
strcpy(MouseButtonFunctions[item->tics], CONFIG_FunctionNumToName(function)); strcpy(MouseButtonFunctions[item->tics], buttonMap.GetButtonName(function));
for (p = MouseButtonFunctions[item->tics]; *p; p++) for (p = MouseButtonFunctions[item->tics]; *p; p++)
{ {
if (*p == '_') if (*p == '_')
@ -1131,7 +1131,7 @@ static SWBOOL MNU_SetAdvancedMouseFunctions(MenuItem_p item)
} }
else else
{ {
strcpy(AdvancedMouseAxisFunctions[axis], CONFIG_FunctionNumToName(MouseDigitalAxes[axis/2][axis%2])); strcpy(AdvancedMouseAxisFunctions[axis], buttonMap.GetButtonName(MouseDigitalAxes[axis/2][axis%2]));
for (p = AdvancedMouseAxisFunctions[axis]; *p; p++) for (p = AdvancedMouseAxisFunctions[axis]; *p; p++)
{ {
if (*p == '_') if (*p == '_')
@ -1359,7 +1359,7 @@ static SWBOOL MNU_SetJoystickButtonFunctions(MenuItem_p item)
} }
else else
{ {
strcpy(JoystickButtonFunctions[button + clicked*MAXJOYBUTTONS], CONFIG_FunctionNumToName(function)); strcpy(JoystickButtonFunctions[button + clicked*MAXJOYBUTTONS], buttonMap.GetButtonName(function));
for (p = JoystickButtonFunctions[button + clicked*MAXJOYBUTTONS]; *p; p++) for (p = JoystickButtonFunctions[button + clicked*MAXJOYBUTTONS]; *p; p++)
{ {
if (*p == '_') if (*p == '_')
@ -1473,7 +1473,7 @@ static SWBOOL MNU_SetJoystickAxisFunctions(MenuItem_p item)
} }
else else
{ {
strcpy(JoystickAxisFunctions[item->tics], CONFIG_FunctionNumToName(function)); strcpy(JoystickAxisFunctions[item->tics], buttonMap.GetButtonName(function));
for (p = JoystickAxisFunctions[item->tics]; *p; p++) for (p = JoystickAxisFunctions[item->tics]; *p; p++)
{ {
if (*p == '_') if (*p == '_')

View file

@ -2419,25 +2419,25 @@ MoveScrollMode2D(PLAYERp pp)
return; return;
// Recenter view if told // Recenter view if told
if (inputState.BUTTON(gamefunc_Center_View)) if (buttonMap.ButtonDown(gamefunc_Center_View))
{ {
Follow_posx = pp->posx; Follow_posx = pp->posx;
Follow_posy = pp->posy; Follow_posy = pp->posy;
} }
// Toggle follow map mode on/off // Toggle follow map mode on/off
if (inputState.BUTTON(gamefunc_Map_Follow_Mode)) if (buttonMap.ButtonDown(gamefunc_Map_Follow_Mode))
{ {
inputState.ClearButton(gamefunc_Map_Follow_Mode); buttonMap.ClearButton(gamefunc_Map_Follow_Mode);
ScrollMode2D = !ScrollMode2D; ScrollMode2D = !ScrollMode2D;
// Reset coords // Reset coords
Follow_posx = pp->posx; Follow_posx = pp->posx;
Follow_posy = pp->posy; Follow_posy = pp->posy;
} }
running = G_CheckAutorun(inputState.BUTTON(gamefunc_Run)); running = G_CheckAutorun(buttonMap.ButtonDown(gamefunc_Run));
if (inputState.BUTTON(gamefunc_Strafe)) if (buttonMap.ButtonDown(gamefunc_Strafe))
mfsvel -= scrl_input.dyaw>>2; mfsvel -= scrl_input.dyaw>>2;
mfsvel -= scrl_input.dx>>2; mfsvel -= scrl_input.dx>>2;
mfvel = -scrl_input.dz>>2; mfvel = -scrl_input.dz>>2;
@ -2454,11 +2454,11 @@ MoveScrollMode2D(PLAYERp pp)
if (!HelpInputMode && !ConPanel) if (!HelpInputMode && !ConPanel)
{ {
if (inputState.BUTTON(gamefunc_Turn_Left)) if (buttonMap.ButtonDown(gamefunc_Turn_Left))
{ {
mfsvel -= -keymove; mfsvel -= -keymove;
} }
if (inputState.BUTTON(gamefunc_Turn_Right)) if (buttonMap.ButtonDown(gamefunc_Turn_Right))
{ {
mfsvel -= keymove; mfsvel -= keymove;
} }
@ -2466,12 +2466,12 @@ MoveScrollMode2D(PLAYERp pp)
if (!InputMode && !ConPanel) if (!InputMode && !ConPanel)
{ {
if (inputState.BUTTON(gamefunc_Strafe_Left)) if (buttonMap.ButtonDown(gamefunc_Strafe_Left))
{ {
mfsvel += keymove; mfsvel += keymove;
} }
if (inputState.BUTTON(gamefunc_Strafe_Right)) if (buttonMap.ButtonDown(gamefunc_Strafe_Right))
{ {
mfsvel += -keymove; mfsvel += -keymove;
} }
@ -2479,12 +2479,12 @@ MoveScrollMode2D(PLAYERp pp)
if (!UsingMenus && !HelpInputMode && !ConPanel) if (!UsingMenus && !HelpInputMode && !ConPanel)
{ {
if (inputState.BUTTON(gamefunc_Move_Forward)) if (buttonMap.ButtonDown(gamefunc_Move_Forward))
{ {
mfvel += keymove; mfvel += keymove;
} }
if (inputState.BUTTON(gamefunc_Move_Backward)) if (buttonMap.ButtonDown(gamefunc_Move_Backward))
{ {
mfvel += -keymove; mfvel += -keymove;
} }