Add gyro invert turn/look options (#1963)

* Don't invert local lean by default

* Add gyro invert turn/look options
This commit is contained in:
ceski 2024-10-14 20:47:26 -07:00 committed by GitHub
parent 59f016d241
commit 54fcbd4416
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -97,6 +97,8 @@ static int gyro_accel_max_threshold;
static int gyro_smooth_threshold;
static int gyro_smooth_time;
static int gyro_tightening;
static boolean gyro_invert_turn;
static boolean gyro_invert_look;
static fixed_t gyro_calibration_a;
static fixed_t gyro_calibration_x;
static fixed_t gyro_calibration_y;
@ -311,12 +313,29 @@ void I_CalcGyroAxes(boolean strafe)
{
if (GyroActive())
{
gyro_axes[GYRO_TURN] = !strafe ? RAD2TIC(gyro_axes[GYRO_TURN]) : 0.0f;
if (!strafe)
{
gyro_axes[GYRO_TURN] = RAD2TIC(gyro_axes[GYRO_TURN]);
if (gyro_invert_turn)
{
gyro_axes[GYRO_TURN] *= -1.0f;
}
}
else
{
gyro_axes[GYRO_TURN] = 0.0f;
}
if (padlook)
{
gyro_axes[GYRO_LOOK] = RAD2TIC(gyro_axes[GYRO_LOOK]);
if (gyro_invert_look)
{
gyro_axes[GYRO_LOOK] *= -1.0f;
}
if (correct_aspect_ratio)
{
gyro_axes[GYRO_LOOK] /= 1.2f;
@ -516,7 +535,7 @@ static void ApplyGyroSpace_Skip(void)
static void ApplyGyroSpace_LocalLean(void)
{
motion.gyro.y = -motion.gyro.z;
motion.gyro.y = motion.gyro.z;
}
static void ApplyGyroSpace_PlayerTurn(void)
@ -829,6 +848,10 @@ void I_BindGyroVaribales(void)
BIND_NUM(gyro_tightening, 30, 0, 100,
"Gyro steadying: tightening threshold "
"(0 = Off; 100 = 10.0 degrees/second)");
BIND_BOOL(gyro_invert_turn, false,
"Invert gyro turn axis");
BIND_BOOL(gyro_invert_look, false,
"Invert gyro look axis");
BIND_NUM(gyro_calibration_a, 0, UL, UL, "Accelerometer calibration");
BIND_NUM(gyro_calibration_x, 0, UL, UL, "Gyro calibration (x-axis)");