HandleGamepadDeviceEvents: Call at all junctures where event_t are digested

Permits controllers to actually be added when starting with -server
This commit is contained in:
toaster 2023-03-19 17:02:37 +00:00
parent dc63847e14
commit 5a7f7b58f0
6 changed files with 17 additions and 1 deletions

View file

@ -1968,6 +1968,7 @@ static boolean CL_ServerConnectionTicker(const char *tmpsave, tic_t *oldtic, tic
{ {
for (; eventtail != eventhead; eventtail = (eventtail+1) & (MAXEVENTS-1)) for (; eventtail != eventhead; eventtail = (eventtail+1) & (MAXEVENTS-1))
{ {
HandleGamepadDeviceEvents(&events[eventtail]);
G_MapEventsToControls(&events[eventtail]); G_MapEventsToControls(&events[eventtail]);
} }

View file

@ -203,7 +203,7 @@ static void HandleGamepadDeviceRemoved(event_t *ev)
} }
/// Respond to added/removed device events, for bookkeeping available gamepads. /// Respond to added/removed device events, for bookkeeping available gamepads.
static void HandleGamepadDeviceEvents(event_t *ev) void HandleGamepadDeviceEvents(event_t *ev)
{ {
I_Assert(ev != NULL); I_Assert(ev != NULL);

View file

@ -165,6 +165,8 @@ boolean G_IsDeviceResponding(INT32 device);
void G_SetDeviceResponding(INT32 device, boolean responding); void G_SetDeviceResponding(INT32 device, boolean responding);
void G_ResetAllDeviceResponding(void); void G_ResetAllDeviceResponding(void);
void HandleGamepadDeviceEvents(event_t *ev);
// remaps the input event to a game control. // remaps the input event to a game control.
void G_MapEventsToControls(event_t *ev); void G_MapEventsToControls(event_t *ev);

View file

@ -871,10 +871,15 @@ INT32 I_GetKey (void)
event_t *ev; event_t *ev;
INT32 rc = 0; INT32 rc = 0;
G_ResetAllDeviceResponding();
// return the first keypress from the event queue // return the first keypress from the event queue
for (; eventtail != eventhead; eventtail = (eventtail+1)&(MAXEVENTS-1)) for (; eventtail != eventhead; eventtail = (eventtail+1)&(MAXEVENTS-1))
{ {
ev = &events[eventtail]; ev = &events[eventtail];
HandleGamepadDeviceEvents(ev);
if (ev->type == ev_keydown || ev->type == ev_console) if (ev->type == ev_keydown || ev->type == ev_console)
{ {
rc = ev->data1; rc = ev->data1;

View file

@ -910,10 +910,15 @@ INT32 I_GetKey (void)
event_t *ev; event_t *ev;
INT32 rc = 0; INT32 rc = 0;
G_ResetAllDeviceResponding();
// return the first keypress from the event queue // return the first keypress from the event queue
for (; eventtail != eventhead; eventtail = (eventtail+1)&(MAXEVENTS-1)) for (; eventtail != eventhead; eventtail = (eventtail+1)&(MAXEVENTS-1))
{ {
ev = &events[eventtail]; ev = &events[eventtail];
HandleGamepadDeviceEvents(ev);
if (ev->type == ev_keydown || ev->type == ev_console) if (ev->type == ev_keydown || ev->type == ev_console)
{ {
rc = ev->data1; rc = ev->data1;

View file

@ -3067,9 +3067,12 @@ INT32 I_GetKey(void)
{ {
event_t *ev; event_t *ev;
G_ResetAllDeviceResponding();
if (eventtail != eventhead) if (eventtail != eventhead)
{ {
ev = &events[eventtail]; ev = &events[eventtail];
HandleGamepadDeviceEvents(ev);
eventtail = (eventtail+1) & (MAXEVENTS-1); eventtail = (eventtail+1) & (MAXEVENTS-1);
if (ev->type == ev_keydown || ev->type == ev_console) if (ev->type == ev_keydown || ev->type == ev_console)
return ev->data1; return ev->data1;