- hooked up the event processing for Shadow Warrior, so keyboard input is working now. Mouse movement is not being processed yet.

Also removed some leftover code from the old input system.
This commit is contained in:
Christoph Oelckers 2019-11-20 22:01:44 +01:00
parent caa450dcb9
commit 2da4294ba5
9 changed files with 38 additions and 111 deletions

View file

@ -69,7 +69,8 @@ bool G_Responder (event_t *ev)
} }
else else
{ {
return C_DoKey (ev, &Bindings, &DoubleBindings); return
C_DoKey (ev, &Bindings, &DoubleBindings);
} }
} }
if (cmd && cmd[0] == '+') if (cmd && cmd[0] == '+')

View file

@ -304,37 +304,6 @@ public:
}; };
typedef enum
{
dir_North,
dir_NorthEast,
dir_East,
dir_SouthEast,
dir_South,
dir_SouthWest,
dir_West,
dir_NorthWest,
dir_None
} direction;
struct UserInput
{
int32_t button0;
int32_t button1;
direction dir;
};
// Shadow Warrior still uses these. :(
inline void CONTROL_GetUserInput(UserInput* inp)
{
}
inline void CONTROL_ClearUserInput(UserInput* inp)
{
}
extern InputState inputState; extern InputState inputState;

View file

@ -268,8 +268,7 @@ playanm(short anim_num)
unsigned char *animbuf; unsigned char *animbuf;
int i, j, k, length = 0, numframes = 0; int i, j, k, length = 0, numframes = 0;
int32_t handle = -1; int32_t handle = -1;
UserInput uinfo = { FALSE, FALSE, dir_None };
ANIMnum = anim_num; ANIMnum = anim_num;
inputState.keyFlushChars(); inputState.keyFlushChars();
@ -318,8 +317,6 @@ playanm(short anim_num)
while (totalclock < ototalclock) while (totalclock < ototalclock)
{ {
handleevents(); handleevents();
CONTROL_GetUserInput(&uinfo);
CONTROL_ClearUserInput(&uinfo);
switch (ANIMnum) switch (ANIMnum)
{ {
case ANIM_INTRO: case ANIM_INTRO:

View file

@ -2247,6 +2247,12 @@ drawscreen(PLAYERp pp)
PreUpdatePanel(); PreUpdatePanel();
if (r_usenewaspect)
{
newaspect_enable = 1;
videoSetCorrectedAspect();
}
smoothratio = min(max(((int32_t) totalclock - ototalclock) * (65536 / synctics),0),65536); smoothratio = min(max(((int32_t) totalclock - ototalclock) * (65536 / synctics),0),65536);
if (!ScreenSavePic) if (!ScreenSavePic)
@ -2453,6 +2459,13 @@ drawscreen(PLAYERp pp)
SET(sprite[j].cstat, CSTAT_SPRITE_ALIGNMENT_FLOOR); SET(sprite[j].cstat, CSTAT_SPRITE_ALIGNMENT_FLOOR);
} }
if (r_usenewaspect)
{
newaspect_enable = 0;
videoSetCorrectedAspect();
}
// if doing a screen save don't need to process the rest // if doing a screen save don't need to process the rest
if (ScreenSavePic) if (ScreenSavePic)
{ {

View file

@ -1612,8 +1612,6 @@ void LogoLevel(void)
{ {
char called; char called;
int fin; int fin;
UserInput uinfo = { FALSE, FALSE, dir_None };
DSPRINTF(ds,"LogoLevel..."); DSPRINTF(ds,"LogoLevel...");
MONO_PRINT(ds); MONO_PRINT(ds);
@ -1652,8 +1650,6 @@ void LogoLevel(void)
while (TRUE) while (TRUE)
{ {
handleevents(); handleevents();
CONTROL_GetUserInput(&uinfo);
CONTROL_ClearUserInput(&uinfo);
if (quitevent) { QuitFlag = TRUE; break; } if (quitevent) { QuitFlag = TRUE; break; }
// taken from top of faketimerhandler // taken from top of faketimerhandler
@ -2259,7 +2255,6 @@ void BonusScreen(PLAYERp pp)
int Tics = 0; int Tics = 0;
int line = 0; int line = 0;
SWBOOL BonusDone; SWBOOL BonusDone;
UserInput uinfo = { FALSE, FALSE, dir_None };
if (Level < 0) Level = 0; if (Level < 0) Level = 0;
@ -2298,8 +2293,6 @@ void BonusScreen(PLAYERp pp)
} }
ototalclock += limit; ototalclock += limit;
CONTROL_GetUserInput(&uinfo);
CONTROL_ClearUserInput(&uinfo);
if (I_GeneralTrigger()) if (I_GeneralTrigger())
{ {
I_GeneralTriggerClear(); I_GeneralTriggerClear();
@ -2905,16 +2898,15 @@ void RunLevel(void)
{ {
handleevents(); handleevents();
OSD_DispatchQueued(); OSD_DispatchQueued();
D_ProcessEvents();
faketimerhandler(); faketimerhandler();
if (quitevent) QuitFlag = TRUE; if (quitevent) QuitFlag = TRUE;
//MONO_PRINT("Before MoveLoop");
MoveLoop(); MoveLoop();
//MONO_PRINT("After MoveLoop");
//MONO_PRINT("Before DrawScreen");
drawscreen(Player + screenpeek); drawscreen(Player + screenpeek);
//MONO_PRINT("After DrawScreen");
if (QuitFlag) if (QuitFlag)
break; break;

View file

@ -44,6 +44,7 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms
#include "pal.h" #include "pal.h"
#include "demo.h" #include "demo.h"
#include "input.h" #include "input.h"
#include "keydef.h"
#include "gamecontrol.h" #include "gamecontrol.h"
#include "gamedefs.h" #include "gamedefs.h"
@ -558,7 +559,7 @@ int SENSITIVITY = SENSE_MIN + (SENSE_DEFAULT *SENSE_MUL);
#define VOL_MUL 16 #define VOL_MUL 16
// User input data for all devices // User input data for all devices
UserInput mnu_input, mnu_input_buffered, order_input_buffered; //UserInput order_input_buffered;
// Menu function call back pointer for multiplay menus // Menu function call back pointer for multiplay menus
SWBOOL(*cust_callback)(UserCall call, MenuItem_p item); SWBOOL(*cust_callback)(UserCall call, MenuItem_p item);
@ -717,14 +718,10 @@ SWBOOL MNU_KeySetupCustom(UserCall call, MenuItem *item)
const char *morestr = "More..."; const char *morestr = "More...";
const char *p; const char *p;
UserInput inpt = {FALSE,FALSE,dir_None}; if (inputState.GetKeyStatus(KEYSC_ESC))
CONTROL_GetUserInput(&inpt);
if (inputState.GetKeyStatus(KEYSC_ESC) || inpt.button1)
{ {
inputState.ClearKeyStatus(sc_Escape); inputState.ClearKeyStatus(sc_Escape);
cust_callback = NULL; cust_callback = NULL;
CONTROL_ClearUserInput(&inpt);
return TRUE; return TRUE;
} }
else if (inputState.GetKeyStatus(sc_Delete)) else if (inputState.GetKeyStatus(sc_Delete))
@ -781,7 +778,6 @@ SWBOOL MNU_KeySetupCustom(UserCall call, MenuItem *item)
currentcol = 0; currentcol = 0;
} }
CONTROL_ClearUserInput(&inpt);
if (NUMGAMEFUNCTIONS > PGSIZ) if (NUMGAMEFUNCTIONS > PGSIZ)
{ {
@ -843,6 +839,7 @@ SWBOOL MNU_KeySetupCustom(UserCall call, MenuItem *item)
static int MNU_SelectButtonFunction(const char *buttonname, int *currentfunc) static int MNU_SelectButtonFunction(const char *buttonname, int *currentfunc)
{ {
// Todo: Branch off to the generic keybind menu.
const int PGSIZ = 9; const int PGSIZ = 9;
const char *strs[] = { "Select the function to assign to", "%s", "or ESCAPE to cancel." }; const char *strs[] = { "Select the function to assign to", "%s", "or ESCAPE to cancel." };
int topitem = 0, botitem = NUMGAMEFUNCTIONS-1; int topitem = 0, botitem = NUMGAMEFUNCTIONS-1;
@ -850,10 +847,7 @@ static int MNU_SelectButtonFunction(const char *buttonname, int *currentfunc)
short w, h=0; short w, h=0;
int returnval = 0; int returnval = 0;
UserInput inpt = {FALSE,FALSE,dir_None}; if (inputState.GetKeyStatus(sc_Escape))
CONTROL_GetUserInput(&inpt);
if (inpt.button1)
{ {
inputState.ClearKeyStatus(sc_Escape); inputState.ClearKeyStatus(sc_Escape);
returnval = -1; returnval = -1;
@ -890,13 +884,12 @@ static int MNU_SelectButtonFunction(const char *buttonname, int *currentfunc)
I_MenuUpClear(); I_MenuUpClear();
*currentfunc = max(0, *currentfunc - 1); *currentfunc = max(0, *currentfunc - 1);
} }
else if (inpt.dir == dir_South) else if (I_MenuDown())
{ {
I_MenuDownClear(); I_MenuDownClear();
*currentfunc = min(NUMGAMEFUNCTIONS - 1, *currentfunc + 1); *currentfunc = min(NUMGAMEFUNCTIONS - 1, *currentfunc + 1);
} }
CONTROL_ClearUserInput(&inpt);
if (NUMGAMEFUNCTIONS-1 > PGSIZ) if (NUMGAMEFUNCTIONS-1 > PGSIZ)
{ {
@ -1262,9 +1255,7 @@ SWBOOL
MNU_OrderCustom(UserCall call, MenuItem *item) MNU_OrderCustom(UserCall call, MenuItem *item)
{ {
static signed char on_screen = 0,last_screen = 0; static signed char on_screen = 0,last_screen = 0;
UserInput order_input;
static int limitmove=0; static int limitmove=0;
UserInput tst_input;
SWBOOL select_held = FALSE; SWBOOL select_held = FALSE;
int zero = 0; int zero = 0;
static SWBOOL DidOrderSound = FALSE; static SWBOOL DidOrderSound = FALSE;
@ -1332,27 +1323,20 @@ MNU_OrderCustom(UserCall call, MenuItem *item)
wanghandle = PlaySound(DIGI_WANGORDER2, &zero, &zero, &zero, v3df_dontpan); wanghandle = PlaySound(DIGI_WANGORDER2, &zero, &zero, &zero, v3df_dontpan);
} }
order_input.button0 = order_input.button1 = FALSE;
order_input.dir = dir_None;
// Zero out the input structure
tst_input.button0 = tst_input.button1 = FALSE;
tst_input.dir = dir_None;
if (!select_held) if (!select_held)
{ {
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 (inputState.GetKeyStatus(KEYSC_SPACE)||inputState.GetKeyStatus(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);
tst_input.dir = dir_South; //tst_input.dir = dir_South;
} }
} }
if (order_input_buffered.button0 || order_input_buffered.button1 || order_input_buffered.dir != dir_None) #if 0
if (inputState.GetKeyStatus(KEY_MOUSE1))
{ {
if (tst_input.button0 == order_input_buffered.button0 && if (tst_input.button0 == order_input_buffered.button0 &&
tst_input.button1 == order_input_buffered.button1 && tst_input.button1 == order_input_buffered.button1 &&
@ -1383,8 +1367,9 @@ MNU_OrderCustom(UserCall call, MenuItem *item)
order_input_buffered.button1 = tst_input.button1; order_input_buffered.button1 = tst_input.button1;
order_input_buffered.dir = tst_input.dir; order_input_buffered.dir = tst_input.dir;
} }
#endif
if (!inputState.GetKeyStatus(KEYSC_ESC) && !order_input_buffered.button1) if (!inputState.GetKeyStatus(KEYSC_ESC))
{ {
cust_callback = MNU_OrderCustom; cust_callback = MNU_OrderCustom;
cust_callback_call = call; cust_callback_call = call;
@ -1729,7 +1714,7 @@ MNU_QuitCustom(UserCall call, MenuItem_p item)
if (!ret) if (!ret)
{ {
if (!mnu_input.button1 && !inputState.GetKeyStatus(sc_N)) if (!inputState.GetKeyStatus(KEY_MOUSE1) && !inputState.GetKeyStatus(sc_N))
{ {
cust_callback = MNU_QuitCustom; cust_callback = MNU_QuitCustom;
cust_callback_call = call; cust_callback_call = call;
@ -1747,7 +1732,7 @@ MNU_QuitCustom(UserCall call, MenuItem_p item)
ExitMenus(); ExitMenus();
} }
if (inputState.GetKeyStatus(sc_Y) || inputState.GetKeyStatus(sc_Enter) || mnu_input.button0) if (inputState.GetKeyStatus(sc_Y) || inputState.GetKeyStatus(sc_Enter) || inputState.GetKeyStatus(KEY_MOUSE1))
{ {
if (CommPlayers >= 2) if (CommPlayers >= 2)
MultiPlayQuitFlag = TRUE; MultiPlayQuitFlag = TRUE;
@ -2197,7 +2182,6 @@ signed char MNU_InputSmallString(char *name, short pix_width)
{ {
char ch; char ch;
short w, h; short w, h;
UserInput con_input;
#define ascii_backspace 8 #define ascii_backspace 8
#define ascii_esc 27 #define ascii_esc 27
@ -2205,14 +2189,11 @@ signed char MNU_InputSmallString(char *name, short pix_width)
if (!MoveSkip4 && !MessageInputMode) if (!MoveSkip4 && !MessageInputMode)
{ {
con_input.dir = dir_None; if (I_MenuUp())
CONTROL_GetUserInput(&con_input);
if (con_input.dir == dir_North)
{ {
CON_CommandHistory(1); CON_CommandHistory(1);
} }
else if (con_input.dir == dir_South) else if (I_MenuDown())
{ {
CON_CommandHistory(-1); CON_CommandHistory(-1);
} }
@ -2290,11 +2271,7 @@ static SWBOOL MNU_Dialog(void)
y += (h + 3); y += (h + 3);
} }
mnu_input.button0 = mnu_input.button1 = FALSE; if (inputState.GetKeyStatus(sc_Y) || inputState.GetKeyStatus(sc_Enter) || inputState.GetKeyStatus(KEY_MOUSE1))
CONTROL_ClearUserInput(&mnu_input);
CONTROL_GetUserInput(&mnu_input);
if (inputState.GetKeyStatus(sc_Y) || inputState.GetKeyStatus(sc_Enter) || mnu_input.button0)
return TRUE; return TRUE;
else else
return FALSE; return FALSE;
@ -3655,10 +3632,8 @@ MNU_SetupMenu(void)
menuarray[0] = currentmenu = rootmenu; menuarray[0] = currentmenu = rootmenu;
if (ControlPanelType == ct_mainmenu) if (ControlPanelType == ct_mainmenu)
mnu_input_buffered.button0 = mnu_input_buffered.button1 = FALSE; //order_input_buffered.button0 = order_input_buffered.button1 = FALSE;
mnu_input_buffered.dir = dir_None; //order_input_buffered.dir = dir_None;
order_input_buffered.button0 = order_input_buffered.button1 = FALSE;
order_input_buffered.dir = dir_None;
ResetKeys(); ResetKeys();
// custom cust_callback starts out as null // custom cust_callback starts out as null
@ -4158,10 +4133,6 @@ void MNU_DoMenu( CTLType type, PLAYERp pp )
//ControlPanelType = type; //ControlPanelType = type;
SetupMenu(); SetupMenu();
// Zero out the input structure
mnu_input.button0 = mnu_input.button1 = FALSE;
mnu_input.dir = dir_None;
// should not get input if you are editing a save game slot // should not get input if you are editing a save game slot
if (totalclock < limitmove) limitmove = (int32_t) totalclock; if (totalclock < limitmove) limitmove = (int32_t) totalclock;
@ -4216,7 +4187,6 @@ void MNU_DoMenu( CTLType type, PLAYERp pp )
if (!FX_SoundActive(handle4)) if (!FX_SoundActive(handle4))
handle4 = PlaySound(DIGI_STAR,&zero,&zero,&zero,v3df_dontpan); handle4 = PlaySound(DIGI_STAR,&zero,&zero,&zero,v3df_dontpan);
resetitem = TRUE; resetitem = TRUE;
mnu_input_buffered.button0 = mnu_input_buffered.button1 = FALSE;
} }
else else
resetitem = FALSE; resetitem = FALSE;

View file

@ -8050,12 +8050,8 @@ domovethings(void)
JS_ProcessEchoSpot(); JS_ProcessEchoSpot();
} }
FAKETIMERHANDLER();
SpriteControl(); SpriteControl();
FAKETIMERHANDLER();
TRAVERSE_CONNECT(pnum) TRAVERSE_CONNECT(pnum)
{ {
extern short screenpeek; extern short screenpeek;
@ -8085,8 +8081,6 @@ domovethings(void)
#endif #endif
} }
FAKETIMERHANDLER();
// do for moving sectors // do for moving sectors
DoPlayerSectorUpdatePreMove(pp); DoPlayerSectorUpdatePreMove(pp);
ChopsCheck(pp); ChopsCheck(pp);

View file

@ -3306,7 +3306,6 @@ void movelava(char *dapic)
for (x = LAVASIZ - 1; x >= 0; x--) for (x = LAVASIZ - 1; x >= 0; x--)
{ {
FAKETIMERHANDLER();
offs = (x + 1) * (LAVASIZ + 2) + 1; offs = (x + 1) * (LAVASIZ + 2) + 1;
ptr = (char *)((x << LAVALOGSIZ) + (intptr_t) dapic); ptr = (char *)((x << LAVALOGSIZ) + (intptr_t) dapic);

View file

@ -6788,8 +6788,7 @@ SpriteControl(void)
#endif #endif
} }
FAKETIMERHANDLER();
// Items and skip2 things // Items and skip2 things
if (MoveSkip2 == 0) if (MoveSkip2 == 0)
{ {
@ -6812,8 +6811,6 @@ SpriteControl(void)
} }
} }
FAKETIMERHANDLER();
if (MoveSkip2 == 0) // limit to 20 times a second if (MoveSkip2 == 0) // limit to 20 times a second
{ {
// move bad guys around // move bad guys around
@ -6868,9 +6865,6 @@ SpriteControl(void)
} }
} }
FAKETIMERHANDLER();
// Skip4 things // Skip4 things
if (MoveSkip4 == 0) // limit to 10 times a second if (MoveSkip4 == 0) // limit to 10 times a second
{ {
@ -6893,8 +6887,6 @@ SpriteControl(void)
} }
} }
FAKETIMERHANDLER();
TRAVERSE_SPRITE_STAT(headspritestat[STAT_NO_STATE], i, nexti) TRAVERSE_SPRITE_STAT(headspritestat[STAT_NO_STATE], i, nexti)
{ {
if (User[i] && User[i]->ActorActionFunc) if (User[i] && User[i]->ActorActionFunc)