Improve simultaneous mouse and gamepad input (#1563)

* Improve simultaneous mouse and gamepad input

* Defer first event (don't eat it) in strict mode
This commit is contained in:
ceski 2024-03-05 21:42:17 -08:00 committed by GitHub
parent b12616d59e
commit 6bb582c26f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 10 additions and 5 deletions

View File

@ -529,9 +529,8 @@ void G_PrepTiccmd(void)
// Gamepad // Gamepad
if (I_UseController()) if (I_UseController() && I_CalcControllerAxes())
{ {
I_CalcControllerAxes();
D_UpdateDeltaTics(); D_UpdateDeltaTics();
if (axes[AXIS_TURN] && !strafe) if (axes[AXIS_TURN] && !strafe)
@ -1181,7 +1180,7 @@ static boolean G_StrictModeSkipEvent(event_t *ev)
first_event = false; first_event = false;
enable_controller = true; enable_controller = true;
} }
return true; // Already "ate" the event above. I_ResetControllerLevel();
} }
return !enable_controller; return !enable_controller;

View File

@ -261,8 +261,10 @@ static void CalcRadial(axes_t *ax, float *xaxis, float *yaxis)
static void (*CalcMovement)(axes_t *ax, float *xaxis, float *yaxis); static void (*CalcMovement)(axes_t *ax, float *xaxis, float *yaxis);
static void (*CalcCamera)(axes_t *ax, float *xaxis, float *yaxis); static void (*CalcCamera)(axes_t *ax, float *xaxis, float *yaxis);
void I_CalcControllerAxes(void) boolean I_CalcControllerAxes(void)
{ {
boolean camera_update = false;
if (movement.x.data || movement.y.data) if (movement.x.data || movement.y.data)
{ {
CalcMovement(&movement, &axes[AXIS_STRAFE], &axes[AXIS_FORWARD]); CalcMovement(&movement, &axes[AXIS_STRAFE], &axes[AXIS_FORWARD]);
@ -282,7 +284,11 @@ void I_CalcControllerAxes(void)
camera.x.data = 0; camera.x.data = 0;
camera.y.data = 0; camera.y.data = 0;
camera_update = true;
} }
return camera_update;
} }
void I_UpdateAxesData(const event_t *ev) void I_UpdateAxesData(const event_t *ev)

View File

@ -48,7 +48,7 @@ extern boolean joy_invert_look; // Invert look axis.
extern float axes[NUM_AXES]; // Calculated controller values. extern float axes[NUM_AXES]; // Calculated controller values.
extern int trigger_threshold; // Trigger threshold (axis resolution). extern int trigger_threshold; // Trigger threshold (axis resolution).
void I_CalcControllerAxes(void); boolean I_CalcControllerAxes(void);
void I_UpdateAxesData(const struct event_s *ev); void I_UpdateAxesData(const struct event_s *ev);
void I_ResetControllerAxes(void); void I_ResetControllerAxes(void);
void I_ResetControllerLevel(void); void I_ResetControllerLevel(void);