Update gyro ranges, defaults, menu items (#1964)

* Increase max gyro sensitivity to 20x

* Increase max gyro steadying to 50 degrees/second

* Increase max gyro acceleration to 20x

* Increase max gyro acceleration threshold to 300 degrees/second

* Expose gyro acceleration thresholds in menu

* Use gyro defaults that match Steam Input
This commit is contained in:
ceski 2024-10-25 13:11:17 -07:00 committed by GitHub
parent 54fcbd4416
commit d3ccce3675
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 50 additions and 72 deletions

View File

@ -267,6 +267,11 @@ boolean I_GyroEnabled(void)
return gyro_enable;
}
boolean I_GyroAcceleration(void)
{
return (gyro_acceleration > 10);
}
void I_SetStickMoving(boolean condition)
{
motion.stick_moving = condition;
@ -475,41 +480,10 @@ static void SmoothGyro_Full(void)
static float raw[2];
static float SmoothGyroScaleMenu(float raw_scale)
{
#define SCALE_SMOOTH_TIME 0.125f
static int scale_index;
static float scale_samples[NUM_SAMPLES];
static uint64_t last_time;
scale_index = (scale_index + (NUM_SAMPLES - 1)) % NUM_SAMPLES;
scale_samples[scale_index] = raw_scale;
uint64_t current_time = I_GetTimeUS();
float delta_time = (current_time - last_time) * 1.0e-6f;
delta_time = BETWEEN(1.0e-6f, SCALE_SMOOTH_TIME, delta_time);
last_time = current_time;
int max_samples = lroundf(SCALE_SMOOTH_TIME / delta_time);
max_samples = BETWEEN(1, NUM_SAMPLES, max_samples);
float smooth_scale = scale_samples[scale_index] / max_samples;
for (int i = 1; i < max_samples; i++)
{
const int index = (scale_index + i) % NUM_SAMPLES;
smooth_scale += scale_samples[index] / max_samples;
}
return BETWEEN(0.0f, 1.0f, smooth_scale);
}
void I_GetRawGyroScaleMenu(float *scale, float *limit)
{
const float deg_per_sec = LENGTH_F(raw[0], raw[1]) * 180.0f / PI_F;
const float raw_scale = BETWEEN(0.0f, 10.0f, deg_per_sec) / 10.0f;
// Smooth the result for accessibility reasons.
*scale = SmoothGyroScaleMenu(raw_scale);
*scale = BETWEEN(0.0f, 50.0f, deg_per_sec) / 50.0f;
*limit = gyro_smooth_threshold / 100.0f;
}
@ -791,11 +765,13 @@ void I_RefreshGyroSettings(void)
motion.stick_action = gyro_stick_action;
AccelerateGyro =
(gyro_acceleration > 10) ? AccelerateGyro_Full : AccelerateGyro_Skip;
I_GyroAcceleration() ? AccelerateGyro_Full : AccelerateGyro_Skip;
motion.min_pitch_sens = gyro_look_sensitivity / 10.0f;
motion.min_yaw_sens = gyro_turn_sensitivity / 10.0f;
motion.max_pitch_sens = motion.min_pitch_sens * gyro_acceleration / 10.0f;
motion.max_yaw_sens = motion.min_yaw_sens * gyro_acceleration / 10.0f;
gyro_accel_max_threshold =
MAX(gyro_accel_max_threshold, gyro_accel_min_threshold);
motion.accel_min_thresh = gyro_accel_min_threshold * PI_F / 180.0f;
motion.accel_max_thresh = gyro_accel_max_threshold * PI_F / 180.0f;
@ -830,24 +806,24 @@ void I_BindGyroVaribales(void)
BIND_NUM_GYRO(gyro_stick_action,
ACTION_NONE, ACTION_NONE, ACTION_ENABLE,
"Camera stick action (0 = None; 1 = Disable Gyro; 2 = Enable Gyro)");
BIND_NUM_GYRO(gyro_turn_sensitivity, 10, 0, 100,
"Gyro turn sensitivity (0 = 0.0x; 100 = 10.0x)");
BIND_NUM_GYRO(gyro_look_sensitivity, 10, 0, 100,
"Gyro look sensitivity (0 = 0.0x; 100 = 10.0x)");
BIND_NUM_GYRO(gyro_acceleration, 20, 10, 40,
"Gyro acceleration multiplier (10 = 1.0x; 40 = 4.0x)");
BIND_NUM(gyro_accel_min_threshold, 0, 0, 200,
BIND_NUM_GYRO(gyro_turn_sensitivity, 25, 0, 200,
"Gyro turn sensitivity (0 = 0.0x; 200 = 20.0x)");
BIND_NUM_GYRO(gyro_look_sensitivity, 25, 0, 200,
"Gyro look sensitivity (0 = 0.0x; 200 = 20.0x)");
BIND_NUM_GYRO(gyro_acceleration, 10, 10, 200,
"Gyro acceleration multiplier (10 = 1.0x; 200 = 20.0x)");
BIND_NUM(gyro_accel_min_threshold, 0, 0, 300,
"Lower threshold for applying gyro acceleration [degrees/second]");
BIND_NUM(gyro_accel_max_threshold, 75, 0, 200,
BIND_NUM(gyro_accel_max_threshold, 75, 0, 300,
"Upper threshold for applying gyro acceleration [degrees/second]");
BIND_NUM_GYRO(gyro_smooth_threshold, 30, 0, 100,
BIND_NUM_GYRO(gyro_smooth_threshold, 30, 0, 500,
"Gyro steadying: smoothing threshold "
"(0 = Off; 100 = 10.0 degrees/second)");
"(0 = Off; 500 = 50.0 degrees/second)");
BIND_NUM(gyro_smooth_time, 125, 0, 500,
"Gyro steadying: smoothing time [milliseconds]");
BIND_NUM(gyro_tightening, 30, 0, 100,
BIND_NUM(gyro_tightening, 30, 0, 500,
"Gyro steadying: tightening threshold "
"(0 = Off; 100 = 10.0 degrees/second)");
"(0 = Off; 500 = 50.0 degrees/second)");
BIND_BOOL(gyro_invert_turn, false,
"Invert gyro turn axis");
BIND_BOOL(gyro_invert_look, false,

View File

@ -48,6 +48,7 @@ void I_LoadGyroCalibration(void);
void I_UpdateGyroCalibrationState(void);
boolean I_GyroEnabled(void);
boolean I_GyroAcceleration(void);
void I_SetStickMoving(boolean condition);
void I_GetRawGyroScaleMenu(float *scale, float *limit);
void I_CalcGyroAxes(boolean strafe);

View File

@ -3075,7 +3075,7 @@ static const char *gyro_action_strings[] = {
"Invert"
};
#define GYRO_SENS_STRINGS_SIZE (100 + 1)
#define GYRO_SENS_STRINGS_SIZE (500 + 1)
static const char **GetGyroSensitivityStrings(void)
{
@ -3090,37 +3090,29 @@ static const char **GetGyroSensitivityStrings(void)
return strings;
}
#define GYRO_ACCEL_STRINGS_SIZE (40 + 1)
#define GYRO_ACCEL_STRINGS_SIZE (200 + 1)
static const char **GetGyroAccelStrings(void)
{
static const char *strings[GYRO_ACCEL_STRINGS_SIZE] = {
[10] = "Off",
[15] = "Low",
[20] = "Medium",
[40] = "High",
"", "", "", "", "", "", "", "", "", "", "Off"
};
char buf[8];
for (int i = 0; i < GYRO_ACCEL_STRINGS_SIZE; i++)
for (int i = 11; i < GYRO_ACCEL_STRINGS_SIZE; i++)
{
if (i < 10)
{
strings[i] = "";
}
else if (i == 10 || i == 15 || i == 20 || i == 40)
{
continue;
}
else
{
M_snprintf(buf, sizeof(buf), "%1d.%1d", i / 10, i % 10);
strings[i] = M_StringDuplicate(buf);
}
M_snprintf(buf, sizeof(buf), "%1d.%1d", i / 10, i % 10);
strings[i] = M_StringDuplicate(buf);
}
return strings;
}
static void UpdateGyroAcceleration(void)
{
UpdateGyroItems();
I_ResetGamepad();
}
static void UpdateGyroSteadying(void)
{
I_UpdateGyroSteadying();
@ -3141,8 +3133,6 @@ static setup_menu_t gyro_settings1[] = {
{"Camera Stick Action", S_CHOICE, CNTR_X, M_SPC, {"gyro_stick_action"},
.strings_id = str_gyro_action, .action = I_ResetGamepad},
MI_GAP,
{"Turn Sensitivity", S_THERMO | S_THRM_SIZE11, CNTR_X, M_THRM_SPC,
{"gyro_turn_sensitivity"}, .strings_id = str_gyro_sens,
.action = I_ResetGamepad},
@ -3151,13 +3141,21 @@ static setup_menu_t gyro_settings1[] = {
{"gyro_look_sensitivity"}, .strings_id = str_gyro_sens,
.action = I_ResetGamepad},
{"Acceleration", S_THERMO, CNTR_X, M_THRM_SPC, {"gyro_acceleration"},
.strings_id = str_gyro_accel, .action = I_ResetGamepad},
{"Acceleration", S_THERMO | S_THRM_SIZE11, CNTR_X, M_THRM_SPC,
{"gyro_acceleration"}, .strings_id = str_gyro_accel,
.action = UpdateGyroAcceleration},
{"Steadying", S_THERMO, CNTR_X, M_THRM_SPC, {"gyro_smooth_threshold"},
.strings_id = str_gyro_sens, .action = UpdateGyroSteadying},
{"Lower Threshold", S_THERMO | S_THRM_SIZE11, CNTR_X, M_THRM_SPC,
{"gyro_accel_min_threshold"}, .action = I_ResetGamepad},
MI_GAP,
{"Upper Threshold", S_THERMO | S_THRM_SIZE11, CNTR_X, M_THRM_SPC,
{"gyro_accel_max_threshold"}, .action = I_ResetGamepad},
{"Steadying", S_THERMO | S_THRM_SIZE11, CNTR_X, M_THRM_SPC,
{"gyro_smooth_threshold"}, .strings_id = str_gyro_sens,
.action = UpdateGyroSteadying},
MI_GAP_Y(2),
{"Calibrate", S_FUNC, CNTR_X, M_SPC,
.action = I_UpdateGyroCalibrationState,
@ -3172,6 +3170,7 @@ static void UpdateGyroItems(void)
{
const boolean gamepad = (I_UseGamepad() && I_GamepadEnabled());
const boolean gyro = (I_GyroEnabled() && I_GyroSupported());
const boolean acceleration = (gamepad && gyro && I_GyroAcceleration());
const boolean condition = (!gamepad || !gyro);
DisableItem(!gamepad || !I_GyroSupported(), gyro_settings1, "gyro_enable");
@ -3181,6 +3180,8 @@ static void UpdateGyroItems(void)
DisableItem(condition, gyro_settings1, "gyro_turn_sensitivity");
DisableItem(condition, gyro_settings1, "gyro_look_sensitivity");
DisableItem(condition, gyro_settings1, "gyro_acceleration");
DisableItem(!acceleration, gyro_settings1, "gyro_accel_min_threshold");
DisableItem(!acceleration, gyro_settings1, "gyro_accel_max_threshold");
DisableItem(condition, gyro_settings1, "gyro_smooth_threshold");
DisableItem(condition, gyro_settings1, "Calibrate");
}