Simplify gamepad calculations

This commit is contained in:
ceski 2024-05-30 22:53:04 -07:00
parent f219f7231d
commit ef34eab76d
4 changed files with 14 additions and 5 deletions

View File

@ -2456,6 +2456,7 @@ void D_DoomMain(void)
G_UpdateSideMove(); G_UpdateSideMove();
G_UpdateAngleFunctions(); G_UpdateAngleFunctions();
G_UpdateLocalViewFunction(); G_UpdateLocalViewFunction();
G_UpdateControllerVariables();
G_UpdateMouseVariables(); G_UpdateMouseVariables();
R_UpdateViewAngleFunction(); R_UpdateViewAngleFunction();

View File

@ -171,6 +171,14 @@ int G_CarryVert(double vert)
static const int direction[] = {1, -1}; static const int direction[] = {1, -1};
static double deltatics; static double deltatics;
static double joy_scale_angle;
static double joy_scale_pitch;
void G_UpdateControllerVariables(void)
{
joy_scale_angle = angleturn[1] * direction[joy_invert_turn];
joy_scale_pitch = angleturn[1] * direction[joy_invert_look] * FRACUNIT;
}
void G_UpdateDeltaTics(void) void G_UpdateDeltaTics(void)
{ {
@ -200,14 +208,12 @@ void G_UpdateDeltaTics(void)
double G_CalcControllerAngle(void) double G_CalcControllerAngle(void)
{ {
return (angleturn[1] * axes[AXIS_TURN] * direction[joy_invert_turn] return (axes[AXIS_TURN] * joy_scale_angle * deltatics);
* deltatics);
} }
double G_CalcControllerPitch(void) double G_CalcControllerPitch(void)
{ {
return (angleturn[1] * axes[AXIS_LOOK] * direction[joy_invert_look] return (axes[AXIS_LOOK] * joy_scale_pitch * deltatics);
* deltatics * FRACUNIT);
} }
int G_CalcControllerSideTurn(int speed) int G_CalcControllerSideTurn(int speed)

View File

@ -35,6 +35,7 @@ int G_CarryVert(double vert);
// Gamepad // Gamepad
void G_UpdateControllerVariables(void);
void G_UpdateDeltaTics(void); void G_UpdateDeltaTics(void);
double G_CalcControllerAngle(void); double G_CalcControllerAngle(void);
double G_CalcControllerPitch(void); double G_CalcControllerPitch(void);

View File

@ -2189,7 +2189,8 @@ static setup_menu_t gen_settings4[] = {
{"Free Look", S_ONOFF, CNTR_X, M_SPC, {"padlook"}, m_null, input_null, {"Free Look", S_ONOFF, CNTR_X, M_SPC, {"padlook"}, m_null, input_null,
str_empty, MN_UpdateFreeLook}, str_empty, MN_UpdateFreeLook},
{"Invert Look", S_ONOFF, CNTR_X, M_SPC, {"joy_invert_look"}}, {"Invert Look", S_ONOFF, CNTR_X, M_SPC, {"joy_invert_look"},
m_null, input_null, str_empty, G_UpdateControllerVariables},
MI_GAP, MI_GAP,