Skip to content

Commit 2fe04da

Browse files
warmenhovenoshaboy
andauthored
add settings for gyroscope/accelerometer sensitivity (#18245)
Co-authored-by: oshaboy <[email protected]>
1 parent c4b655a commit 2fe04da

File tree

10 files changed

+86
-2
lines changed

10 files changed

+86
-2
lines changed

config.def.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1589,6 +1589,9 @@
15891589
#define DEFAULT_AXIS_THRESHOLD 0.5f
15901590
#define DEFAULT_ANALOG_DEADZONE 0.0f
15911591
#define DEFAULT_ANALOG_SENSITIVITY 1.0f
1592+
#define DEFAULT_SENSOR_ACCELEROMETER_SENSITIVITY 1.0f
1593+
#define DEFAULT_SENSOR_GYROSCOPE_SENSITIVITY 1.0f
1594+
15921595

15931596
/* Describes speed of which turbo-enabled buttons toggle. */
15941597
#define DEFAULT_TURBO_ENABLE true

configuration.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2357,6 +2357,8 @@ static struct config_float_setting *populate_settings_float(
23572357
SETTING_FLOAT("input_axis_threshold", &settings->floats.input_axis_threshold, true, DEFAULT_AXIS_THRESHOLD, false);
23582358
SETTING_FLOAT("input_analog_deadzone", &settings->floats.input_analog_deadzone, true, DEFAULT_ANALOG_DEADZONE, false);
23592359
SETTING_FLOAT("input_analog_sensitivity", &settings->floats.input_analog_sensitivity, true, DEFAULT_ANALOG_SENSITIVITY, false);
2360+
SETTING_FLOAT("input_sensor_accelerometer_sensitivity",&settings->floats.input_sensor_accelerometer_sensitivity, true, DEFAULT_SENSOR_ACCELEROMETER_SENSITIVITY, false);
2361+
SETTING_FLOAT("input_sensor_gyroscope_sensitivity", &settings->floats.input_sensor_gyroscope_sensitivity, true, DEFAULT_SENSOR_GYROSCOPE_SENSITIVITY, false);
23602362
#ifdef HAVE_OVERLAY
23612363
SETTING_FLOAT("input_overlay_opacity", &settings->floats.input_overlay_opacity, true, DEFAULT_INPUT_OVERLAY_OPACITY, false);
23622364
SETTING_FLOAT("input_osk_overlay_opacity", &settings->floats.input_osk_overlay_opacity, true, DEFAULT_INPUT_OVERLAY_OPACITY, false);

configuration.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,8 @@ typedef struct settings
463463
float input_analog_deadzone;
464464
float input_axis_threshold;
465465
float input_analog_sensitivity;
466+
float input_sensor_accelerometer_sensitivity;
467+
float input_sensor_gyroscope_sensitivity;
466468
#ifdef _3DS
467469
float bottom_font_scale;
468470
#endif

input/input_driver.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4520,8 +4520,17 @@ void joypad_driver_reinit(void *data, const char *joypad_driver_name)
45204520
**/
45214521
float input_get_sensor_state(unsigned port, unsigned id)
45224522
{
4523-
bool input_sensors_enable = config_get_ptr()->bools.input_sensors_enable;
4524-
return input_driver_get_sensor(port, input_sensors_enable, id);
4523+
settings_t *settings = config_get_ptr();
4524+
bool input_sensors_enable = settings->bools.input_sensors_enable;
4525+
float sensitivity;
4526+
if (id >= RETRO_SENSOR_ACCELEROMETER_X && id <= RETRO_SENSOR_ACCELEROMETER_Z) {
4527+
sensitivity = settings->floats.input_sensor_accelerometer_sensitivity;
4528+
} else if (id >= RETRO_SENSOR_GYROSCOPE_X && id <= RETRO_SENSOR_GYROSCOPE_Z) {
4529+
sensitivity = settings->floats.input_sensor_gyroscope_sensitivity;
4530+
} else {
4531+
sensitivity = 1.0f;
4532+
}
4533+
return input_driver_get_sensor(port, input_sensors_enable, id) * sensitivity;
45254534
}
45264535

45274536
/**

intl/msg_hash_lbl.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1890,6 +1890,14 @@ MSG_HASH(
18901890
MENU_ENUM_LABEL_INPUT_ANALOG_SENSITIVITY,
18911891
"input_analog_sensitivity"
18921892
)
1893+
MSG_HASH(
1894+
MENU_ENUM_LABEL_INPUT_SENSOR_ACCELEROMETER_SENSITIVITY,
1895+
"input_sensor_accelerometer_sensitivity"
1896+
)
1897+
MSG_HASH(
1898+
MENU_ENUM_LABEL_INPUT_SENSOR_GYROSCOPE_SENSITIVITY,
1899+
"input_sensor_gyroscope_sensitivity"
1900+
)
18931901
#ifdef GEKKO
18941902
MSG_HASH(
18951903
MENU_ENUM_LABEL_INPUT_MOUSE_SCALE,

intl/msg_hash_us.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3441,10 +3441,26 @@ MSG_HASH(
34413441
MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_SENSITIVITY,
34423442
"Analog Sensitivity"
34433443
)
3444+
MSG_HASH(
3445+
MENU_ENUM_LABEL_VALUE_INPUT_SENSOR_ACCELEROMETER_SENSITIVITY,
3446+
"Accelerometer Sensitivity"
3447+
)
3448+
MSG_HASH(
3449+
MENU_ENUM_LABEL_VALUE_INPUT_SENSOR_GYROSCOPE_SENSITIVITY,
3450+
"Gyroscope Sensitivity"
3451+
)
34443452
MSG_HASH(
34453453
MENU_ENUM_SUBLABEL_INPUT_ANALOG_SENSITIVITY,
34463454
"Adjust the sensitivity of analog sticks."
34473455
)
3456+
MSG_HASH(
3457+
MENU_ENUM_SUBLABEL_INPUT_SENSOR_ACCELEROMETER_SENSITIVITY,
3458+
"Adjust the sensitivity of the Accelerometer."
3459+
)
3460+
MSG_HASH(
3461+
MENU_ENUM_SUBLABEL_INPUT_SENSOR_GYROSCOPE_SENSITIVITY,
3462+
"Adjust the sensitivity of the Gyroscope."
3463+
)
34483464
MSG_HASH(
34493465
MENU_ENUM_LABEL_VALUE_INPUT_BIND_TIMEOUT,
34503466
"Bind Timeout"

menu/cbs/menu_cbs_sublabel.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,10 @@ DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_input_touch_vmouse_gesture, MENU_
574574
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_button_axis_threshold, MENU_ENUM_SUBLABEL_INPUT_BUTTON_AXIS_THRESHOLD)
575575
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_analog_deadzone, MENU_ENUM_SUBLABEL_INPUT_ANALOG_DEADZONE)
576576
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_analog_sensitivity, MENU_ENUM_SUBLABEL_INPUT_ANALOG_SENSITIVITY)
577+
578+
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_sensor_accelerometer_sensitivity, MENU_ENUM_SUBLABEL_INPUT_SENSOR_ACCELEROMETER_SENSITIVITY)
579+
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_sensor_gyroscope_sensitivity, MENU_ENUM_SUBLABEL_INPUT_SENSOR_GYROSCOPE_SENSITIVITY)
580+
577581
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_input_turbo_enable, MENU_ENUM_SUBLABEL_INPUT_TURBO_ENABLE)
578582
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_input_turbo_period, MENU_ENUM_SUBLABEL_INPUT_TURBO_PERIOD)
579583
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_input_turbo_duty_cycle, MENU_ENUM_SUBLABEL_INPUT_TURBO_DUTY_CYCLE)
@@ -4753,6 +4757,12 @@ int menu_cbs_init_bind_sublabel(menu_file_list_cbs_t *cbs,
47534757
case MENU_ENUM_LABEL_INPUT_ANALOG_SENSITIVITY:
47544758
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_analog_sensitivity);
47554759
break;
4760+
case MENU_ENUM_LABEL_INPUT_SENSOR_ACCELEROMETER_SENSITIVITY:
4761+
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_sensor_accelerometer_sensitivity);
4762+
break;
4763+
case MENU_ENUM_LABEL_INPUT_SENSOR_GYROSCOPE_SENSITIVITY:
4764+
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_sensor_gyroscope_sensitivity);
4765+
break;
47564766
#if defined(GEKKO)
47574767
case MENU_ENUM_LABEL_INPUT_MOUSE_SCALE:
47584768
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_input_mouse_scale);

menu/menu_displaylist.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8290,6 +8290,8 @@ unsigned menu_displaylist_build_list(
82908290
{MENU_ENUM_LABEL_INPUT_BUTTON_AXIS_THRESHOLD, PARSE_ONLY_FLOAT, true},
82918291
{MENU_ENUM_LABEL_INPUT_ANALOG_DEADZONE, PARSE_ONLY_FLOAT, true},
82928292
{MENU_ENUM_LABEL_INPUT_ANALOG_SENSITIVITY, PARSE_ONLY_FLOAT, true},
8293+
{MENU_ENUM_LABEL_INPUT_SENSOR_ACCELEROMETER_SENSITIVITY,PARSE_ONLY_FLOAT, true },
8294+
{MENU_ENUM_LABEL_INPUT_SENSOR_GYROSCOPE_SENSITIVITY, PARSE_ONLY_FLOAT, true },
82938295
#if defined(GEKKO)
82948296
{MENU_ENUM_LABEL_INPUT_MOUSE_SCALE, PARSE_ONLY_UINT, true},
82958297
#endif

menu/menu_setting.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15835,6 +15835,36 @@ static bool setting_append_list(
1583515835
(*list)[list_info->index - 1].action_ok = &setting_action_ok_uint;
1583615836
menu_settings_list_current_add_range(list, list_info, -5.0, 5.0, 0.1, true, true);
1583715837

15838+
CONFIG_FLOAT(
15839+
list, list_info,
15840+
&settings->floats.input_sensor_accelerometer_sensitivity,
15841+
MENU_ENUM_LABEL_INPUT_SENSOR_ACCELEROMETER_SENSITIVITY,
15842+
MENU_ENUM_LABEL_VALUE_INPUT_SENSOR_ACCELEROMETER_SENSITIVITY,
15843+
DEFAULT_SENSOR_ACCELEROMETER_SENSITIVITY,
15844+
"%.1f",
15845+
&group_info,
15846+
&subgroup_info,
15847+
parent_group,
15848+
general_write_handler,
15849+
general_read_handler);
15850+
(*list)[list_info->index - 1].action_ok = &setting_action_ok_uint;
15851+
menu_settings_list_current_add_range(list, list_info, -5.0, 5.0, 0.1, true, true);
15852+
15853+
CONFIG_FLOAT(
15854+
list, list_info,
15855+
&settings->floats.input_sensor_gyroscope_sensitivity,
15856+
MENU_ENUM_LABEL_INPUT_SENSOR_GYROSCOPE_SENSITIVITY,
15857+
MENU_ENUM_LABEL_VALUE_INPUT_SENSOR_GYROSCOPE_SENSITIVITY,
15858+
DEFAULT_SENSOR_GYROSCOPE_SENSITIVITY,
15859+
"%.1f",
15860+
&group_info,
15861+
&subgroup_info,
15862+
parent_group,
15863+
general_write_handler,
15864+
general_read_handler);
15865+
(*list)[list_info->index - 1].action_ok = &setting_action_ok_uint;
15866+
menu_settings_list_current_add_range(list, list_info, -5.0, 5.0, 0.1, true, true);
15867+
1583815868
CONFIG_UINT(
1583915869
list, list_info,
1584015870
&settings->uints.input_bind_timeout,

msg_hash.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1325,6 +1325,8 @@ enum msg_hash_enums
13251325
MENU_LABEL(INPUT_TOUCH_SCALE),
13261326
MENU_LABEL(INPUT_ANALOG_DEADZONE),
13271327
MENU_LABEL(INPUT_ANALOG_SENSITIVITY),
1328+
MENU_LABEL(INPUT_SENSOR_ACCELEROMETER_SENSITIVITY),
1329+
MENU_LABEL(INPUT_SENSOR_GYROSCOPE_SENSITIVITY),
13281330
MENU_LABEL(INPUT_BIND_TIMEOUT),
13291331
MENU_LABEL(INPUT_BIND_HOLD),
13301332
MENU_LABEL(INPUT_REMAP_BINDS_ENABLE),

0 commit comments

Comments
 (0)