- moved all keyboard related code into the InputState class, so that looking for this stuff is easier.

Sadly there's 1ß00 lines of code using this...
This commit is contained in:
Christoph Oelckers 2019-11-04 00:53:55 +01:00
parent 1b65510bc2
commit b747df60ee
50 changed files with 1009 additions and 1069 deletions

View file

@ -717,7 +717,6 @@ set (PCH_SOURCES
mact/src/animlib.cpp mact/src/animlib.cpp
mact/src/control.cpp mact/src/control.cpp
mact/src/joystick.cpp mact/src/joystick.cpp
mact/src/keyboard.cpp
mact/src/input.cpp mact/src/input.cpp
thirdparty/src/base64.cpp thirdparty/src/base64.cpp

View file

@ -409,7 +409,7 @@ void PreloadCache(void)
int cnt = 0; int cnt = 0;
int percentDisplayed = -1; int percentDisplayed = -1;
for (int i=0; i<kMaxTiles && !KB_KeyPressed(sc_Space); i++) for (int i=0; i<kMaxTiles && !inputState.GetKeyStatus(sc_Space); i++)
{ {
if (TestBitString(gotpic, i)) if (TestBitString(gotpic, i))
{ {
@ -817,7 +817,7 @@ 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 (BUTTON(gamefunc_See_Chase_View) && !alt && !shift) if (inputState.BUTTON(gamefunc_See_Chase_View) && !alt && !shift)
{ {
inputState.ClearButton(gamefunc_See_Chase_View); inputState.ClearButton(gamefunc_See_Chase_View);
if (gViewPos > VIEWPOS_0) if (gViewPos > VIEWPOS_0)
@ -825,7 +825,7 @@ void LocalKeys(void)
else else
gViewPos = VIEWPOS_1; gViewPos = VIEWPOS_1;
} }
if (BUTTON(gamefunc_See_Coop_View)) if (inputState.BUTTON(gamefunc_See_Coop_View))
{ {
inputState.ClearButton(gamefunc_See_Coop_View); inputState.ClearButton(gamefunc_See_Coop_View);
if (gGameOptions.nGameType == 1) if (gGameOptions.nGameType == 1)
@ -851,7 +851,7 @@ void LocalKeys(void)
} }
if (gDoQuickSave) if (gDoQuickSave)
{ {
keyFlushScans(); inputState.keyFlushScans();
switch (gDoQuickSave) switch (gDoQuickSave)
{ {
case 1: case 1:
@ -865,7 +865,7 @@ void LocalKeys(void)
return; return;
} }
char key; char key;
if ((key = keyGetScan()) != 0) if ((key = inputState.keyGetScan()) != 0)
{ {
if ((alt || shift) && gGameOptions.nGameType > 0 && key >= sc_F1 && key <= sc_F10) if ((alt || shift) && gGameOptions.nGameType > 0 && key >= sc_F1 && key <= sc_F10)
{ {
@ -879,7 +879,7 @@ void LocalKeys(void)
gPlayerMsg.Set(*CombatMacros[fk]); gPlayerMsg.Set(*CombatMacros[fk]);
gPlayerMsg.Send(); gPlayerMsg.Send();
} }
keyFlushScans(); inputState.keyFlushScans();
inputState.ClearKeyStatus(key); inputState.ClearKeyStatus(key);
inputState.ClearButton(gamefunc_See_Chase_View); inputState.ClearButton(gamefunc_See_Chase_View);
return; return;
@ -895,7 +895,7 @@ void LocalKeys(void)
} }
break; break;
case sc_Escape: case sc_Escape:
keyFlushScans(); inputState.keyFlushScans();
if (gGameStarted && gPlayer[myconnectindex].pXSprite->health != 0) if (gGameStarted && gPlayer[myconnectindex].pXSprite->health != 0)
{ {
if (!gGameMenuMgr.m_bActive) if (!gGameMenuMgr.m_bActive)
@ -908,45 +908,45 @@ void LocalKeys(void)
} }
return; return;
case sc_F1: case sc_F1:
keyFlushScans(); inputState.keyFlushScans();
if (gGameOptions.nGameType == 0) if (gGameOptions.nGameType == 0)
gGameMenuMgr.Push(&menuOrder,-1); gGameMenuMgr.Push(&menuOrder,-1);
break; break;
case sc_F2: case sc_F2:
keyFlushScans(); inputState.keyFlushScans();
if (!gGameMenuMgr.m_bActive && gGameOptions.nGameType == 0) if (!gGameMenuMgr.m_bActive && gGameOptions.nGameType == 0)
gGameMenuMgr.Push(&menuSaveGame,-1); gGameMenuMgr.Push(&menuSaveGame,-1);
break; break;
case sc_F3: case sc_F3:
keyFlushScans(); inputState.keyFlushScans();
if (!gGameMenuMgr.m_bActive && gGameOptions.nGameType == 0) if (!gGameMenuMgr.m_bActive && gGameOptions.nGameType == 0)
gGameMenuMgr.Push(&menuLoadGame,-1); gGameMenuMgr.Push(&menuLoadGame,-1);
break; break;
case sc_F4: case sc_F4:
keyFlushScans(); inputState.keyFlushScans();
if (!gGameMenuMgr.m_bActive) if (!gGameMenuMgr.m_bActive)
gGameMenuMgr.Push(&menuOptionsSound,-1); gGameMenuMgr.Push(&menuOptionsSound,-1);
return; return;
case sc_F5: case sc_F5:
keyFlushScans(); inputState.keyFlushScans();
if (!gGameMenuMgr.m_bActive) if (!gGameMenuMgr.m_bActive)
gGameMenuMgr.Push(&menuOptions,-1); gGameMenuMgr.Push(&menuOptions,-1);
return; return;
case sc_F6: case sc_F6:
keyFlushScans(); inputState.keyFlushScans();
DoQuickSave(); DoQuickSave();
break; break;
case sc_F8: case sc_F8:
keyFlushScans(); inputState.keyFlushScans();
if (!gGameMenuMgr.m_bActive) if (!gGameMenuMgr.m_bActive)
gGameMenuMgr.Push(&menuOptionsDisplayMode, -1); gGameMenuMgr.Push(&menuOptionsDisplayMode, -1);
return; return;
case sc_F9: case sc_F9:
keyFlushScans(); inputState.keyFlushScans();
DoQuickLoad(); DoQuickLoad();
break; break;
case sc_F10: case sc_F10:
keyFlushScans(); inputState.keyFlushScans();
if (!gGameMenuMgr.m_bActive) if (!gGameMenuMgr.m_bActive)
gGameMenuMgr.Push(&menuQuit,-1); gGameMenuMgr.Push(&menuQuit,-1);
break; break;
@ -1359,9 +1359,9 @@ RESTART:
gRestartGame = 0; gRestartGame = 0;
if (gGameOptions.nGameType > 0) if (gGameOptions.nGameType > 0)
{ {
KB_ClearKeysDown(); inputState.ClearKeysDown();
KB_FlushKeyboardQueue(); inputState.keyFlushChars();
keyFlushScans(); inputState.keyFlushScans();
} }
else if (gDemo.at1 && !bAddUserMap && !bNoDemo) else if (gDemo.at1 && !bAddUserMap && !bNoDemo)
gDemo.Playback(); gDemo.Playback();

View file

@ -45,7 +45,7 @@ BEGIN_BLD_NS
int32_t ctrlCheckAllInput(void) int32_t ctrlCheckAllInput(void)
{ {
return ( return (
KB_KeyWaiting() || inputState.keyBufferWaiting() ||
MOUSE_GetButtons() || MOUSE_GetButtons() ||
JOYSTICK_GetButtons() JOYSTICK_GetButtons()
); );
@ -53,8 +53,8 @@ int32_t ctrlCheckAllInput(void)
void ctrlClearAllInput(void) void ctrlClearAllInput(void)
{ {
KB_FlushKeyboardQueue(); inputState.keyFlushChars();
KB_ClearKeysDown(); inputState.ClearKeysDown();
MOUSE_ClearAllButtons(); MOUSE_ClearAllButtons();
JOYSTICK_ClearAllButtons(); JOYSTICK_ClearAllButtons();
} }
@ -124,7 +124,7 @@ void ctrlGetInput(void)
if (in_aimmode) if (in_aimmode)
g_MyAimMode = 0; g_MyAimMode = 0;
if (BUTTON(gamefunc_Mouse_Aiming)) if (inputState.BUTTON(gamefunc_Mouse_Aiming))
{ {
if (in_aimmode) if (in_aimmode)
g_MyAimMode = 1; g_MyAimMode = 1;
@ -175,14 +175,14 @@ void ctrlGetInput(void)
gInput.keyFlags.quit = 1; gInput.keyFlags.quit = 1;
if (gGameStarted && gInputMode != kInputMessage && gInputMode != kInputMenu if (gGameStarted && gInputMode != kInputMessage && gInputMode != kInputMenu
&& BUTTON(gamefunc_Send_Message)) && inputState.BUTTON(gamefunc_Send_Message))
{ {
inputState.ClearButton(gamefunc_Send_Message); inputState.ClearButton(gamefunc_Send_Message);
keyFlushScans(); inputState.keyFlushScans();
gInputMode = kInputMessage; gInputMode = kInputMessage;
} }
if (BUTTON(gamefunc_AutoRun)) if (inputState.BUTTON(gamefunc_AutoRun))
{ {
inputState.ClearButton(gamefunc_AutoRun); inputState.ClearButton(gamefunc_AutoRun);
gAutoRun = !gAutoRun; gAutoRun = !gAutoRun;
@ -192,20 +192,20 @@ void ctrlGetInput(void)
viewSetMessage("Auto run OFF"); viewSetMessage("Auto run OFF");
} }
if (BUTTON(gamefunc_Map_Toggle)) if (inputState.BUTTON(gamefunc_Map_Toggle))
{ {
inputState.ClearButton(gamefunc_Map_Toggle); inputState.ClearButton(gamefunc_Map_Toggle);
viewToggle(gViewMode); viewToggle(gViewMode);
} }
if (BUTTON(gamefunc_Map_Follow_Mode)) if (inputState.BUTTON(gamefunc_Map_Follow_Mode))
{ {
inputState.ClearButton(gamefunc_Map_Follow_Mode); inputState.ClearButton(gamefunc_Map_Follow_Mode);
gFollowMap = !gFollowMap; gFollowMap = !gFollowMap;
gViewMap.FollowMode(gFollowMap); gViewMap.FollowMode(gFollowMap);
} }
if (BUTTON(gamefunc_Shrink_Screen)) if (inputState.BUTTON(gamefunc_Shrink_Screen))
{ {
if (gViewMode == 3) if (gViewMode == 3)
{ {
@ -219,7 +219,7 @@ void ctrlGetInput(void)
} }
} }
if (BUTTON(gamefunc_Enlarge_Screen)) if (inputState.BUTTON(gamefunc_Enlarge_Screen))
{ {
if (gViewMode == 3) if (gViewMode == 3)
{ {
@ -233,104 +233,104 @@ void ctrlGetInput(void)
} }
} }
if (BUTTON(gamefunc_Toggle_Crosshair)) if (inputState.BUTTON(gamefunc_Toggle_Crosshair))
{ {
inputState.ClearButton(gamefunc_Toggle_Crosshair); inputState.ClearButton(gamefunc_Toggle_Crosshair);
cl_crosshair = !cl_crosshair; cl_crosshair = !cl_crosshair;
} }
if (BUTTON(gamefunc_Next_Weapon)) if (inputState.BUTTON(gamefunc_Next_Weapon))
{ {
inputState.ClearButton(gamefunc_Next_Weapon); inputState.ClearButton(gamefunc_Next_Weapon);
gInput.keyFlags.nextWeapon = 1; gInput.keyFlags.nextWeapon = 1;
} }
if (BUTTON(gamefunc_Previous_Weapon)) if (inputState.BUTTON(gamefunc_Previous_Weapon))
{ {
inputState.ClearButton(gamefunc_Previous_Weapon); inputState.ClearButton(gamefunc_Previous_Weapon);
gInput.keyFlags.prevWeapon = 1; gInput.keyFlags.prevWeapon = 1;
} }
if (BUTTON(gamefunc_Show_Opponents_Weapon)) if (inputState.BUTTON(gamefunc_Show_Opponents_Weapon))
{ {
inputState.ClearButton(gamefunc_Show_Opponents_Weapon); inputState.ClearButton(gamefunc_Show_Opponents_Weapon);
cl_showweapon = (cl_showweapon + 1) & 3; cl_showweapon = (cl_showweapon + 1) & 3;
} }
if (BUTTON(gamefunc_Jump)) if (inputState.BUTTON(gamefunc_Jump))
gInput.buttonFlags.jump = 1; gInput.buttonFlags.jump = 1;
if (BUTTON(gamefunc_Crouch)) if (inputState.BUTTON(gamefunc_Crouch))
gInput.buttonFlags.crouch = 1; gInput.buttonFlags.crouch = 1;
if (BUTTON(gamefunc_Weapon_Fire)) if (inputState.BUTTON(gamefunc_Fire))
gInput.buttonFlags.shoot = 1; gInput.buttonFlags.shoot = 1;
if (BUTTON(gamefunc_Weapon_Special_Fire)) if (inputState.BUTTON(gamefunc_Alt_Fire))
gInput.buttonFlags.shoot2 = 1; gInput.buttonFlags.shoot2 = 1;
if (BUTTON(gamefunc_Open)) if (inputState.BUTTON(gamefunc_Open))
{ {
inputState.ClearButton(gamefunc_Open); inputState.ClearButton(gamefunc_Open);
gInput.keyFlags.action = 1; gInput.keyFlags.action = 1;
} }
gInput.buttonFlags.lookUp = BUTTON(gamefunc_Look_Up); gInput.buttonFlags.lookUp = inputState.BUTTON(gamefunc_Look_Up);
gInput.buttonFlags.lookDown = BUTTON(gamefunc_Look_Down); gInput.buttonFlags.lookDown = inputState.BUTTON(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 = BUTTON(gamefunc_Aim_Up); gInput.buttonFlags.lookUp = inputState.BUTTON(gamefunc_Aim_Up);
gInput.buttonFlags.lookDown = BUTTON(gamefunc_Aim_Down); gInput.buttonFlags.lookDown = inputState.BUTTON(gamefunc_Aim_Down);
} }
if (BUTTON(gamefunc_Aim_Center)) if (inputState.BUTTON(gamefunc_Aim_Center))
{ {
inputState.ClearButton(gamefunc_Aim_Center); inputState.ClearButton(gamefunc_Aim_Center);
gInput.keyFlags.lookCenter = 1; gInput.keyFlags.lookCenter = 1;
} }
gInput.keyFlags.spin180 = BUTTON(gamefunc_Turn_Around); gInput.keyFlags.spin180 = inputState.BUTTON(gamefunc_Turn_Around);
if (BUTTON(gamefunc_Inventory_Left)) if (inputState.BUTTON(gamefunc_Inventory_Left))
{ {
inputState.ClearButton(gamefunc_Inventory_Left); inputState.ClearButton(gamefunc_Inventory_Left);
gInput.keyFlags.prevItem = 1; gInput.keyFlags.prevItem = 1;
} }
if (BUTTON(gamefunc_Inventory_Right)) if (inputState.BUTTON(gamefunc_Inventory_Right))
{ {
inputState.ClearButton(gamefunc_Inventory_Right); inputState.ClearButton(gamefunc_Inventory_Right);
gInput.keyFlags.nextItem = 1; gInput.keyFlags.nextItem = 1;
} }
if (BUTTON(gamefunc_Inventory_Use)) if (inputState.BUTTON(gamefunc_Inventory_Use))
{ {
inputState.ClearButton(gamefunc_Inventory_Use); inputState.ClearButton(gamefunc_Inventory_Use);
gInput.keyFlags.useItem = 1; gInput.keyFlags.useItem = 1;
} }
if (BUTTON(gamefunc_BeastVision)) if (inputState.BUTTON(gamefunc_BeastVision))
{ {
inputState.ClearButton(gamefunc_BeastVision); inputState.ClearButton(gamefunc_BeastVision);
gInput.useFlags.useBeastVision = 1; gInput.useFlags.useBeastVision = 1;
} }
if (BUTTON(gamefunc_CrystalBall)) if (inputState.BUTTON(gamefunc_CrystalBall))
{ {
inputState.ClearButton(gamefunc_CrystalBall); inputState.ClearButton(gamefunc_CrystalBall);
gInput.useFlags.useCrystalBall = 1; gInput.useFlags.useCrystalBall = 1;
} }
if (BUTTON(gamefunc_JumpBoots)) if (inputState.BUTTON(gamefunc_JumpBoots))
{ {
inputState.ClearButton(gamefunc_JumpBoots); inputState.ClearButton(gamefunc_JumpBoots);
gInput.useFlags.useJumpBoots = 1; gInput.useFlags.useJumpBoots = 1;
} }
if (BUTTON(gamefunc_MedKit)) if (inputState.BUTTON(gamefunc_MedKit))
{ {
inputState.ClearButton(gamefunc_MedKit); inputState.ClearButton(gamefunc_MedKit);
gInput.useFlags.useMedKit = 1; gInput.useFlags.useMedKit = 1;
@ -338,60 +338,60 @@ void ctrlGetInput(void)
for (int i = 0; i < 10; i++) for (int i = 0; i < 10; i++)
{ {
if (BUTTON(gamefunc_Weapon_1 + i)) if (inputState.BUTTON(gamefunc_Weapon_1 + i))
{ {
inputState.ClearButton(gamefunc_Weapon_1 + i); inputState.ClearButton(gamefunc_Weapon_1 + i);
gInput.newWeapon = 1 + i; gInput.newWeapon = 1 + i;
} }
} }
if (BUTTON(gamefunc_ProximityBombs)) if (inputState.BUTTON(gamefunc_ProximityBombs))
{ {
inputState.ClearButton(gamefunc_ProximityBombs); inputState.ClearButton(gamefunc_ProximityBombs);
gInput.newWeapon = 11; gInput.newWeapon = 11;
} }
if (BUTTON(gamefunc_RemoteBombs)) if (inputState.BUTTON(gamefunc_RemoteBombs))
{ {
inputState.ClearButton(gamefunc_RemoteBombs); inputState.ClearButton(gamefunc_RemoteBombs);
gInput.newWeapon = 12; gInput.newWeapon = 12;
} }
if (BUTTON(gamefunc_Holster_Weapon)) if (inputState.BUTTON(gamefunc_Holster_Weapon))
{ {
inputState.ClearButton(gamefunc_Holster_Weapon); inputState.ClearButton(gamefunc_Holster_Weapon);
gInput.keyFlags.holsterWeapon = 1; gInput.keyFlags.holsterWeapon = 1;
} }
char run = G_CheckAutorun(BUTTON(gamefunc_Run)); char run = G_CheckAutorun(inputState.BUTTON(gamefunc_Run));
char run2 = false; // What??? BUTTON(gamefunc_Run); char run2 = false; // What??? inputState.BUTTON(gamefunc_Run);
gInput.syncFlags.run = run; gInput.syncFlags.run = run;
if (BUTTON(gamefunc_Move_Forward)) if (inputState.BUTTON(gamefunc_Move_Forward))
forward += (1+run)<<10; forward += (1+run)<<10;
if (BUTTON(gamefunc_Move_Backward)) if (inputState.BUTTON(gamefunc_Move_Backward))
forward -= (1+run)<<10; forward -= (1+run)<<10;
char turnLeft = 0, turnRight = 0; char turnLeft = 0, turnRight = 0;
if (BUTTON(gamefunc_Strafe)) if (inputState.BUTTON(gamefunc_Strafe))
{ {
if (BUTTON(gamefunc_Turn_Left)) if (inputState.BUTTON(gamefunc_Turn_Left))
strafe += (1 + run) << 10; strafe += (1 + run) << 10;
if (BUTTON(gamefunc_Turn_Right)) if (inputState.BUTTON(gamefunc_Turn_Right))
strafe -= (1 + run) << 10; strafe -= (1 + run) << 10;
} }
else else
{ {
if (BUTTON(gamefunc_Strafe_Left)) if (inputState.BUTTON(gamefunc_Strafe_Left))
strafe += (1 + run) << 10; strafe += (1 + run) << 10;
if (BUTTON(gamefunc_Strafe_Right)) if (inputState.BUTTON(gamefunc_Strafe_Right))
strafe -= (1 + run) << 10; strafe -= (1 + run) << 10;
if (BUTTON(gamefunc_Turn_Left)) if (inputState.BUTTON(gamefunc_Turn_Left))
turnLeft = 1; turnLeft = 1;
if (BUTTON(gamefunc_Turn_Right)) if (inputState.BUTTON(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 (BUTTON(gamefunc_Strafe)) if (inputState.BUTTON(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);
@ -428,10 +428,10 @@ void ctrlGetInput(void)
if (!in_mouseflip) if (!in_mouseflip)
gInput.q16mlook = -gInput.q16mlook; gInput.q16mlook = -gInput.q16mlook;
if (KB_KeyPressed(sc_Pause)) // 0xc5 in disassembly if (inputState.GetKeyStatus(sc_Pause)) // 0xc5 in disassembly
{ {
gInput.keyFlags.pause = 1; gInput.keyFlags.pause = 1;
KB_ClearKeyDown(sc_Pause); inputState.ClearKeyStatus(sc_Pause);
} }
if (!gViewMap.bFollowMode && gViewMode == 4) if (!gViewMap.bFollowMode && gViewMode == 4)

View file

@ -48,7 +48,7 @@ char Wait(int nTicks)
while (totalclock < nTicks) while (totalclock < nTicks)
{ {
gameHandleEvents(); gameHandleEvents();
char key = keyGetScan(); char key = inputState.keyGetScan();
if (key) if (key)
{ {
if (key == sc_Escape) // sc_Escape if (key == sc_Escape) // sc_Escape
@ -71,7 +71,7 @@ char DoFade(char r, char g, char b, int nTicks)
gFrameClock += 2; gFrameClock += 2;
scrNextPage(); scrNextPage();
scrFadeAmount(divscale16(ClipHigh((int)totalclock, nTicks), nTicks)); scrFadeAmount(divscale16(ClipHigh((int)totalclock, nTicks), nTicks));
if (keyGetScan()) if (inputState.keyGetScan())
return 0; return 0;
} while (totalclock <= nTicks); } while (totalclock <= nTicks);
#endif #endif
@ -90,7 +90,7 @@ char DoUnFade(int nTicks)
gFrameClock += 2; gFrameClock += 2;
scrNextPage(); scrNextPage();
scrFadeAmount(0x10000-divscale16(ClipHigh((int)totalclock, nTicks), nTicks)); scrFadeAmount(0x10000-divscale16(ClipHigh((int)totalclock, nTicks), nTicks));
if (keyGetScan()) if (inputState.keyGetScan())
return 0; return 0;
} while (totalclock <= nTicks); } while (totalclock <= nTicks);
#endif #endif

View file

@ -289,7 +289,7 @@ void CDemo::ProcessKeys(void)
case kInputGame: case kInputGame:
{ {
char nKey; char nKey;
while ((nKey = keyGetScan()) != 0) while ((nKey = inputState.keyGetScan()) != 0)
{ {
switch (nKey) switch (nKey)
{ {

View file

@ -85,7 +85,7 @@ void CEndGameMgr::ProcessKeys(void)
//} //}
//else //else
{ {
char ch = keyGetScan(); char ch = inputState.keyGetScan();
if (!ch) if (!ch)
return; return;
if (gGameOptions.nGameType > 0 || numplayers > 1) if (gGameOptions.nGameType > 0 || numplayers > 1)
@ -103,7 +103,7 @@ void CEndGameMgr::Setup(void)
at0 = 1; at0 = 1;
EndLevel(); EndLevel();
sndStartSample(268, 128, -1, 1); sndStartSample(268, 128, -1, 1);
keyFlushScans(); inputState.keyFlushScans();
} }
//int gNextLevel; //int gNextLevel;

View file

@ -230,10 +230,10 @@ void CGameMenuMgr::Process(void)
event.at0 = 0; event.at0 = 0;
event.at2 = 0; event.at2 = 0;
char key; char key;
if (!pActiveMenu->MouseEvent(event) && (key = keyGetScan()) != 0 ) if (!pActiveMenu->MouseEvent(event) && (key = inputState.keyGetScan()) != 0 )
{ {
keyFlushScans(); inputState.keyFlushScans();
keyFlushChars(); inputState.keyFlushChars();
event.at2 = key; event.at2 = key;
switch (key) switch (key)
{ {
@ -293,8 +293,8 @@ void CGameMenuMgr::Process(void)
void CGameMenuMgr::Deactivate(void) void CGameMenuMgr::Deactivate(void)
{ {
Clear(); Clear();
keyFlushScans(); inputState.keyFlushScans();
keyFlushChars(); inputState.keyFlushChars();
m_bActive = false; m_bActive = false;
mouseLockToWindow(1); mouseLockToWindow(1);
@ -1121,10 +1121,9 @@ CGameMenuItemKeyList::CGameMenuItemKeyList(const char *a1, int a2, int a3, int a
void CGameMenuItemKeyList::Scan(void) void CGameMenuItemKeyList::Scan(void)
{ {
KB_FlushKeyboardQueue(); inputState.keyFlushChars();
KB_FlushKeyboardQueueScans(); inputState.keyFlushScans();
KB_ClearKeysDown(); inputState.ClearKeysDown();
KB_LastScan = 0;
bScan = true; bScan = true;
} }
@ -1199,17 +1198,17 @@ bool CGameMenuItemKeyList::Event(CGameMenuEvent &event)
{ {
if (bScan) if (bScan)
{ {
if (KB_LastScan && KB_LastScan != sc_Pause) if (inputState.GetLastScanCode() && inputState.GetLastScanCode() != sc_Pause)
{ {
if (KB_KeyWaiting()) if (inputState.keyBufferWaiting())
KB_GetCh(); inputState.keyGetChar();
Bindings.SetBind(KB_LastScan, CONFIG_FunctionNumToName(nFocus)); Bindings.SetBind(inputState.GetLastScanCode(), CONFIG_FunctionNumToName(nFocus));
KB_FlushKeyboardQueue(); inputState.keyFlushChars();
KB_FlushKeyboardQueueScans(); inputState.keyFlushScans();
KB_ClearKeysDown(); inputState.ClearKeysDown();
keyFlushScans(); inputState.keyFlushScans();
keyFlushChars(); inputState.keyFlushChars();
bScan = 0; bScan = 0;
} }
return false; return false;
@ -2049,8 +2048,8 @@ bool CGameMenuItemZEditBitmap::Event(CGameMenuEvent &event)
gGameMenuMgr.m_bScanning = false; gGameMenuMgr.m_bScanning = false;
} }
gSaveGameActive = false; gSaveGameActive = false;
KB_ClearKeyDown(sc_Enter); inputState.ClearKeyStatus(sc_Enter);
KB_ClearKeyDown(sc_kpad_Enter); inputState.ClearKeyStatus(sc_kpad_Enter);
return false; return false;
} }
strncpy(buffer, at20, at24); strncpy(buffer, at20, at24);

View file

@ -29,9 +29,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#define BGSTRETCH (hud_bgstretch ? 1024 : 0) #define BGSTRETCH (hud_bgstretch ? 1024 : 0)
#define WIN_IS_PRESSED ( KB_KeyPressed( sc_RightWin ) || KB_KeyPressed( sc_LeftWin ) ) #define WIN_IS_PRESSED ( inputState.GetKeyStatus( sc_RightWin ) || inputState.GetKeyStatus( sc_LeftWin ) )
#define ALT_IS_PRESSED ( KB_KeyPressed( sc_RightAlt ) || KB_KeyPressed( sc_LeftAlt ) ) #define ALT_IS_PRESSED ( inputState.GetKeyStatus( sc_RightAlt ) || inputState.GetKeyStatus( sc_LeftAlt ) )
#define SHIFTS_IS_PRESSED ( KB_KeyPressed( sc_RightShift ) || KB_KeyPressed( sc_LeftShift ) ) #define SHIFTS_IS_PRESSED ( inputState.GetKeyStatus( sc_RightShift ) || inputState.GetKeyStatus( sc_LeftShift ) )
#define TRAVERSE_SPRITE_SECT(l, o, n) (o) = (l); ((o) != -1) && ((n) = nextspritesect[o]); (o) = (n) #define TRAVERSE_SPRITE_SECT(l, o, n) (o) = (l); ((o) != -1) && ((n) = nextspritesect[o]); (o) = (n)
#define TRAVERSE_SPRITE_STAT(l, o, n) (o) = (l); ((o) != -1) && ((n) = nextspritestat[o]); (o) = (n) #define TRAVERSE_SPRITE_STAT(l, o, n) (o) = (l); ((o) != -1) && ((n) = nextspritestat[o]); (o) = (n)

View file

@ -580,14 +580,14 @@ void CPlayerMsg::Send(void)
} }
Term(); Term();
keyFlushScans(); inputState.keyFlushScans();
} }
void CPlayerMsg::ProcessKeys(void) void CPlayerMsg::ProcessKeys(void)
{ {
if (KB_KeyPressed(sc_Escape)) Term(); if (inputState.GetKeyStatus(sc_Escape)) Term();
#if 0 #if 0
int key = keyGetScan(); int key = inputState.keyGetScan();
int ch; int ch;
if (key != 0) if (key != 0)
{ {

View file

@ -1012,7 +1012,7 @@ void netInitialize(bool bConsole)
netServerDisconnect(); netServerDisconnect();
QuitGame(); QuitGame();
} }
if (!bConsole && KB_KeyPressed(sc_Escape)) if (!bConsole && inputState.GetKeyStatus(sc_Escape))
{ {
netServerDisconnect(); netServerDisconnect();
netDeinitialize(); netDeinitialize();
@ -1173,7 +1173,7 @@ void netInitialize(bool bConsole)
netClientDisconnect(); netClientDisconnect();
QuitGame(); QuitGame();
} }
if (!bConsole && KB_KeyPressed(sc_Escape)) if (!bConsole && inputState.GetKeyStatus(sc_Escape))
{ {
netClientDisconnect(); netClientDisconnect();
netDeinitialize(); netDeinitialize();

View file

@ -107,14 +107,6 @@ char CONSTEXPR const g_keyAsciiTableShift[128] = {
0 , 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 , 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
}; };
extern char g_keyFIFO[KEYFIFOSIZ];
extern char g_keyAsciiFIFO[KEYFIFOSIZ];
extern uint8_t g_keyAsciiPos;
extern uint8_t g_keyAsciiEnd;
extern uint8_t g_keyFIFOend;
extern void keySetState(int32_t key, int32_t state);
// mouse // mouse
extern vec2_t g_mousePos; extern vec2_t g_mousePos;
extern vec2_t g_mouseAbs; extern vec2_t g_mouseAbs;
@ -179,24 +171,6 @@ void joySetCallback(void (*callback)(int32_t,int32_t));
const char *joyGetName(int32_t what, int32_t num); // what: 0=axis, 1=button, 2=hat const char *joyGetName(int32_t what, int32_t num); // what: 0=axis, 1=button, 2=hat
void joyScanDevices(void); void joyScanDevices(void);
char keyGetScan(void);
char keyGetChar(void);
#define keyBufferWaiting() (g_keyAsciiPos != g_keyAsciiEnd)
static FORCE_INLINE int keyBufferFull(void)
{
return ((g_keyAsciiEnd+1)&(KEYFIFOSIZ-1)) == g_keyAsciiPos;
}
static FORCE_INLINE void keyBufferInsert(char code)
{
g_keyAsciiFIFO[g_keyAsciiEnd] = code;
g_keyAsciiEnd = ((g_keyAsciiEnd+1)&(KEYFIFOSIZ-1));
}
void keyFlushScans(void);
void keyFlushChars(void);
void mouseInit(void); void mouseInit(void);
void mouseUninit(void); void mouseUninit(void);
int32_t mouseReadAbs(vec2_t *pResult, vec2_t const *pInput); int32_t mouseReadAbs(vec2_t *pResult, vec2_t const *pInput);

View file

@ -26,68 +26,11 @@ int32_t g_borderless=2;
// input // input
char inputdevices = 0; char inputdevices = 0;
char g_keyFIFO[KEYFIFOSIZ];
char g_keyAsciiFIFO[KEYFIFOSIZ];
uint8_t g_keyFIFOpos;
uint8_t g_keyFIFOend;
uint8_t g_keyAsciiPos;
uint8_t g_keyAsciiEnd;
void (*keypresscallback)(int32_t, int32_t); void (*keypresscallback)(int32_t, int32_t);
void keySetCallback(void (*callback)(int32_t, int32_t)) { keypresscallback = callback; } void keySetCallback(void (*callback)(int32_t, int32_t)) { keypresscallback = callback; }
void keySetState(int32_t key, int32_t state)
{
inputState.SetKeyStatus(key, state);
event_t ev = { (uint8_t)(state ? EV_KeyDown : EV_KeyUp), 0, (uint16_t)key };
D_PostEvent(&ev);
if (state)
{
g_keyFIFO[g_keyFIFOend] = key;
g_keyFIFO[(g_keyFIFOend+1)&(KEYFIFOSIZ-1)] = state;
g_keyFIFOend = ((g_keyFIFOend+2)&(KEYFIFOSIZ-1));
}
}
char keyGetScan(void)
{
if (g_keyFIFOpos == g_keyFIFOend)
return 0;
char const c = g_keyFIFO[g_keyFIFOpos];
g_keyFIFOpos = ((g_keyFIFOpos + 2) & (KEYFIFOSIZ - 1));
return c;
}
void keyFlushScans(void)
{
Bmemset(&g_keyFIFO,0,sizeof(g_keyFIFO));
g_keyFIFOpos = g_keyFIFOend = 0;
}
//
// character-based input functions
//
char keyGetChar(void)
{
if (g_keyAsciiPos == g_keyAsciiEnd)
return 0;
char const c = g_keyAsciiFIFO[g_keyAsciiPos];
g_keyAsciiPos = ((g_keyAsciiPos + 1) & (KEYFIFOSIZ - 1));
return c;
}
void keyFlushChars(void)
{
Bmemset(&g_keyAsciiFIFO,0,sizeof(g_keyAsciiFIFO));
g_keyAsciiPos = g_keyAsciiEnd = 0;
}
vec2_t g_mousePos; vec2_t g_mousePos;
vec2_t g_mouseAbs; vec2_t g_mouseAbs;

View file

@ -1249,7 +1249,7 @@ void OSD_CaptureInput(int cap)
mouseGrabInput(cap == 0 ? g_mouseLockedToWindow : 0); mouseGrabInput(cap == 0 ? g_mouseLockedToWindow : 0);
onshowosd(cap); onshowosd(cap);
keyFlushChars(); inputState.keyFlushChars();
} }

View file

@ -1889,10 +1889,10 @@ int32_t handleevents_pollsdl(void)
{ {
code = ev.text.text[j]; code = ev.text.text[j];
if (code != g_keyAsciiTable[OSD_OSDKey()] && !keyBufferFull()) if (code != g_keyAsciiTable[OSD_OSDKey()] && !inputState.keyBufferFull())
{ {
if (OSD_HandleChar(code)) if (OSD_HandleChar(code))
keyBufferInsert(code); inputState.keyBufferInsert(code);
} }
} while (j < SDL_TEXTINPUTEVENT_TEXT_SIZE-1 && ev.text.text[++j]); } while (j < SDL_TEXTINPUTEVENT_TEXT_SIZE-1 && ev.text.text[++j]);
break; break;
@ -1910,7 +1910,7 @@ int32_t handleevents_pollsdl(void)
KMOD_LALT|KMOD_RALT|KMOD_LGUI|KMOD_RGUI; KMOD_LALT|KMOD_RALT|KMOD_LGUI|KMOD_RGUI;
// XXX: see osd.c, OSD_HandleChar(), there are more... // XXX: see osd.c, OSD_HandleChar(), there are more...
if (ev.key.type == SDL_KEYDOWN && !keyBufferFull() && if (ev.key.type == SDL_KEYDOWN && !inputState.keyBufferFull() &&
(sc == SDL_SCANCODE_RETURN || sc == SDL_SCANCODE_KP_ENTER || (sc == SDL_SCANCODE_RETURN || sc == SDL_SCANCODE_KP_ENTER ||
sc == SDL_SCANCODE_ESCAPE || sc == SDL_SCANCODE_ESCAPE ||
sc == SDL_SCANCODE_BACKSPACE || sc == SDL_SCANCODE_BACKSPACE ||
@ -1928,10 +1928,10 @@ int32_t handleevents_pollsdl(void)
default: keyvalue = sc - SDL_SCANCODE_A + 1; break; // Ctrl+A --> 1, etc. default: keyvalue = sc - SDL_SCANCODE_A + 1; break; // Ctrl+A --> 1, etc.
} }
if (OSD_HandleChar(keyvalue)) if (OSD_HandleChar(keyvalue))
keyBufferInsert(keyvalue); inputState.keyBufferInsert(keyvalue);
} }
else if (ev.key.type == SDL_KEYDOWN && else if (ev.key.type == SDL_KEYDOWN &&
ev.key.keysym.sym != g_keyAsciiTable[OSD_OSDKey()] && !keyBufferFull() && ev.key.keysym.sym != g_keyAsciiTable[OSD_OSDKey()] && !inputState.keyBufferFull() &&
!SDL_IsTextInputActive()) !SDL_IsTextInputActive())
{ {
/* /*
@ -2007,7 +2007,7 @@ int32_t handleevents_pollsdl(void)
if ((unsigned)keyvalue <= 0x7Fu) if ((unsigned)keyvalue <= 0x7Fu)
{ {
if (OSD_HandleChar(keyvalue)) if (OSD_HandleChar(keyvalue))
keyBufferInsert(keyvalue); inputState.keyBufferInsert(keyvalue);
} }
} }
@ -2025,7 +2025,7 @@ int32_t handleevents_pollsdl(void)
if (keypresscallback) if (keypresscallback)
keypresscallback(j, 0); keypresscallback(j, 0);
} }
keySetState(j, 0); inputState.keySetState(j, 0);
} }
} }
break; break;
@ -2038,7 +2038,7 @@ int32_t handleevents_pollsdl(void)
if (keypresscallback) if (keypresscallback)
keypresscallback(code, 1); keypresscallback(code, 1);
} }
keySetState(code, 1); inputState.keySetState(code, 1);
} }
else else
{ {
@ -2049,7 +2049,7 @@ int32_t handleevents_pollsdl(void)
if (code == 0x59) // pause if (code == 0x59) // pause
break; break;
# endif # endif
keySetState(code, 0); inputState.keySetState(code, 0);
if (keypresscallback) if (keypresscallback)
keypresscallback(code, 0); keypresscallback(code, 0);
} }

View file

@ -26,7 +26,7 @@
int eventhead; int eventhead;
int eventtail; int eventtail;
event_t events[MAXEVENTS]; event_t events[NUM_EVENTS];
//========================================================================== //==========================================================================
// //
@ -138,7 +138,7 @@ bool G_Responder (event_t *ev)
void D_ProcessEvents (void) void D_ProcessEvents (void)
{ {
event_t *ev; event_t *ev;
for (; eventtail != eventhead ; eventtail = (eventtail+1)&(MAXEVENTS-1)) for (; eventtail != eventhead ; eventtail = (eventtail+1)&(NUM_EVENTS-1))
{ {
ev = &events[eventtail]; ev = &events[eventtail];
if (ev->type == EV_None) if (ev->type == EV_None)
@ -193,7 +193,7 @@ void D_PostEvent (const event_t *ev)
} }
} }
#endif #endif
eventhead = (eventhead+1)&(MAXEVENTS-1); eventhead = (eventhead+1)&(NUM_EVENTS-1);
} }
//========================================================================== //==========================================================================
@ -213,7 +213,7 @@ void D_PostEvent (const event_t *ev)
void D_RemoveNextCharEvent() void D_RemoveNextCharEvent()
{ {
assert(events[eventtail].type == EV_GUI_Event && events[eventtail].subtype == EV_GUI_KeyDown); assert(events[eventtail].type == EV_GUI_Event && events[eventtail].subtype == EV_GUI_KeyDown);
for (int evnum = eventtail; evnum != eventhead; evnum = (evnum+1) & (MAXEVENTS-1)) for (int evnum = eventtail; evnum != eventhead; evnum = (evnum+1) & (NUM_EVENTS-1))
{ {
event_t *ev = &events[evnum]; event_t *ev = &events[evnum];
if (ev->type != EV_GUI_Event) if (ev->type != EV_GUI_Event)

View file

@ -65,9 +65,12 @@ void D_ProcessEvents(void);
// //
// GLOBAL VARIABLES // GLOBAL VARIABLES
// //
#define MAXEVENTS 128 enum
{
NUM_EVENTS = 128
};
extern event_t events[MAXEVENTS]; extern event_t events[NUM_EVENTS];
#endif #endif

View file

@ -96,8 +96,6 @@ static const GameFuncNameDesc gamefuncs[] = {
{ gamefunc_Toggle_Crouch, "Toggle_Crouch"}, { gamefunc_Toggle_Crouch, "Toggle_Crouch"},
{ gamefunc_See_Chase_View, "See_Chase_View"}, // the following were added by Blood { gamefunc_See_Chase_View, "See_Chase_View"}, // the following were added by Blood
{ gamefunc_Turn_Around, "Turn_Around"}, { gamefunc_Turn_Around, "Turn_Around"},
{ gamefunc_Weapon_Fire, "Weapon_Fire"},
{ gamefunc_Weapon_Special_Fire, "Weapon_Special_Fire"},
{ gamefunc_Aim_Center, "Aim_Center"}, { gamefunc_Aim_Center, "Aim_Center"},
{ gamefunc_Tilt_Left, "Tilt_Left"}, { gamefunc_Tilt_Left, "Tilt_Left"},
{ gamefunc_Tilt_Right, "Tilt_Right"}, { gamefunc_Tilt_Right, "Tilt_Right"},
@ -621,7 +619,7 @@ int32_t JoystickAnalogueInvert[MAXJOYAXES];
static const char* mousedefaults[MAXMOUSEBUTTONS] = static const char* mousedefaults[MAXMOUSEBUTTONS] =
{ {
"Weapon_Fire", "Fire",
"Weapon_Special_Fire", "Weapon_Special_Fire",
"", "",
"", "",
@ -1156,7 +1154,7 @@ FString CONFIG_GetGameFuncOnMouse(int gameFunc)
auto keys = Bindings.GetKeysForCommand(binding); auto keys = Bindings.GetKeysForCommand(binding);
for (auto key : keys) for (auto key : keys)
{ {
if (key >= KEY_FIRSTMOUSEBUTTON && key < KEY_FIRSTJOYBUTTON) if ((key >= KEY_FIRSTMOUSEBUTTON && key < KEY_FIRSTJOYBUTTON) || (key >= KEY_MWHEELUP && key <= KEY_MWHEELLEFT))
{ {
auto scan = KB_ScanCodeToString(key); auto scan = KB_ScanCodeToString(key);
if (scan) return scan; if (scan) return scan;
@ -1172,7 +1170,7 @@ char const* CONFIG_GetGameFuncOnJoystick(int gameFunc)
auto keys = Bindings.GetKeysForCommand(binding); auto keys = Bindings.GetKeysForCommand(binding);
for (auto key : keys) for (auto key : keys)
{ {
if (key >= KEY_FIRSTJOYBUTTON) if (key >= KEY_FIRSTJOYBUTTON && !(key >= KEY_MWHEELUP && key <= KEY_MWHEELLEFT))
{ {
auto scan = KB_ScanCodeToString(key); auto scan = KB_ScanCodeToString(key);
if (scan) return scan; if (scan) return scan;
@ -1245,9 +1243,9 @@ void CONFIG_InitMouseAndController()
} }
CONFIG_SetupMouse(); CONFIG_SetupMouse();
CONFIG_SetupJoystick(); CONFIG_SetupJoystick();
KB_ClearKeysDown(); inputState.ClearKeysDown();
KB_FlushKeyboardQueue(); inputState.keyFlushChars();
KB_FlushKeyboardQueueScans(); inputState.keyFlushScans();
} }

View file

@ -4,11 +4,10 @@
#include "tarray.h" #include "tarray.h"
#include "scancodes.h" #include "scancodes.h"
#include "c_bind.h" #include "c_bind.h"
#include "d_event.h"
typedef uint8_t kb_scancode; typedef uint8_t kb_scancode;
extern kb_scancode KB_LastScan;
typedef struct typedef struct
{ {
const char* key; const char* key;
@ -103,8 +102,6 @@ enum GameFunction_t
gamefunc_Toggle_Crouch, gamefunc_Toggle_Crouch,
gamefunc_See_Chase_View, // this was added by Blood gamefunc_See_Chase_View, // this was added by Blood
gamefunc_Turn_Around, gamefunc_Turn_Around,
gamefunc_Weapon_Fire,
gamefunc_Weapon_Special_Fire,
gamefunc_Aim_Center, gamefunc_Aim_Center,
gamefunc_Tilt_Left, gamefunc_Tilt_Left,
gamefunc_Tilt_Right, gamefunc_Tilt_Right,
@ -125,6 +122,10 @@ enum GameFunction_t
class InputState class InputState
{ {
enum
{
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 // 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 // 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. // because it does not track what triggered the button.
@ -137,6 +138,15 @@ class InputState
ButtonStateFlags ButtonState[NUMGAMEFUNCTIONS]; ButtonStateFlags ButtonState[NUMGAMEFUNCTIONS];
uint8_t KeyStatus[NUMKEYS]; uint8_t KeyStatus[NUMKEYS];
char g_keyFIFO[KEYFIFOSIZ];
char g_keyAsciiFIFO[KEYFIFOSIZ];
uint8_t g_keyFIFOpos;
uint8_t g_keyFIFOend;
uint8_t g_keyAsciiPos;
uint8_t g_keyAsciiEnd;
kb_scancode KB_LastScan;
public: public:
bool BUTTON(int x) bool BUTTON(int x)
@ -219,33 +229,113 @@ public:
CONTROL_BindsEnabled = on; CONTROL_BindsEnabled = on;
} }
bool keyBufferWaiting()
{
return (g_keyAsciiPos != g_keyAsciiEnd);
}
int keyBufferFull(void)
{
return ((g_keyAsciiEnd + 1) & (KEYFIFOSIZ - 1)) == g_keyAsciiPos;
}
void keyBufferInsert(char code)
{
g_keyAsciiFIFO[g_keyAsciiEnd] = code;
g_keyAsciiEnd = ((g_keyAsciiEnd + 1) & (KEYFIFOSIZ - 1));
}
void keySetState(int32_t key, int32_t state)
{
SetKeyStatus(key, state);
event_t ev = { (uint8_t)(state ? EV_KeyDown : EV_KeyUp), 0, (int16_t)key };
D_PostEvent(&ev);
if (state)
{
g_keyFIFO[g_keyFIFOend] = key;
g_keyFIFO[(g_keyFIFOend + 1) & (KEYFIFOSIZ - 1)] = state;
g_keyFIFOend = ((g_keyFIFOend + 2) & (KEYFIFOSIZ - 1));
}
}
char keyGetScan(void)
{
if (g_keyFIFOpos == g_keyFIFOend)
return 0;
char const c = g_keyFIFO[g_keyFIFOpos];
g_keyFIFOpos = ((g_keyFIFOpos + 2) & (KEYFIFOSIZ - 1));
return c;
}
void keyFlushScans(void)
{
Bmemset(&g_keyFIFO, 0, sizeof(g_keyFIFO));
g_keyFIFOpos = g_keyFIFOend = 0;
}
//
// character-based input functions
//
char keyGetChar(void)
{
if (g_keyAsciiPos == g_keyAsciiEnd)
return 0;
char const c = g_keyAsciiFIFO[g_keyAsciiPos];
g_keyAsciiPos = ((g_keyAsciiPos + 1) & (KEYFIFOSIZ - 1));
return c;
}
void keyFlushChars(void)
{
Bmemset(&g_keyAsciiFIFO, 0, sizeof(g_keyAsciiFIFO));
g_keyAsciiPos = g_keyAsciiEnd = 0;
}
inline bool UnboundKeyPressed(int scan)
{
return (GetKeyStatus(scan) != 0 && Bindings.GetBind(scan) == nullptr);
}
kb_scancode GetLastScanCode()
{
return (KB_LastScan);
}
void SetLastScanCode(kb_scancode scancode)
{
KB_LastScan = (scancode);
}
void ClearLastScanCode()
{
KB_LastScan = sc_None;
}
void ClearKeysDown(void)
{
KB_LastScan = 0;
ClearAllKeyStatus();
}
}; };
extern InputState inputState; extern InputState inputState;
inline bool BUTTON(int x) static inline void KB_KeyEvent(int32_t scancode, int32_t keypressed)
{ {
return inputState.BUTTON(x); if (keypressed) inputState.SetLastScanCode(scancode);
} }
inline uint8_t KB_KeyPressed(int scan) void keySetCallback(void (*callback)(int32_t, int32_t));
{ inline void KB_Startup(void) { keySetCallback(KB_KeyEvent); }
return inputState.GetKeyStatus(scan); inline void KB_Shutdown(void) { keySetCallback((void (*)(int32_t, int32_t))NULL); }
}
inline void KB_ClearKeyDown(int scan)
{
inputState.ClearKeyStatus(scan);
}
inline bool KB_UnBoundKeyPressed(int scan)
{
return (inputState.GetKeyStatus(scan) != 0 && Bindings.GetBind(scan) == nullptr);
}
inline void KB_ClearKeysDown(void)
{
KB_LastScan = 0;
inputState.ClearAllKeyStatus();
}

View file

@ -32,31 +32,9 @@ Modifications for JonoF's port by Jonathon Fowler (jf@jonof.id.au)
#include "baselayer.h" // for the keyboard stuff #include "baselayer.h" // for the keyboard stuff
#include "scancodes.h" #include "scancodes.h"
#include "inputstate.h"
#include "c_bind.h"
extern kb_scancode KB_LastScan;
#define KB_GetLastScanCode() (KB_LastScan)
#define KB_SetLastScanCode(scancode) \
{ \
KB_LastScan = (scancode); \
}
#define KB_ClearLastScanCode() \
{ \
KB_SetLastScanCode(sc_None); \
}
#define KB_GetCh keyGetChar
#define KB_KeyWaiting keyBufferWaiting
#define KB_FlushKeyboardQueue keyFlushChars
#define KB_FlushKeyboardQueueScans keyFlushScans
static inline void KB_KeyEvent(int32_t scancode, int32_t keypressed)
{
if (keypressed)
KB_LastScan = scancode;
}
void KB_Startup(void);
void KB_Shutdown(void);
const char * KB_ScanCodeToString( int scancode ); // convert scancode into a string const char * KB_ScanCodeToString( int scancode ); // convert scancode into a string
int KB_StringToScanCode( const char * string ); // convert a string into a scancode int KB_StringToScanCode( const char * string ); // convert a string into a scancode

View file

@ -248,7 +248,7 @@ static void G_CheatGetInv(DukePlayer_t *pPlayer)
static void end_cheat(DukePlayer_t * const pPlayer) static void end_cheat(DukePlayer_t * const pPlayer)
{ {
pPlayer->cheat_phase = 0; pPlayer->cheat_phase = 0;
KB_FlushKeyboardQueue(); inputState.keyFlushChars();
} }
static int32_t cheatbuflen; static int32_t cheatbuflen;
@ -310,9 +310,9 @@ void G_DoCheats(void)
{ {
int ch; int ch;
while (KB_KeyWaiting()) while (inputState.keyBufferWaiting())
{ {
ch = Btolower(KB_GetCh()); ch = Btolower(inputState.keyGetChar());
if (!((ch >= 'a' && ch <= 'z') || (ch >= '0' && ch <= '9'))) if (!((ch >= 'a' && ch <= 'z') || (ch >= '0' && ch <= '9')))
{ {
@ -326,7 +326,7 @@ void G_DoCheats(void)
// cheat string matching logic below. // cheat string matching logic below.
Bassert(cheatbuflen < (signed)sizeof(cheatbuf)); Bassert(cheatbuflen < (signed)sizeof(cheatbuf));
cheatbuf[cheatbuflen] = 0; cheatbuf[cheatbuflen] = 0;
// KB_ClearKeysDown(); // inputState.ClearKeysDown();
for (cheatNum=0; cheatNum < NUMCHEATCODES; cheatNum++) for (cheatNum=0; cheatNum < NUMCHEATCODES; cheatNum++)
{ {
@ -434,7 +434,7 @@ void G_DoCheats(void)
case CHEAT_KEYS: case CHEAT_KEYS:
pPlayer->got_access = 7; pPlayer->got_access = 7;
KB_FlushKeyboardQueue(); inputState.keyFlushChars();
P_DoQuote(QUOTE_CHEAT_ALL_KEYS, pPlayer); P_DoQuote(QUOTE_CHEAT_ALL_KEYS, pPlayer);
end_cheat(pPlayer); end_cheat(pPlayer);
return; return;
@ -465,7 +465,7 @@ void G_DoCheats(void)
case CHEAT_ALLEN: case CHEAT_ALLEN:
P_DoQuote(QUOTE_CHEAT_ALLEN, pPlayer); P_DoQuote(QUOTE_CHEAT_ALLEN, pPlayer);
pPlayer->cheat_phase = 0; pPlayer->cheat_phase = 0;
KB_ClearKeyDown(sc_N); inputState.ClearKeyStatus(sc_N);
return; return;
case CHEAT_CORNHOLIO: case CHEAT_CORNHOLIO:
@ -628,7 +628,7 @@ void G_DoCheats(void)
case CHEAT_CASHMAN: case CHEAT_CASHMAN:
ud.cashman = 1-ud.cashman; ud.cashman = 1-ud.cashman;
KB_ClearKeyDown(sc_N); inputState.ClearKeyStatus(sc_N);
pPlayer->cheat_phase = 0; pPlayer->cheat_phase = 0;
return; return;
@ -675,7 +675,7 @@ void G_DoCheats(void)
case CHEAT_BETA: case CHEAT_BETA:
P_DoQuote(QUOTE_CHEAT_BETA, pPlayer); P_DoQuote(QUOTE_CHEAT_BETA, pPlayer);
KB_ClearKeyDown(sc_H); inputState.ClearKeyStatus(sc_H);
end_cheat(pPlayer); end_cheat(pPlayer);
return; return;
@ -705,7 +705,7 @@ void G_DoCheats(void)
ud.eog = 1; ud.eog = 1;
pPlayer->player_par = 0; pPlayer->player_par = 0;
pPlayer->gm |= MODE_EOL; pPlayer->gm |= MODE_EOL;
KB_FlushKeyboardQueue(); inputState.keyFlushChars();
return; return;
default: default:
@ -717,17 +717,17 @@ void G_DoCheats(void)
} }
else else
{ {
if (KB_KeyPressed((uint8_t) CheatKeys[0])) if (inputState.GetKeyStatus((uint8_t) CheatKeys[0]))
{ {
if (pPlayer->cheat_phase >= 0 && numplayers < 2 && ud.recstat == 0) if (pPlayer->cheat_phase >= 0 && numplayers < 2 && ud.recstat == 0)
{ {
if (CheatKeys[0] == CheatKeys[1]) if (CheatKeys[0] == CheatKeys[1])
KB_ClearKeyDown((uint8_t) CheatKeys[0]); inputState.ClearKeyStatus((uint8_t) CheatKeys[0]);
pPlayer->cheat_phase = -1; pPlayer->cheat_phase = -1;
} }
} }
if (KB_KeyPressed((uint8_t) CheatKeys[1])) if (inputState.GetKeyStatus((uint8_t) CheatKeys[1]))
{ {
if (pPlayer->cheat_phase == -1) if (pPlayer->cheat_phase == -1)
{ {
@ -742,13 +742,13 @@ void G_DoCheats(void)
// P_DoQuote(QUOTE_25,pPlayer); // P_DoQuote(QUOTE_25,pPlayer);
cheatbuflen = 0; cheatbuflen = 0;
} }
KB_FlushKeyboardQueue(); inputState.keyFlushChars();
} }
else if (pPlayer->cheat_phase != 0) else if (pPlayer->cheat_phase != 0)
{ {
pPlayer->cheat_phase = 0; pPlayer->cheat_phase = 0;
KB_ClearKeyDown((uint8_t) CheatKeys[0]); inputState.ClearKeyStatus((uint8_t) CheatKeys[0]);
KB_ClearKeyDown((uint8_t) CheatKeys[1]); inputState.ClearKeyStatus((uint8_t) CheatKeys[1]);
} }
} }
} }

View file

@ -907,9 +907,9 @@ nextdemo_nomenu:
{ {
ControlInfo noshareinfo; ControlInfo noshareinfo;
CONTROL_GetInput(&noshareinfo); CONTROL_GetInput(&noshareinfo);
if (BUTTON(gamefunc_SendMessage)) if (inputState.BUTTON(gamefunc_SendMessage))
{ {
KB_FlushKeyboardQueue(); inputState.keyFlushChars();
inputState.ClearButton(gamefunc_SendMessage); inputState.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

@ -190,7 +190,7 @@ void G_HandleSpecialKeys(void)
CONTROL_GetInput(&noshareinfo); CONTROL_GetInput(&noshareinfo);
} }
if (g_networkMode != NET_DEDICATED_SERVER && ALT_IS_PRESSED && KB_KeyPressed(sc_Enter)) if (g_networkMode != NET_DEDICATED_SERVER && ALT_IS_PRESSED && inputState.GetKeyStatus(sc_Enter))
{ {
if (videoSetGameMode(!ScreenMode, ScreenWidth, ScreenHeight, ScreenBPP, ud.detail)) if (videoSetGameMode(!ScreenMode, ScreenWidth, ScreenHeight, ScreenBPP, ud.detail))
{ {
@ -202,14 +202,14 @@ void G_HandleSpecialKeys(void)
else else
ScreenMode = !ScreenMode; ScreenMode = !ScreenMode;
KB_ClearKeyDown(sc_Enter); inputState.ClearKeyStatus(sc_Enter);
g_restorePalette = 1; g_restorePalette = 1;
G_UpdateScreenArea(); G_UpdateScreenArea();
} }
if (KB_UnBoundKeyPressed(sc_F12)) if (inputState.UnboundKeyPressed(sc_F12))
{ {
KB_ClearKeyDown(sc_F12); inputState.ClearKeyStatus(sc_F12);
videoCaptureScreen(); videoCaptureScreen();
P_DoQuote(QUOTE_SCREEN_SAVED, &myplayer); P_DoQuote(QUOTE_SCREEN_SAVED, &myplayer);
} }
@ -4513,18 +4513,18 @@ void G_HandleLocalKeys(void)
if (g_player[myconnectindex].gotvote == 0 && voting != -1 && voting != myconnectindex) if (g_player[myconnectindex].gotvote == 0 && voting != -1 && voting != myconnectindex)
{ {
if (KB_UnBoundKeyPressed(sc_F1) || KB_UnBoundKeyPressed(sc_F2) || cl_autovote) if (inputState.UnboundKeyPressed(sc_F1) || inputState.UnboundKeyPressed(sc_F2) || cl_autovote)
{ {
G_AddUserQuote("Vote Cast"); G_AddUserQuote("Vote Cast");
Net_SendMapVote(KB_UnBoundKeyPressed(sc_F1) || cl_autovote ? cl_autovote-1 : 0); Net_SendMapVote(inputState.UnboundKeyPressed(sc_F1) || cl_autovote ? cl_autovote-1 : 0);
KB_ClearKeyDown(sc_F1); inputState.ClearKeyStatus(sc_F1);
KB_ClearKeyDown(sc_F2); inputState.ClearKeyStatus(sc_F2);
} }
} }
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 (BUTTON(gamefunc_Enlarge_Screen)) if (inputState.BUTTON(gamefunc_Enlarge_Screen))
{ {
inputState.ClearButton(gamefunc_Enlarge_Screen); inputState.ClearButton(gamefunc_Enlarge_Screen);
@ -4543,7 +4543,7 @@ void G_HandleLocalKeys(void)
G_UpdateScreenArea(); G_UpdateScreenArea();
} }
if (BUTTON(gamefunc_Shrink_Screen)) if (inputState.BUTTON(gamefunc_Shrink_Screen))
{ {
inputState.ClearButton(gamefunc_Shrink_Screen); inputState.ClearButton(gamefunc_Shrink_Screen);
@ -4566,7 +4566,7 @@ 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 (BUTTON(gamefunc_See_Coop_View) && (GTFLAGS(GAMETYPE_COOPVIEW) || ud.recstat == 2)) if (inputState.BUTTON(gamefunc_See_Coop_View) && (GTFLAGS(GAMETYPE_COOPVIEW) || ud.recstat == 2))
{ {
inputState.ClearButton(gamefunc_See_Coop_View); inputState.ClearButton(gamefunc_See_Coop_View);
screenpeek = connectpoint2[screenpeek]; screenpeek = connectpoint2[screenpeek];
@ -4574,21 +4574,21 @@ void G_HandleLocalKeys(void)
g_restorePalette = -1; g_restorePalette = -1;
} }
if ((g_netServer || ud.multimode > 1) && BUTTON(gamefunc_Show_Opponents_Weapon)) if ((g_netServer || ud.multimode > 1) && inputState.BUTTON(gamefunc_Show_Opponents_Weapon))
{ {
inputState.ClearButton(gamefunc_Show_Opponents_Weapon); inputState.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 (BUTTON(gamefunc_Toggle_Crosshair)) if (inputState.BUTTON(gamefunc_Toggle_Crosshair))
{ {
inputState.ClearButton(gamefunc_Toggle_Crosshair); inputState.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 && BUTTON(gamefunc_Map_Follow_Mode)) if (ud.overhead_on && inputState.BUTTON(gamefunc_Map_Follow_Mode))
{ {
inputState.ClearButton(gamefunc_Map_Follow_Mode); inputState.ClearButton(gamefunc_Map_Follow_Mode);
ud.scrollmode = 1-ud.scrollmode; ud.scrollmode = 1-ud.scrollmode;
@ -4601,9 +4601,9 @@ void G_HandleLocalKeys(void)
P_DoQuote(QUOTE_MAP_FOLLOW_OFF+ud.scrollmode, &myplayer); P_DoQuote(QUOTE_MAP_FOLLOW_OFF+ud.scrollmode, &myplayer);
} }
if (KB_UnBoundKeyPressed(sc_ScrollLock)) if (inputState.UnboundKeyPressed(sc_ScrollLock))
{ {
KB_ClearKeyDown(sc_ScrollLock); inputState.ClearKeyStatus(sc_ScrollLock);
switch (ud.recstat) switch (ud.recstat)
{ {
@ -4619,9 +4619,9 @@ void G_HandleLocalKeys(void)
if (ud.recstat == 2) if (ud.recstat == 2)
{ {
if (KB_KeyPressed(sc_Space)) if (inputState.GetKeyStatus(sc_Space))
{ {
KB_ClearKeyDown(sc_Space); inputState.ClearKeyStatus(sc_Space);
g_demo_paused = !g_demo_paused; g_demo_paused = !g_demo_paused;
g_demo_rewind = 0; g_demo_rewind = 0;
@ -4630,18 +4630,18 @@ void G_HandleLocalKeys(void)
FX_StopAllSounds(); FX_StopAllSounds();
} }
if (KB_KeyPressed(sc_Tab)) if (inputState.GetKeyStatus(sc_Tab))
{ {
KB_ClearKeyDown(sc_Tab); inputState.ClearKeyStatus(sc_Tab);
g_demo_showStats = !g_demo_showStats; g_demo_showStats = !g_demo_showStats;
} }
#if 0 #if 0
if (KB_KeyPressed(sc_kpad_Plus)) if (inputState.GetKeyStatus(sc_kpad_Plus))
{ {
G_InitTimer(240); G_InitTimer(240);
} }
else if (KB_KeyPressed(sc_kpad_Minus)) else if (inputState.GetKeyStatus(sc_kpad_Minus))
{ {
G_InitTimer(60); G_InitTimer(60);
} }
@ -4651,9 +4651,9 @@ void G_HandleLocalKeys(void)
} }
#endif #endif
if (KB_KeyPressed(sc_kpad_6)) if (inputState.GetKeyStatus(sc_kpad_6))
{ {
KB_ClearKeyDown(sc_kpad_6); inputState.ClearKeyStatus(sc_kpad_6);
int const fwdTics = (15 << (int)ALT_IS_PRESSED) << (2 * (int)SHIFTS_IS_PRESSED); int const fwdTics = (15 << (int)ALT_IS_PRESSED) << (2 * (int)SHIFTS_IS_PRESSED);
g_demo_goalCnt = g_demo_paused ? g_demo_cnt + 1 : g_demo_cnt + REALGAMETICSPERSEC * fwdTics; g_demo_goalCnt = g_demo_paused ? g_demo_cnt + 1 : g_demo_cnt + REALGAMETICSPERSEC * fwdTics;
@ -4664,9 +4664,9 @@ void G_HandleLocalKeys(void)
else else
Demo_PrepareWarp(); Demo_PrepareWarp();
} }
else if (KB_KeyPressed(sc_kpad_4)) else if (inputState.GetKeyStatus(sc_kpad_4))
{ {
KB_ClearKeyDown(sc_kpad_4); inputState.ClearKeyStatus(sc_kpad_4);
int const rewindTics = (15 << (int)ALT_IS_PRESSED) << (2 * (int)SHIFTS_IS_PRESSED); int const rewindTics = (15 << (int)ALT_IS_PRESSED) << (2 * (int)SHIFTS_IS_PRESSED);
g_demo_goalCnt = g_demo_paused ? g_demo_cnt - 1 : g_demo_cnt - REALGAMETICSPERSEC * rewindTics; g_demo_goalCnt = g_demo_paused ? g_demo_cnt - 1 : g_demo_cnt - REALGAMETICSPERSEC * rewindTics;
@ -4686,9 +4686,9 @@ void G_HandleLocalKeys(void)
// NOTE: sc_F1 .. sc_F10 are contiguous. sc_F11 is not sc_F10+1. // NOTE: sc_F1 .. sc_F10 are contiguous. sc_F11 is not sc_F10+1.
for (bssize_t j=sc_F1; j<=sc_F10; j++) for (bssize_t j=sc_F1; j<=sc_F10; j++)
if (KB_UnBoundKeyPressed(j)) if (inputState.UnboundKeyPressed(j))
{ {
KB_ClearKeyDown(j); inputState.ClearKeyStatus(j);
ridiculeNum = j - sc_F1 + 1; ridiculeNum = j - sc_F1 + 1;
break; break;
} }
@ -4739,17 +4739,17 @@ 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) && BUTTON(gamefunc_SendMessage)) if ((g_netServer || ud.multimode > 1) && inputState.BUTTON(gamefunc_SendMessage))
{ {
KB_FlushKeyboardQueue(); inputState.keyFlushChars();
inputState.ClearButton(gamefunc_SendMessage); inputState.ClearButton(gamefunc_SendMessage);
myplayer.gm |= MODE_TYPE; myplayer.gm |= MODE_TYPE;
typebuf[0] = 0; typebuf[0] = 0;
} }
if (KB_UnBoundKeyPressed(sc_F1) && !(G_GetLogoFlags() & LOGO_NOHELP)/* || (ud.show_help && I_AdvanceTrigger())*/) if (inputState.UnboundKeyPressed(sc_F1) && !(G_GetLogoFlags() & LOGO_NOHELP)/* || (ud.show_help && I_AdvanceTrigger())*/)
{ {
KB_ClearKeyDown(sc_F1); inputState.ClearKeyStatus(sc_F1);
Menu_Change(MENU_STORY); Menu_Change(MENU_STORY);
S_PauseSounds(true); S_PauseSounds(true);
@ -4765,9 +4765,9 @@ void G_HandleLocalKeys(void)
// if((!net_server && ud.multimode < 2)) // if((!net_server && ud.multimode < 2))
{ {
if (ud.recstat != 2 && KB_UnBoundKeyPressed(sc_F2)) if (ud.recstat != 2 && inputState.UnboundKeyPressed(sc_F2))
{ {
KB_ClearKeyDown(sc_F2); inputState.ClearKeyStatus(sc_F2);
FAKE_F2: FAKE_F2:
if (sprite[myplayer.i].extra <= 0) if (sprite[myplayer.i].extra <= 0)
@ -4789,9 +4789,9 @@ FAKE_F2:
} }
} }
if (KB_UnBoundKeyPressed(sc_F3)) if (inputState.UnboundKeyPressed(sc_F3))
{ {
KB_ClearKeyDown(sc_F3); inputState.ClearKeyStatus(sc_F3);
FAKE_F3: FAKE_F3:
Menu_Change(MENU_LOAD); Menu_Change(MENU_LOAD);
@ -4808,9 +4808,9 @@ FAKE_F3:
} }
} }
if (KB_UnBoundKeyPressed(sc_F4)) if (inputState.UnboundKeyPressed(sc_F4))
{ {
KB_ClearKeyDown(sc_F4); inputState.ClearKeyStatus(sc_F4);
S_PauseSounds(true); S_PauseSounds(true);
Menu_Open(myconnectindex); Menu_Open(myconnectindex);
@ -4824,12 +4824,12 @@ FAKE_F3:
Menu_Change(MENU_SOUND_INGAME); Menu_Change(MENU_SOUND_INGAME);
} }
if (KB_UnBoundKeyPressed(sc_F5) && MusicEnabled()) if (inputState.UnboundKeyPressed(sc_F5) && MusicEnabled())
{ {
map_t *const pMapInfo = &g_mapInfo[g_musicIndex]; map_t *const pMapInfo = &g_mapInfo[g_musicIndex];
char *const musicString = apStrings[QUOTE_MUSIC]; char *const musicString = apStrings[QUOTE_MUSIC];
KB_ClearKeyDown(sc_F5); inputState.ClearKeyStatus(sc_F5);
if (pMapInfo->musicfn != NULL) if (pMapInfo->musicfn != NULL)
Bsnprintf(musicString, MAXQUOTELEN, "%s. Use SHIFT-F5 to change.", pMapInfo->musicfn); Bsnprintf(musicString, MAXQUOTELEN, "%s. Use SHIFT-F5 to change.", pMapInfo->musicfn);
@ -4839,7 +4839,7 @@ FAKE_F3:
P_DoQuote(QUOTE_MUSIC, g_player[myconnectindex].ps); P_DoQuote(QUOTE_MUSIC, g_player[myconnectindex].ps);
} }
if ((BUTTON(gamefunc_Quick_Save) || g_doQuickSave == 1) && (myplayer.gm & MODE_GAME)) if ((inputState.BUTTON(gamefunc_Quick_Save) || g_doQuickSave == 1) && (myplayer.gm & MODE_GAME))
{ {
inputState.ClearButton(gamefunc_Quick_Save); inputState.ClearButton(gamefunc_Quick_Save);
@ -4848,7 +4848,7 @@ FAKE_F3:
if (!g_lastusersave.isValid()) if (!g_lastusersave.isValid())
goto FAKE_F2; goto FAKE_F2;
KB_FlushKeyboardQueue(); inputState.keyFlushChars();
if (sprite[myplayer.i].extra <= 0) if (sprite[myplayer.i].extra <= 0)
{ {
@ -4876,7 +4876,7 @@ FAKE_F3:
} }
} }
if (BUTTON(gamefunc_Third_Person_View)) if (inputState.BUTTON(gamefunc_Third_Person_View))
{ {
inputState.ClearButton(gamefunc_Third_Person_View); inputState.ClearButton(gamefunc_Third_Person_View);
@ -4888,9 +4888,9 @@ FAKE_F3:
P_DoQuote(QUOTE_VIEW_MODE_OFF + myplayer.over_shoulder_on, &myplayer); P_DoQuote(QUOTE_VIEW_MODE_OFF + myplayer.over_shoulder_on, &myplayer);
} }
if (KB_UnBoundKeyPressed(sc_F8)) if (inputState.UnboundKeyPressed(sc_F8))
{ {
KB_ClearKeyDown(sc_F8); inputState.ClearKeyStatus(sc_F8);
int const fta = !ud.fta_on; int const fta = !ud.fta_on;
ud.fta_on = 1; ud.fta_on = 1;
@ -4898,7 +4898,7 @@ FAKE_F3:
ud.fta_on = fta; ud.fta_on = fta;
} }
if ((BUTTON(gamefunc_Quick_Load) || g_doQuickSave == 2) && (myplayer.gm & MODE_GAME)) if ((inputState.BUTTON(gamefunc_Quick_Load) || g_doQuickSave == 2) && (myplayer.gm & MODE_GAME))
{ {
inputState.ClearButton(gamefunc_Quick_Load); inputState.ClearButton(gamefunc_Quick_Load);
@ -4908,17 +4908,17 @@ FAKE_F3:
goto FAKE_F3; goto FAKE_F3;
else if (g_quickload->isValid()) else if (g_quickload->isValid())
{ {
KB_FlushKeyboardQueue(); inputState.keyFlushChars();
KB_ClearKeysDown(); inputState.ClearKeysDown();
S_PauseSounds(true); S_PauseSounds(true);
if (G_LoadPlayerMaybeMulti(*g_quickload) != 0) if (G_LoadPlayerMaybeMulti(*g_quickload) != 0)
g_quickload->reset(); g_quickload->reset();
} }
} }
if (KB_UnBoundKeyPressed(sc_F10)) if (inputState.UnboundKeyPressed(sc_F10))
{ {
KB_ClearKeyDown(sc_F10); inputState.ClearKeyStatus(sc_F10);
Menu_Change(MENU_QUIT_INGAME); Menu_Change(MENU_QUIT_INGAME);
S_PauseSounds(true); S_PauseSounds(true);
@ -4931,9 +4931,9 @@ FAKE_F3:
} }
} }
if (KB_UnBoundKeyPressed(sc_F11)) if (inputState.UnboundKeyPressed(sc_F11))
{ {
KB_ClearKeyDown(sc_F11); inputState.ClearKeyStatus(sc_F11);
Menu_Change(MENU_COLCORR_INGAME); Menu_Change(MENU_COLCORR_INGAME);
S_PauseSounds(true); S_PauseSounds(true);
@ -4951,10 +4951,10 @@ FAKE_F3:
int const timerOffset = ((int) totalclock - nonsharedtimer); int const timerOffset = ((int) totalclock - nonsharedtimer);
nonsharedtimer += timerOffset; nonsharedtimer += timerOffset;
if (BUTTON(gamefunc_Enlarge_Screen)) if (inputState.BUTTON(gamefunc_Enlarge_Screen))
myplayer.zoom += mulscale6(timerOffset, max<int>(myplayer.zoom, 256)); myplayer.zoom += mulscale6(timerOffset, max<int>(myplayer.zoom, 256));
if (BUTTON(gamefunc_Shrink_Screen)) if (inputState.BUTTON(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,14 +4970,14 @@ FAKE_F3:
G_UpdateScreenArea(); G_UpdateScreenArea();
} }
if (BUTTON(gamefunc_AutoRun)) if (inputState.BUTTON(gamefunc_AutoRun))
{ {
inputState.ClearButton(gamefunc_AutoRun); inputState.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 (BUTTON(gamefunc_Map)) if (inputState.BUTTON(gamefunc_Map))
{ {
inputState.ClearButton(gamefunc_Map); inputState.ClearButton(gamefunc_Map);
if (ud.last_overhead != ud.overhead_on && ud.last_overhead) if (ud.last_overhead != ud.overhead_on && ud.last_overhead)
@ -6043,7 +6043,7 @@ void G_BackToMenu(void)
g_player[myconnectindex].ps->gm = 0; g_player[myconnectindex].ps->gm = 0;
Menu_Open(myconnectindex); Menu_Open(myconnectindex);
Menu_Change(MENU_MAIN); Menu_Change(MENU_MAIN);
KB_FlushKeyboardQueue(); inputState.keyFlushChars();
} }
static int G_EndOfLevel(void) static int G_EndOfLevel(void)
@ -6597,7 +6597,7 @@ MAIN_LOOP_RESTART:
// handle CON_SAVE and CON_SAVENN // handle CON_SAVE and CON_SAVENN
if (g_saveRequested) if (g_saveRequested)
{ {
KB_FlushKeyboardQueue(); inputState.keyFlushChars();
videoNextPage(); videoNextPage();
g_screenCapture = 1; g_screenCapture = 1;

View file

@ -1067,8 +1067,8 @@ static int32_t VM_ResetPlayer(int const playerNum, int32_t vmFlags, int32_t cons
{ {
if (resetFlags & 4) if (resetFlags & 4)
{ {
KB_FlushKeyboardQueue(); inputState.keyFlushChars();
KB_ClearKeysDown(); inputState.ClearKeysDown();
FX_StopAllSounds(); FX_StopAllSounds();
S_ClearSoundLocks(); S_ClearSoundLocks();
if (G_LoadPlayerMaybeMulti(*g_quickload) != 0) if (G_LoadPlayerMaybeMulti(*g_quickload) != 0)
@ -1080,7 +1080,7 @@ static int32_t VM_ResetPlayer(int const playerNum, int32_t vmFlags, int32_t cons
else if (!(resetFlags & 1)) else if (!(resetFlags & 1))
{ {
Menu_Open(playerNum); Menu_Open(playerNum);
KB_ClearKeyDown(sc_Space); inputState.ClearKeyStatus(sc_Space);
I_AdvanceTriggerClear(); I_AdvanceTriggerClear();
Menu_Change(MENU_RESETPLAYER); Menu_Change(MENU_RESETPLAYER);
} }

View file

@ -49,8 +49,8 @@ BEGIN_DUKE_NS
static FORCE_INLINE void Menu_StartTextInput() static FORCE_INLINE void Menu_StartTextInput()
{ {
KB_FlushKeyboardQueue(); inputState.keyFlushChars();
KB_ClearKeysDown(); inputState.ClearKeysDown();
} }
static FORCE_INLINE void Menu_StopTextInput() static FORCE_INLINE void Menu_StopTextInput()
@ -2861,26 +2861,26 @@ static void Menu_PreInput(MenuEntry_t *entry)
{ {
case MENU_KEYBOARDKEYS: case MENU_KEYBOARDKEYS:
if (KB_KeyPressed(sc_Delete)) if (inputState.GetKeyStatus(sc_Delete))
{ {
Bindings.UnbindACommand(CONFIG_FunctionNumToName(M_KEYBOARDKEYS.currentEntry)); Bindings.UnbindACommand(CONFIG_FunctionNumToName(M_KEYBOARDKEYS.currentEntry));
S_PlaySound(KICK_HIT); S_PlaySound(KICK_HIT);
KB_ClearKeyDown(sc_Delete); inputState.ClearKeyStatus(sc_Delete);
} }
break; break;
case MENU_LOAD: case MENU_LOAD:
if (KB_KeyPressed(sc_Delete)) if (inputState.GetKeyStatus(sc_Delete))
{ {
KB_ClearKeyDown(sc_Delete); inputState.ClearKeyStatus(sc_Delete);
if (M_LOAD.currentEntry < g_nummenusaves) if (M_LOAD.currentEntry < g_nummenusaves)
Menu_Change(MENU_LOADDELVERIFY); Menu_Change(MENU_LOADDELVERIFY);
} }
break; break;
case MENU_SAVE: case MENU_SAVE:
if (KB_KeyPressed(sc_Delete)) if (inputState.GetKeyStatus(sc_Delete))
{ {
KB_ClearKeyDown(sc_Delete); inputState.ClearKeyStatus(sc_Delete);
if (0 < M_SAVE.currentEntry && M_SAVE.currentEntry <= (int32_t)g_nummenusaves) if (0 < M_SAVE.currentEntry && M_SAVE.currentEntry <= (int32_t)g_nummenusaves)
Menu_Change(MENU_SAVEDELVERIFY); Menu_Change(MENU_SAVEDELVERIFY);
} }
@ -2916,12 +2916,12 @@ static int32_t Menu_PreCustom2ColScreen(MenuEntry_t *entry)
{ {
auto column = (MenuCustom2Col_t*)entry->entry; auto column = (MenuCustom2Col_t*)entry->entry;
int32_t sc = KB_GetLastScanCode(); int32_t sc = inputState.GetLastScanCode();
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, CONFIG_FunctionNumToName(M_KEYBOARDKEYS.currentEntry));
KB_ClearKeyDown(sc); inputState.ClearKeyStatus(sc);
return -1; return -1;
} }
@ -3383,8 +3383,8 @@ static void Menu_Custom2ColScreen(/*MenuEntry_t *entry*/)
{ {
if (g_currentMenu == MENU_KEYBOARDKEYS) if (g_currentMenu == MENU_KEYBOARDKEYS)
{ {
KB_FlushKeyboardQueue(); inputState.keyFlushChars();
KB_ClearLastScanCode(); inputState.ClearLastScanCode();
} }
} }
@ -3553,8 +3553,8 @@ static void Menu_Verify(int32_t input)
switch (input) switch (input)
{ {
default: default:
KB_FlushKeyboardQueue(); inputState.keyFlushChars();
KB_ClearKeysDown(); inputState.ClearKeysDown();
FX_StopAllSounds(); FX_StopAllSounds();
if (G_LoadPlayerMaybeMulti(*g_quickload) == 0) if (G_LoadPlayerMaybeMulti(*g_quickload) == 0)
@ -3594,8 +3594,8 @@ static void Menu_Verify(int32_t input)
g_quickload = &g_lastusersave; g_quickload = &g_lastusersave;
} }
KB_FlushKeyboardQueue(); inputState.keyFlushChars();
KB_ClearKeysDown(); inputState.ClearKeysDown();
if (G_LoadPlayerMaybeMulti(sv)) if (G_LoadPlayerMaybeMulti(sv))
Menu_Change(MENU_PREVIOUS); Menu_Change(MENU_PREVIOUS);
@ -3845,7 +3845,7 @@ static void Menu_FileSelectInit(MenuFileSelect_t *object)
object->currentList = 1; object->currentList = 1;
#endif #endif
KB_FlushKeyboardQueue(); inputState.keyFlushChars();
} }
static void Menu_FileSelect(int32_t input) static void Menu_FileSelect(int32_t input)
@ -6393,29 +6393,29 @@ static void Menu_RunInput(Menu_t *cm)
S_PlaySound(PISTOL_BODYHIT); S_PlaySound(PISTOL_BODYHIT);
} }
else if (KB_KeyPressed(sc_Home)) else if (inputState.GetKeyStatus(sc_Home))
{ {
KB_ClearKeyDown(sc_Home); inputState.ClearKeyStatus(sc_Home);
Menu_RunInput_FileSelect_Movement(object, MM_Home); Menu_RunInput_FileSelect_Movement(object, MM_Home);
S_PlaySound(KICK_HIT); S_PlaySound(KICK_HIT);
} }
else if (KB_KeyPressed(sc_End)) else if (inputState.GetKeyStatus(sc_End))
{ {
KB_ClearKeyDown(sc_End); inputState.ClearKeyStatus(sc_End);
Menu_RunInput_FileSelect_Movement(object, MM_End); Menu_RunInput_FileSelect_Movement(object, MM_End);
S_PlaySound(KICK_HIT); S_PlaySound(KICK_HIT);
} }
else if (KB_KeyPressed(sc_PgUp)) else if (inputState.GetKeyStatus(sc_PgUp))
{ {
int32_t i; int32_t i;
CACHE1D_FIND_REC *seeker = object->findhigh[object->currentList]; CACHE1D_FIND_REC *seeker = object->findhigh[object->currentList];
KB_ClearKeyDown(sc_PgUp); inputState.ClearKeyStatus(sc_PgUp);
for (i = 0; i < 6; ++i) for (i = 0; i < 6; ++i)
{ {
@ -6432,13 +6432,13 @@ static void Menu_RunInput(Menu_t *cm)
S_PlaySound(KICK_HIT); S_PlaySound(KICK_HIT);
} }
} }
else if (KB_KeyPressed(sc_PgDn)) else if (inputState.GetKeyStatus(sc_PgDn))
{ {
int32_t i; int32_t i;
CACHE1D_FIND_REC *seeker = object->findhigh[object->currentList]; CACHE1D_FIND_REC *seeker = object->findhigh[object->currentList];
KB_ClearKeyDown(sc_PgDn); inputState.ClearKeyStatus(sc_PgDn);
for (i = 0; i < 6; ++i) for (i = 0; i < 6; ++i)
{ {
@ -6487,7 +6487,7 @@ static void Menu_RunInput(Menu_t *cm)
{ {
// JBF 20040208: seek to first name matching pressed character // JBF 20040208: seek to first name matching pressed character
char ch2, ch; char ch2, ch;
ch = KB_GetCh(); ch = inputState.keyGetChar();
if (ch > 0 && ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || (ch >= '0' && ch <= '9'))) if (ch > 0 && ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || (ch >= '0' && ch <= '9')))
{ {
CACHE1D_FIND_REC *seeker = object->findhigh[object->currentList]->usera; CACHE1D_FIND_REC *seeker = object->findhigh[object->currentList]->usera;
@ -6543,10 +6543,10 @@ static void Menu_RunInput(Menu_t *cm)
break; break;
case Verify: case Verify:
if (I_ReturnTrigger() || KB_KeyPressed(sc_N) || Menu_RunInput_MouseReturn()) if (I_ReturnTrigger() || inputState.GetKeyStatus(sc_N) || Menu_RunInput_MouseReturn())
{ {
I_ReturnTriggerClear(); I_ReturnTriggerClear();
KB_ClearKeyDown(sc_N); inputState.ClearKeyStatus(sc_N);
m_mousecaught = 1; m_mousecaught = 1;
Menu_Verify(0); Menu_Verify(0);
@ -6556,12 +6556,12 @@ static void Menu_RunInput(Menu_t *cm)
S_PlaySound(EXITMENUSOUND); S_PlaySound(EXITMENUSOUND);
} }
if (I_AdvanceTrigger() || KB_KeyPressed(sc_Y) || Menu_RunInput_MouseAdvance()) if (I_AdvanceTrigger() || inputState.GetKeyStatus(sc_Y) || Menu_RunInput_MouseAdvance())
{ {
auto verify = (MenuVerify_t*)cm->object; auto verify = (MenuVerify_t*)cm->object;
I_AdvanceTriggerClear(); I_AdvanceTriggerClear();
KB_ClearKeyDown(sc_Y); inputState.ClearKeyStatus(sc_Y);
m_mousecaught = 1; m_mousecaught = 1;
Menu_Verify(1); Menu_Verify(1);
@ -6767,17 +6767,17 @@ static void Menu_RunInput(Menu_t *cm)
Menu_AnimateChange(cm->parentID, cm->parentAnimation); Menu_AnimateChange(cm->parentID, cm->parentAnimation);
} }
else if (KB_KeyPressed(sc_Home)) else if (inputState.GetKeyStatus(sc_Home))
{ {
KB_ClearKeyDown(sc_Home); inputState.ClearKeyStatus(sc_Home);
S_PlaySound(KICK_HIT); S_PlaySound(KICK_HIT);
currentry = Menu_RunInput_Menu_Movement(menu, MM_Home); currentry = Menu_RunInput_Menu_Movement(menu, MM_Home);
} }
else if (KB_KeyPressed(sc_End)) else if (inputState.GetKeyStatus(sc_End))
{ {
KB_ClearKeyDown(sc_End); inputState.ClearKeyStatus(sc_End);
S_PlaySound(KICK_HIT); S_PlaySound(KICK_HIT);
@ -6849,17 +6849,17 @@ static void Menu_RunInput(Menu_t *cm)
if (!Menu_RunInput_EntryOptionList_Activate(currentry, object)) if (!Menu_RunInput_EntryOptionList_Activate(currentry, object))
S_PlaySound(PISTOL_BODYHIT); S_PlaySound(PISTOL_BODYHIT);
} }
else if (KB_KeyPressed(sc_Home)) else if (inputState.GetKeyStatus(sc_Home))
{ {
KB_ClearKeyDown(sc_Home); inputState.ClearKeyStatus(sc_Home);
S_PlaySound(KICK_HIT); S_PlaySound(KICK_HIT);
Menu_RunInput_EntryOptionList_Movement(object, MM_Home); Menu_RunInput_EntryOptionList_Movement(object, MM_Home);
} }
else if (KB_KeyPressed(sc_End)) else if (inputState.GetKeyStatus(sc_End))
{ {
KB_ClearKeyDown(sc_End); inputState.ClearKeyStatus(sc_End);
S_PlaySound(KICK_HIT); S_PlaySound(KICK_HIT);
@ -6915,7 +6915,7 @@ void M_DisplayMenus(void)
return; return;
} }
if (!Menu_IsTextInput(m_currentMenu) && KB_KeyPressed(sc_Q)) if (!Menu_IsTextInput(m_currentMenu) && inputState.GetKeyStatus(sc_Q))
Menu_AnimateChange(MENU_QUIT, MA_Advance); Menu_AnimateChange(MENU_QUIT, MA_Advance);
int32_t mousestatus = mouseReadAbs(&m_mousepos, &g_mouseAbs); int32_t mousestatus = mouseReadAbs(&m_mousepos, &g_mouseAbs);

View file

@ -5077,9 +5077,9 @@ void Net_SendMessage(void)
mpgametext(mpgametext_x, ud.screen_size > 0 ? (200 - 45) << 16 : (200 - 8) << 16, typebuf, 0, 0, 0, 0); mpgametext(mpgametext_x, ud.screen_size > 0 ? (200 - 45) << 16 : (200 - 8) << 16, typebuf, 0, 0, 0, 0);
if (KB_KeyWaiting()) if (inputState.keyBufferWaiting())
{ {
i = KB_GetCh(); i = inputState.keyGetChar();
if (i == 'A' || i == 'a' || i == 13) if (i == 'A' || i == 'a' || i == 13)
g_chatPlayer = ud.multimode; g_chatPlayer = ud.multimode;
@ -5097,17 +5097,17 @@ void Net_SendMessage(void)
typebuf[0] = 0; typebuf[0] = 0;
} }
KB_ClearKeyDown(sc_1); inputState.ClearKeyStatus(sc_1);
KB_ClearKeyDown(sc_2); inputState.ClearKeyStatus(sc_2);
KB_ClearKeyDown(sc_3); inputState.ClearKeyStatus(sc_3);
KB_ClearKeyDown(sc_4); inputState.ClearKeyStatus(sc_4);
KB_ClearKeyDown(sc_5); inputState.ClearKeyStatus(sc_5);
KB_ClearKeyDown(sc_6); inputState.ClearKeyStatus(sc_6);
KB_ClearKeyDown(sc_7); inputState.ClearKeyStatus(sc_7);
KB_ClearKeyDown(sc_8); inputState.ClearKeyStatus(sc_8);
KB_ClearKeyDown(sc_A); inputState.ClearKeyStatus(sc_A);
KB_ClearKeyDown(sc_Escape); inputState.ClearKeyStatus(sc_Escape);
KB_ClearKeyDown(sc_Enter); inputState.ClearKeyStatus(sc_Enter);
} }
} }
} }
@ -5127,7 +5127,7 @@ void Net_SendMessage(void)
if (hitstate == 1) if (hitstate == 1)
{ {
KB_ClearKeyDown(sc_Enter); inputState.ClearKeyStatus(sc_Enter);
if (Bstrlen(typebuf) == 0) if (Bstrlen(typebuf) == 0)
{ {
g_player[myconnectindex].ps->gm &= ~(MODE_TYPE | MODE_SENDTOWHOM); g_player[myconnectindex].ps->gm &= ~(MODE_TYPE | MODE_SENDTOWHOM);

View file

@ -2894,7 +2894,7 @@ void P_GetInput(int const playerNum)
auto const pPlayer = g_player[playerNum].ps; auto const pPlayer = g_player[playerNum].ps;
ControlInfo info; ControlInfo info;
if ((pPlayer->gm & (MODE_MENU|MODE_TYPE)) || (ud.pause_on && !KB_KeyPressed(sc_Pause))) if ((pPlayer->gm & (MODE_MENU|MODE_TYPE)) || (ud.pause_on && !inputState.GetKeyStatus(sc_Pause)))
{ {
if (!(pPlayer->gm&MODE_MENU)) if (!(pPlayer->gm&MODE_MENU))
CONTROL_GetInput(&info); CONTROL_GetInput(&info);
@ -2910,11 +2910,11 @@ void P_GetInput(int const playerNum)
D_ProcessEvents(); D_ProcessEvents();
if (in_aimmode) if (in_aimmode)
g_MyAimMode = BUTTON(gamefunc_Mouse_Aiming); g_MyAimMode = inputState.BUTTON(gamefunc_Mouse_Aiming);
else else
{ {
g_oldAimStat = g_myAimStat; g_oldAimStat = g_myAimStat;
g_myAimStat = BUTTON(gamefunc_Mouse_Aiming); g_myAimStat = inputState.BUTTON(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(BUTTON(gamefunc_Run)); int const playerRunning = G_CheckAutorun(inputState.BUTTON(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 (BUTTON(gamefunc_Strafe)) if (inputState.BUTTON(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 (BUTTON(gamefunc_Strafe)) if (inputState.BUTTON(gamefunc_Strafe))
{ {
if (BUTTON(gamefunc_Turn_Left) && !(pPlayer->movement_lock&4)) if (inputState.BUTTON(gamefunc_Turn_Left) && !(pPlayer->movement_lock&4))
input.svel -= -keyMove; input.svel -= -keyMove;
if (BUTTON(gamefunc_Turn_Right) && !(pPlayer->movement_lock&8)) if (inputState.BUTTON(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 (BUTTON(gamefunc_Turn_Left)) if (inputState.BUTTON(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 (BUTTON(gamefunc_Turn_Right)) else if (inputState.BUTTON(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 (BUTTON(gamefunc_Strafe_Left) && !(pPlayer->movement_lock & 4)) if (inputState.BUTTON(gamefunc_Strafe_Left) && !(pPlayer->movement_lock & 4))
input.svel += keyMove; input.svel += keyMove;
if (BUTTON(gamefunc_Strafe_Right) && !(pPlayer->movement_lock & 8)) if (inputState.BUTTON(gamefunc_Strafe_Right) && !(pPlayer->movement_lock & 8))
input.svel += -keyMove; input.svel += -keyMove;
if (BUTTON(gamefunc_Move_Forward) && !(pPlayer->movement_lock & 1)) if (inputState.BUTTON(gamefunc_Move_Forward) && !(pPlayer->movement_lock & 1))
input.fvel += keyMove; input.fvel += keyMove;
if (BUTTON(gamefunc_Move_Backward) && !(pPlayer->movement_lock & 2)) if (inputState.BUTTON(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,31 +3033,31 @@ 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 (BUTTON(weaponSelection)) if (inputState.BUTTON(weaponSelection))
{ {
weaponSelection -= (gamefunc_Weapon_1 - 1); weaponSelection -= (gamefunc_Weapon_1 - 1);
break; break;
} }
} }
if (BUTTON(gamefunc_Last_Weapon)) if (inputState.BUTTON(gamefunc_Last_Weapon))
weaponSelection = 14; weaponSelection = 14;
else if (BUTTON(gamefunc_Alt_Weapon)) else if (inputState.BUTTON(gamefunc_Alt_Weapon))
weaponSelection = 13; weaponSelection = 13;
else if (BUTTON(gamefunc_Next_Weapon) || (BUTTON(gamefunc_Dpad_Select) && input.fvel > 0)) else if (inputState.BUTTON(gamefunc_Next_Weapon) || (inputState.BUTTON(gamefunc_Dpad_Select) && input.fvel > 0))
weaponSelection = 12; weaponSelection = 12;
else if (BUTTON(gamefunc_Previous_Weapon) || (BUTTON(gamefunc_Dpad_Select) && input.fvel < 0)) else if (inputState.BUTTON(gamefunc_Previous_Weapon) || (inputState.BUTTON(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) | (BUTTON(gamefunc_Fire) << SK_FIRE); localInput.bits = (weaponSelection << SK_WEAPON_BITS) | (inputState.BUTTON(gamefunc_Fire) << SK_FIRE);
localInput.bits |= (BUTTON(gamefunc_Open) << SK_OPEN); localInput.bits |= (inputState.BUTTON(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 && BUTTON(gamefunc_Toggle_Crouch)) if (pPlayer->cheat_phase == 0 && inputState.BUTTON(gamefunc_Toggle_Crouch))
{ {
pPlayer->crouch_toggle = !pPlayer->crouch_toggle && crouchable; pPlayer->crouch_toggle = !pPlayer->crouch_toggle && crouchable;
@ -3065,58 +3065,58 @@ void P_GetInput(int const playerNum)
inputState.ClearButton(gamefunc_Toggle_Crouch); inputState.ClearButton(gamefunc_Toggle_Crouch);
} }
if (BUTTON(gamefunc_Crouch) || BUTTON(gamefunc_Jump) || pPlayer->jetpack_on || (!crouchable && pPlayer->on_ground)) if (inputState.BUTTON(gamefunc_Crouch) || inputState.BUTTON(gamefunc_Jump) || pPlayer->jetpack_on || (!crouchable && pPlayer->on_ground))
pPlayer->crouch_toggle = 0; pPlayer->crouch_toggle = 0;
int const crouching = BUTTON(gamefunc_Crouch) || BUTTON(gamefunc_Toggle_Crouch) || pPlayer->crouch_toggle; int const crouching = inputState.BUTTON(gamefunc_Crouch) || inputState.BUTTON(gamefunc_Toggle_Crouch) || pPlayer->crouch_toggle;
localInput.bits |= (BUTTON(gamefunc_Jump) << SK_JUMP) | (crouching << SK_CROUCH); localInput.bits |= (inputState.BUTTON(gamefunc_Jump) << SK_JUMP) | (crouching << SK_CROUCH);
localInput.bits |= (BUTTON(gamefunc_Aim_Up) || (BUTTON(gamefunc_Dpad_Aiming) && input.fvel > 0)) << SK_AIM_UP; localInput.bits |= (inputState.BUTTON(gamefunc_Aim_Up) || (inputState.BUTTON(gamefunc_Dpad_Aiming) && input.fvel > 0)) << SK_AIM_UP;
localInput.bits |= (BUTTON(gamefunc_Aim_Down) || (BUTTON(gamefunc_Dpad_Aiming) && input.fvel < 0)) << SK_AIM_DOWN; localInput.bits |= (inputState.BUTTON(gamefunc_Aim_Down) || (inputState.BUTTON(gamefunc_Dpad_Aiming) && input.fvel < 0)) << SK_AIM_DOWN;
localInput.bits |= (BUTTON(gamefunc_Center_View) << SK_CENTER_VIEW); localInput.bits |= (inputState.BUTTON(gamefunc_Center_View) << SK_CENTER_VIEW);
localInput.bits |= (BUTTON(gamefunc_Look_Left) << SK_LOOK_LEFT) | (BUTTON(gamefunc_Look_Right) << SK_LOOK_RIGHT); localInput.bits |= (inputState.BUTTON(gamefunc_Look_Left) << SK_LOOK_LEFT) | (inputState.BUTTON(gamefunc_Look_Right) << SK_LOOK_RIGHT);
localInput.bits |= (BUTTON(gamefunc_Look_Up) << SK_LOOK_UP) | (BUTTON(gamefunc_Look_Down) << SK_LOOK_DOWN); localInput.bits |= (inputState.BUTTON(gamefunc_Look_Up) << SK_LOOK_UP) | (inputState.BUTTON(gamefunc_Look_Down) << SK_LOOK_DOWN);
localInput.bits |= (playerRunning << SK_RUN); localInput.bits |= (playerRunning << SK_RUN);
localInput.bits |= (BUTTON(gamefunc_Inventory_Left) || (BUTTON(gamefunc_Dpad_Select) && (input.svel > 0 || input.q16avel < 0))) << SK_INV_LEFT; localInput.bits |= (inputState.BUTTON(gamefunc_Inventory_Left) || (inputState.BUTTON(gamefunc_Dpad_Select) && (input.svel > 0 || input.q16avel < 0))) << SK_INV_LEFT;
localInput.bits |= (BUTTON(gamefunc_Inventory_Right) || (BUTTON(gamefunc_Dpad_Select) && (input.svel < 0 || input.q16avel > 0))) << SK_INV_RIGHT; localInput.bits |= (inputState.BUTTON(gamefunc_Inventory_Right) || (inputState.BUTTON(gamefunc_Dpad_Select) && (input.svel < 0 || input.q16avel > 0))) << SK_INV_RIGHT;
localInput.bits |= (BUTTON(gamefunc_Inventory) << SK_INVENTORY); localInput.bits |= (inputState.BUTTON(gamefunc_Inventory) << SK_INVENTORY);
localInput.bits |= (BUTTON(gamefunc_Steroids) << SK_STEROIDS) | (BUTTON(gamefunc_NightVision) << SK_NIGHTVISION); localInput.bits |= (inputState.BUTTON(gamefunc_Steroids) << SK_STEROIDS) | (inputState.BUTTON(gamefunc_NightVision) << SK_NIGHTVISION);
localInput.bits |= (BUTTON(gamefunc_MedKit) << SK_MEDKIT) | (BUTTON(gamefunc_Holo_Duke) << SK_HOLODUKE); localInput.bits |= (inputState.BUTTON(gamefunc_MedKit) << SK_MEDKIT) | (inputState.BUTTON(gamefunc_Holo_Duke) << SK_HOLODUKE);
localInput.bits |= (BUTTON(gamefunc_Jetpack) << SK_JETPACK); localInput.bits |= (inputState.BUTTON(gamefunc_Jetpack) << SK_JETPACK);
localInput.bits |= BUTTON(gamefunc_Holster_Weapon) << SK_HOLSTER; localInput.bits |= inputState.BUTTON(gamefunc_Holster_Weapon) << SK_HOLSTER;
localInput.bits |= BUTTON(gamefunc_Quick_Kick) << SK_QUICK_KICK; localInput.bits |= inputState.BUTTON(gamefunc_Quick_Kick) << SK_QUICK_KICK;
localInput.bits |= BUTTON(gamefunc_TurnAround) << SK_TURNAROUND; localInput.bits |= inputState.BUTTON(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 |= KB_KeyPressed(sc_Pause) << SK_PAUSE; localInput.bits |= inputState.GetKeyStatus(sc_Pause) << SK_PAUSE;
localInput.bits |= ((uint32_t)KB_KeyPressed(sc_Escape)) << SK_ESCAPE; localInput.bits |= ((uint32_t)inputState.GetKeyStatus(sc_Escape)) << SK_ESCAPE;
if (BUTTON(gamefunc_Dpad_Select)) if (inputState.BUTTON(gamefunc_Dpad_Select))
{ {
input.fvel = 0; input.fvel = 0;
input.svel = 0; input.svel = 0;
input.q16avel = 0; input.q16avel = 0;
} }
else if (BUTTON(gamefunc_Dpad_Aiming)) else if (inputState.BUTTON(gamefunc_Dpad_Aiming))
input.fvel = 0; input.fvel = 0;
if (PWEAPON(playerNum, pPlayer->curr_weapon, Flags) & WEAPON_SEMIAUTO && BUTTON(gamefunc_Fire)) if (PWEAPON(playerNum, pPlayer->curr_weapon, Flags) & WEAPON_SEMIAUTO && inputState.BUTTON(gamefunc_Fire))
inputState.ClearButton(gamefunc_Fire); inputState.ClearButton(gamefunc_Fire);
localInput.extbits = (BUTTON(gamefunc_Move_Forward) || (input.fvel > 0)); localInput.extbits = (inputState.BUTTON(gamefunc_Move_Forward) || (input.fvel > 0));
localInput.extbits |= (BUTTON(gamefunc_Move_Backward) || (input.fvel < 0)) << 1; localInput.extbits |= (inputState.BUTTON(gamefunc_Move_Backward) || (input.fvel < 0)) << 1;
localInput.extbits |= (BUTTON(gamefunc_Strafe_Left) || (input.svel > 0)) << 2; localInput.extbits |= (inputState.BUTTON(gamefunc_Strafe_Left) || (input.svel > 0)) << 2;
localInput.extbits |= (BUTTON(gamefunc_Strafe_Right) || (input.svel < 0)) << 3; localInput.extbits |= (inputState.BUTTON(gamefunc_Strafe_Right) || (input.svel < 0)) << 3;
localInput.extbits |= BUTTON(gamefunc_Turn_Left)<<4; localInput.extbits |= inputState.BUTTON(gamefunc_Turn_Left)<<4;
localInput.extbits |= BUTTON(gamefunc_Turn_Right)<<5; localInput.extbits |= inputState.BUTTON(gamefunc_Turn_Right)<<5;
localInput.extbits |= BUTTON(gamefunc_Alt_Fire)<<6; localInput.extbits |= inputState.BUTTON(gamefunc_Alt_Fire)<<6;
if (ud.scrollmode && ud.overhead_on) if (ud.scrollmode && ud.overhead_on)
{ {

View file

@ -407,7 +407,7 @@ static void G_DoLoadScreen(const char *statustext, int percent)
if (!statustext) if (!statustext)
{ {
KB_FlushKeyboardQueue(); inputState.keyFlushChars();
ud.screen_size = screenSize; ud.screen_size = screenSize;
} }
} }
@ -449,7 +449,7 @@ void G_CacheMapData(void)
int cnt = 0; int cnt = 0;
int percentDisplayed = -1; int percentDisplayed = -1;
for (int i=0; i<MAXTILES && !KB_KeyPressed(sc_Space); i++) for (int i=0; i<MAXTILES && !inputState.GetKeyStatus(sc_Space); i++)
{ {
if (!(i&7) && !gotpic[i>>3]) if (!(i&7) && !gotpic[i>>3])
{ {
@ -1652,9 +1652,9 @@ static void G_FadeLoad(int32_t r, int32_t g, int32_t b, int32_t start, int32_t e
sampletimer(); sampletimer();
nexttic += ticwait; nexttic += ticwait;
if (KB_KeyPressed(sc_Space)) if (inputState.GetKeyStatus(sc_Space))
{ {
KB_ClearKeyDown(sc_Space); inputState.ClearKeyStatus(sc_Space);
return; return;
} }

View file

@ -1255,7 +1255,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 (BUTTON(gamefunc_Show_DukeMatch_Scores)) if (inputState.BUTTON(gamefunc_Show_DukeMatch_Scores))
G_ShowScores(); G_ShowScores();
if (g_Debug) if (g_Debug)
@ -1496,7 +1496,7 @@ void gameDisplayTitleScreen(void)
P_SetGamePalette(g_player[myconnectindex].ps, TITLEPAL, 8 + 2 + 1); // JBF 20040308 P_SetGamePalette(g_player[myconnectindex].ps, TITLEPAL, 8 + 2 + 1); // JBF 20040308
renderFlushPerms(); renderFlushPerms();
rotatesprite_fs(160 << 16, 100 << 16, 65536L, 0, BETASCREEN, 0, 0, 2 + 8 + 64 + BGSTRETCH); rotatesprite_fs(160 << 16, 100 << 16, 65536L, 0, BETASCREEN, 0, 0, 2 + 8 + 64 + BGSTRETCH);
KB_FlushKeyboardQueue(); inputState.keyFlushChars();
fadepaltile(0, 0, 0, 252, 0, -28, BETASCREEN); fadepaltile(0, 0, 0, 252, 0, -28, BETASCREEN);
totalclock = 0; totalclock = 0;
@ -2181,7 +2181,7 @@ void G_BonusScreen(int32_t bonusonly)
P_SetGamePalette(g_player[myconnectindex].ps, BASEPAL, 8+2+1); // JBF 20040308 P_SetGamePalette(g_player[myconnectindex].ps, BASEPAL, 8+2+1); // JBF 20040308
G_FadePalette(0, 0, 0, 252); // JBF 20031228 G_FadePalette(0, 0, 0, 252); // JBF 20031228
KB_FlushKeyboardQueue(); inputState.keyFlushChars();
totalclock = 0; totalclock = 0;
bonuscnt = 0; bonuscnt = 0;
@ -2473,7 +2473,7 @@ void G_BonusScreen(int32_t bonusonly)
I_ClearAllInput(); I_ClearAllInput();
if (totalclock < (60*13)) if (totalclock < (60*13))
{ {
KB_FlushKeyboardQueue(); inputState.keyFlushChars();
totalclock = (60*13); totalclock = (60*13);
} }
else if (totalclock < 1000000000) else if (totalclock < 1000000000)

View file

@ -2594,7 +2594,7 @@ void P_HandleSharedKeys(int playerNum)
{ {
if (TEST_SYNC_KEY(playerBits, SK_PAUSE)) if (TEST_SYNC_KEY(playerBits, SK_PAUSE))
{ {
KB_ClearKeyDown(sc_Pause); inputState.ClearKeyStatus(sc_Pause);
if (ud.pause_on) if (ud.pause_on)
ud.pause_on = 0; ud.pause_on = 0;
else ud.pause_on = 1+SHIFTS_IS_PRESSED; else ud.pause_on = 1+SHIFTS_IS_PRESSED;

View file

@ -35,14 +35,14 @@ char typebuf[TYPEBUFSIZE];
int32_t I_CheckAllInput(void) int32_t I_CheckAllInput(void)
{ {
return return
KB_KeyWaiting() inputState.keyBufferWaiting()
|| MOUSE_GetButtons() || MOUSE_GetButtons()
|| JOYSTICK_GetButtons(); || JOYSTICK_GetButtons();
} }
void I_ClearAllInput(void) void I_ClearAllInput(void)
{ {
KB_FlushKeyboardQueue(); inputState.keyFlushChars();
KB_ClearKeysDown(); inputState.ClearKeysDown();
MOUSE_ClearAllButtons(); MOUSE_ClearAllButtons();
JOYSTICK_ClearAllButtons(); JOYSTICK_ClearAllButtons();
inputState.ClearAllButtons(); inputState.ClearAllButtons();
@ -52,17 +52,17 @@ void I_ClearAllInput(void)
int32_t I_TextSubmit(void) int32_t I_TextSubmit(void)
{ {
return return
KB_KeyPressed(sc_Enter) inputState.GetKeyStatus(sc_Enter)
|| KB_KeyPressed(sc_kpad_Enter) || inputState.GetKeyStatus(sc_kpad_Enter)
//|| MOUSEINACTIVECONDITIONAL(MOUSE_GetButtons()&LEFT_MOUSE) //|| MOUSEINACTIVECONDITIONAL(MOUSE_GetButtons()&LEFT_MOUSE)
|| (JOYSTICK_GetGameControllerButtons()&(1<<GAMECONTROLLER_BUTTON_A)); || (JOYSTICK_GetGameControllerButtons()&(1<<GAMECONTROLLER_BUTTON_A));
} }
void I_TextSubmitClear(void) void I_TextSubmitClear(void)
{ {
KB_FlushKeyboardQueue(); inputState.keyFlushChars();
KB_ClearKeyDown(sc_kpad_Enter); inputState.ClearKeyStatus(sc_kpad_Enter);
KB_ClearKeyDown(sc_Enter); inputState.ClearKeyStatus(sc_Enter);
MOUSE_ClearButton(LEFT_MOUSE); MOUSE_ClearButton(LEFT_MOUSE);
JOYSTICK_ClearGameControllerButton(1<<GAMECONTROLLER_BUTTON_A); JOYSTICK_ClearGameControllerButton(1<<GAMECONTROLLER_BUTTON_A);
} }
@ -71,27 +71,27 @@ int32_t I_AdvanceTrigger(void)
{ {
return return
I_TextSubmit() I_TextSubmit()
|| KB_KeyPressed(sc_Space); || inputState.GetKeyStatus(sc_Space);
} }
void I_AdvanceTriggerClear(void) void I_AdvanceTriggerClear(void)
{ {
I_TextSubmitClear(); I_TextSubmitClear();
KB_ClearKeyDown(sc_Space); inputState.ClearKeyStatus(sc_Space);
} }
int32_t I_ReturnTrigger(void) int32_t I_ReturnTrigger(void)
{ {
return return
KB_KeyPressed(sc_Escape) inputState.GetKeyStatus(sc_Escape)
|| (MOUSE_GetButtons()&RIGHT_MOUSE) || (MOUSE_GetButtons()&RIGHT_MOUSE)
|| (JOYSTICK_GetGameControllerButtons()&(1<<GAMECONTROLLER_BUTTON_B)); || (JOYSTICK_GetGameControllerButtons()&(1<<GAMECONTROLLER_BUTTON_B));
} }
void I_ReturnTriggerClear(void) void I_ReturnTriggerClear(void)
{ {
KB_FlushKeyboardQueue(); inputState.keyFlushChars();
KB_ClearKeyDown(sc_Escape); inputState.ClearKeyStatus(sc_Escape);
MOUSE_ClearButton(RIGHT_MOUSE); MOUSE_ClearButton(RIGHT_MOUSE);
JOYSTICK_ClearGameControllerButton(1<<GAMECONTROLLER_BUTTON_B); JOYSTICK_ClearGameControllerButton(1<<GAMECONTROLLER_BUTTON_B);
} }
@ -101,9 +101,9 @@ int32_t I_GeneralTrigger(void)
return return
I_AdvanceTrigger() I_AdvanceTrigger()
|| I_ReturnTrigger() || I_ReturnTrigger()
|| BUTTON(gamefunc_Open) || inputState.BUTTON(gamefunc_Open)
//|| MOUSEINACTIVECONDITIONAL(BUTTON(gamefunc_Fire)) //|| MOUSEINACTIVECONDITIONAL(inputState.BUTTON(gamefunc_Fire))
|| BUTTON(gamefunc_Crouch) || inputState.BUTTON(gamefunc_Crouch)
|| (JOYSTICK_GetGameControllerButtons()&(1<<GAMECONTROLLER_BUTTON_START)); || (JOYSTICK_GetGameControllerButtons()&(1<<GAMECONTROLLER_BUTTON_START));
} }
@ -121,14 +121,14 @@ void I_GeneralTriggerClear(void)
int32_t I_EscapeTrigger(void) int32_t I_EscapeTrigger(void)
{ {
return return
KB_KeyPressed(sc_Escape) inputState.GetKeyStatus(sc_Escape)
|| (JOYSTICK_GetGameControllerButtons()&(1<<GAMECONTROLLER_BUTTON_START)); || (JOYSTICK_GetGameControllerButtons()&(1<<GAMECONTROLLER_BUTTON_START));
} }
void I_EscapeTriggerClear(void) void I_EscapeTriggerClear(void)
{ {
KB_FlushKeyboardQueue(); inputState.keyFlushChars();
KB_ClearKeyDown(sc_Escape); inputState.ClearKeyStatus(sc_Escape);
JOYSTICK_ClearGameControllerButton(1<<GAMECONTROLLER_BUTTON_START); JOYSTICK_ClearGameControllerButton(1<<GAMECONTROLLER_BUTTON_START);
} }
@ -136,10 +136,10 @@ void I_EscapeTriggerClear(void)
int32_t I_MenuUp(void) int32_t I_MenuUp(void)
{ {
return return
KB_KeyPressed(sc_UpArrow) inputState.GetKeyStatus(sc_UpArrow)
|| KB_KeyPressed(sc_kpad_8) || inputState.GetKeyStatus(sc_kpad_8)
|| (MOUSE_GetButtons()&WHEELUP_MOUSE) || (MOUSE_GetButtons()&WHEELUP_MOUSE)
|| BUTTON(gamefunc_Move_Forward) || inputState.BUTTON(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);
@ -147,8 +147,8 @@ int32_t I_MenuUp(void)
void I_MenuUpClear(void) void I_MenuUpClear(void)
{ {
KB_ClearKeyDown(sc_UpArrow); inputState.ClearKeyStatus(sc_UpArrow);
KB_ClearKeyDown(sc_kpad_8); inputState.ClearKeyStatus(sc_kpad_8);
MOUSE_ClearButton(WHEELUP_MOUSE); MOUSE_ClearButton(WHEELUP_MOUSE);
inputState.ClearButton(gamefunc_Move_Forward); inputState.ClearButton(gamefunc_Move_Forward);
JOYSTICK_ClearHat(0); JOYSTICK_ClearHat(0);
@ -160,10 +160,10 @@ void I_MenuUpClear(void)
int32_t I_MenuDown(void) int32_t I_MenuDown(void)
{ {
return return
KB_KeyPressed(sc_DownArrow) inputState.GetKeyStatus(sc_DownArrow)
|| KB_KeyPressed(sc_kpad_2) || inputState.GetKeyStatus(sc_kpad_2)
|| (MOUSE_GetButtons()&WHEELDOWN_MOUSE) || (MOUSE_GetButtons()&WHEELDOWN_MOUSE)
|| BUTTON(gamefunc_Move_Backward) || inputState.BUTTON(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);
@ -171,9 +171,9 @@ int32_t I_MenuDown(void)
void I_MenuDownClear(void) void I_MenuDownClear(void)
{ {
KB_ClearKeyDown(sc_DownArrow); inputState.ClearKeyStatus(sc_DownArrow);
KB_ClearKeyDown(sc_kpad_2); inputState.ClearKeyStatus(sc_kpad_2);
KB_ClearKeyDown(sc_PgDn); inputState.ClearKeyStatus(sc_PgDn);
MOUSE_ClearButton(WHEELDOWN_MOUSE); MOUSE_ClearButton(WHEELDOWN_MOUSE);
inputState.ClearButton(gamefunc_Move_Backward); inputState.ClearButton(gamefunc_Move_Backward);
JOYSTICK_ClearHat(0); JOYSTICK_ClearHat(0);
@ -185,11 +185,11 @@ void I_MenuDownClear(void)
int32_t I_MenuLeft(void) int32_t I_MenuLeft(void)
{ {
return return
KB_KeyPressed(sc_LeftArrow) inputState.GetKeyStatus(sc_LeftArrow)
|| KB_KeyPressed(sc_kpad_4) || inputState.GetKeyStatus(sc_kpad_4)
|| (inputState.ShiftPressed() && KB_KeyPressed(sc_Tab)) || (inputState.ShiftPressed() && inputState.GetKeyStatus(sc_Tab))
|| BUTTON(gamefunc_Turn_Left) || inputState.BUTTON(gamefunc_Turn_Left)
|| BUTTON(gamefunc_Strafe_Left) || inputState.BUTTON(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);
@ -197,9 +197,9 @@ int32_t I_MenuLeft(void)
void I_MenuLeftClear(void) void I_MenuLeftClear(void)
{ {
KB_ClearKeyDown(sc_LeftArrow); inputState.ClearKeyStatus(sc_LeftArrow);
KB_ClearKeyDown(sc_kpad_4); inputState.ClearKeyStatus(sc_kpad_4);
KB_ClearKeyDown(sc_Tab); inputState.ClearKeyStatus(sc_Tab);
inputState.ClearButton(gamefunc_Turn_Left); inputState.ClearButton(gamefunc_Turn_Left);
inputState.ClearButton(gamefunc_Strafe_Left); inputState.ClearButton(gamefunc_Strafe_Left);
JOYSTICK_ClearHat(0); JOYSTICK_ClearHat(0);
@ -211,11 +211,11 @@ void I_MenuLeftClear(void)
int32_t I_MenuRight(void) int32_t I_MenuRight(void)
{ {
return return
KB_KeyPressed(sc_RightArrow) inputState.GetKeyStatus(sc_RightArrow)
|| KB_KeyPressed(sc_kpad_6) || inputState.GetKeyStatus(sc_kpad_6)
|| (!inputState.ShiftPressed() && KB_KeyPressed(sc_Tab)) || (!inputState.ShiftPressed() && inputState.GetKeyStatus(sc_Tab))
|| BUTTON(gamefunc_Turn_Right) || inputState.BUTTON(gamefunc_Turn_Right)
|| BUTTON(gamefunc_Strafe_Right) || inputState.BUTTON(gamefunc_Strafe_Right)
|| (MOUSE_GetButtons()&MIDDLE_MOUSE) || (MOUSE_GetButtons()&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))
@ -225,9 +225,9 @@ int32_t I_MenuRight(void)
void I_MenuRightClear(void) void I_MenuRightClear(void)
{ {
KB_ClearKeyDown(sc_RightArrow); inputState.ClearKeyStatus(sc_RightArrow);
KB_ClearKeyDown(sc_kpad_6); inputState.ClearKeyStatus(sc_kpad_6);
KB_ClearKeyDown(sc_Tab); inputState.ClearKeyStatus(sc_Tab);
inputState.ClearButton(gamefunc_Turn_Right); inputState.ClearButton(gamefunc_Turn_Right);
inputState.ClearButton(gamefunc_Strafe_Right); inputState.ClearButton(gamefunc_Strafe_Right);
MOUSE_ClearButton(MIDDLE_MOUSE); MOUSE_ClearButton(MIDDLE_MOUSE);
@ -242,7 +242,7 @@ int32_t I_PanelUp(void)
return return
I_MenuUp() I_MenuUp()
|| I_MenuLeft() || I_MenuLeft()
|| KB_KeyPressed(sc_PgUp) || inputState.GetKeyStatus(sc_PgUp)
; ;
} }
@ -250,7 +250,7 @@ void I_PanelUpClear(void)
{ {
I_MenuUpClear(); I_MenuUpClear();
I_MenuLeftClear(); I_MenuLeftClear();
KB_ClearKeyDown(sc_PgUp); inputState.ClearKeyStatus(sc_PgUp);
} }
@ -259,7 +259,7 @@ int32_t I_PanelDown(void)
return return
I_MenuDown() I_MenuDown()
|| I_MenuRight() || I_MenuRight()
|| KB_KeyPressed(sc_PgDn) || inputState.GetKeyStatus(sc_PgDn)
|| I_AdvanceTrigger() || I_AdvanceTrigger()
; ;
} }
@ -268,7 +268,7 @@ void I_PanelDownClear(void)
{ {
I_MenuDownClear(); I_MenuDownClear();
I_MenuRightClear(); I_MenuRightClear();
KB_ClearKeyDown(sc_PgDn); inputState.ClearKeyStatus(sc_PgDn);
I_AdvanceTriggerClear(); I_AdvanceTriggerClear();
} }
@ -312,7 +312,7 @@ int32_t I_EnterText(char *t, int32_t maxlength, int32_t flags)
char ch; char ch;
int32_t inputloc = strlen(typebuf); int32_t inputloc = strlen(typebuf);
while ((ch = KB_GetCh()) != 0) while ((ch = inputState.keyGetChar()) != 0)
{ {
if (ch == asc_BackSpace) if (ch == asc_BackSpace)
{ {

View file

@ -1,44 +0,0 @@
/*
* keyboard.c
* MACT library -to- JonoF's Build Port Keyboard Glue
*
* by Jonathon Fowler
*
* Since we don't have the source to the MACT library I've had to
* concoct some magic to glue its idea of controllers into that of
* my Build port.
*
*/
//-------------------------------------------------------------------------
/*
Duke Nukem Copyright (C) 1996, 2003 3D Realms Entertainment
This file is part of Duke Nukem 3D version 1.5 - Atomic Edition
Duke Nukem 3D is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
//-------------------------------------------------------------------------
#include "compat.h"
#include "keyboard.h"
#include "control.h"
kb_scancode KB_LastScan;
void KB_Startup(void) { keySetCallback(KB_KeyEvent); }
void KB_Shutdown(void) { keySetCallback((void (*)(int32_t, int32_t))NULL); }

View file

@ -238,7 +238,7 @@ static void G_CheatGetInv(DukePlayer_t *pPlayer)
static void end_cheat(DukePlayer_t * const pPlayer) static void end_cheat(DukePlayer_t * const pPlayer)
{ {
pPlayer->cheat_phase = 0; pPlayer->cheat_phase = 0;
KB_FlushKeyboardQueue(); inputState.keyFlushChars();
} }
static int32_t cheatbuflen; static int32_t cheatbuflen;
@ -303,9 +303,9 @@ void G_DoCheats(void)
{ {
int ch; int ch;
while (KB_KeyWaiting()) while (inputState.keyBufferWaiting())
{ {
ch = Btolower(KB_GetCh()); ch = Btolower(inputState.keyGetChar());
if (!((ch >= 'a' && ch <= 'z') || (ch >= '0' && ch <= '9'))) if (!((ch >= 'a' && ch <= 'z') || (ch >= '0' && ch <= '9')))
{ {
@ -319,7 +319,7 @@ void G_DoCheats(void)
// cheat string matching logic below. // cheat string matching logic below.
Bassert(cheatbuflen < (signed)sizeof(cheatbuf)); Bassert(cheatbuflen < (signed)sizeof(cheatbuf));
cheatbuf[cheatbuflen] = 0; cheatbuf[cheatbuflen] = 0;
// KB_ClearKeysDown(); // inputState.ClearKeysDown();
for (cheatNum=0; cheatNum < NUMCHEATCODES; cheatNum++) for (cheatNum=0; cheatNum < NUMCHEATCODES; cheatNum++)
{ {
@ -415,7 +415,7 @@ void G_DoCheats(void)
if (RR) if (RR)
for (int key = 0; key < 5; key++) for (int key = 0; key < 5; key++)
pPlayer->keys[key] = 1; pPlayer->keys[key] = 1;
KB_FlushKeyboardQueue(); inputState.keyFlushChars();
P_DoQuote(QUOTE_CHEAT_ALL_KEYS, pPlayer); P_DoQuote(QUOTE_CHEAT_ALL_KEYS, pPlayer);
end_cheat(pPlayer); end_cheat(pPlayer);
return; return;
@ -441,7 +441,7 @@ void G_DoCheats(void)
if (RR) if (RR)
{ {
P_DoQuote(QUOTE_JETPACK_ON, pPlayer); P_DoQuote(QUOTE_JETPACK_ON, pPlayer);
KB_FlushKeyboardQueue(); inputState.keyFlushChars();
} }
else else
{ {
@ -454,7 +454,7 @@ void G_DoCheats(void)
case CHEAT_ALLEN: case CHEAT_ALLEN:
P_DoQuote(QUOTE_CHEAT_ALLEN, pPlayer); P_DoQuote(QUOTE_CHEAT_ALLEN, pPlayer);
pPlayer->cheat_phase = 0; pPlayer->cheat_phase = 0;
KB_ClearKeyDown(sc_N); inputState.ClearKeyStatus(sc_N);
return; return;
case CHEAT_CORNHOLIO: case CHEAT_CORNHOLIO:
@ -632,7 +632,7 @@ void G_DoCheats(void)
case CHEAT_CASHMAN: case CHEAT_CASHMAN:
ud.cashman = 1-ud.cashman; ud.cashman = 1-ud.cashman;
KB_ClearKeyDown(sc_N); inputState.ClearKeyStatus(sc_N);
pPlayer->cheat_phase = 0; pPlayer->cheat_phase = 0;
return; return;
@ -682,7 +682,7 @@ void G_DoCheats(void)
case CHEAT_BETA: case CHEAT_BETA:
P_DoQuote(QUOTE_CHEAT_BETA, pPlayer); P_DoQuote(QUOTE_CHEAT_BETA, pPlayer);
KB_ClearKeyDown(sc_H); inputState.ClearKeyStatus(sc_H);
end_cheat(pPlayer); end_cheat(pPlayer);
return; return;
@ -721,7 +721,7 @@ void G_DoCheats(void)
pPlayer->player_par = 0; pPlayer->player_par = 0;
pPlayer->gm |= MODE_EOL; pPlayer->gm |= MODE_EOL;
} }
KB_FlushKeyboardQueue(); inputState.keyFlushChars();
return; return;
case CHEAT_RAJOSEPH: case CHEAT_RAJOSEPH:
@ -729,25 +729,25 @@ void G_DoCheats(void)
pPlayer->ammo_amount[MOTORCYCLE_WEAPON] = pPlayer->max_ammo_amount[MOTORCYCLE_WEAPON]; pPlayer->ammo_amount[MOTORCYCLE_WEAPON] = pPlayer->max_ammo_amount[MOTORCYCLE_WEAPON];
P_DoQuote(126, pPlayer); P_DoQuote(126, pPlayer);
end_cheat(pPlayer); end_cheat(pPlayer);
KB_FlushKeyboardQueue(); inputState.keyFlushChars();
return; return;
case CHEAT_RAMRBILL: case CHEAT_RAMRBILL:
P_QuickKill(pPlayer); P_QuickKill(pPlayer);
P_DoQuote(127, pPlayer); P_DoQuote(127, pPlayer);
end_cheat(pPlayer); end_cheat(pPlayer);
KB_FlushKeyboardQueue(); inputState.keyFlushChars();
return; return;
case CHEAT_RAGARY: case CHEAT_RAGARY:
S_PlayRRMusic(10); S_PlayRRMusic(10);
end_cheat(pPlayer); end_cheat(pPlayer);
KB_FlushKeyboardQueue(); inputState.keyFlushChars();
return; return;
case CHEAT_RANOAH: case CHEAT_RANOAH:
end_cheat(pPlayer); end_cheat(pPlayer);
KB_FlushKeyboardQueue(); inputState.keyFlushChars();
return; return;
case CHEAT_RARHETT: case CHEAT_RARHETT:
@ -758,33 +758,33 @@ void G_DoCheats(void)
sprite[pPlayer->i].extra = 1; sprite[pPlayer->i].extra = 1;
P_DoQuote(128, pPlayer); P_DoQuote(128, pPlayer);
end_cheat(pPlayer); end_cheat(pPlayer);
KB_FlushKeyboardQueue(); inputState.keyFlushChars();
return; return;
case CHEAT_RAAARON: case CHEAT_RAAARON:
pPlayer->drug_mode = pPlayer->drug_mode ? 0 : 5; pPlayer->drug_mode = pPlayer->drug_mode ? 0 : 5;
pPlayer->drug_timer = (int32_t) totalclock; pPlayer->drug_timer = (int32_t) totalclock;
end_cheat(pPlayer); end_cheat(pPlayer);
KB_FlushKeyboardQueue(); inputState.keyFlushChars();
return; return;
case CHEAT_RANOCHEAT: case CHEAT_RANOCHEAT:
pPlayer->nocheat = 1; pPlayer->nocheat = 1;
P_DoQuote(130, pPlayer); P_DoQuote(130, pPlayer);
end_cheat(pPlayer); end_cheat(pPlayer);
KB_FlushKeyboardQueue(); inputState.keyFlushChars();
return; return;
case CHEAT_RATONY: case CHEAT_RATONY:
g_changeEnemySize = 2; g_changeEnemySize = 2;
end_cheat(pPlayer); end_cheat(pPlayer);
KB_FlushKeyboardQueue(); inputState.keyFlushChars();
return; return;
case CHEAT_RAVAN: case CHEAT_RAVAN:
g_changeEnemySize = 3; g_changeEnemySize = 3;
end_cheat(pPlayer); end_cheat(pPlayer);
KB_FlushKeyboardQueue(); inputState.keyFlushChars();
return; return;
case CHEAT_RAKFC: case CHEAT_RAKFC:
@ -797,7 +797,7 @@ void G_DoCheats(void)
} }
P_DoQuote(139, pPlayer); P_DoQuote(139, pPlayer);
end_cheat(pPlayer); end_cheat(pPlayer);
KB_FlushKeyboardQueue(); inputState.keyFlushChars();
return; return;
case CHEAT_RAWOLESLAGLE: case CHEAT_RAWOLESLAGLE:
@ -812,7 +812,7 @@ void G_DoCheats(void)
P_DoQuote(131, pPlayer); P_DoQuote(131, pPlayer);
} }
end_cheat(pPlayer); end_cheat(pPlayer);
KB_FlushKeyboardQueue(); inputState.keyFlushChars();
return; return;
case CHEAT_RAMIKAEL: case CHEAT_RAMIKAEL:
@ -830,7 +830,7 @@ void G_DoCheats(void)
pPlayer->keys[key] = 1; pPlayer->keys[key] = 1;
P_DoQuote(5, pPlayer); P_DoQuote(5, pPlayer);
end_cheat(pPlayer); end_cheat(pPlayer);
KB_FlushKeyboardQueue(); inputState.keyFlushChars();
return; return;
case CHEAT_RAGREG: case CHEAT_RAGREG:
@ -845,7 +845,7 @@ void G_DoCheats(void)
P_DoQuote(137, pPlayer); P_DoQuote(137, pPlayer);
} }
end_cheat(pPlayer); end_cheat(pPlayer);
KB_FlushKeyboardQueue(); inputState.keyFlushChars();
return; return;
case CHEAT_RAARIJIT: case CHEAT_RAARIJIT:
@ -854,7 +854,7 @@ void G_DoCheats(void)
pPlayer->ammo_amount[BOAT_WEAPON] = pPlayer->max_ammo_amount[BOAT_WEAPON]; pPlayer->ammo_amount[BOAT_WEAPON] = pPlayer->max_ammo_amount[BOAT_WEAPON];
P_DoQuote(136, pPlayer); P_DoQuote(136, pPlayer);
end_cheat(pPlayer); end_cheat(pPlayer);
KB_FlushKeyboardQueue(); inputState.keyFlushChars();
return; return;
default: default:
@ -866,17 +866,17 @@ void G_DoCheats(void)
} }
else else
{ {
if (KB_KeyPressed((uint8_t) CheatKeys[0])) if (inputState.GetKeyStatus((uint8_t) CheatKeys[0]))
{ {
if (pPlayer->cheat_phase >= 0 && numplayers < 2 && ud.recstat == 0) if (pPlayer->cheat_phase >= 0 && numplayers < 2 && ud.recstat == 0)
{ {
if (CheatKeys[0] == CheatKeys[1]) if (CheatKeys[0] == CheatKeys[1])
KB_ClearKeyDown((uint8_t) CheatKeys[0]); inputState.ClearKeyStatus((uint8_t) CheatKeys[0]);
pPlayer->cheat_phase = -1; pPlayer->cheat_phase = -1;
} }
} }
if (KB_KeyPressed((uint8_t) CheatKeys[1])) if (inputState.GetKeyStatus((uint8_t) CheatKeys[1]))
{ {
if (pPlayer->cheat_phase == -1) if (pPlayer->cheat_phase == -1)
{ {
@ -891,13 +891,13 @@ void G_DoCheats(void)
// P_DoQuote(QUOTE_25,pPlayer); // P_DoQuote(QUOTE_25,pPlayer);
cheatbuflen = 0; cheatbuflen = 0;
} }
KB_FlushKeyboardQueue(); inputState.keyFlushChars();
} }
else if (pPlayer->cheat_phase != 0) else if (pPlayer->cheat_phase != 0)
{ {
pPlayer->cheat_phase = 0; pPlayer->cheat_phase = 0;
KB_ClearKeyDown((uint8_t) CheatKeys[0]); inputState.ClearKeyStatus((uint8_t) CheatKeys[0]);
KB_ClearKeyDown((uint8_t) CheatKeys[1]); inputState.ClearKeyStatus((uint8_t) CheatKeys[1]);
} }
} }
} }

View file

@ -915,9 +915,9 @@ nextdemo_nomenu:
{ {
ControlInfo noshareinfo; ControlInfo noshareinfo;
CONTROL_GetInput(&noshareinfo); CONTROL_GetInput(&noshareinfo);
if (BUTTON(gamefunc_SendMessage)) if (inputState.BUTTON(gamefunc_SendMessage))
{ {
KB_FlushKeyboardQueue(); inputState.keyFlushChars();
inputState.ClearButton(gamefunc_SendMessage); inputState.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

@ -170,7 +170,7 @@ void G_HandleSpecialKeys(void)
// CONTROL_ProcessBinds(); // CONTROL_ProcessBinds();
if (/*g_networkMode != NET_DEDICATED_SERVER && */ALT_IS_PRESSED && KB_KeyPressed(sc_Enter)) if (/*g_networkMode != NET_DEDICATED_SERVER && */ALT_IS_PRESSED && inputState.GetKeyStatus(sc_Enter))
{ {
if (videoSetGameMode(!ScreenMode,ScreenWidth,ScreenHeight,ScreenBPP,ud.detail)) if (videoSetGameMode(!ScreenMode,ScreenWidth,ScreenHeight,ScreenBPP,ud.detail))
{ {
@ -179,14 +179,14 @@ void G_HandleSpecialKeys(void)
G_GameExit("Failed to recover from failure to set fullscreen video mode.\n"); G_GameExit("Failed to recover from failure to set fullscreen video mode.\n");
} }
else ScreenMode = !ScreenMode; else ScreenMode = !ScreenMode;
KB_ClearKeyDown(sc_Enter); inputState.ClearKeyStatus(sc_Enter);
g_restorePalette = 1; g_restorePalette = 1;
G_UpdateScreenArea(); G_UpdateScreenArea();
} }
if (KB_UnBoundKeyPressed(sc_F12)) if (inputState.UnboundKeyPressed(sc_F12))
{ {
KB_ClearKeyDown(sc_F12); inputState.ClearKeyStatus(sc_F12);
videoCaptureScreen(); videoCaptureScreen();
P_DoQuote(QUOTE_SCREEN_SAVED, g_player[myconnectindex].ps); P_DoQuote(QUOTE_SCREEN_SAVED, g_player[myconnectindex].ps);
} }
@ -195,7 +195,7 @@ void G_HandleSpecialKeys(void)
if (!(g_player[myconnectindex].ps->gm & MODE_GAME)) if (!(g_player[myconnectindex].ps->gm & MODE_GAME))
OSD_DispatchQueued(); OSD_DispatchQueued();
if (g_quickExit == 0 && KB_KeyPressed(sc_LeftControl) && KB_KeyPressed(sc_LeftAlt) && (KB_KeyPressed(sc_Delete)||KB_KeyPressed(sc_End))) if (g_quickExit == 0 && inputState.GetKeyStatus(sc_LeftControl) && inputState.GetKeyStatus(sc_LeftAlt) && (inputState.GetKeyStatus(sc_Delete)||inputState.GetKeyStatus(sc_End)))
{ {
g_quickExit = 1; g_quickExit = 1;
G_GameExit("Quick Exit."); G_GameExit("Quick Exit.");
@ -6034,18 +6034,18 @@ void G_HandleLocalKeys(void)
if (g_player[myconnectindex].gotvote == 0 && voting != -1 && voting != myconnectindex) if (g_player[myconnectindex].gotvote == 0 && voting != -1 && voting != myconnectindex)
{ {
if (KB_UnBoundKeyPressed(sc_F1) || KB_UnBoundKeyPressed(sc_F2) || cl_autovote) if (inputState.UnboundKeyPressed(sc_F1) || inputState.UnboundKeyPressed(sc_F2) || cl_autovote)
{ {
G_AddUserQuote("Vote Cast"); G_AddUserQuote("Vote Cast");
Net_SendMapVote(KB_UnBoundKeyPressed(sc_F1) || cl_autovote ? cl_autovote-1 : 0); Net_SendMapVote(inputState.UnboundKeyPressed(sc_F1) || cl_autovote ? cl_autovote-1 : 0);
KB_ClearKeyDown(sc_F1); inputState.ClearKeyStatus(sc_F1);
KB_ClearKeyDown(sc_F2); inputState.ClearKeyStatus(sc_F2);
} }
} }
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 (BUTTON(gamefunc_Enlarge_Screen)) if (inputState.BUTTON(gamefunc_Enlarge_Screen))
{ {
inputState.ClearButton(gamefunc_Enlarge_Screen); inputState.ClearButton(gamefunc_Enlarge_Screen);
@ -6064,7 +6064,7 @@ void G_HandleLocalKeys(void)
G_UpdateScreenArea(); G_UpdateScreenArea();
} }
if (BUTTON(gamefunc_Shrink_Screen)) if (inputState.BUTTON(gamefunc_Shrink_Screen))
{ {
inputState.ClearButton(gamefunc_Shrink_Screen); inputState.ClearButton(gamefunc_Shrink_Screen);
@ -6087,7 +6087,7 @@ 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 (BUTTON(gamefunc_See_Coop_View) && (GTFLAGS(GAMETYPE_COOPVIEW) || ud.recstat == 2)) if (inputState.BUTTON(gamefunc_See_Coop_View) && (GTFLAGS(GAMETYPE_COOPVIEW) || ud.recstat == 2))
{ {
inputState.ClearButton(gamefunc_See_Coop_View); inputState.ClearButton(gamefunc_See_Coop_View);
screenpeek = connectpoint2[screenpeek]; screenpeek = connectpoint2[screenpeek];
@ -6095,21 +6095,21 @@ void G_HandleLocalKeys(void)
g_restorePalette = -1; g_restorePalette = -1;
} }
if ((g_netServer || ud.multimode > 1) && BUTTON(gamefunc_Show_Opponents_Weapon)) if ((g_netServer || ud.multimode > 1) && inputState.BUTTON(gamefunc_Show_Opponents_Weapon))
{ {
inputState.ClearButton(gamefunc_Show_Opponents_Weapon); inputState.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 (BUTTON(gamefunc_Toggle_Crosshair)) if (inputState.BUTTON(gamefunc_Toggle_Crosshair))
{ {
inputState.ClearButton(gamefunc_Toggle_Crosshair); inputState.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 && BUTTON(gamefunc_Map_Follow_Mode)) if (ud.overhead_on && inputState.BUTTON(gamefunc_Map_Follow_Mode))
{ {
inputState.ClearButton(gamefunc_Map_Follow_Mode); inputState.ClearButton(gamefunc_Map_Follow_Mode);
ud.scrollmode = 1-ud.scrollmode; ud.scrollmode = 1-ud.scrollmode;
@ -6122,9 +6122,9 @@ void G_HandleLocalKeys(void)
P_DoQuote(QUOTE_MAP_FOLLOW_OFF+ud.scrollmode,g_player[myconnectindex].ps); P_DoQuote(QUOTE_MAP_FOLLOW_OFF+ud.scrollmode,g_player[myconnectindex].ps);
} }
if (KB_UnBoundKeyPressed(sc_ScrollLock)) if (inputState.UnboundKeyPressed(sc_ScrollLock))
{ {
KB_ClearKeyDown(sc_ScrollLock); inputState.ClearKeyStatus(sc_ScrollLock);
switch (ud.recstat) switch (ud.recstat)
{ {
@ -6140,9 +6140,9 @@ void G_HandleLocalKeys(void)
if (ud.recstat == 2) if (ud.recstat == 2)
{ {
if (KB_KeyPressed(sc_Space)) if (inputState.GetKeyStatus(sc_Space))
{ {
KB_ClearKeyDown(sc_Space); inputState.ClearKeyStatus(sc_Space);
g_demo_paused = !g_demo_paused; g_demo_paused = !g_demo_paused;
g_demo_rewind = 0; g_demo_rewind = 0;
@ -6151,18 +6151,18 @@ void G_HandleLocalKeys(void)
FX_StopAllSounds(); FX_StopAllSounds();
} }
if (KB_KeyPressed(sc_Tab)) if (inputState.GetKeyStatus(sc_Tab))
{ {
KB_ClearKeyDown(sc_Tab); inputState.ClearKeyStatus(sc_Tab);
g_demo_showStats = !g_demo_showStats; g_demo_showStats = !g_demo_showStats;
} }
#if 0 #if 0
if (KB_KeyPressed(sc_kpad_Plus)) if (inputState.GetKeyStatus(sc_kpad_Plus))
{ {
G_InitTimer(240); G_InitTimer(240);
} }
else if (KB_KeyPressed(sc_kpad_Minus)) else if (inputState.GetKeyStatus(sc_kpad_Minus))
{ {
G_InitTimer(60); G_InitTimer(60);
} }
@ -6172,9 +6172,9 @@ void G_HandleLocalKeys(void)
} }
#endif #endif
if (KB_KeyPressed(sc_kpad_6)) if (inputState.GetKeyStatus(sc_kpad_6))
{ {
KB_ClearKeyDown(sc_kpad_6); inputState.ClearKeyStatus(sc_kpad_6);
int const fwdTics = (15 << (int)ALT_IS_PRESSED) << (2 * (int)SHIFTS_IS_PRESSED); int const fwdTics = (15 << (int)ALT_IS_PRESSED) << (2 * (int)SHIFTS_IS_PRESSED);
g_demo_goalCnt = g_demo_paused ? g_demo_cnt + 1 : g_demo_cnt + REALGAMETICSPERSEC * fwdTics; g_demo_goalCnt = g_demo_paused ? g_demo_cnt + 1 : g_demo_cnt + REALGAMETICSPERSEC * fwdTics;
@ -6185,9 +6185,9 @@ void G_HandleLocalKeys(void)
else else
Demo_PrepareWarp(); Demo_PrepareWarp();
} }
else if (KB_KeyPressed(sc_kpad_4)) else if (inputState.GetKeyStatus(sc_kpad_4))
{ {
KB_ClearKeyDown(sc_kpad_4); inputState.ClearKeyStatus(sc_kpad_4);
int const rewindTics = (15 << (int)ALT_IS_PRESSED) << (2 * (int)SHIFTS_IS_PRESSED); int const rewindTics = (15 << (int)ALT_IS_PRESSED) << (2 * (int)SHIFTS_IS_PRESSED);
g_demo_goalCnt = g_demo_paused ? g_demo_cnt - 1 : g_demo_cnt - REALGAMETICSPERSEC * rewindTics; g_demo_goalCnt = g_demo_paused ? g_demo_cnt - 1 : g_demo_cnt - REALGAMETICSPERSEC * rewindTics;
@ -6206,9 +6206,9 @@ void G_HandleLocalKeys(void)
// NOTE: sc_F1 .. sc_F10 are contiguous. sc_F11 is not sc_F10+1. // NOTE: sc_F1 .. sc_F10 are contiguous. sc_F11 is not sc_F10+1.
for (bssize_t j=sc_F1; j<=sc_F10; j++) for (bssize_t j=sc_F1; j<=sc_F10; j++)
if (KB_UnBoundKeyPressed(j)) if (inputState.UnboundKeyPressed(j))
{ {
KB_ClearKeyDown(j); inputState.ClearKeyStatus(j);
ridiculeNum = j - sc_F1 + 1; ridiculeNum = j - sc_F1 + 1;
break; break;
} }
@ -6257,17 +6257,17 @@ 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) && BUTTON(gamefunc_SendMessage)) if ((g_netServer || ud.multimode > 1) && inputState.BUTTON(gamefunc_SendMessage))
{ {
KB_FlushKeyboardQueue(); inputState.keyFlushChars();
inputState.ClearButton(gamefunc_SendMessage); inputState.ClearButton(gamefunc_SendMessage);
g_player[myconnectindex].ps->gm |= MODE_TYPE; g_player[myconnectindex].ps->gm |= MODE_TYPE;
typebuf[0] = 0; typebuf[0] = 0;
} }
if (KB_UnBoundKeyPressed(sc_F1)/* || (ud.show_help && I_AdvanceTrigger())*/) if (inputState.UnboundKeyPressed(sc_F1)/* || (ud.show_help && I_AdvanceTrigger())*/)
{ {
KB_ClearKeyDown(sc_F1); inputState.ClearKeyStatus(sc_F1);
Menu_Change(MENU_STORY); Menu_Change(MENU_STORY);
S_PauseSounds(true); S_PauseSounds(true);
@ -6283,9 +6283,9 @@ void G_HandleLocalKeys(void)
// if((!net_server && ud.multimode < 2)) // if((!net_server && ud.multimode < 2))
{ {
if (ud.recstat != 2 && (!RRRA || ud.player_skill != 4) && (!RR || RRRA || ud.player_skill != 5) && KB_UnBoundKeyPressed(sc_F2)) if (ud.recstat != 2 && (!RRRA || ud.player_skill != 4) && (!RR || RRRA || ud.player_skill != 5) && inputState.UnboundKeyPressed(sc_F2))
{ {
KB_ClearKeyDown(sc_F2); inputState.ClearKeyStatus(sc_F2);
FAKE_F2: FAKE_F2:
if (sprite[g_player[myconnectindex].ps->i].extra <= 0) if (sprite[g_player[myconnectindex].ps->i].extra <= 0)
@ -6307,9 +6307,9 @@ FAKE_F2:
} }
} }
if ((!RRRA || ud.player_skill != 4) && (!RR || RRRA || ud.player_skill != 5) && KB_UnBoundKeyPressed(sc_F3)) if ((!RRRA || ud.player_skill != 4) && (!RR || RRRA || ud.player_skill != 5) && inputState.UnboundKeyPressed(sc_F3))
{ {
KB_ClearKeyDown(sc_F3); inputState.ClearKeyStatus(sc_F3);
FAKE_F3: FAKE_F3:
Menu_Change(MENU_LOAD); Menu_Change(MENU_LOAD);
@ -6326,9 +6326,9 @@ FAKE_F3:
} }
} }
if (KB_UnBoundKeyPressed(sc_F4)) if (inputState.UnboundKeyPressed(sc_F4))
{ {
KB_ClearKeyDown(sc_F4); inputState.ClearKeyStatus(sc_F4);
S_PauseSounds(true); S_PauseSounds(true);
Menu_Open(myconnectindex); Menu_Open(myconnectindex);
@ -6342,12 +6342,12 @@ FAKE_F3:
Menu_Change(MENU_SOUND_INGAME); Menu_Change(MENU_SOUND_INGAME);
} }
if (KB_UnBoundKeyPressed(sc_F5) && MusicEnabled()) if (inputState.UnboundKeyPressed(sc_F5) && MusicEnabled())
{ {
map_t *const pMapInfo = &g_mapInfo[g_musicIndex]; map_t *const pMapInfo = &g_mapInfo[g_musicIndex];
char *const musicString = apStrings[QUOTE_MUSIC]; char *const musicString = apStrings[QUOTE_MUSIC];
KB_ClearKeyDown(sc_F5); inputState.ClearKeyStatus(sc_F5);
if (pMapInfo->musicfn != NULL) if (pMapInfo->musicfn != NULL)
Bsnprintf(musicString, MAXQUOTELEN, "%s. Use SHIFT-F5 to change.", pMapInfo->musicfn); Bsnprintf(musicString, MAXQUOTELEN, "%s. Use SHIFT-F5 to change.", pMapInfo->musicfn);
@ -6357,7 +6357,7 @@ FAKE_F3:
P_DoQuote(QUOTE_MUSIC, g_player[myconnectindex].ps); P_DoQuote(QUOTE_MUSIC, g_player[myconnectindex].ps);
} }
if ((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 ((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))
{ {
inputState.ClearButton(gamefunc_Quick_Save); inputState.ClearButton(gamefunc_Quick_Save);
@ -6366,7 +6366,7 @@ FAKE_F3:
if (!g_lastusersave.isValid()) if (!g_lastusersave.isValid())
goto FAKE_F2; goto FAKE_F2;
KB_FlushKeyboardQueue(); inputState.keyFlushChars();
if (sprite[g_player[myconnectindex].ps->i].extra <= 0) if (sprite[g_player[myconnectindex].ps->i].extra <= 0)
{ {
@ -6394,7 +6394,7 @@ FAKE_F3:
} }
} }
if (BUTTON(gamefunc_Third_Person_View)) if (inputState.BUTTON(gamefunc_Third_Person_View))
{ {
inputState.ClearButton(gamefunc_Third_Person_View); inputState.ClearButton(gamefunc_Third_Person_View);
@ -6409,9 +6409,9 @@ FAKE_F3:
} }
} }
if (KB_UnBoundKeyPressed(sc_F8)) if (inputState.UnboundKeyPressed(sc_F8))
{ {
KB_ClearKeyDown(sc_F8); inputState.ClearKeyStatus(sc_F8);
int const fta = !ud.fta_on; int const fta = !ud.fta_on;
ud.fta_on = 1; ud.fta_on = 1;
@ -6419,7 +6419,7 @@ FAKE_F3:
ud.fta_on = fta; ud.fta_on = fta;
} }
if ((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 ((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))
{ {
inputState.ClearButton(gamefunc_Quick_Load); inputState.ClearButton(gamefunc_Quick_Load);
@ -6429,17 +6429,17 @@ FAKE_F3:
goto FAKE_F3; goto FAKE_F3;
else if (g_quickload->isValid()) else if (g_quickload->isValid())
{ {
KB_FlushKeyboardQueue(); inputState.keyFlushChars();
KB_ClearKeysDown(); inputState.ClearKeysDown();
S_PauseSounds(true); S_PauseSounds(true);
if (G_LoadPlayerMaybeMulti(*g_quickload) != 0) if (G_LoadPlayerMaybeMulti(*g_quickload) != 0)
g_quickload->reset(); g_quickload->reset();
} }
} }
if (KB_UnBoundKeyPressed(sc_F10)) if (inputState.UnboundKeyPressed(sc_F10))
{ {
KB_ClearKeyDown(sc_F10); inputState.ClearKeyStatus(sc_F10);
Menu_Change(MENU_QUIT_INGAME); Menu_Change(MENU_QUIT_INGAME);
S_PauseSounds(true); S_PauseSounds(true);
@ -6452,9 +6452,9 @@ FAKE_F3:
} }
} }
if (KB_UnBoundKeyPressed(sc_F11)) if (inputState.UnboundKeyPressed(sc_F11))
{ {
KB_ClearKeyDown(sc_F11); inputState.ClearKeyStatus(sc_F11);
Menu_Change(MENU_COLCORR_INGAME); Menu_Change(MENU_COLCORR_INGAME);
S_PauseSounds(true); S_PauseSounds(true);
@ -6472,10 +6472,10 @@ FAKE_F3:
int const timerOffset = ((int) totalclock - nonsharedtimer); int const timerOffset = ((int) totalclock - nonsharedtimer);
nonsharedtimer += timerOffset; nonsharedtimer += timerOffset;
if (BUTTON(gamefunc_Enlarge_Screen)) if (inputState.BUTTON(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 (BUTTON(gamefunc_Shrink_Screen)) if (inputState.BUTTON(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,14 +6491,14 @@ FAKE_F3:
G_UpdateScreenArea(); G_UpdateScreenArea();
} }
if (BUTTON(gamefunc_AutoRun)) if (inputState.BUTTON(gamefunc_AutoRun))
{ {
inputState.ClearButton(gamefunc_AutoRun); inputState.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 (BUTTON(gamefunc_Map)) if (inputState.BUTTON(gamefunc_Map))
{ {
inputState.ClearButton(gamefunc_Map); inputState.ClearButton(gamefunc_Map);
if (ud.last_overhead != ud.overhead_on && ud.last_overhead) if (ud.last_overhead != ud.overhead_on && ud.last_overhead)
@ -7440,7 +7440,7 @@ void G_BackToMenu(void)
g_player[myconnectindex].ps->gm = 0; g_player[myconnectindex].ps->gm = 0;
Menu_Open(myconnectindex); Menu_Open(myconnectindex);
Menu_Change(MENU_MAIN); Menu_Change(MENU_MAIN);
KB_FlushKeyboardQueue(); inputState.keyFlushChars();
} }
static int G_EndOfLevel(void) static int G_EndOfLevel(void)
@ -8003,7 +8003,7 @@ MAIN_LOOP_RESTART:
// handle CON_SAVE and CON_SAVENN // handle CON_SAVE and CON_SAVENN
if (g_saveRequested) if (g_saveRequested)
{ {
KB_FlushKeyboardQueue(); inputState.keyFlushChars();
videoNextPage(); videoNextPage();
g_screenCapture = 1; g_screenCapture = 1;

View file

@ -1063,7 +1063,7 @@ static int32_t VM_ResetPlayer(int const playerNum, int32_t vmFlags)
if (g_quickload && g_quickload->isValid() && ud.recstat != 2) if (g_quickload && g_quickload->isValid() && ud.recstat != 2)
{ {
Menu_Open(playerNum); Menu_Open(playerNum);
KB_ClearKeyDown(sc_Space); inputState.ClearKeyStatus(sc_Space);
I_AdvanceTriggerClear(); I_AdvanceTriggerClear();
Menu_Change(MENU_RESETPLAYER); Menu_Change(MENU_RESETPLAYER);
} }

View file

@ -46,8 +46,8 @@ int32_t g_skillSoundVoice = -1;
static FORCE_INLINE void Menu_StartTextInput() static FORCE_INLINE void Menu_StartTextInput()
{ {
KB_FlushKeyboardQueue(); inputState.keyFlushChars();
KB_ClearKeysDown(); inputState.ClearKeysDown();
#if defined EDUKE32_TOUCH_DEVICES && defined SDL_MAJOR_VERSION && SDL_MAJOR_VERSION > 1 #if defined EDUKE32_TOUCH_DEVICES && defined SDL_MAJOR_VERSION && SDL_MAJOR_VERSION > 1
# if defined __ANDROID__ # if defined __ANDROID__
AndroidShowKeyboard(1); AndroidShowKeyboard(1);
@ -3237,26 +3237,26 @@ static void Menu_PreInput(MenuEntry_t *entry)
{ {
case MENU_KEYBOARDKEYS: case MENU_KEYBOARDKEYS:
if (KB_KeyPressed(sc_Delete)) if (inputState.GetKeyStatus(sc_Delete))
{ {
Bindings.UnbindACommand(CONFIG_FunctionNumToName(M_KEYBOARDKEYS.currentEntry)); Bindings.UnbindACommand(CONFIG_FunctionNumToName(M_KEYBOARDKEYS.currentEntry));
S_PlaySound(RR ? 335 : KICK_HIT); S_PlaySound(RR ? 335 : KICK_HIT);
KB_ClearKeyDown(sc_Delete); inputState.ClearKeyStatus(sc_Delete);
} }
break; break;
case MENU_LOAD: case MENU_LOAD:
if (KB_KeyPressed(sc_Delete)) if (inputState.GetKeyStatus(sc_Delete))
{ {
KB_ClearKeyDown(sc_Delete); inputState.ClearKeyStatus(sc_Delete);
if (M_LOAD.currentEntry < g_nummenusaves) if (M_LOAD.currentEntry < g_nummenusaves)
Menu_Change(MENU_LOADDELVERIFY); Menu_Change(MENU_LOADDELVERIFY);
} }
break; break;
case MENU_SAVE: case MENU_SAVE:
if (KB_KeyPressed(sc_Delete)) if (inputState.GetKeyStatus(sc_Delete))
{ {
KB_ClearKeyDown(sc_Delete); inputState.ClearKeyStatus(sc_Delete);
if (0 < M_SAVE.currentEntry && M_SAVE.currentEntry <= (int32_t)g_nummenusaves) if (0 < M_SAVE.currentEntry && M_SAVE.currentEntry <= (int32_t)g_nummenusaves)
Menu_Change(MENU_SAVEDELVERIFY); Menu_Change(MENU_SAVEDELVERIFY);
} }
@ -3292,13 +3292,13 @@ static int32_t Menu_PreCustom2ColScreen(MenuEntry_t *entry)
{ {
auto *column = (MenuCustom2Col_t*)entry->entry; auto *column = (MenuCustom2Col_t*)entry->entry;
int32_t sc = KB_GetLastScanCode(); int32_t sc = inputState.GetLastScanCode();
if (sc != sc_None) if (sc != sc_None)
{ {
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, CONFIG_FunctionNumToName(M_KEYBOARDKEYS.currentEntry));
KB_ClearKeyDown(sc); inputState.ClearKeyStatus(sc);
return -1; return -1;
} }
@ -3766,8 +3766,8 @@ static void Menu_Custom2ColScreen(/*MenuEntry_t *entry*/)
{ {
if (g_currentMenu == MENU_KEYBOARDKEYS) if (g_currentMenu == MENU_KEYBOARDKEYS)
{ {
KB_FlushKeyboardQueue(); inputState.keyFlushChars();
KB_ClearLastScanCode(); inputState.ClearLastScanCode();
} }
} }
@ -3936,8 +3936,8 @@ static void Menu_Verify(int32_t input)
switch (input) switch (input)
{ {
default: default:
KB_FlushKeyboardQueue(); inputState.keyFlushChars();
KB_ClearKeysDown(); inputState.ClearKeysDown();
FX_StopAllSounds(); FX_StopAllSounds();
if (G_LoadPlayerMaybeMulti(*g_quickload) == 0) if (G_LoadPlayerMaybeMulti(*g_quickload) == 0)
@ -3976,8 +3976,8 @@ static void Menu_Verify(int32_t input)
g_quickload = &g_lastusersave; g_quickload = &g_lastusersave;
} }
KB_FlushKeyboardQueue(); inputState.keyFlushChars();
KB_ClearKeysDown(); inputState.ClearKeysDown();
Menu_Change(MENU_CLOSE); Menu_Change(MENU_CLOSE);
@ -4183,7 +4183,7 @@ static void Menu_FileSelectInit(MenuFileSelect_t *object)
object->currentList = 1; object->currentList = 1;
#endif #endif
KB_FlushKeyboardQueue(); inputState.keyFlushChars();
} }
static void Menu_FileSelect(int32_t input) static void Menu_FileSelect(int32_t input)
@ -6794,29 +6794,29 @@ static void Menu_RunInput(Menu_t *cm)
S_PlaySound(RR ? 341 : PISTOL_BODYHIT); S_PlaySound(RR ? 341 : PISTOL_BODYHIT);
} }
else if (KB_KeyPressed(sc_Home)) else if (inputState.GetKeyStatus(sc_Home))
{ {
KB_ClearKeyDown(sc_Home); inputState.ClearKeyStatus(sc_Home);
Menu_RunInput_FileSelect_Movement(object, MM_Home); Menu_RunInput_FileSelect_Movement(object, MM_Home);
S_PlaySound(RR ? 335 : KICK_HIT); S_PlaySound(RR ? 335 : KICK_HIT);
} }
else if (KB_KeyPressed(sc_End)) else if (inputState.GetKeyStatus(sc_End))
{ {
KB_ClearKeyDown(sc_End); inputState.ClearKeyStatus(sc_End);
Menu_RunInput_FileSelect_Movement(object, MM_End); Menu_RunInput_FileSelect_Movement(object, MM_End);
S_PlaySound(RR ? 335 : KICK_HIT); S_PlaySound(RR ? 335 : KICK_HIT);
} }
else if (KB_KeyPressed(sc_PgUp)) else if (inputState.GetKeyStatus(sc_PgUp))
{ {
int32_t i; int32_t i;
CACHE1D_FIND_REC *seeker = object->findhigh[object->currentList]; CACHE1D_FIND_REC *seeker = object->findhigh[object->currentList];
KB_ClearKeyDown(sc_PgUp); inputState.ClearKeyStatus(sc_PgUp);
for (i = 0; i < 6; ++i) for (i = 0; i < 6; ++i)
{ {
@ -6833,13 +6833,13 @@ static void Menu_RunInput(Menu_t *cm)
S_PlaySound(RR ? 335 : KICK_HIT); S_PlaySound(RR ? 335 : KICK_HIT);
} }
} }
else if (KB_KeyPressed(sc_PgDn)) else if (inputState.GetKeyStatus(sc_PgDn))
{ {
int32_t i; int32_t i;
CACHE1D_FIND_REC *seeker = object->findhigh[object->currentList]; CACHE1D_FIND_REC *seeker = object->findhigh[object->currentList];
KB_ClearKeyDown(sc_PgDn); inputState.ClearKeyStatus(sc_PgDn);
for (i = 0; i < 6; ++i) for (i = 0; i < 6; ++i)
{ {
@ -6888,7 +6888,7 @@ static void Menu_RunInput(Menu_t *cm)
{ {
// JBF 20040208: seek to first name matching pressed character // JBF 20040208: seek to first name matching pressed character
char ch2, ch; char ch2, ch;
ch = KB_GetCh(); ch = inputState.keyGetChar();
if (ch > 0 && ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || (ch >= '0' && ch <= '9'))) if (ch > 0 && ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || (ch >= '0' && ch <= '9')))
{ {
CACHE1D_FIND_REC *seeker = object->findhigh[object->currentList]->usera; CACHE1D_FIND_REC *seeker = object->findhigh[object->currentList]->usera;
@ -6944,10 +6944,10 @@ static void Menu_RunInput(Menu_t *cm)
break; break;
case Verify: case Verify:
if (I_ReturnTrigger() || KB_KeyPressed(sc_N) || Menu_RunInput_MouseReturn()) if (I_ReturnTrigger() || inputState.GetKeyStatus(sc_N) || Menu_RunInput_MouseReturn())
{ {
I_ReturnTriggerClear(); I_ReturnTriggerClear();
KB_ClearKeyDown(sc_N); inputState.ClearKeyStatus(sc_N);
m_mousecaught = 1; m_mousecaught = 1;
Menu_Verify(0); Menu_Verify(0);
@ -6957,12 +6957,12 @@ static void Menu_RunInput(Menu_t *cm)
S_PlaySound(EXITMENUSOUND); S_PlaySound(EXITMENUSOUND);
} }
if (I_AdvanceTrigger() || KB_KeyPressed(sc_Y) || Menu_RunInput_MouseAdvance()) if (I_AdvanceTrigger() || inputState.GetKeyStatus(sc_Y) || Menu_RunInput_MouseAdvance())
{ {
auto *verify = (MenuVerify_t*)cm->object; auto *verify = (MenuVerify_t*)cm->object;
I_AdvanceTriggerClear(); I_AdvanceTriggerClear();
KB_ClearKeyDown(sc_Y); inputState.ClearKeyStatus(sc_Y);
m_mousecaught = 1; m_mousecaught = 1;
Menu_Verify(1); Menu_Verify(1);
@ -7038,9 +7038,9 @@ static void Menu_RunInput(Menu_t *cm)
S_PlayRRMusic(2+menu->currentEntry); S_PlayRRMusic(2+menu->currentEntry);
} }
} }
else if (KB_KeyPressed(sc_1)) else if (inputState.GetKeyStatus(sc_1))
{ {
KB_ClearKeyDown(sc_1); inputState.ClearKeyStatus(sc_1);
menu->currentEntry = 0; menu->currentEntry = 0;
S_PlaySound(RR ? 335 : KICK_HIT); S_PlaySound(RR ? 335 : KICK_HIT);
@ -7050,9 +7050,9 @@ static void Menu_RunInput(Menu_t *cm)
S_PlayRRMusic(2+menu->currentEntry); S_PlayRRMusic(2+menu->currentEntry);
} }
} }
else if (KB_KeyPressed(sc_2)) else if (inputState.GetKeyStatus(sc_2))
{ {
KB_ClearKeyDown(sc_2); inputState.ClearKeyStatus(sc_2);
menu->currentEntry = 1; menu->currentEntry = 1;
S_PlaySound(RR ? 335 : KICK_HIT); S_PlaySound(RR ? 335 : KICK_HIT);
@ -7062,9 +7062,9 @@ static void Menu_RunInput(Menu_t *cm)
S_PlayRRMusic(2+menu->currentEntry); S_PlayRRMusic(2+menu->currentEntry);
} }
} }
else if (KB_KeyPressed(sc_3)) else if (inputState.GetKeyStatus(sc_3))
{ {
KB_ClearKeyDown(sc_3); inputState.ClearKeyStatus(sc_3);
menu->currentEntry = 2; menu->currentEntry = 2;
S_PlaySound(RR ? 335 : KICK_HIT); S_PlaySound(RR ? 335 : KICK_HIT);
@ -7074,9 +7074,9 @@ static void Menu_RunInput(Menu_t *cm)
S_PlayRRMusic(2+menu->currentEntry); S_PlayRRMusic(2+menu->currentEntry);
} }
} }
else if (KB_KeyPressed(sc_4)) else if (inputState.GetKeyStatus(sc_4))
{ {
KB_ClearKeyDown(sc_4); inputState.ClearKeyStatus(sc_4);
menu->currentEntry = 3; menu->currentEntry = 3;
S_PlaySound(RR ? 335 : KICK_HIT); S_PlaySound(RR ? 335 : KICK_HIT);
@ -7086,9 +7086,9 @@ static void Menu_RunInput(Menu_t *cm)
S_PlayRRMusic(2+menu->currentEntry); S_PlayRRMusic(2+menu->currentEntry);
} }
} }
else if (KB_KeyPressed(sc_5)) else if (inputState.GetKeyStatus(sc_5))
{ {
KB_ClearKeyDown(sc_5); inputState.ClearKeyStatus(sc_5);
menu->currentEntry = 4; menu->currentEntry = 4;
S_PlaySound(RR ? 335 : KICK_HIT); S_PlaySound(RR ? 335 : KICK_HIT);
@ -7098,9 +7098,9 @@ static void Menu_RunInput(Menu_t *cm)
S_PlayRRMusic(2+menu->currentEntry); S_PlayRRMusic(2+menu->currentEntry);
} }
} }
else if (KB_KeyPressed(sc_6)) else if (inputState.GetKeyStatus(sc_6))
{ {
KB_ClearKeyDown(sc_6); inputState.ClearKeyStatus(sc_6);
menu->currentEntry = 5; menu->currentEntry = 5;
S_PlaySound(RR ? 335 : KICK_HIT); S_PlaySound(RR ? 335 : KICK_HIT);
@ -7110,9 +7110,9 @@ static void Menu_RunInput(Menu_t *cm)
S_PlayRRMusic(2+menu->currentEntry); S_PlayRRMusic(2+menu->currentEntry);
} }
} }
else if (KB_KeyPressed(sc_7)) else if (inputState.GetKeyStatus(sc_7))
{ {
KB_ClearKeyDown(sc_7); inputState.ClearKeyStatus(sc_7);
menu->currentEntry = 6; menu->currentEntry = 6;
S_PlaySound(RR ? 335 : KICK_HIT); S_PlaySound(RR ? 335 : KICK_HIT);
@ -7122,9 +7122,9 @@ static void Menu_RunInput(Menu_t *cm)
S_PlayRRMusic(2+menu->currentEntry); S_PlayRRMusic(2+menu->currentEntry);
} }
} }
else if (KB_KeyPressed(sc_8)) else if (inputState.GetKeyStatus(sc_8))
{ {
KB_ClearKeyDown(sc_8); inputState.ClearKeyStatus(sc_8);
menu->currentEntry = 7; menu->currentEntry = 7;
S_PlaySound(RR ? 335 : KICK_HIT); S_PlaySound(RR ? 335 : KICK_HIT);
@ -7334,17 +7334,17 @@ static void Menu_RunInput(Menu_t *cm)
Menu_AnimateChange(cm->parentID, cm->parentAnimation); Menu_AnimateChange(cm->parentID, cm->parentAnimation);
} }
else if (KB_KeyPressed(sc_Home)) else if (inputState.GetKeyStatus(sc_Home))
{ {
KB_ClearKeyDown(sc_Home); inputState.ClearKeyStatus(sc_Home);
S_PlaySound(RR ? 335 : KICK_HIT); S_PlaySound(RR ? 335 : KICK_HIT);
currentry = Menu_RunInput_Menu_Movement(menu, MM_Home); currentry = Menu_RunInput_Menu_Movement(menu, MM_Home);
} }
else if (KB_KeyPressed(sc_End)) else if (inputState.GetKeyStatus(sc_End))
{ {
KB_ClearKeyDown(sc_End); inputState.ClearKeyStatus(sc_End);
S_PlaySound(RR ? 335 : KICK_HIT); S_PlaySound(RR ? 335 : KICK_HIT);
@ -7416,17 +7416,17 @@ static void Menu_RunInput(Menu_t *cm)
if (!Menu_RunInput_EntryOptionList_Activate(currentry, object)) if (!Menu_RunInput_EntryOptionList_Activate(currentry, object))
S_PlaySound(RR ? 341 : PISTOL_BODYHIT); S_PlaySound(RR ? 341 : PISTOL_BODYHIT);
} }
else if (KB_KeyPressed(sc_Home)) else if (inputState.GetKeyStatus(sc_Home))
{ {
KB_ClearKeyDown(sc_Home); inputState.ClearKeyStatus(sc_Home);
S_PlaySound(RR ? 335 : KICK_HIT); S_PlaySound(RR ? 335 : KICK_HIT);
Menu_RunInput_EntryOptionList_Movement(object, MM_Home); Menu_RunInput_EntryOptionList_Movement(object, MM_Home);
} }
else if (KB_KeyPressed(sc_End)) else if (inputState.GetKeyStatus(sc_End))
{ {
KB_ClearKeyDown(sc_End); inputState.ClearKeyStatus(sc_End);
S_PlaySound(RR ? 335 : KICK_HIT); S_PlaySound(RR ? 335 : KICK_HIT);
@ -7482,7 +7482,7 @@ void M_DisplayMenus(void)
return; return;
} }
if (!Menu_IsTextInput(m_currentMenu) && KB_KeyPressed(sc_Q)) if (!Menu_IsTextInput(m_currentMenu) && inputState.GetKeyStatus(sc_Q))
Menu_AnimateChange(MENU_QUIT, MA_Advance); Menu_AnimateChange(MENU_QUIT, MA_Advance);
int32_t mousestatus = mouseReadAbs(&m_mousepos, &g_mouseAbs); int32_t mousestatus = mouseReadAbs(&m_mousepos, &g_mouseAbs);

View file

@ -3644,9 +3644,9 @@ void Net_SendMessage(void)
mpgametext(mpgametext_x, ud.screen_size > 0 ? (200-45)<<16 : (200-8)<<16, typebuf, 0, 0, 0, 0); mpgametext(mpgametext_x, ud.screen_size > 0 ? (200-45)<<16 : (200-8)<<16, typebuf, 0, 0, 0, 0);
if (KB_KeyWaiting()) if (inputState.keyBufferWaiting())
{ {
i = KB_GetCh(); i = inputState.keyGetChar();
if (i == 'A' || i == 'a' || i == 13) if (i == 'A' || i == 'a' || i == 13)
g_chatPlayer = ud.multimode; g_chatPlayer = ud.multimode;
@ -3664,17 +3664,17 @@ void Net_SendMessage(void)
typebuf[0] = 0; typebuf[0] = 0;
} }
KB_ClearKeyDown(sc_1); inputState.ClearKeyStatus(sc_1);
KB_ClearKeyDown(sc_2); inputState.ClearKeyStatus(sc_2);
KB_ClearKeyDown(sc_3); inputState.ClearKeyStatus(sc_3);
KB_ClearKeyDown(sc_4); inputState.ClearKeyStatus(sc_4);
KB_ClearKeyDown(sc_5); inputState.ClearKeyStatus(sc_5);
KB_ClearKeyDown(sc_6); inputState.ClearKeyStatus(sc_6);
KB_ClearKeyDown(sc_7); inputState.ClearKeyStatus(sc_7);
KB_ClearKeyDown(sc_8); inputState.ClearKeyStatus(sc_8);
KB_ClearKeyDown(sc_A); inputState.ClearKeyStatus(sc_A);
KB_ClearKeyDown(sc_Escape); inputState.ClearKeyStatus(sc_Escape);
KB_ClearKeyDown(sc_Enter); inputState.ClearKeyStatus(sc_Enter);
} }
} }
} }
@ -3695,7 +3695,7 @@ void Net_SendMessage(void)
if (hitstate == 1) if (hitstate == 1)
{ {
KB_ClearKeyDown(sc_Enter); inputState.ClearKeyStatus(sc_Enter);
if (Bstrlen(typebuf) == 0) if (Bstrlen(typebuf) == 0)
{ {
g_player[myconnectindex].ps->gm &= ~(MODE_TYPE|MODE_SENDTOWHOM); g_player[myconnectindex].ps->gm &= ~(MODE_TYPE|MODE_SENDTOWHOM);

View file

@ -2743,7 +2743,7 @@ void P_GetInput(int playerNum)
auto const pPlayer = g_player[playerNum].ps; auto const pPlayer = g_player[playerNum].ps;
ControlInfo info; ControlInfo info;
if ((pPlayer->gm & (MODE_MENU|MODE_TYPE)) || (ud.pause_on && !KB_KeyPressed(sc_Pause))) if ((pPlayer->gm & (MODE_MENU|MODE_TYPE)) || (ud.pause_on && !inputState.GetKeyStatus(sc_Pause)))
{ {
if (!(pPlayer->gm&MODE_MENU)) if (!(pPlayer->gm&MODE_MENU))
CONTROL_GetInput(&info); CONTROL_GetInput(&info);
@ -2759,11 +2759,11 @@ void P_GetInput(int playerNum)
D_ProcessEvents(); D_ProcessEvents();
if (in_aimmode) if (in_aimmode)
g_MyAimMode = BUTTON(gamefunc_Mouse_Aiming); g_MyAimMode = inputState.BUTTON(gamefunc_Mouse_Aiming);
else else
{ {
g_oldAimStat = g_myAimStat; g_oldAimStat = g_myAimStat;
g_myAimStat = BUTTON(gamefunc_Mouse_Aiming); g_myAimStat = inputState.BUTTON(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(BUTTON(gamefunc_Run)); int const playerRunning = G_CheckAutorun(inputState.BUTTON(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 (BUTTON(gamefunc_Strafe)) if (inputState.BUTTON(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 (BUTTON(gamefunc_Strafe)) if (inputState.BUTTON(gamefunc_Strafe))
{ {
if (BUTTON(gamefunc_Turn_Left) && !(pPlayer->movement_lock&4)) if (inputState.BUTTON(gamefunc_Turn_Left) && !(pPlayer->movement_lock&4))
input.svel -= -keyMove; input.svel -= -keyMove;
if (BUTTON(gamefunc_Turn_Right) && !(pPlayer->movement_lock&8)) if (inputState.BUTTON(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 (BUTTON(gamefunc_Turn_Left)) if (inputState.BUTTON(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 (BUTTON(gamefunc_Turn_Right)) else if (inputState.BUTTON(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 (BUTTON(gamefunc_Strafe_Left) && !(pPlayer->movement_lock & 4)) if (inputState.BUTTON(gamefunc_Strafe_Left) && !(pPlayer->movement_lock & 4))
input.svel += keyMove; input.svel += keyMove;
if (BUTTON(gamefunc_Strafe_Right) && !(pPlayer->movement_lock & 8)) if (inputState.BUTTON(gamefunc_Strafe_Right) && !(pPlayer->movement_lock & 8))
input.svel += -keyMove; input.svel += -keyMove;
if (RR) if (RR)
{ {
/*if (BUTTON(gamefunc_Quick_Kick)) /*if (inputState.BUTTON(gamefunc_Quick_Kick))
{ {
localInput.bits |= BUTTON(gamefunc_Move_Forward)<<SK_AIM_UP; localInput.bits |= inputState.BUTTON(gamefunc_Move_Forward)<<SK_AIM_UP;
localInput.bits |= BUTTON(gamefunc_Move_Backward)<<SK_AIM_DOWN; localInput.bits |= inputState.BUTTON(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 (BUTTON(gamefunc_Move_Forward)) if (inputState.BUTTON(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 (BUTTON(gamefunc_Move_Backward)) if (inputState.BUTTON(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 (BUTTON(gamefunc_Move_Forward)) if (inputState.BUTTON(gamefunc_Move_Forward))
input.fvel += keyMove; input.fvel += keyMove;
if (BUTTON(gamefunc_Move_Backward)) if (inputState.BUTTON(gamefunc_Move_Backward))
input.fvel += -keyMove; input.fvel += -keyMove;
} }
} }
} }
else else
{ {
if (BUTTON(gamefunc_Move_Forward) && !(g_player[playerNum].ps->movement_lock & 1)) if (inputState.BUTTON(gamefunc_Move_Forward) && !(g_player[playerNum].ps->movement_lock & 1))
input.fvel += keyMove; input.fvel += keyMove;
if (BUTTON(gamefunc_Move_Backward) && !(g_player[playerNum].ps->movement_lock & 2)) if (inputState.BUTTON(gamefunc_Move_Backward) && !(g_player[playerNum].ps->movement_lock & 2))
input.fvel += -keyMove; input.fvel += -keyMove;
} }
@ -2925,31 +2925,31 @@ 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 (BUTTON(weaponSelection)) if (inputState.BUTTON(weaponSelection))
{ {
weaponSelection -= (gamefunc_Weapon_1 - 1); weaponSelection -= (gamefunc_Weapon_1 - 1);
break; break;
} }
} }
if (BUTTON(gamefunc_Last_Weapon)) if (inputState.BUTTON(gamefunc_Last_Weapon))
weaponSelection = 14; weaponSelection = 14;
else if (BUTTON(gamefunc_Alt_Weapon)) else if (inputState.BUTTON(gamefunc_Alt_Weapon))
weaponSelection = 13; weaponSelection = 13;
else if (BUTTON(gamefunc_Next_Weapon) || (BUTTON(gamefunc_Dpad_Select) && input.fvel > 0)) else if (inputState.BUTTON(gamefunc_Next_Weapon) || (inputState.BUTTON(gamefunc_Dpad_Select) && input.fvel > 0))
weaponSelection = 12; weaponSelection = 12;
else if (BUTTON(gamefunc_Previous_Weapon) || (BUTTON(gamefunc_Dpad_Select) && input.fvel < 0)) else if (inputState.BUTTON(gamefunc_Previous_Weapon) || (inputState.BUTTON(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) | (BUTTON(gamefunc_Fire) << SK_FIRE); localInput.bits = (weaponSelection << SK_WEAPON_BITS) | (inputState.BUTTON(gamefunc_Fire) << SK_FIRE);
localInput.bits |= (BUTTON(gamefunc_Open) << SK_OPEN); localInput.bits |= (inputState.BUTTON(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 (BUTTON(gamefunc_Toggle_Crouch)) if (inputState.BUTTON(gamefunc_Toggle_Crouch))
{ {
pPlayer->crouch_toggle = !pPlayer->crouch_toggle && crouchable; pPlayer->crouch_toggle = !pPlayer->crouch_toggle && crouchable;
@ -2957,38 +2957,38 @@ void P_GetInput(int playerNum)
inputState.ClearButton(gamefunc_Toggle_Crouch); inputState.ClearButton(gamefunc_Toggle_Crouch);
} }
if (BUTTON(gamefunc_Crouch) || BUTTON(gamefunc_Jump) || pPlayer->jetpack_on || (!crouchable && pPlayer->on_ground)) if (inputState.BUTTON(gamefunc_Crouch) || inputState.BUTTON(gamefunc_Jump) || pPlayer->jetpack_on || (!crouchable && pPlayer->on_ground))
pPlayer->crouch_toggle = 0; pPlayer->crouch_toggle = 0;
int const crouching = BUTTON(gamefunc_Crouch) || BUTTON(gamefunc_Toggle_Crouch) || pPlayer->crouch_toggle; int const crouching = inputState.BUTTON(gamefunc_Crouch) || inputState.BUTTON(gamefunc_Toggle_Crouch) || pPlayer->crouch_toggle;
localInput.bits |= (BUTTON(gamefunc_Jump) << SK_JUMP) | (crouching << SK_CROUCH); localInput.bits |= (inputState.BUTTON(gamefunc_Jump) << SK_JUMP) | (crouching << SK_CROUCH);
localInput.bits |= (BUTTON(gamefunc_Aim_Up) || (BUTTON(gamefunc_Dpad_Aiming) && input.fvel > 0)) << SK_AIM_UP; localInput.bits |= (inputState.BUTTON(gamefunc_Aim_Up) || (inputState.BUTTON(gamefunc_Dpad_Aiming) && input.fvel > 0)) << SK_AIM_UP;
localInput.bits |= (BUTTON(gamefunc_Aim_Down) || (BUTTON(gamefunc_Dpad_Aiming) && input.fvel < 0)) << SK_AIM_DOWN; localInput.bits |= (inputState.BUTTON(gamefunc_Aim_Down) || (inputState.BUTTON(gamefunc_Dpad_Aiming) && input.fvel < 0)) << SK_AIM_DOWN;
localInput.bits |= (BUTTON(gamefunc_Center_View) << SK_CENTER_VIEW); localInput.bits |= (inputState.BUTTON(gamefunc_Center_View) << SK_CENTER_VIEW);
localInput.bits |= (BUTTON(gamefunc_Look_Left) << SK_LOOK_LEFT) | (BUTTON(gamefunc_Look_Right) << SK_LOOK_RIGHT); localInput.bits |= (inputState.BUTTON(gamefunc_Look_Left) << SK_LOOK_LEFT) | (inputState.BUTTON(gamefunc_Look_Right) << SK_LOOK_RIGHT);
localInput.bits |= (BUTTON(gamefunc_Look_Up) << SK_LOOK_UP) | (BUTTON(gamefunc_Look_Down) << SK_LOOK_DOWN); localInput.bits |= (inputState.BUTTON(gamefunc_Look_Up) << SK_LOOK_UP) | (inputState.BUTTON(gamefunc_Look_Down) << SK_LOOK_DOWN);
localInput.bits |= (playerRunning << SK_RUN); localInput.bits |= (playerRunning << SK_RUN);
localInput.bits |= (BUTTON(gamefunc_Inventory_Left) || (BUTTON(gamefunc_Dpad_Select) && (input.svel > 0 || input.q16avel < 0))) << SK_INV_LEFT; localInput.bits |= (inputState.BUTTON(gamefunc_Inventory_Left) || (inputState.BUTTON(gamefunc_Dpad_Select) && (input.svel > 0 || input.q16avel < 0))) << SK_INV_LEFT;
localInput.bits |= (BUTTON(gamefunc_Inventory_Right) || (BUTTON(gamefunc_Dpad_Select) && (input.svel < 0 || input.q16avel > 0))) << SK_INV_RIGHT; localInput.bits |= (inputState.BUTTON(gamefunc_Inventory_Right) || (inputState.BUTTON(gamefunc_Dpad_Select) && (input.svel < 0 || input.q16avel > 0))) << SK_INV_RIGHT;
localInput.bits |= (BUTTON(gamefunc_Inventory) << SK_INVENTORY); localInput.bits |= (inputState.BUTTON(gamefunc_Inventory) << SK_INVENTORY);
localInput.bits |= (BUTTON(gamefunc_Steroids) << SK_STEROIDS) | (BUTTON(gamefunc_NightVision) << SK_NIGHTVISION); localInput.bits |= (inputState.BUTTON(gamefunc_Steroids) << SK_STEROIDS) | (inputState.BUTTON(gamefunc_NightVision) << SK_NIGHTVISION);
localInput.bits |= (BUTTON(gamefunc_MedKit) << SK_MEDKIT) | (BUTTON(gamefunc_Holo_Duke) << SK_HOLODUKE); localInput.bits |= (inputState.BUTTON(gamefunc_MedKit) << SK_MEDKIT) | (inputState.BUTTON(gamefunc_Holo_Duke) << SK_HOLODUKE);
localInput.bits |= (BUTTON(gamefunc_Jetpack) << SK_JETPACK); localInput.bits |= (inputState.BUTTON(gamefunc_Jetpack) << SK_JETPACK);
localInput.bits |= BUTTON(gamefunc_Holster_Weapon) << SK_HOLSTER; localInput.bits |= inputState.BUTTON(gamefunc_Holster_Weapon) << SK_HOLSTER;
localInput.bits |= BUTTON(gamefunc_Quick_Kick) << SK_QUICK_KICK; localInput.bits |= inputState.BUTTON(gamefunc_Quick_Kick) << SK_QUICK_KICK;
localInput.bits |= BUTTON(gamefunc_TurnAround) << SK_TURNAROUND; localInput.bits |= inputState.BUTTON(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 |= KB_KeyPressed(sc_Pause) << SK_PAUSE; localInput.bits |= inputState.GetKeyStatus(sc_Pause) << SK_PAUSE;
localInput.bits |= ((uint32_t)KB_KeyPressed(sc_Escape)) << SK_ESCAPE; localInput.bits |= ((uint32_t)inputState.GetKeyStatus(sc_Escape)) << SK_ESCAPE;
if (RR) if (RR)
{ {
@ -3000,21 +3000,21 @@ void P_GetInput(int playerNum)
localInput.bits |= 1 << SK_LOOK_DOWN; localInput.bits |= 1 << SK_LOOK_DOWN;
} }
if (BUTTON(gamefunc_Dpad_Select)) if (inputState.BUTTON(gamefunc_Dpad_Select))
{ {
input.fvel = 0; input.fvel = 0;
input.svel = 0; input.svel = 0;
input.q16avel = 0; input.q16avel = 0;
} }
else if (BUTTON(gamefunc_Dpad_Aiming)) else if (inputState.BUTTON(gamefunc_Dpad_Aiming))
input.fvel = 0; input.fvel = 0;
localInput.extbits = (BUTTON(gamefunc_Move_Forward) || (input.fvel > 0)); localInput.extbits = (inputState.BUTTON(gamefunc_Move_Forward) || (input.fvel > 0));
localInput.extbits |= (BUTTON(gamefunc_Move_Backward) || (input.fvel < 0)) << 1; localInput.extbits |= (inputState.BUTTON(gamefunc_Move_Backward) || (input.fvel < 0)) << 1;
localInput.extbits |= (BUTTON(gamefunc_Strafe_Left) || (input.svel > 0)) << 2; localInput.extbits |= (inputState.BUTTON(gamefunc_Strafe_Left) || (input.svel > 0)) << 2;
localInput.extbits |= (BUTTON(gamefunc_Strafe_Right) || (input.svel < 0)) << 3; localInput.extbits |= (inputState.BUTTON(gamefunc_Strafe_Right) || (input.svel < 0)) << 3;
localInput.extbits |= BUTTON(gamefunc_Turn_Left)<<4; localInput.extbits |= inputState.BUTTON(gamefunc_Turn_Left)<<4;
localInput.extbits |= BUTTON(gamefunc_Turn_Right)<<5; localInput.extbits |= inputState.BUTTON(gamefunc_Turn_Right)<<5;
if (ud.scrollmode && ud.overhead_on) if (ud.scrollmode && ud.overhead_on)
{ {
@ -3049,7 +3049,7 @@ void P_GetInputMotorcycle(int playerNum)
auto const pPlayer = g_player[playerNum].ps; auto const pPlayer = g_player[playerNum].ps;
ControlInfo info; ControlInfo info;
if ((pPlayer->gm & (MODE_MENU|MODE_TYPE)) || (ud.pause_on && !KB_KeyPressed(sc_Pause))) if ((pPlayer->gm & (MODE_MENU|MODE_TYPE)) || (ud.pause_on && !inputState.GetKeyStatus(sc_Pause)))
{ {
if (!(pPlayer->gm&MODE_MENU)) if (!(pPlayer->gm&MODE_MENU))
CONTROL_GetInput(&info); CONTROL_GetInput(&info);
@ -3065,11 +3065,11 @@ void P_GetInputMotorcycle(int playerNum)
D_ProcessEvents(); D_ProcessEvents();
if (in_aimmode) if (in_aimmode)
g_MyAimMode = BUTTON(gamefunc_Mouse_Aiming); g_MyAimMode = inputState.BUTTON(gamefunc_Mouse_Aiming);
else else
{ {
g_oldAimStat = g_myAimStat; g_oldAimStat = g_myAimStat;
g_myAimStat = BUTTON(gamefunc_Mouse_Aiming); g_myAimStat = inputState.BUTTON(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(BUTTON(gamefunc_Run)); int const playerRunning = G_CheckAutorun(inputState.BUTTON(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 = BUTTON(gamefunc_Fire) << SK_FIRE; localInput.bits = inputState.BUTTON(gamefunc_Fire) << SK_FIRE;
localInput.bits |= BUTTON(gamefunc_Steroids) << SK_STEROIDS; localInput.bits |= inputState.BUTTON(gamefunc_Steroids) << SK_STEROIDS;
localInput.bits |= BUTTON(gamefunc_NightVision) << SK_NIGHTVISION; localInput.bits |= inputState.BUTTON(gamefunc_NightVision) << SK_NIGHTVISION;
localInput.bits |= BUTTON(gamefunc_MedKit) << SK_MEDKIT; localInput.bits |= inputState.BUTTON(gamefunc_MedKit) << SK_MEDKIT;
localInput.bits |= (BUTTON(gamefunc_Inventory_Left) || localInput.bits |= (inputState.BUTTON(gamefunc_Inventory_Left) ||
(BUTTON(gamefunc_Dpad_Select) && (input.svel > 0 || input.q16avel < 0))) << SK_INV_LEFT; (inputState.BUTTON(gamefunc_Dpad_Select) && (input.svel > 0 || input.q16avel < 0))) << SK_INV_LEFT;
localInput.bits |= KB_KeyPressed(sc_Pause) << SK_PAUSE; localInput.bits |= inputState.GetKeyStatus(sc_Pause) << SK_PAUSE;
localInput.bits |= BUTTON(gamefunc_Holo_Duke) << SK_HOLODUKE; localInput.bits |= inputState.BUTTON(gamefunc_Holo_Duke) << SK_HOLODUKE;
localInput.bits |= BUTTON(gamefunc_Jetpack) << SK_JETPACK; localInput.bits |= inputState.BUTTON(gamefunc_Jetpack) << SK_JETPACK;
localInput.bits |= (g_gameQuit << SK_GAMEQUIT); localInput.bits |= (g_gameQuit << SK_GAMEQUIT);
localInput.bits |= (BUTTON(gamefunc_Inventory_Right) || localInput.bits |= (inputState.BUTTON(gamefunc_Inventory_Right) ||
(BUTTON(gamefunc_Dpad_Select) && (input.svel < 0 || input.q16avel > 0))) << SK_INV_RIGHT; (inputState.BUTTON(gamefunc_Dpad_Select) && (input.svel < 0 || input.q16avel > 0))) << SK_INV_RIGHT;
localInput.bits |= BUTTON(gamefunc_Open) << SK_OPEN; localInput.bits |= inputState.BUTTON(gamefunc_Open) << SK_OPEN;
localInput.bits |= BUTTON(gamefunc_Inventory) << SK_INVENTORY; localInput.bits |= inputState.BUTTON(gamefunc_Inventory) << SK_INVENTORY;
localInput.bits |= ((uint32_t)KB_KeyPressed(sc_Escape)) << SK_ESCAPE; localInput.bits |= ((uint32_t)inputState.GetKeyStatus(sc_Escape)) << SK_ESCAPE;
if (BUTTON(gamefunc_Dpad_Select)) if (inputState.BUTTON(gamefunc_Dpad_Select))
{ {
input.fvel = 0; input.fvel = 0;
input.svel = 0; input.svel = 0;
input.q16avel = 0; input.q16avel = 0;
} }
if (BUTTON(gamefunc_Dpad_Aiming)) if (inputState.BUTTON(gamefunc_Dpad_Aiming))
input.fvel = 0; input.fvel = 0;
localInput.extbits = (BUTTON(gamefunc_Move_Forward) || (input.fvel > 0)); localInput.extbits = (inputState.BUTTON(gamefunc_Move_Forward) || (input.fvel > 0));
localInput.extbits |= (BUTTON(gamefunc_Move_Backward) || (input.fvel < 0)) << 1; localInput.extbits |= (inputState.BUTTON(gamefunc_Move_Backward) || (input.fvel < 0)) << 1;
localInput.extbits |= (BUTTON(gamefunc_Strafe_Left) || (input.svel > 0)) << 2; localInput.extbits |= (inputState.BUTTON(gamefunc_Strafe_Left) || (input.svel > 0)) << 2;
localInput.extbits |= (BUTTON(gamefunc_Strafe_Right) || (input.svel < 0)) << 3; localInput.extbits |= (inputState.BUTTON(gamefunc_Strafe_Right) || (input.svel < 0)) << 3;
int const turn = input.q16avel / 32; int const turn = input.q16avel / 32;
int turnLeft = BUTTON(gamefunc_Turn_Left) || BUTTON(gamefunc_Strafe_Left); int turnLeft = inputState.BUTTON(gamefunc_Turn_Left) || inputState.BUTTON(gamefunc_Strafe_Left);
int turnRight = BUTTON(gamefunc_Turn_Right) || BUTTON(gamefunc_Strafe_Right); int turnRight = inputState.BUTTON(gamefunc_Turn_Right) || inputState.BUTTON(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 |= (BUTTON(gamefunc_Move_Forward) || BUTTON(gamefunc_Strafe)) << SK_JUMP; localInput.bits |= (inputState.BUTTON(gamefunc_Move_Forward) || inputState.BUTTON(gamefunc_Strafe)) << SK_JUMP;
localInput.bits |= BUTTON(gamefunc_Move_Backward) << SK_AIM_UP; localInput.bits |= inputState.BUTTON(gamefunc_Move_Backward) << SK_AIM_UP;
localInput.bits |= BUTTON(gamefunc_Run) << SK_CROUCH; localInput.bits |= inputState.BUTTON(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 = BUTTON(gamefunc_Move_Backward) && pPlayer->moto_speed <= 0; int const moveBack = inputState.BUTTON(gamefunc_Move_Backward) && pPlayer->moto_speed <= 0;
if (pPlayer->moto_speed == 0 || !pPlayer->on_ground) if (pPlayer->moto_speed == 0 || !pPlayer->on_ground)
{ {
@ -3347,7 +3347,7 @@ void P_GetInputBoat(int playerNum)
auto const pPlayer = g_player[playerNum].ps; auto const pPlayer = g_player[playerNum].ps;
ControlInfo info; ControlInfo info;
if ((pPlayer->gm & (MODE_MENU|MODE_TYPE)) || (ud.pause_on && !KB_KeyPressed(sc_Pause))) if ((pPlayer->gm & (MODE_MENU|MODE_TYPE)) || (ud.pause_on && !inputState.GetKeyStatus(sc_Pause)))
{ {
if (!(pPlayer->gm&MODE_MENU)) if (!(pPlayer->gm&MODE_MENU))
CONTROL_GetInput(&info); CONTROL_GetInput(&info);
@ -3363,11 +3363,11 @@ void P_GetInputBoat(int playerNum)
D_ProcessEvents(); D_ProcessEvents();
if (in_aimmode) if (in_aimmode)
g_MyAimMode = BUTTON(gamefunc_Mouse_Aiming); g_MyAimMode = inputState.BUTTON(gamefunc_Mouse_Aiming);
else else
{ {
g_oldAimStat = g_myAimStat; g_oldAimStat = g_myAimStat;
g_myAimStat = BUTTON(gamefunc_Mouse_Aiming); g_myAimStat = inputState.BUTTON(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(BUTTON(gamefunc_Run)); int const playerRunning = G_CheckAutorun(inputState.BUTTON(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 = BUTTON(gamefunc_Fire) << SK_FIRE; localInput.bits = inputState.BUTTON(gamefunc_Fire) << SK_FIRE;
localInput.bits |= BUTTON(gamefunc_Steroids) << SK_STEROIDS; localInput.bits |= inputState.BUTTON(gamefunc_Steroids) << SK_STEROIDS;
localInput.bits |= BUTTON(gamefunc_NightVision) << SK_NIGHTVISION; localInput.bits |= inputState.BUTTON(gamefunc_NightVision) << SK_NIGHTVISION;
localInput.bits |= BUTTON(gamefunc_MedKit) << SK_MEDKIT; localInput.bits |= inputState.BUTTON(gamefunc_MedKit) << SK_MEDKIT;
localInput.bits |= (BUTTON(gamefunc_Inventory_Left) || localInput.bits |= (inputState.BUTTON(gamefunc_Inventory_Left) ||
(BUTTON(gamefunc_Dpad_Select) && (input.svel > 0 || input.q16avel < 0))) << SK_INV_LEFT; (inputState.BUTTON(gamefunc_Dpad_Select) && (input.svel > 0 || input.q16avel < 0))) << SK_INV_LEFT;
localInput.bits |= KB_KeyPressed(sc_Pause) << SK_PAUSE; localInput.bits |= inputState.GetKeyStatus(sc_Pause) << SK_PAUSE;
localInput.bits |= BUTTON(gamefunc_Holo_Duke) << SK_HOLODUKE; localInput.bits |= inputState.BUTTON(gamefunc_Holo_Duke) << SK_HOLODUKE;
localInput.bits |= BUTTON(gamefunc_Jetpack) << SK_JETPACK; localInput.bits |= inputState.BUTTON(gamefunc_Jetpack) << SK_JETPACK;
localInput.bits |= (g_gameQuit << SK_GAMEQUIT); localInput.bits |= (g_gameQuit << SK_GAMEQUIT);
localInput.bits |= (BUTTON(gamefunc_Inventory_Right) || localInput.bits |= (inputState.BUTTON(gamefunc_Inventory_Right) ||
(BUTTON(gamefunc_Dpad_Select) && (input.svel < 0 || input.q16avel > 0))) << SK_INV_RIGHT; (inputState.BUTTON(gamefunc_Dpad_Select) && (input.svel < 0 || input.q16avel > 0))) << SK_INV_RIGHT;
localInput.bits |= BUTTON(gamefunc_Open) << SK_OPEN; localInput.bits |= inputState.BUTTON(gamefunc_Open) << SK_OPEN;
localInput.bits |= BUTTON(gamefunc_Inventory) << SK_INVENTORY; localInput.bits |= inputState.BUTTON(gamefunc_Inventory) << SK_INVENTORY;
localInput.bits |= ((uint32_t)KB_KeyPressed(sc_Escape)) << SK_ESCAPE; localInput.bits |= ((uint32_t)inputState.GetKeyStatus(sc_Escape)) << SK_ESCAPE;
if (BUTTON(gamefunc_Dpad_Select)) if (inputState.BUTTON(gamefunc_Dpad_Select))
{ {
input.fvel = 0; input.fvel = 0;
input.svel = 0; input.svel = 0;
input.q16avel = 0; input.q16avel = 0;
} }
if (BUTTON(gamefunc_Dpad_Aiming)) if (inputState.BUTTON(gamefunc_Dpad_Aiming))
input.fvel = 0; input.fvel = 0;
localInput.extbits = (BUTTON(gamefunc_Move_Forward) || (input.fvel > 0)); localInput.extbits = (inputState.BUTTON(gamefunc_Move_Forward) || (input.fvel > 0));
localInput.extbits |= (BUTTON(gamefunc_Move_Backward) || (input.fvel < 0)) << 1; localInput.extbits |= (inputState.BUTTON(gamefunc_Move_Backward) || (input.fvel < 0)) << 1;
localInput.extbits |= (BUTTON(gamefunc_Strafe_Left) || (input.svel > 0)) << 2; localInput.extbits |= (inputState.BUTTON(gamefunc_Strafe_Left) || (input.svel > 0)) << 2;
localInput.extbits |= (BUTTON(gamefunc_Strafe_Right) || (input.svel < 0)) << 3; localInput.extbits |= (inputState.BUTTON(gamefunc_Strafe_Right) || (input.svel < 0)) << 3;
int const turn = input.q16avel / 32; int const turn = input.q16avel / 32;
int turnLeft = BUTTON(gamefunc_Turn_Left) || BUTTON(gamefunc_Strafe_Left); int turnLeft = inputState.BUTTON(gamefunc_Turn_Left) || inputState.BUTTON(gamefunc_Strafe_Left);
int turnRight = BUTTON(gamefunc_Turn_Right) || BUTTON(gamefunc_Strafe_Right); int turnRight = inputState.BUTTON(gamefunc_Turn_Right) || inputState.BUTTON(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 |= (BUTTON(gamefunc_Move_Forward) || BUTTON(gamefunc_Strafe)) << SK_JUMP; localInput.bits |= (inputState.BUTTON(gamefunc_Move_Forward) || inputState.BUTTON(gamefunc_Strafe)) << SK_JUMP;
localInput.bits |= BUTTON(gamefunc_Move_Backward) << SK_AIM_UP; localInput.bits |= inputState.BUTTON(gamefunc_Move_Backward) << SK_AIM_UP;
localInput.bits |= BUTTON(gamefunc_Run) << SK_CROUCH; localInput.bits |= inputState.BUTTON(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

@ -528,7 +528,7 @@ static void G_DoLoadScreen(const char *statustext, int32_t percent)
if (!statustext) if (!statustext)
{ {
KB_FlushKeyboardQueue(); inputState.keyFlushChars();
ud.screen_size = i; ud.screen_size = i;
} }
} }
@ -2205,9 +2205,9 @@ static void G_FadeLoad(int32_t r, int32_t g, int32_t b, int32_t start, int32_t e
sampletimer(); sampletimer();
nexttic += ticwait; nexttic += ticwait;
if (KB_KeyPressed(sc_Space)) if (inputState.GetKeyStatus(sc_Space))
{ {
KB_ClearKeyDown(sc_Space); inputState.ClearKeyStatus(sc_Space);
return; return;
} }

View file

@ -1253,7 +1253,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 (BUTTON(gamefunc_Show_DukeMatch_Scores)) if (inputState.BUTTON(gamefunc_Show_DukeMatch_Scores))
G_ShowScores(); G_ShowScores();
if (g_Debug) if (g_Debug)
@ -1321,9 +1321,9 @@ void fadepal(int32_t r, int32_t g, int32_t b, int32_t start, int32_t end, int32_
// (end-start)/step + 1 iterations // (end-start)/step + 1 iterations
do do
{ {
if (KB_KeyPressed(sc_Space)) if (inputState.GetKeyStatus(sc_Space))
{ {
KB_ClearKeyDown(sc_Space); inputState.ClearKeyStatus(sc_Space);
videoFadePalette(r, g, b, end); // have to set to end fade value if we break! videoFadePalette(r, g, b, end); // have to set to end fade value if we break!
return; return;
} }
@ -1350,9 +1350,9 @@ static void fadepaltile(int32_t r, int32_t g, int32_t b, int32_t start, int32_t
#ifdef __ANDROID__ //Needed for N7 2013 to stop corruption while fading video #ifdef __ANDROID__ //Needed for N7 2013 to stop corruption while fading video
videoClearViewableArea(0); videoClearViewableArea(0);
#endif #endif
if (KB_KeyPressed(sc_Space)) if (inputState.GetKeyStatus(sc_Space))
{ {
KB_ClearKeyDown(sc_Space); inputState.ClearKeyStatus(sc_Space);
videoFadePalette(r, g, b, end); // have to set to end fade value if we break! videoFadePalette(r, g, b, end); // have to set to end fade value if we break!
return; return;
} }
@ -1579,7 +1579,7 @@ void G_DisplayLogo(void)
P_SetGamePalette(g_player[myconnectindex].ps, TITLEPAL, 8+2+1); // JBF 20040308 P_SetGamePalette(g_player[myconnectindex].ps, TITLEPAL, 8+2+1); // JBF 20040308
renderFlushPerms(); renderFlushPerms();
rotatesprite_fs(160<<16, 100<<16, 65536L, 0, BETASCREEN, 0, 0, 2+8+64+BGSTRETCH); rotatesprite_fs(160<<16, 100<<16, 65536L, 0, BETASCREEN, 0, 0, 2+8+64+BGSTRETCH);
KB_FlushKeyboardQueue(); inputState.keyFlushChars();
fadepaltile(0, 0, 0, 252, 0, -28, BETASCREEN); fadepaltile(0, 0, 0, 252, 0, -28, BETASCREEN);
totalclock = 0; totalclock = 0;
@ -2206,7 +2206,7 @@ void G_BonusScreen(int32_t bonusonly)
P_SetGamePalette(g_player[myconnectindex].ps, BASEPAL, 8+2+1); // JBF 20040308 P_SetGamePalette(g_player[myconnectindex].ps, BASEPAL, 8+2+1); // JBF 20040308
G_FadePalette(0, 0, 0, 252); // JBF 20031228 G_FadePalette(0, 0, 0, 252); // JBF 20031228
KB_FlushKeyboardQueue(); inputState.keyFlushChars();
totalclock = 0; totalclock = 0;
bonuscnt = 0; bonuscnt = 0;
@ -2594,7 +2594,7 @@ void G_BonusScreen(int32_t bonusonly)
I_ClearAllInput(); I_ClearAllInput();
if (totalclock < (60*13)) if (totalclock < (60*13))
{ {
KB_FlushKeyboardQueue(); inputState.keyFlushChars();
totalclock = (60*13); totalclock = (60*13);
} }
else if (totalclock < 1000000000) else if (totalclock < 1000000000)
@ -2784,7 +2784,7 @@ void G_BonusScreenRRRA(int32_t bonusonly)
{ {
showMap = 1; showMap = 1;
MUSIC_StopSong(); MUSIC_StopSong();
KB_FlushKeyboardQueue(); inputState.keyFlushChars();
P_SetGamePalette(g_player[myconnectindex].ps, BASEPAL, 8+2+1); P_SetGamePalette(g_player[myconnectindex].ps, BASEPAL, 8+2+1);
G_ShowMapFrame(); G_ShowMapFrame();
@ -2798,7 +2798,7 @@ void G_BonusScreenRRRA(int32_t bonusonly)
P_SetGamePalette(g_player[myconnectindex].ps, BASEPAL, 8+2+1); // JBF 20040308 P_SetGamePalette(g_player[myconnectindex].ps, BASEPAL, 8+2+1); // JBF 20040308
//G_FadePalette(0, 0, 0, 252); // JBF 20031228 //G_FadePalette(0, 0, 0, 252); // JBF 20031228
KB_FlushKeyboardQueue(); inputState.keyFlushChars();
totalclock = 0; totalclock = 0;
bonuscnt = 0; bonuscnt = 0;
@ -3104,7 +3104,7 @@ void G_BonusScreenRRRA(int32_t bonusonly)
if (totalclock < (60*13)) if (totalclock < (60*13))
{ {
KB_FlushKeyboardQueue(); inputState.keyFlushChars();
totalclock = (60*13); totalclock = (60*13);
} }
else if (totalclock < 1000000000) else if (totalclock < 1000000000)

View file

@ -3642,7 +3642,7 @@ void P_HandleSharedKeys(int playerNum)
if (TEST_SYNC_KEY(playerBits, SK_PAUSE)) if (TEST_SYNC_KEY(playerBits, SK_PAUSE))
{ {
KB_ClearKeyDown(sc_Pause); inputState.ClearKeyStatus(sc_Pause);
if (ud.pause_on) if (ud.pause_on)
ud.pause_on = 0; ud.pause_on = 0;
else ud.pause_on = 1+SHIFTS_IS_PRESSED; else ud.pause_on = 1+SHIFTS_IS_PRESSED;

View file

@ -271,8 +271,8 @@ playanm(short anim_num)
ANIMnum = anim_num; ANIMnum = anim_num;
KB_FlushKeyboardQueue(); inputState.keyFlushChars();
KB_ClearKeysDown(); inputState.ClearKeysDown();
DSPRINTF(ds,"PlayAnm"); DSPRINTF(ds,"PlayAnm");
MONO_PRINT(ds); MONO_PRINT(ds);
@ -322,11 +322,11 @@ playanm(short anim_num)
switch (ANIMnum) switch (ANIMnum)
{ {
case ANIM_INTRO: case ANIM_INTRO:
if (KB_KeyWaiting() || uinfo.button0 || uinfo.button1 || quitevent) if (inputState.keyBufferWaiting() || uinfo.button0 || uinfo.button1 || quitevent)
goto ENDOFANIMLOOP; goto ENDOFANIMLOOP;
break; break;
case ANIM_SERP: case ANIM_SERP:
if (KB_KeyPressed(KEYSC_ESC) || uinfo.button1 || quitevent) if (inputState.GetKeyStatus(KEYSC_ESC) || uinfo.button1 || quitevent)
goto ENDOFANIMLOOP; goto ENDOFANIMLOOP;
break; break;
} }
@ -371,8 +371,8 @@ ENDOFANIMLOOP:
videoSetPalette(0, BASEPAL, 2); videoSetPalette(0, BASEPAL, 2);
KB_FlushKeyboardQueue(); inputState.keyFlushChars();
KB_ClearKeysDown(); inputState.ClearKeysDown();
ANIM_FreeAnim(); ANIM_FreeAnim();
} }
END_SW_NS END_SW_NS

View file

@ -399,9 +399,9 @@ void CheatInput(void)
if (!CheatInputMode) if (!CheatInputMode)
{ {
if (KB_KeyPressed(KEYSC_S)) if (inputState.GetKeyStatus(KEYSC_S))
{ {
//KB_KeyPressed(KEYSC_S) = FALSE; //inputState.GetKeyStatus(KEYSC_S) = FALSE;
CheatInputMode = TRUE; CheatInputMode = TRUE;
strcpy(CheatInputString,"s"); strcpy(CheatInputString,"s");
} }
@ -418,7 +418,7 @@ void CheatInput(void)
case FALSE: // Input finished (RETURN) case FALSE: // Input finished (RETURN)
case -1: // Cancel Input (pressed ESC) or Err case -1: // Cancel Input (pressed ESC) or Err
CheatInputMode = FALSE; CheatInputMode = FALSE;
KB_FlushKeyboardQueue(); inputState.keyFlushChars();
return; return;
case TRUE: // Got input case TRUE: // Got input
@ -446,7 +446,7 @@ void CheatInput(void)
match = TRUE; match = TRUE;
CheatInputMode = FALSE; CheatInputMode = FALSE;
KB_FlushKeyboardQueue(); inputState.keyFlushChars();
if (ci[i].CheatInputFunc) if (ci[i].CheatInputFunc)
(*ci[i].CheatInputFunc)(Player, CheatInputString); (*ci[i].CheatInputFunc)(Player, CheatInputString);
@ -467,7 +467,7 @@ void CheatInput(void)
//MONO_PRINT(ds); //MONO_PRINT(ds);
CheatInputMode = FALSE; CheatInputMode = FALSE;
KB_FlushKeyboardQueue(); inputState.keyFlushChars();
} }
} }
} }

View file

@ -457,21 +457,21 @@ DemoPlayBack(void)
// fast forward and slow mo // fast forward and slow mo
if (DemoEdit) if (DemoEdit)
{ {
if (KB_KeyPressed(KEYSC_F)) if (inputState.GetKeyStatus(KEYSC_F))
{ {
if (KB_KeyPressed(KEYSC_LSHIFT) || KB_KeyPressed(KEYSC_RSHIFT)) if (inputState.GetKeyStatus(KEYSC_LSHIFT) || inputState.GetKeyStatus(KEYSC_RSHIFT))
totalclock += synctics; totalclock += synctics;
else else
totalclock += synctics-1; totalclock += synctics-1;
} }
if (KB_KeyPressed(KEYSC_S)) if (inputState.GetKeyStatus(KEYSC_S))
totalclock += 1-synctics; totalclock += 1-synctics;
} }
else else
{ {
if (BUTTON(gamefunc_See_Coop_View)) if (inputState.BUTTON(gamefunc_See_Coop_View))
{ {
inputState.ClearButton(gamefunc_See_Coop_View); inputState.ClearButton(gamefunc_See_Coop_View);
@ -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 (BUTTON(gamefunc_Move_Forward) || if (inputState.BUTTON(gamefunc_Move_Forward) ||
BUTTON(gamefunc_Move_Backward) || inputState.BUTTON(gamefunc_Move_Backward) ||
BUTTON(gamefunc_Turn_Left) || inputState.BUTTON(gamefunc_Turn_Left) ||
BUTTON(gamefunc_Turn_Right) || inputState.BUTTON(gamefunc_Turn_Right) ||
BUTTON(gamefunc_Fire) || inputState.BUTTON(gamefunc_Fire) ||
BUTTON(gamefunc_Open) || inputState.BUTTON(gamefunc_Open) ||
BUTTON(gamefunc_Jump) || inputState.BUTTON(gamefunc_Jump) ||
BUTTON(gamefunc_Crouch) || inputState.BUTTON(gamefunc_Crouch) ||
BUTTON(gamefunc_Look_Up) || inputState.BUTTON(gamefunc_Look_Up) ||
BUTTON(gamefunc_Look_Down)) inputState.BUTTON(gamefunc_Look_Down))
{ {
DemoBackupBuffer(); DemoBackupBuffer();
@ -517,7 +517,7 @@ DemoPlayBack(void)
} }
} }
if (BUTTON(gamefunc_See_Co_Op_View)) if (inputState.BUTTON(gamefunc_See_Co_Op_View))
{ {
screenpeek += 1; screenpeek += 1;
if (screenpeek > numplayers-1) if (screenpeek > numplayers-1)

View file

@ -1044,17 +1044,17 @@ ResizeView(PLAYERp pp)
if (dimensionmode == 2 || dimensionmode == 5 || dimensionmode == 6) if (dimensionmode == 2 || dimensionmode == 5 || dimensionmode == 6)
{ {
if (KB_KeyPressed(KEYSC_DASH)||KB_KeyPressed(KEYSC_GMINUS)) if (inputState.GetKeyStatus(KEYSC_DASH)||inputState.GetKeyStatus(KEYSC_GMINUS))
{ {
if ((zoom -= (zoom >> 4)) < 48) zoom = 48; if ((zoom -= (zoom >> 4)) < 48) zoom = 48;
} }
if (KB_KeyPressed(KEYSC_EQUAL)||KB_KeyPressed(KEYSC_GPLUS)) if (inputState.GetKeyStatus(KEYSC_EQUAL)||inputState.GetKeyStatus(KEYSC_GPLUS))
{ {
if ((zoom += (zoom >> 4)) > 4096) zoom = 4096; if ((zoom += (zoom >> 4)) > 4096) zoom = 4096;
} }
if (KB_KeyPressed(KEYSC_ESC)) if (inputState.GetKeyStatus(KEYSC_ESC))
{ {
extern SWBOOL ScrollMode2D; extern SWBOOL ScrollMode2D;
@ -1066,14 +1066,14 @@ ResizeView(PLAYERp pp)
} }
else else
{ {
if (BUTTON(gamefunc_Shrink_Screen)) // && if (inputState.BUTTON(gamefunc_Shrink_Screen)) // &&
{ {
inputState.ClearButton(gamefunc_Shrink_Screen); inputState.ClearButton(gamefunc_Shrink_Screen);
SetBorder(pp, gs.BorderNum + 1); SetBorder(pp, gs.BorderNum + 1);
SetRedrawScreen(pp); SetRedrawScreen(pp);
} }
if (BUTTON(gamefunc_Enlarge_Screen)) // && if (inputState.BUTTON(gamefunc_Enlarge_Screen)) // &&
{ {
inputState.ClearButton(gamefunc_Enlarge_Screen); inputState.ClearButton(gamefunc_Enlarge_Screen);
SetBorder(pp, gs.BorderNum - 1); SetBorder(pp, gs.BorderNum - 1);
@ -1671,7 +1671,7 @@ void ScreenCaptureKeys(void)
return; return;
// screen capture // screen capture
if (KB_KeyPressed(KEYSC_F12)) if (inputState.GetKeyStatus(KEYSC_F12))
{ {
inputState.ClearKeyStatus(KEYSC_F12); inputState.ClearKeyStatus(KEYSC_F12);
PauseAction(); PauseAction();

View file

@ -1603,7 +1603,7 @@ KeyPressed(void)
for (i = 0; i < NUMKEYS; i++) for (i = 0; i < NUMKEYS; i++)
{ {
if (KB_KeyPressed(i)) if (inputState.GetKeyStatus(i))
return TRUE; return TRUE;
} }
@ -1797,7 +1797,7 @@ CreditsLevel(void)
if (!SongIsPlaying()) if (!SongIsPlaying())
break; break;
if (KB_KeyPressed(KEYSC_ESC)) if (inputState.GetKeyStatus(KEYSC_ESC))
break; break;
} }
@ -2170,7 +2170,7 @@ MenuLevel(void)
BorderAdjust = TRUE; BorderAdjust = TRUE;
//LoadGameOutsideMoveLoop = FALSE; //LoadGameOutsideMoveLoop = FALSE;
inputState.ClearKeyStatus(sc_Escape); inputState.ClearKeyStatus(sc_Escape);
KB_ClearKeysDown(); inputState.ClearKeysDown();
//ExitMenus(); //ExitMenus();
UsingMenus = FALSE; UsingMenus = FALSE;
InMenuLevel = FALSE; InMenuLevel = FALSE;
@ -2410,7 +2410,7 @@ BonusScreen(PLAYERp pp)
videoClearViewableArea(0L); videoClearViewableArea(0L);
videoNextPage(); videoNextPage();
KB_ClearKeysDown(); inputState.ClearKeysDown();
totalclock = ototalclock = 0; totalclock = ototalclock = 0;
limit = synctics; limit = synctics;
@ -2444,7 +2444,7 @@ BonusScreen(PLAYERp pp)
CONTROL_GetUserInput(&uinfo); CONTROL_GetUserInput(&uinfo);
CONTROL_ClearUserInput(&uinfo); CONTROL_ClearUserInput(&uinfo);
if (KB_KeyPressed(KEYSC_SPACE) || KB_KeyPressed(KEYSC_ENTER) || uinfo.button0 || uinfo.button1) if (inputState.GetKeyStatus(KEYSC_SPACE) || inputState.GetKeyStatus(KEYSC_ENTER) || uinfo.button0 || uinfo.button1)
{ {
if (State >= s_BonusRest && State < &s_BonusRest[SIZ(s_BonusRest)]) if (State >= s_BonusRest && State < &s_BonusRest[SIZ(s_BonusRest)])
{ {
@ -2738,7 +2738,7 @@ StatScreen(PLAYERp mpp)
PlaySong(voc[DIGI_ENDLEV].name, 3, TRUE, TRUE); PlaySong(voc[DIGI_ENDLEV].name, 3, TRUE, TRUE);
} }
while (!KB_KeyPressed(KEYSC_SPACE) && !KB_KeyPressed(KEYSC_ENTER)) while (!inputState.GetKeyStatus(KEYSC_SPACE) && !inputState.GetKeyStatus(KEYSC_ENTER))
{ {
handleevents(); handleevents();
@ -3443,7 +3443,7 @@ SinglePlayInput(PLAYERp pp)
int pnum = myconnectindex; int pnum = myconnectindex;
uint8_t* kp; uint8_t* kp;
if (BUTTON(gamefunc_See_Co_Op_View) && !UsingMenus && !ConPanel && dimensionmode == 3) if (inputState.BUTTON(gamefunc_See_Co_Op_View) && !UsingMenus && !ConPanel && dimensionmode == 3)
{ {
short oldscreenpeek = screenpeek; short oldscreenpeek = screenpeek;
@ -3479,7 +3479,7 @@ DebugKeys(PLAYERp pp)
{ {
short w, h; short w, h;
if (!(KB_KeyPressed(KEYSC_ALT) || KB_KeyPressed(KEYSC_RALT))) if (!(inputState.GetKeyStatus(KEYSC_ALT) || inputState.GetKeyStatus(KEYSC_RALT)))
return; return;
if (InputMode) if (InputMode)
@ -3492,9 +3492,9 @@ DebugKeys(PLAYERp pp)
// visiblity adjust // visiblity adjust
// //
if (KB_KeyPressed(KEYSC_L) > 0) if (inputState.GetKeyStatus(KEYSC_L) > 0)
{ {
if (KB_KeyPressed(KEYSC_LSHIFT) | KB_KeyPressed(KEYSC_RSHIFT)) // SHIFT if (inputState.GetKeyStatus(KEYSC_LSHIFT) | inputState.GetKeyStatus(KEYSC_RSHIFT)) // SHIFT
{ {
g_visibility = g_visibility - (g_visibility >> 3); g_visibility = g_visibility - (g_visibility >> 3);
@ -3506,7 +3506,7 @@ DebugKeys(PLAYERp pp)
} }
else else
{ {
KB_KeyPressed(KEYSC_L) = 0; inputState.GetKeyStatus(KEYSC_L) = 0;
g_visibility = g_visibility - (g_visibility >> 3); g_visibility = g_visibility - (g_visibility >> 3);
@ -3519,12 +3519,12 @@ DebugKeys(PLAYERp pp)
// parallax changes // parallax changes
// //
if (KB_KeyPressed(KEYSC_X)) if (inputState.GetKeyStatus(KEYSC_X))
{ {
if (KB_KeyPressed(KEYSC_LSHIFT)) if (inputState.GetKeyStatus(KEYSC_LSHIFT))
{ {
KB_KeyPressed(KEYSC_LSHIFT) = FALSE; inputState.GetKeyStatus(KEYSC_LSHIFT) = FALSE;
KB_KeyPressed(KEYSC_X) = 0; inputState.GetKeyStatus(KEYSC_X) = 0;
parallaxyoffs_override += 10; parallaxyoffs_override += 10;
@ -3533,7 +3533,7 @@ DebugKeys(PLAYERp pp)
} }
else else
{ {
KB_KeyPressed(KEYSC_X) = 0; inputState.GetKeyStatus(KEYSC_X) = 0;
parallaxtype++; parallaxtype++;
if (parallaxtype > 2) if (parallaxtype > 2)
parallaxtype = 0; parallaxtype = 0;
@ -3550,12 +3550,12 @@ ConKey(void)
// Console Input Panel // Console Input Panel
if (!ConPanel && dimensionmode == 3) if (!ConPanel && dimensionmode == 3)
{ {
//if (KB_KeyPressed(KEYSC_TILDE) && KB_KeyPressed(KEYSC_LSHIFT)) //if (inputState.GetKeyStatus(KEYSC_TILDE) && inputState.GetKeyStatus(KEYSC_LSHIFT))
if (KB_KeyPressed(KEYSC_TILDE)) if (inputState.GetKeyStatus(KEYSC_TILDE))
{ {
KB_KeyPressed(KEYSC_TILDE) = FALSE; inputState.GetKeyStatus(KEYSC_TILDE) = FALSE;
//KB_KeyPressed(KEYSC_LSHIFT) = FALSE; //inputState.GetKeyStatus(KEYSC_LSHIFT) = FALSE;
KB_FlushKeyboardQueue(); inputState.keyFlushChars();
ConPanel = TRUE; ConPanel = TRUE;
InputMode = TRUE; InputMode = TRUE;
ConInputMode = TRUE; ConInputMode = TRUE;
@ -3566,12 +3566,12 @@ ConKey(void)
} }
else if (ConPanel) else if (ConPanel)
{ {
//if (KB_KeyPressed(KEYSC_TILDE) && KB_KeyPressed(KEYSC_LSHIFT)) //if (inputState.GetKeyStatus(KEYSC_TILDE) && inputState.GetKeyStatus(KEYSC_LSHIFT))
if (KB_KeyPressed(KEYSC_TILDE)) if (inputState.GetKeyStatus(KEYSC_TILDE))
{ {
KB_KeyPressed(KEYSC_TILDE) = FALSE; inputState.GetKeyStatus(KEYSC_TILDE) = FALSE;
//KB_KeyPressed(KEYSC_LSHIFT) = FALSE; //inputState.GetKeyStatus(KEYSC_LSHIFT) = FALSE;
KB_FlushKeyboardQueue(); inputState.keyFlushChars();
ConPanel = FALSE; ConPanel = FALSE;
ConInputMode = FALSE; ConInputMode = FALSE;
InputMode = FALSE; InputMode = FALSE;
@ -3594,16 +3594,16 @@ FunctionKeys(PLAYERp pp)
rts_delay++; rts_delay++;
if (KB_KeyPressed(sc_F1)) { fn_key = 1; } if (inputState.GetKeyStatus(sc_F1)) { fn_key = 1; }
if (KB_KeyPressed(sc_F2)) { fn_key = 2; } if (inputState.GetKeyStatus(sc_F2)) { fn_key = 2; }
if (KB_KeyPressed(sc_F3)) { fn_key = 3; } if (inputState.GetKeyStatus(sc_F3)) { fn_key = 3; }
if (KB_KeyPressed(sc_F4)) { fn_key = 4; } if (inputState.GetKeyStatus(sc_F4)) { fn_key = 4; }
if (KB_KeyPressed(sc_F5)) { fn_key = 5; } if (inputState.GetKeyStatus(sc_F5)) { fn_key = 5; }
if (KB_KeyPressed(sc_F6)) { fn_key = 6; } if (inputState.GetKeyStatus(sc_F6)) { fn_key = 6; }
if (KB_KeyPressed(sc_F7)) { fn_key = 7; } if (inputState.GetKeyStatus(sc_F7)) { fn_key = 7; }
if (KB_KeyPressed(sc_F8)) { fn_key = 8; } if (inputState.GetKeyStatus(sc_F8)) { fn_key = 8; }
if (KB_KeyPressed(sc_F9)) { fn_key = 9; } if (inputState.GetKeyStatus(sc_F9)) { fn_key = 9; }
if (KB_KeyPressed(sc_F10)) { fn_key = 10; } if (inputState.GetKeyStatus(sc_F10)) { fn_key = 10; }
if (inputState.AltPressed()) if (inputState.AltPressed())
{ {
@ -3661,7 +3661,7 @@ FunctionKeys(PLAYERp pp)
if (numplayers <= 1) if (numplayers <= 1)
{ {
// F2 save menu // F2 save menu
if (KB_KeyPressed(KEYSC_F2)) if (inputState.GetKeyStatus(KEYSC_F2))
{ {
inputState.ClearKeyStatus(KEYSC_F2); inputState.ClearKeyStatus(KEYSC_F2);
if (!TEST(pp->Flags, PF_DEAD)) if (!TEST(pp->Flags, PF_DEAD))
@ -3672,7 +3672,7 @@ FunctionKeys(PLAYERp pp)
} }
// F3 load menu // F3 load menu
if (KB_KeyPressed(KEYSC_F3)) if (inputState.GetKeyStatus(KEYSC_F3))
{ {
inputState.ClearKeyStatus(KEYSC_F3); inputState.ClearKeyStatus(KEYSC_F3);
if (!TEST(pp->Flags, PF_DEAD)) if (!TEST(pp->Flags, PF_DEAD))
@ -3683,7 +3683,7 @@ FunctionKeys(PLAYERp pp)
} }
// F6 option menu // F6 option menu
if (KB_KeyPressed(KEYSC_F6)) if (inputState.GetKeyStatus(KEYSC_F6))
{ {
extern SWBOOL QuickSaveMode; extern SWBOOL QuickSaveMode;
inputState.ClearKeyStatus(KEYSC_F6); inputState.ClearKeyStatus(KEYSC_F6);
@ -3696,7 +3696,7 @@ FunctionKeys(PLAYERp pp)
} }
// F9 quick load // F9 quick load
if (KB_KeyPressed(KEYSC_F9)) if (inputState.GetKeyStatus(KEYSC_F9))
{ {
inputState.ClearKeyStatus(KEYSC_F9); inputState.ClearKeyStatus(KEYSC_F9);
@ -3708,7 +3708,7 @@ FunctionKeys(PLAYERp pp)
} }
else else
{ {
KB_ClearKeysDown(); inputState.ClearKeysDown();
inputState.SetKeyStatus(sc_Escape); inputState.SetKeyStatus(sc_Escape);
ControlPanelType = ct_quickloadmenu; ControlPanelType = ct_quickloadmenu;
} }
@ -3719,7 +3719,7 @@ FunctionKeys(PLAYERp pp)
// F4 sound menu // F4 sound menu
if (KB_KeyPressed(KEYSC_F4)) if (inputState.GetKeyStatus(KEYSC_F4))
{ {
inputState.ClearKeyStatus(KEYSC_F4); inputState.ClearKeyStatus(KEYSC_F4);
inputState.SetKeyStatus(sc_Escape); inputState.SetKeyStatus(sc_Escape);
@ -3728,11 +3728,11 @@ FunctionKeys(PLAYERp pp)
// F7 VIEW control // F7 VIEW control
if (KB_KeyPressed(KEYSC_F7)) if (inputState.GetKeyStatus(KEYSC_F7))
{ {
inputState.ClearKeyStatus(KEYSC_F7); inputState.ClearKeyStatus(KEYSC_F7);
if (KB_KeyPressed(KEYSC_LSHIFT) || KB_KeyPressed(KEYSC_RSHIFT)) if (inputState.GetKeyStatus(KEYSC_LSHIFT) || inputState.GetKeyStatus(KEYSC_RSHIFT))
{ {
if (TEST(pp->Flags, PF_VIEW_FROM_OUTSIDE)) if (TEST(pp->Flags, PF_VIEW_FROM_OUTSIDE))
pp->view_outside_dang = NORM_ANGLE(pp->view_outside_dang + 256); pp->view_outside_dang = NORM_ANGLE(pp->view_outside_dang + 256);
@ -3752,7 +3752,7 @@ FunctionKeys(PLAYERp pp)
} }
// F8 toggle messages // F8 toggle messages
if (KB_KeyPressed(KEYSC_F8)) if (inputState.GetKeyStatus(KEYSC_F8))
{ {
inputState.ClearKeyStatus(KEYSC_F8); inputState.ClearKeyStatus(KEYSC_F8);
@ -3765,7 +3765,7 @@ FunctionKeys(PLAYERp pp)
} }
// F10 quit menu // F10 quit menu
if (KB_KeyPressed(KEYSC_F10)) if (inputState.GetKeyStatus(KEYSC_F10))
{ {
inputState.ClearKeyStatus(KEYSC_F10); inputState.ClearKeyStatus(KEYSC_F10);
inputState.SetKeyStatus(sc_Escape); inputState.SetKeyStatus(sc_Escape);
@ -3773,7 +3773,7 @@ FunctionKeys(PLAYERp pp)
} }
// F11 gamma correction // F11 gamma correction
if (KB_KeyPressed(KEYSC_F11) > 0) if (inputState.GetKeyStatus(KEYSC_F11) > 0)
{ {
inputState.ClearKeyStatus(KEYSC_F11); inputState.ClearKeyStatus(KEYSC_F11);
// Do this entirely in the video backend. // Do this entirely in the video backend.
@ -3787,7 +3787,7 @@ void PauseKey(PLAYERp pp)
extern short QuickLoadNum; extern short QuickLoadNum;
extern SWBOOL enabled; extern SWBOOL enabled;
if (KB_KeyPressed(sc_Pause) && !CommEnabled && !InputMode && !UsingMenus && !CheatInputMode && !ConPanel) if (inputState.GetKeyStatus(sc_Pause) && !CommEnabled && !InputMode && !UsingMenus && !CheatInputMode && !ConPanel)
{ {
inputState.ClearKeyStatus(sc_Pause); inputState.ClearKeyStatus(sc_Pause);
@ -3844,10 +3844,10 @@ void GetMessageInput(PLAYERp pp)
if (!MessageInputMode && !ConInputMode) if (!MessageInputMode && !ConInputMode)
{ {
if (BUTTON(gamefunc_SendMessage)) if (inputState.BUTTON(gamefunc_SendMessage))
{ {
inputState.ClearButton(gamefunc_SendMessage); inputState.ClearButton(gamefunc_SendMessage);
KB_FlushKeyboardQueue(); inputState.keyFlushChars();
MessageInputMode = TRUE; MessageInputMode = TRUE;
InputMode = TRUE; InputMode = TRUE;
TeamSendTeam = FALSE; TeamSendTeam = FALSE;
@ -3870,8 +3870,8 @@ void GetMessageInput(PLAYERp pp)
case -1: // Cancel Input (pressed ESC) or Err case -1: // Cancel Input (pressed ESC) or Err
MessageInputMode = FALSE; MessageInputMode = FALSE;
InputMode = FALSE; InputMode = FALSE;
KB_ClearKeysDown(); inputState.ClearKeysDown();
KB_FlushKeyboardQueue(); inputState.keyFlushChars();
break; break;
case FALSE: // Input finished (RETURN) case FALSE: // Input finished (RETURN)
if (MessageInputString[0] == '\0') if (MessageInputString[0] == '\0')
@ -3879,8 +3879,8 @@ void GetMessageInput(PLAYERp pp)
// no input // no input
MessageInputMode = FALSE; MessageInputMode = FALSE;
InputMode = FALSE; InputMode = FALSE;
KB_ClearKeysDown(); inputState.ClearKeysDown();
KB_FlushKeyboardQueue(); inputState.keyFlushChars();
inputState.ClearButton(gamefunc_Inventory); inputState.ClearButton(gamefunc_Inventory);
} }
else else
@ -3913,8 +3913,8 @@ SEND_MESSAGE:
// broadcast message // broadcast message
MessageInputMode = FALSE; MessageInputMode = FALSE;
InputMode = FALSE; InputMode = FALSE;
KB_ClearKeysDown(); inputState.ClearKeysDown();
KB_FlushKeyboardQueue(); inputState.keyFlushChars();
inputState.ClearButton(gamefunc_Inventory); inputState.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
@ -4001,24 +4001,24 @@ void GetConInput(PLAYERp pp)
{ {
case -1: // Cancel Input (pressed ESC) or Err case -1: // Cancel Input (pressed ESC) or Err
InputMode = FALSE; InputMode = FALSE;
KB_ClearKeysDown(); inputState.ClearKeysDown();
KB_FlushKeyboardQueue(); inputState.keyFlushChars();
memset(MessageInputString, '\0', sizeof(MessageInputString)); memset(MessageInputString, '\0', sizeof(MessageInputString));
break; break;
case FALSE: // Input finished (RETURN) case FALSE: // Input finished (RETURN)
if (MessageInputString[0] == '\0') if (MessageInputString[0] == '\0')
{ {
InputMode = FALSE; InputMode = FALSE;
KB_ClearKeysDown(); inputState.ClearKeysDown();
KB_FlushKeyboardQueue(); inputState.keyFlushChars();
inputState.ClearButton(gamefunc_Inventory); inputState.ClearButton(gamefunc_Inventory);
memset(MessageInputString, '\0', sizeof(MessageInputString)); memset(MessageInputString, '\0', sizeof(MessageInputString));
} }
else else
{ {
InputMode = FALSE; InputMode = FALSE;
KB_ClearKeysDown(); inputState.ClearKeysDown();
KB_FlushKeyboardQueue(); inputState.keyFlushChars();
inputState.ClearButton(gamefunc_Inventory); inputState.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
@ -4041,10 +4041,10 @@ void GetHelpInput(PLAYERp pp)
{ {
extern SWBOOL GamePaused; extern SWBOOL GamePaused;
if (KB_KeyPressed(KEYSC_ALT) || KB_KeyPressed(KEYSC_RALT)) if (inputState.GetKeyStatus(KEYSC_ALT) || inputState.GetKeyStatus(KEYSC_RALT))
return; return;
if (KB_KeyPressed(KEYSC_LSHIFT) || KB_KeyPressed(KEYSC_RSHIFT)) if (inputState.GetKeyStatus(KEYSC_LSHIFT) || inputState.GetKeyStatus(KEYSC_RSHIFT))
return; return;
if (MessageInputMode || ConInputMode) if (MessageInputMode || ConInputMode)
@ -4053,7 +4053,7 @@ void GetHelpInput(PLAYERp pp)
// F1 help menu // F1 help menu
if (!HelpInputMode) if (!HelpInputMode)
{ {
if (KB_KeyPressed(KEYSC_F1)) if (inputState.GetKeyStatus(KEYSC_F1))
{ {
inputState.ClearKeyStatus(KEYSC_F11); inputState.ClearKeyStatus(KEYSC_F11);
HelpPage = 0; HelpPage = 0;
@ -4066,10 +4066,10 @@ void GetHelpInput(PLAYERp pp)
} }
else if (HelpInputMode) else if (HelpInputMode)
{ {
if (KB_KeyPressed(KEYSC_ESC)) if (inputState.GetKeyStatus(KEYSC_ESC))
{ {
inputState.ClearKeyStatus(sc_Escape); inputState.ClearKeyStatus(sc_Escape);
KB_ClearKeysDown(); inputState.ClearKeysDown();
PanelUpdateMode = TRUE; PanelUpdateMode = TRUE;
HelpInputMode = FALSE; HelpInputMode = FALSE;
InputMode = FALSE; InputMode = FALSE;
@ -4078,7 +4078,7 @@ void GetHelpInput(PLAYERp pp)
SetRedrawScreen(pp); SetRedrawScreen(pp);
} }
if (KB_KeyPressed(KEYSC_SPACE) || KB_KeyPressed(KEYSC_ENTER) || KB_KeyPressed(KEYSC_PGDN) || KB_KeyPressed(KEYSC_DOWN) || KB_KeyPressed(KEYSC_RIGHT) || KB_KeyPressed(sc_kpad_3) || KB_KeyPressed(sc_kpad_2) || KB_KeyPressed(sc_kpad_6)) if (inputState.GetKeyStatus(KEYSC_SPACE) || inputState.GetKeyStatus(KEYSC_ENTER) || inputState.GetKeyStatus(KEYSC_PGDN) || inputState.GetKeyStatus(KEYSC_DOWN) || inputState.GetKeyStatus(KEYSC_RIGHT) || inputState.GetKeyStatus(sc_kpad_3) || inputState.GetKeyStatus(sc_kpad_2) || inputState.GetKeyStatus(sc_kpad_6))
{ {
inputState.ClearKeyStatus(KEYSC_SPACE); inputState.ClearKeyStatus(KEYSC_SPACE);
inputState.ClearKeyStatus(KEYSC_ENTER); inputState.ClearKeyStatus(KEYSC_ENTER);
@ -4098,7 +4098,7 @@ void GetHelpInput(PLAYERp pp)
// CTW MODIFICATION END // CTW MODIFICATION END
} }
if (KB_KeyPressed(KEYSC_PGUP) || KB_KeyPressed(KEYSC_UP) || KB_KeyPressed(KEYSC_LEFT) || KB_KeyPressed(sc_kpad_9) || KB_KeyPressed(sc_kpad_8) || KB_KeyPressed(sc_kpad_4)) if (inputState.GetKeyStatus(KEYSC_PGUP) || inputState.GetKeyStatus(KEYSC_UP) || inputState.GetKeyStatus(KEYSC_LEFT) || inputState.GetKeyStatus(sc_kpad_9) || inputState.GetKeyStatus(sc_kpad_8) || inputState.GetKeyStatus(sc_kpad_4))
{ {
inputState.ClearKeyStatus(KEYSC_PGUP); inputState.ClearKeyStatus(KEYSC_PGUP);
inputState.ClearKeyStatus(KEYSC_UP); inputState.ClearKeyStatus(KEYSC_UP);
@ -4167,7 +4167,7 @@ getinput(SW_PACKET *loc)
if (in_aimmode) if (in_aimmode)
g_MyAimMode = 0; g_MyAimMode = 0;
if (BUTTON(gamefunc_Mouse_Aiming)) if (inputState.BUTTON(gamefunc_Mouse_Aiming))
{ {
if (in_aimmode) if (in_aimmode)
g_MyAimMode = 1; g_MyAimMode = 1;
@ -4205,7 +4205,7 @@ getinput(SW_PACKET *loc)
} }
// MAP KEY // MAP KEY
if (BUTTON(gamefunc_Map)) if (inputState.BUTTON(gamefunc_Map))
{ {
inputState.ClearButton(gamefunc_Map); inputState.ClearButton(gamefunc_Map);
@ -4230,7 +4230,7 @@ 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 (BUTTON(gamefunc_Map_Follow_Mode)) if (inputState.BUTTON(gamefunc_Map_Follow_Mode))
{ {
inputState.ClearButton(gamefunc_Map_Follow_Mode); inputState.ClearButton(gamefunc_Map_Follow_Mode);
ScrollMode2D = !ScrollMode2D; ScrollMode2D = !ScrollMode2D;
@ -4249,11 +4249,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, ((!!KB_KeyPressed(KEYSC_SPACE)) | BUTTON(gamefunc_Open))); SET_LOC_KEY(loc->bits, SK_SPACE_BAR, ((!!inputState.GetKeyStatus(KEYSC_SPACE)) | inputState.BUTTON(gamefunc_Open)));
running = G_CheckAutorun(BUTTON(gamefunc_Run)); running = G_CheckAutorun(inputState.BUTTON(gamefunc_Run));
if (BUTTON(gamefunc_Strafe) && !pp->sop) if (inputState.BUTTON(gamefunc_Strafe) && !pp->sop)
svel = -info.dyaw; svel = -info.dyaw;
else else
{ {
@ -4291,16 +4291,16 @@ getinput(SW_PACKET *loc)
keymove = NORMALKEYMOVE; keymove = NORMALKEYMOVE;
} }
if (BUTTON(gamefunc_Strafe) && !pp->sop) if (inputState.BUTTON(gamefunc_Strafe) && !pp->sop)
{ {
if (BUTTON(gamefunc_Turn_Left)) if (inputState.BUTTON(gamefunc_Turn_Left))
svel -= -keymove; svel -= -keymove;
if (BUTTON(gamefunc_Turn_Right)) if (inputState.BUTTON(gamefunc_Turn_Right))
svel -= keymove; svel -= keymove;
} }
else else
{ {
if (BUTTON(gamefunc_Turn_Left)) if (inputState.BUTTON(gamefunc_Turn_Left))
{ {
turnheldtime += synctics; turnheldtime += synctics;
if (turnheldtime >= TURBOTURNTIME) if (turnheldtime >= TURBOTURNTIME)
@ -4308,7 +4308,7 @@ getinput(SW_PACKET *loc)
else else
angvel -= PREAMBLETURN; angvel -= PREAMBLETURN;
} }
else if (BUTTON(gamefunc_Turn_Right)) else if (inputState.BUTTON(gamefunc_Turn_Right))
{ {
turnheldtime += synctics; turnheldtime += synctics;
if (turnheldtime >= TURBOTURNTIME) if (turnheldtime >= TURBOTURNTIME)
@ -4322,13 +4322,13 @@ getinput(SW_PACKET *loc)
} }
} }
if (BUTTON(gamefunc_Strafe_Left) && !pp->sop) if (inputState.BUTTON(gamefunc_Strafe_Left) && !pp->sop)
svel += keymove; svel += keymove;
if (BUTTON(gamefunc_Strafe_Right) && !pp->sop) if (inputState.BUTTON(gamefunc_Strafe_Right) && !pp->sop)
svel += -keymove; svel += -keymove;
if (BUTTON(gamefunc_Move_Forward)) if (inputState.BUTTON(gamefunc_Move_Forward))
{ {
vel += keymove; vel += keymove;
//DSPRINTF(ds,"vel key %d",vel); //DSPRINTF(ds,"vel key %d",vel);
@ -4340,7 +4340,7 @@ getinput(SW_PACKET *loc)
//DebugWriteString(ds); //DebugWriteString(ds);
} }
if (BUTTON(gamefunc_Move_Backward)) if (inputState.BUTTON(gamefunc_Move_Backward))
vel += -keymove; vel += -keymove;
@ -4377,36 +4377,36 @@ getinput(SW_PACKET *loc)
SET_LOC_KEY(loc->bits, SK_AUTO_AIM, TRUE); SET_LOC_KEY(loc->bits, SK_AUTO_AIM, TRUE);
} }
} }
else if (KB_KeyPressed(sc_Pause)) else if (inputState.GetKeyStatus(sc_Pause))
{ {
SET_LOC_KEY(loc->bits, SK_PAUSE, KB_KeyPressed(sc_Pause)); SET_LOC_KEY(loc->bits, SK_PAUSE, inputState.GetKeyStatus(sc_Pause));
inputState.ClearKeyStatus(sc_Pause); inputState.ClearKeyStatus(sc_Pause);
} }
SET_LOC_KEY(loc->bits, SK_CENTER_VIEW, BUTTON(gamefunc_Center_View)); SET_LOC_KEY(loc->bits, SK_CENTER_VIEW, inputState.BUTTON(gamefunc_Center_View));
SET_LOC_KEY(loc->bits, SK_RUN, BUTTON(gamefunc_Run)); SET_LOC_KEY(loc->bits, SK_RUN, inputState.BUTTON(gamefunc_Run));
SET_LOC_KEY(loc->bits, SK_SHOOT, BUTTON(gamefunc_Fire)); SET_LOC_KEY(loc->bits, SK_SHOOT, inputState.BUTTON(gamefunc_Fire));
// actually snap // actually snap
SET_LOC_KEY(loc->bits, SK_SNAP_UP, BUTTON(gamefunc_Aim_Up)); SET_LOC_KEY(loc->bits, SK_SNAP_UP, inputState.BUTTON(gamefunc_Aim_Up));
SET_LOC_KEY(loc->bits, SK_SNAP_DOWN, BUTTON(gamefunc_Aim_Down)); SET_LOC_KEY(loc->bits, SK_SNAP_DOWN, inputState.BUTTON(gamefunc_Aim_Down));
// actually just look // actually just look
SET_LOC_KEY(loc->bits, SK_LOOK_UP, BUTTON(gamefunc_Look_Up)); SET_LOC_KEY(loc->bits, SK_LOOK_UP, inputState.BUTTON(gamefunc_Look_Up));
SET_LOC_KEY(loc->bits, SK_LOOK_DOWN, BUTTON(gamefunc_Look_Down)); SET_LOC_KEY(loc->bits, SK_LOOK_DOWN, inputState.BUTTON(gamefunc_Look_Down));
for (i = 0; i < MAX_WEAPONS_KEYS; i++) for (i = 0; i < MAX_WEAPONS_KEYS; i++)
{ {
if (BUTTON(gamefunc_Weapon_1 + i)) if (inputState.BUTTON(gamefunc_Weapon_1 + i))
{ {
SET(loc->bits, i + 1); SET(loc->bits, i + 1);
break; break;
} }
} }
if (BUTTON(gamefunc_Next_Weapon)) if (inputState.BUTTON(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;
@ -4446,7 +4446,7 @@ getinput(SW_PACKET *loc)
} }
if (BUTTON(gamefunc_Previous_Weapon)) if (inputState.BUTTON(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;
@ -4484,40 +4484,40 @@ getinput(SW_PACKET *loc)
} }
inv_hotkey = 0; inv_hotkey = 0;
if (BUTTON(gamefunc_Med_Kit)) if (inputState.BUTTON(gamefunc_Med_Kit))
inv_hotkey = INVENTORY_MEDKIT+1; inv_hotkey = INVENTORY_MEDKIT+1;
if (BUTTON(gamefunc_Smoke_Bomb)) if (inputState.BUTTON(gamefunc_Smoke_Bomb))
inv_hotkey = INVENTORY_CLOAK+1; inv_hotkey = INVENTORY_CLOAK+1;
if (BUTTON(gamefunc_Night_Vision)) if (inputState.BUTTON(gamefunc_Night_Vision))
inv_hotkey = INVENTORY_NIGHT_VISION+1; inv_hotkey = INVENTORY_NIGHT_VISION+1;
if (BUTTON(gamefunc_Gas_Bomb)) if (inputState.BUTTON(gamefunc_Gas_Bomb))
inv_hotkey = INVENTORY_CHEMBOMB+1; inv_hotkey = INVENTORY_CHEMBOMB+1;
if (BUTTON(gamefunc_Flash_Bomb) && dimensionmode == 3) if (inputState.BUTTON(gamefunc_Flash_Bomb) && dimensionmode == 3)
inv_hotkey = INVENTORY_FLASHBOMB+1; inv_hotkey = INVENTORY_FLASHBOMB+1;
if (BUTTON(gamefunc_Caltrops)) if (inputState.BUTTON(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, BUTTON(gamefunc_Inventory)); SET_LOC_KEY(loc->bits, SK_INV_USE, inputState.BUTTON(gamefunc_Inventory));
SET_LOC_KEY(loc->bits, SK_OPERATE, BUTTON(gamefunc_Open)); SET_LOC_KEY(loc->bits, SK_OPERATE, inputState.BUTTON(gamefunc_Open));
SET_LOC_KEY(loc->bits, SK_JUMP, BUTTON(gamefunc_Jump)); SET_LOC_KEY(loc->bits, SK_JUMP, inputState.BUTTON(gamefunc_Jump));
SET_LOC_KEY(loc->bits, SK_CRAWL, BUTTON(gamefunc_Crouch)); SET_LOC_KEY(loc->bits, SK_CRAWL, inputState.BUTTON(gamefunc_Crouch));
SET_LOC_KEY(loc->bits, SK_TURN_180, BUTTON(gamefunc_TurnAround)); SET_LOC_KEY(loc->bits, SK_TURN_180, inputState.BUTTON(gamefunc_TurnAround));
SET_LOC_KEY(loc->bits, SK_INV_LEFT, BUTTON(gamefunc_Inventory_Left)); SET_LOC_KEY(loc->bits, SK_INV_LEFT, inputState.BUTTON(gamefunc_Inventory_Left));
SET_LOC_KEY(loc->bits, SK_INV_RIGHT, BUTTON(gamefunc_Inventory_Right)); SET_LOC_KEY(loc->bits, SK_INV_RIGHT, inputState.BUTTON(gamefunc_Inventory_Right));
SET_LOC_KEY(loc->bits, SK_HIDE_WEAPON, BUTTON(gamefunc_Holster_Weapon)); SET_LOC_KEY(loc->bits, SK_HIDE_WEAPON, inputState.BUTTON(gamefunc_Holster_Weapon));
// need BUTTON // need BUTTON
SET_LOC_KEY(loc->bits, SK_CRAWL_LOCK, KB_KeyPressed(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 (BUTTON(gamefunc_See_Co_Op_View)) if (inputState.BUTTON(gamefunc_See_Co_Op_View))
{ {
inputState.ClearButton(gamefunc_See_Co_Op_View); inputState.ClearButton(gamefunc_See_Co_Op_View);
@ -4556,7 +4556,7 @@ getinput(SW_PACKET *loc)
FunctionKeys(pp); FunctionKeys(pp);
if (BUTTON(gamefunc_Toggle_Crosshair)) if (inputState.BUTTON(gamefunc_Toggle_Crosshair))
{ {
inputState.ClearButton(gamefunc_Toggle_Crosshair); inputState.ClearButton(gamefunc_Toggle_Crosshair);
pToggleCrosshair(pp); pToggleCrosshair(pp);

View file

@ -621,10 +621,10 @@ MNU_ParentalCustom(void)
else else
{ {
// clear keyboard buffer // clear keyboard buffer
while (KB_KeyWaiting()) while (inputState.keyBufferWaiting())
{ {
if (KB_GetCh() == 0) if (inputState.keyGetChar() == 0)
KB_GetCh(); inputState.keyGetChar();
} }
// toggle edit mode // toggle edit mode
@ -672,14 +672,14 @@ SWBOOL MNU_KeySetupCustom(UserCall call, MenuItem *item)
short w, h = 8; short w, h = 8;
int i, j, y; int i, j, y;
if (KB_KeyPressed(KEYSC_ESC)) if (inputState.GetKeyStatus(KEYSC_ESC))
{ {
KB_ClearKeyDown(sc_Escape); inputState.ClearKeyStatus(sc_Escape);
currentmode = 0; currentmode = 0;
} }
else if (KB_GetLastScanCode() > 0) else if (inputState.GetLastScanCode() > 0)
{ {
KB_ClearKeyDown(KB_GetLastScanCode()); inputState.ClearKeyStatus(inputState.GetLastScanCode());
//KeyboardKeys[currentkey][currentcol] = KB_GetLastScanCode(); //KeyboardKeys[currentkey][currentcol] = KB_GetLastScanCode();
if (currentkey != gamefunc_Show_Console) if (currentkey != gamefunc_Show_Console)
@ -692,7 +692,7 @@ SWBOOL MNU_KeySetupCustom(UserCall call, MenuItem *item)
} }
else else
{ {
OSD_CaptureKey(KB_GetLastScanCode()); OSD_CaptureKey(inputState.GetLastScanCode());
} }
currentmode = 0; currentmode = 0;
@ -726,48 +726,48 @@ SWBOOL MNU_KeySetupCustom(UserCall call, MenuItem *item)
UserInput inpt = {FALSE,FALSE,dir_None}; UserInput inpt = {FALSE,FALSE,dir_None};
CONTROL_GetUserInput(&inpt); CONTROL_GetUserInput(&inpt);
if (KB_KeyPressed(KEYSC_ESC) || inpt.button1) if (inputState.GetKeyStatus(KEYSC_ESC) || inpt.button1)
{ {
inputState.ClearKeyStatus(sc_Escape); inputState.ClearKeyStatus(sc_Escape);
cust_callback = NULL; cust_callback = NULL;
CONTROL_ClearUserInput(&inpt); CONTROL_ClearUserInput(&inpt);
return TRUE; return TRUE;
} }
else if (KB_KeyPressed(sc_Delete)) else if (inputState.GetKeyStatus(sc_Delete))
{ {
KB_ClearKeyDown(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(CONFIG_FunctionNumToName(M_KEYBOARDKEYS.currentEntry));
} }
} }
else if (KB_KeyPressed(sc_Home)) else if (inputState.GetKeyStatus(sc_Home))
{ {
currentkey = 0; currentkey = 0;
KB_ClearKeyDown(sc_Home); inputState.ClearKeyStatus(sc_Home);
} }
else if (KB_KeyPressed(sc_End)) else if (inputState.GetKeyStatus(sc_End))
{ {
currentkey = NUMGAMEFUNCTIONS-1; currentkey = NUMGAMEFUNCTIONS-1;
KB_ClearKeyDown(sc_End); inputState.ClearKeyStatus(sc_End);
} }
else if (KB_KeyPressed(sc_PgDn)) else if (inputState.GetKeyStatus(sc_PgDn))
{ {
currentkey += PGSIZ; currentkey += PGSIZ;
if (currentkey >= NUMGAMEFUNCTIONS) currentkey = NUMGAMEFUNCTIONS-1; if (currentkey >= NUMGAMEFUNCTIONS) currentkey = NUMGAMEFUNCTIONS-1;
KB_ClearKeyDown(sc_PgDn); inputState.ClearKeyStatus(sc_PgDn);
} }
else if (KB_KeyPressed(sc_PgUp)) else if (inputState.GetKeyStatus(sc_PgUp))
{ {
currentkey -= PGSIZ; currentkey -= PGSIZ;
if (currentkey < 0) currentkey = 0; if (currentkey < 0) currentkey = 0;
KB_ClearKeyDown(sc_PgUp); inputState.ClearKeyStatus(sc_PgUp);
} }
else if (inpt.button0) else if (inpt.button0)
{ {
currentmode = 1; currentmode = 1;
KB_ClearLastScanCode(); inputState.ClearLastScanCode();
KB_ClearKeysDown(); inputState.ClearKeysDown();
} }
else if (inpt.dir == dir_North) currentkey = max(0,currentkey-1); else if (inpt.dir == dir_North) currentkey = max(0,currentkey-1);
else if (inpt.dir == dir_South) currentkey = min(NUMGAMEFUNCTIONS-1,currentkey+1); else if (inpt.dir == dir_South) currentkey = min(NUMGAMEFUNCTIONS-1,currentkey+1);
@ -852,30 +852,30 @@ static int MNU_SelectButtonFunction(const char *buttonname, int *currentfunc)
if (inpt.button1) if (inpt.button1)
{ {
KB_ClearKeyDown(sc_Escape); inputState.ClearKeyStatus(sc_Escape);
returnval = -1; returnval = -1;
} }
else if (KB_KeyPressed(sc_Home)) else if (inputState.GetKeyStatus(sc_Home))
{ {
*currentfunc = 0; *currentfunc = 0;
KB_ClearKeyDown(sc_Home); inputState.ClearKeyStatus(sc_Home);
} }
else if (KB_KeyPressed(sc_End)) else if (inputState.GetKeyStatus(sc_End))
{ {
*currentfunc = NUMGAMEFUNCTIONS-1; // -1 because the last one is the console and the top is 'none' *currentfunc = NUMGAMEFUNCTIONS-1; // -1 because the last one is the console and the top is 'none'
KB_ClearKeyDown(sc_End); inputState.ClearKeyStatus(sc_End);
} }
else if (KB_KeyPressed(sc_PgDn)) else if (inputState.GetKeyStatus(sc_PgDn))
{ {
*currentfunc += PGSIZ; *currentfunc += PGSIZ;
if (*currentfunc >= NUMGAMEFUNCTIONS) *currentfunc = NUMGAMEFUNCTIONS-1; if (*currentfunc >= NUMGAMEFUNCTIONS) *currentfunc = NUMGAMEFUNCTIONS-1;
KB_ClearKeyDown(sc_PgDn); inputState.ClearKeyStatus(sc_PgDn);
} }
else if (KB_KeyPressed(sc_PgUp)) else if (inputState.GetKeyStatus(sc_PgUp))
{ {
*currentfunc -= PGSIZ; *currentfunc -= PGSIZ;
if (*currentfunc < 0) *currentfunc = 0; if (*currentfunc < 0) *currentfunc = 0;
KB_ClearKeyDown(sc_PgUp); inputState.ClearKeyStatus(sc_PgUp);
} }
else if (inpt.button0) else if (inpt.button0)
{ {
@ -1571,7 +1571,7 @@ MNU_OrderCustom(UserCall call, MenuItem *item)
CONTROL_GetUserInput(&tst_input); CONTROL_GetUserInput(&tst_input);
//order_input_buffered.dir = tst_input.dir; //order_input_buffered.dir = tst_input.dir;
// Support a few other keys too // Support a few other keys too
if (KB_KeyPressed(KEYSC_SPACE)||KB_KeyPressed(KEYSC_ENTER)) if (inputState.GetKeyStatus(KEYSC_SPACE)||inputState.GetKeyStatus(KEYSC_ENTER))
{ {
inputState.ClearKeyStatus(KEYSC_SPACE); inputState.ClearKeyStatus(KEYSC_SPACE);
inputState.ClearKeyStatus(KEYSC_ENTER); inputState.ClearKeyStatus(KEYSC_ENTER);
@ -1611,7 +1611,7 @@ MNU_OrderCustom(UserCall call, MenuItem *item)
order_input_buffered.dir = tst_input.dir; order_input_buffered.dir = tst_input.dir;
} }
if (!KB_KeyPressed(KEYSC_ESC) && !order_input_buffered.button1) if (!inputState.GetKeyStatus(KEYSC_ESC) && !order_input_buffered.button1)
{ {
cust_callback = MNU_OrderCustom; cust_callback = MNU_OrderCustom;
cust_callback_call = call; cust_callback_call = call;
@ -1751,7 +1751,7 @@ MNU_OrderCustom(UserCall call, MenuItem *item)
} }
} }
//KB_ClearKeysDown(); //inputState.ClearKeysDown();
return TRUE; return TRUE;
} }
@ -1952,7 +1952,7 @@ MNU_QuitCustom(UserCall call, MenuItem_p item)
if (!ret) if (!ret)
{ {
if (!mnu_input.button1 && !KB_KeyPressed(sc_N)) if (!mnu_input.button1 && !inputState.GetKeyStatus(sc_N))
{ {
cust_callback = MNU_QuitCustom; cust_callback = MNU_QuitCustom;
cust_callback_call = call; cust_callback_call = call;
@ -1970,7 +1970,7 @@ MNU_QuitCustom(UserCall call, MenuItem_p item)
ExitMenus(); ExitMenus();
} }
if (KB_KeyPressed(sc_Y) || KB_KeyPressed(sc_Enter) || mnu_input.button0) if (inputState.GetKeyStatus(sc_Y) || inputState.GetKeyStatus(sc_Enter) || mnu_input.button0)
{ {
if (CommPlayers >= 2) if (CommPlayers >= 2)
MultiPlayQuitFlag = TRUE; MultiPlayQuitFlag = TRUE;
@ -1980,7 +1980,7 @@ MNU_QuitCustom(UserCall call, MenuItem_p item)
ExitMenus(); ExitMenus();
} }
KB_ClearKeysDown(); inputState.ClearKeysDown();
return TRUE; return TRUE;
} }
@ -2021,7 +2021,7 @@ MNU_QuickLoadCustom(UserCall call, MenuItem_p item)
if (ret == FALSE) if (ret == FALSE)
{ {
if (KB_KeyPressed(sc_N) || KB_KeyPressed(sc_Space) || KB_KeyPressed(sc_Enter)) if (inputState.GetKeyStatus(sc_N) || inputState.GetKeyStatus(sc_Space) || inputState.GetKeyStatus(sc_Enter))
{ {
cust_callback = NULL; cust_callback = NULL;
if (ReloadPrompt) if (ReloadPrompt)
@ -2033,7 +2033,7 @@ MNU_QuickLoadCustom(UserCall call, MenuItem_p item)
GlobInfoStringTime = bak; GlobInfoStringTime = bak;
} }
KB_ClearKeysDown(); inputState.ClearKeysDown();
ExitMenus(); ExitMenus();
} }
else else
@ -2048,7 +2048,7 @@ MNU_QuickLoadCustom(UserCall call, MenuItem_p item)
// Y pressed // Y pressed
cust_callback = NULL; cust_callback = NULL;
KB_ClearKeysDown(); inputState.ClearKeysDown();
LoadSaveMsg("Loading..."); LoadSaveMsg("Loading...");
PauseAction(); PauseAction();
@ -2064,11 +2064,11 @@ MNU_QuickLoadCustom(UserCall call, MenuItem_p item)
LastSaveNum = -1; LastSaveNum = -1;
// do a load game here // do a load game here
KB_ClearKeysDown(); inputState.ClearKeysDown();
ExitMenus(); ExitMenus();
} }
KB_ClearKeysDown(); inputState.ClearKeysDown();
return TRUE; return TRUE;
} }
@ -2448,14 +2448,14 @@ MNU_InputSmallString(char *name, short pix_width)
} }
} }
while (KB_KeyWaiting()) while (inputState.keyBufferWaiting())
{ {
ch = KB_GetCh(); ch = inputState.keyGetChar();
// skip any extended key // skip any extended key
if (ch == 0) if (ch == 0)
{ {
ch = KB_GetCh(); ch = inputState.keyGetChar();
if (ch == 104) // extended enter if (ch == 104) // extended enter
ch = ascii_return; ch = ascii_return;
else else
@ -2525,7 +2525,7 @@ MNU_Dialog(void)
CONTROL_ClearUserInput(&mnu_input); CONTROL_ClearUserInput(&mnu_input);
CONTROL_GetUserInput(&mnu_input); CONTROL_GetUserInput(&mnu_input);
if (KB_KeyPressed(sc_Y) || KB_KeyPressed(sc_Enter) || mnu_input.button0) if (inputState.GetKeyStatus(sc_Y) || inputState.GetKeyStatus(sc_Enter) || mnu_input.button0)
return TRUE; return TRUE;
else else
return FALSE; return FALSE;
@ -2545,9 +2545,9 @@ MNU_InputString(char *name, short pix_width)
#define ascii_esc 27 #define ascii_esc 27
#define ascii_return 13 #define ascii_return 13
while (KB_KeyWaiting()) while (inputState.keyBufferWaiting())
{ {
ch = KB_GetCh(); ch = inputState.keyGetChar();
////DSPRINTF(ds, "%c %d", ch, ch); ////DSPRINTF(ds, "%c %d", ch, ch);
//MONO_PRINT(ds); //MONO_PRINT(ds);
@ -2555,7 +2555,7 @@ MNU_InputString(char *name, short pix_width)
// skip most extended keys // skip most extended keys
if (ch == 0) if (ch == 0)
{ {
ch = KB_GetCh(); ch = inputState.keyGetChar();
////DSPRINTF(ds, "extended key %c %d", ch, ch); ////DSPRINTF(ds, "extended key %c %d", ch, ch);
//MONO_PRINT(ds); //MONO_PRINT(ds);
@ -2723,10 +2723,10 @@ MNU_GetSaveCustom(void)
strcpy(BackupSaveGameDescr, SaveGameDescr[save_num]); strcpy(BackupSaveGameDescr, SaveGameDescr[save_num]);
// clear keyboard buffer // clear keyboard buffer
while (KB_KeyWaiting()) while (inputState.keyBufferWaiting())
{ {
if (KB_GetCh() == 0) if (inputState.keyGetChar() == 0)
KB_GetCh(); inputState.keyGetChar();
} }
// toggle edit mode // toggle edit mode
@ -2800,8 +2800,8 @@ MNU_LoadSaveMove(UserCall call, MenuItem_p item)
QuickSaveMode = FALSE; QuickSaveMode = FALSE;
MenuInputMode = TRUE; MenuInputMode = TRUE;
strcpy(BackupSaveGameDescr, SaveGameDescr[game_num]); strcpy(BackupSaveGameDescr, SaveGameDescr[game_num]);
KB_ClearKeysDown(); inputState.ClearKeysDown();
KB_FlushKeyboardQueue(); inputState.keyFlushChars();
} }
LastSaveNum = game_num; LastSaveNum = game_num;
@ -2813,17 +2813,17 @@ MNU_LoadSaveMove(UserCall call, MenuItem_p item)
if (SavePrompt) if (SavePrompt)
{ {
if (KB_KeyPressed(sc_Y) || KB_KeyPressed(sc_Enter)) if (inputState.GetKeyStatus(sc_Y) || inputState.GetKeyStatus(sc_Enter))
{ {
KB_ClearKeyDown(sc_Y); inputState.ClearKeyStatus(sc_Y);
KB_ClearKeyDown(sc_Enter); inputState.ClearKeyStatus(sc_Enter);
SavePrompt = FALSE; SavePrompt = FALSE;
// use input // use input
item->custom(); item->custom();
} }
else if (KB_KeyPressed(sc_N)) else if (inputState.GetKeyStatus(sc_N))
{ {
KB_ClearKeyDown(sc_N); inputState.ClearKeyStatus(sc_N);
strcpy(SaveGameDescr[game_num], BackupSaveGameDescr); strcpy(SaveGameDescr[game_num], BackupSaveGameDescr);
SavePrompt = FALSE; SavePrompt = FALSE;
MenuInputMode = FALSE; MenuInputMode = FALSE;
@ -2836,7 +2836,7 @@ MNU_LoadSaveMove(UserCall call, MenuItem_p item)
case -1: // Cancel Input (pressed ESC) or Err case -1: // Cancel Input (pressed ESC) or Err
strcpy(SaveGameDescr[game_num], BackupSaveGameDescr); strcpy(SaveGameDescr[game_num], BackupSaveGameDescr);
MenuInputMode = FALSE; MenuInputMode = FALSE;
KB_ClearKeysDown(); inputState.ClearKeysDown();
break; break;
case FALSE: // Input finished (RETURN) case FALSE: // Input finished (RETURN)
// no input // no input
@ -2849,7 +2849,7 @@ MNU_LoadSaveMove(UserCall call, MenuItem_p item)
{ {
GotInput = TRUE; GotInput = TRUE;
} }
KB_ClearKeyDown(sc_Enter); inputState.ClearKeyStatus(sc_Enter);
break; break;
case TRUE: // Got input case TRUE: // Got input
break; break;
@ -4369,7 +4369,7 @@ MNU_DoHotkey(void)
index = 0; index = 0;
for (item = currentmenu->items; item->type != mt_none; item++) for (item = currentmenu->items; item->type != mt_none; item++)
{ {
if (KB_KeyPressed(item->hotkey) && item->hotkey != 0) if (inputState.GetKeyStatus(item->hotkey) && item->hotkey != 0)
{ {
MNU_SelectItem(currentmenu, index, FALSE); MNU_SelectItem(currentmenu, index, FALSE);
return TRUE; return TRUE;
@ -4498,7 +4498,7 @@ void MNU_DoMenu(CTLType type, PLAYERp pp)
static int handle5=0; static int handle5=0;
if (!FX_SoundActive(handle5)) if (!FX_SoundActive(handle5))
handle5 = PlaySound(DIGI_SWORDSWOOSH,&zero,&zero,&zero,v3df_dontpan); handle5 = PlaySound(DIGI_SWORDSWOOSH,&zero,&zero,&zero,v3df_dontpan);
KB_ClearKeysDown(); inputState.ClearKeysDown();
MNU_DoItem(); MNU_DoItem();
resetitem = TRUE; resetitem = TRUE;
} }
@ -4540,7 +4540,7 @@ void MNU_DoMenu(CTLType type, PLAYERp pp)
if (resetitem) if (resetitem)
{ {
KB_ClearKeysDown(); inputState.ClearKeysDown();
ResetKeys(); ResetKeys();
} }
} }
@ -4560,10 +4560,10 @@ MNU_CheckForMenus(void)
} }
else else
{ {
if ((KB_KeyPressed(KEYSC_ESC)) && dimensionmode == 3 && !ConPanel) if ((inputState.GetKeyStatus(KEYSC_ESC)) && dimensionmode == 3 && !ConPanel)
{ {
inputState.ClearKeyStatus(sc_Escape); inputState.ClearKeyStatus(sc_Escape);
KB_ClearKeysDown(); inputState.ClearKeysDown();
// setup sliders/buttons // setup sliders/buttons
MNU_InitMenus(); MNU_InitMenus();
MNU_DoMenu(ct_mainmenu, Player + myconnectindex); MNU_DoMenu(ct_mainmenu, Player + myconnectindex);
@ -4586,7 +4586,7 @@ MNU_CheckForMenusAnyKey(void)
if (KeyPressed()) if (KeyPressed())
{ {
ResetKeys(); ResetKeys();
KB_ClearKeysDown(); inputState.ClearKeysDown();
MNU_InitMenus(); MNU_InitMenus();
MNU_DoMenu(ct_mainmenu, Player + myconnectindex); MNU_DoMenu(ct_mainmenu, Player + myconnectindex);
pMenuClearTextLine(Player + myconnectindex); pMenuClearTextLine(Player + myconnectindex);

View file

@ -637,7 +637,7 @@ waitforeverybody(void)
} }
#endif #endif
//KB_KeyPressed(KEYSC_ESC) = FALSE; //inputState.GetKeyStatus(KEYSC_ESC) = FALSE;
Player[myconnectindex].playerreadyflag++; Player[myconnectindex].playerreadyflag++;
while (TRUE) while (TRUE)
@ -657,7 +657,7 @@ waitforeverybody(void)
if (quitevent || (wfe_ExitCallback && wfe_ExitCallback())) if (quitevent || (wfe_ExitCallback && wfe_ExitCallback()))
{ {
// allow exit // allow exit
//if (KB_KeyPressed(KEYSC_ESC)) //if (inputState.GetKeyStatus(KEYSC_ESC))
{ {
short pnum; short pnum;
//TRAVERSE_CONNECT(pnum) //TRAVERSE_CONNECT(pnum)
@ -940,7 +940,7 @@ faketimerhandler(void)
extern SWBOOL BotMode; extern SWBOOL BotMode;
#if 0 #if 0
if (KB_KeyPressed(KEYSC_PERIOD)) if (inputState.GetKeyStatus(KEYSC_PERIOD))
{ {
extern unsigned int MoveThingsCount; extern unsigned int MoveThingsCount;
MoveThingsCount++; MoveThingsCount++;

View file

@ -1580,17 +1580,17 @@ pSwordRest(PANEL_SPRITEp psp)
SWBOOL force = !!TEST(psp->flags, PANF_UNHIDE_SHOOT); SWBOOL force = !!TEST(psp->flags, PANF_UNHIDE_SHOOT);
#if 0 #if 0
if (KB_KeyPressed(KEYSC_SEMI)) if (inputState.GetKeyStatus(KEYSC_SEMI))
{ {
KB_KeyPressed(KEYSC_SEMI) = 0; inputState.GetKeyStatus(KEYSC_SEMI) = 0;
SwordAng -= 4; SwordAng -= 4;
//DSPRINTF(ds,"SwordAng %d", SwordAng); //DSPRINTF(ds,"SwordAng %d", SwordAng);
MONO_PRINT(ds); MONO_PRINT(ds);
} }
if (KB_KeyPressed(KEYSC_QUOTE)) if (inputState.GetKeyStatus(KEYSC_QUOTE))
{ {
KB_KeyPressed(KEYSC_QUOTE) = 0; inputState.GetKeyStatus(KEYSC_QUOTE) = 0;
SwordAng += 4; SwordAng += 4;
//DSPRINTF(ds,"SwordAng %d", SwordAng); //DSPRINTF(ds,"SwordAng %d", SwordAng);
MONO_PRINT(ds); MONO_PRINT(ds);

View file

@ -2419,14 +2419,14 @@ MoveScrollMode2D(PLAYERp pp)
return; return;
// Recenter view if told // Recenter view if told
if (BUTTON(gamefunc_Center_View)) if (inputState.BUTTON(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 (BUTTON(gamefunc_Map_Follow_Mode)) if (inputState.BUTTON(gamefunc_Map_Follow_Mode))
{ {
inputState.ClearButton(gamefunc_Map_Follow_Mode); inputState.ClearButton(gamefunc_Map_Follow_Mode);
ScrollMode2D = !ScrollMode2D; ScrollMode2D = !ScrollMode2D;
@ -2435,9 +2435,9 @@ MoveScrollMode2D(PLAYERp pp)
Follow_posy = pp->posy; Follow_posy = pp->posy;
} }
running = G_CheckAutorun(BUTTON(gamefunc_Run)); running = G_CheckAutorun(inputState.BUTTON(gamefunc_Run));
if (BUTTON(gamefunc_Strafe)) if (inputState.BUTTON(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 (BUTTON(gamefunc_Turn_Left)) if (inputState.BUTTON(gamefunc_Turn_Left))
{ {
mfsvel -= -keymove; mfsvel -= -keymove;
} }
if (BUTTON(gamefunc_Turn_Right)) if (inputState.BUTTON(gamefunc_Turn_Right))
{ {
mfsvel -= keymove; mfsvel -= keymove;
} }
@ -2466,12 +2466,12 @@ MoveScrollMode2D(PLAYERp pp)
if (!InputMode && !ConPanel) if (!InputMode && !ConPanel)
{ {
if (BUTTON(gamefunc_Strafe_Left)) if (inputState.BUTTON(gamefunc_Strafe_Left))
{ {
mfsvel += keymove; mfsvel += keymove;
} }
if (BUTTON(gamefunc_Strafe_Right)) if (inputState.BUTTON(gamefunc_Strafe_Right))
{ {
mfsvel += -keymove; mfsvel += -keymove;
} }
@ -2479,12 +2479,12 @@ MoveScrollMode2D(PLAYERp pp)
if (!UsingMenus && !HelpInputMode && !ConPanel) if (!UsingMenus && !HelpInputMode && !ConPanel)
{ {
if (BUTTON(gamefunc_Move_Forward)) if (inputState.BUTTON(gamefunc_Move_Forward))
{ {
mfvel += keymove; mfvel += keymove;
} }
if (BUTTON(gamefunc_Move_Backward)) if (inputState.BUTTON(gamefunc_Move_Backward))
{ {
mfvel += -keymove; mfvel += -keymove;
} }
@ -4116,7 +4116,7 @@ SWBOOL PlayerFlyKey(PLAYERp pp)
if (InputMode) if (InputMode)
return FALSE; return FALSE;
key = KB_KeyPressed(KEYSC_J); key = inputState.GetKeyStatus(KEYSC_J);
if (key) if (key)
inputState.ClearKeyStatus(KEYSC_J); inputState.ClearKeyStatus(KEYSC_J);
@ -7398,7 +7398,7 @@ DoPlayerRun(PLAYERp pp)
} }
// Crawl lock // Crawl lock
// if (KB_KeyPressed(KEYSC_NUM)) // if (inputState.GetKeyStatus(KEYSC_NUM))
if (TEST_SYNC_KEY(pp, SK_CRAWL_LOCK)) if (TEST_SYNC_KEY(pp, SK_CRAWL_LOCK))
{ {
if (FLAG_KEY_PRESSED(pp, SK_CRAWL_LOCK)) if (FLAG_KEY_PRESSED(pp, SK_CRAWL_LOCK))
@ -7983,9 +7983,9 @@ domovethings(void)
#if 0 #if 0
{ {
extern SWBOOL PauseKeySet; extern SWBOOL PauseKeySet;
if (KB_KeyPressed(KEYSC_F5) && !(KB_KeyPressed(KEYSC_ALT) || KB_KeyPressed(KEYSC_RALT)) && !PauseKeySet) if (inputState.GetKeyStatus(KEYSC_F5) && !(inputState.GetKeyStatus(KEYSC_ALT) || inputState.GetKeyStatus(KEYSC_RALT)) && !PauseKeySet)
{ {
KB_KeyPressed(KEYSC_F5) = 0; inputState.GetKeyStatus(KEYSC_F5) = 0;
ResChange(); ResChange();
} }
} }