Skip to content

Commit

Permalink
More menu stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
oshaboy committed Jan 17, 2025
1 parent e33b667 commit 5563b32
Show file tree
Hide file tree
Showing 8 changed files with 144 additions and 113 deletions.
11 changes: 1 addition & 10 deletions configuration.c
Original file line number Diff line number Diff line change
Expand Up @@ -6009,13 +6009,11 @@ bool input_remapping_load_file(void *data, const char *path)
{
"accel_x","accel_y", "accel_z",
"gyro_x","gyro_y","gyro_z"
/*,"light"*/
};
static const char * sensor_strings_flip[RETROPAD_RETRO_SENSOR_LAST] =
{
"accel_x_flip","accel_y_flip", "accel_z_flip",
"gyro_x_flip","gyro_y_flip","gyro_z_flip"
/*,"light_flip"*/
};
for (j = 0; j < RETROPAD_RETRO_SENSOR_LAST; j++){

Expand All @@ -6032,12 +6030,6 @@ bool input_remapping_load_file(void *data, const char *path)

configuration_set_uint(settings,
settings->uints.input_sensor_ids[i][j], sensor_remap);

config_get_bool(conf, sensor_flip_ident, &sensor_flip_remap);

configuration_set_bool(settings,
settings->bools.input_sensor_flip_axis[i][j], sensor_flip_remap);


}
}
Expand Down Expand Up @@ -6079,13 +6071,11 @@ bool input_remapping_save_file(const char *path)
{
"accel_x","accel_y", "accel_z",
"gyro_x","gyro_y","gyro_z"
/*,"light" */
};
static const char * sensor_strings_flip[RETROPAD_RETRO_SENSOR_LAST] =
{
"accel_x_flip","accel_y_flip", "accel_z_flip",
"gyro_x_flip","gyro_y_flip","gyro_z_flip"
/*,"light_flip"*/
};
config_file_t *conf = NULL;
runloop_state_t *runloop_st = runloop_state_get_ptr();
Expand Down Expand Up @@ -6418,6 +6408,7 @@ uint8_t input_config_bind_map_get_retro_key(unsigned bind_index)
return keybind->retro_key;
}


void input_config_reset_autoconfig_binds(unsigned port)
{
unsigned i;
Expand Down
1 change: 0 additions & 1 deletion configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,6 @@ typedef struct settings
bool input_touch_vmouse_trackball;
bool input_touch_vmouse_gesture;
#endif
bool input_sensor_flip_axis[MAX_USERS][RETROPAD_RETRO_SENSOR_LAST];

/* Frame time counter */
bool frame_time_counter_reset_after_fastforwarding;
Expand Down
48 changes: 6 additions & 42 deletions intl/msg_hash_lbl.h
Original file line number Diff line number Diff line change
Expand Up @@ -2009,65 +2009,29 @@ MSG_HASH(
"input_player%u_sensor_index"
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_INPUT_SENSOR_MAPPINGS,
"input_player%u_sensor_mappings"
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_INPUT_SENSOR_ACCELEROMETER_X,
MENU_ENUM_LABEL_INPUT_SENSOR_ACCELEROMETER_X,
"input_player%u_accelerometer_x_binding"
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_INPUT_SENSOR_ACCELEROMETER_X_FLIP,
"input_player%u_accelerometer_x_flip"
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_INPUT_SENSOR_ACCELEROMETER_Y,
MENU_ENUM_LABEL_INPUT_SENSOR_ACCELEROMETER_Y,
"input_player%u_accelerometer_y_binding"
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_INPUT_SENSOR_ACCELEROMETER_Y_FLIP,
"input_player%u_accelerometer_y_flip"
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_INPUT_SENSOR_ACCELEROMETER_Z,
MENU_ENUM_LABEL_INPUT_SENSOR_ACCELEROMETER_Z,
"input_player%u_accelerometer_z_binding"
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_INPUT_SENSOR_ACCELEROMETER_Z_FLIP,
"input_player%u_accelerometer_z_flip"
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_INPUT_SENSOR_GYROSCOPE_X,
MENU_ENUM_LABEL_INPUT_SENSOR_GYROSCOPE_X,
"input_player%u_gyroscope_x"
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_INPUT_SENSOR_GYROSCOPE_X_FLIP,
"input_player%u_gyroscope_x_flip"
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_INPUT_SENSOR_GYROSCOPE_Y,
MENU_ENUM_LABEL_INPUT_SENSOR_GYROSCOPE_Y,
"input_player%u_gyroscope_y"
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_INPUT_SENSOR_GYROSCOPE_Y_FLIP,
"input_player%u_gyroscope_y_flip"
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_INPUT_SENSOR_GYROSCOPE_Z,
MENU_ENUM_LABEL_INPUT_SENSOR_GYROSCOPE_Z,
"input_player%u_gyroscope_z"
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_INPUT_SENSOR_GYROSCOPE_Z_FLIP,
"input_player%u_gyroscope_z_flip"
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_INPUT_SENSOR_LIGHT,
"input_player%u_light"
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_INPUT_SENSOR_LIGHT_FLIP,
"input_player%u_light_flip"
)
MSG_HASH(
MENU_ENUM_LABEL_INPUT_JOYPAD_INDEX,
"input_player%u_joypad_index"
Expand Down
37 changes: 5 additions & 32 deletions intl/msg_hash_us.h
Original file line number Diff line number Diff line change
Expand Up @@ -4371,66 +4371,39 @@ MSG_HASH(
MENU_ENUM_LABEL_VALUE_INPUT_SENSOR_INDEX,
"Sensor Index"
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_INPUT_SENSOR_MAPPINGS,
"Sensor Mappings"
)

MSG_HASH(
MENU_ENUM_LABEL_VALUE_INPUT_SENSOR_ACCELEROMETER_X,
"Accelerometer X Binding"
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_INPUT_SENSOR_ACCELEROMETER_X_FLIP,
"Accelerometer X Flip"
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_INPUT_SENSOR_ACCELEROMETER_Y,
"Accelerometer Y Binding"
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_INPUT_SENSOR_ACCELEROMETER_Y_FLIP,
"Accelerometer Y Flip"
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_INPUT_SENSOR_ACCELEROMETER_Z,
"Accelerometer Z Binding"
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_INPUT_SENSOR_ACCELEROMETER_Z_FLIP,
"Accelerometer Z Flip"
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_INPUT_SENSOR_GYROSCOPE_X,
"Gyroscope X Binding"
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_INPUT_SENSOR_GYROSCOPE_X_FLIP,
"Gyroscope X Flip"
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_INPUT_SENSOR_GYROSCOPE_Y,
"Gyroscope Y Binding"
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_INPUT_SENSOR_GYROSCOPE_Y_FLIP,
"Gyroscope Y Flip"
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_INPUT_SENSOR_GYROSCOPE_Z,
"Gyroscope Z Binding"
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_INPUT_SENSOR_GYROSCOPE_Z_FLIP,
"Gyroscope Z Flip"
MENU_ENUM_LABEL_INPUT_ABS_SOURCE_VALUE,
"ABS Source %u Value"
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_INPUT_SENSOR_LIGHT,
"Light Binding"
MENU_ENUM_LABEL_INPUT_ABS_SOURCE,
"ABS Source %u"
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_INPUT_SENSOR_LIGHT_FLIP,
"Light Flip"
)
MSG_HASH(
MENU_ENUM_SUBLABEL_INPUT_MOUSE_INDEX,
"The physical mouse as recognized by RetroArch."
Expand Down
123 changes: 106 additions & 17 deletions menu/menu_setting.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,10 @@
if (SETTINGS_LIST_APPEND(a, b)) \
config_float(a, b, c, d, e, f, g, h, i, j, k, l)

#define CONFIG_FLOAT_ALT(a, b, c, d, e, f, g, h, i, j, k, l) \
if (SETTINGS_LIST_APPEND(a, b)) \
config_float_alt(a, b, c, d, e, f, g, h, i, j, k, l)

#define CONFIG_DIR(a, b, c, d, e, f, g, h, i, j, k, l, m) \
if (SETTINGS_LIST_APPEND(a, b)) \
config_dir(a, b, c, d, e, f, g, h, i, j, k, l, m)
Expand Down Expand Up @@ -2323,6 +2327,29 @@ static void config_float(
MENU_SETTINGS_LIST_CURRENT_ADD_ENUM_VALUE_IDX(list, list_info, SHORT_enum_idx);
}

static void config_float_alt(
rarch_setting_t **list,
rarch_setting_info_t *list_info,
float *target,
const char *name, const char *SHORT,
float default_value, const char *rounding,
rarch_setting_group_info_t *group_info,
rarch_setting_group_info_t *subgroup_info,
const char *parent_group,
change_handler_t change_handler, change_handler_t read_handler)
{
(*list)[list_info->index++] = setting_float_setting(
name,
SHORT, target, default_value, rounding,
group_info->name, subgroup_info->name, parent_group,
change_handler, read_handler, false);
(*list)[list_info->index - 1].ui_type = ST_UI_TYPE_FLOAT_SPINBOX;
/*
MENU_SETTINGS_LIST_CURRENT_ADD_ENUM_IDX_PTR(list, list_info, name_enum_idx);
MENU_SETTINGS_LIST_CURRENT_ADD_ENUM_VALUE_IDX(list, list_info, SHORT_enum_idx);
*/
}

static void config_path(
rarch_setting_t **list,
rarch_setting_info_t *list_info,
Expand Down Expand Up @@ -8242,6 +8269,19 @@ setting_get_string_representation_st_float_video_refresh_rate_auto(
else
strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NOT_AVAILABLE), len);
}
static void
setting_get_string_representation_st_float_sensor_auto(
rarch_setting_t *setting, char *s, size_t len){

settings_t * settings = config_get_ptr();
int remapped_port = settings->uints.input_sensor_index[setting->index_offset];
int sensor_poll=input_driver_get_sensor(
remapped_port,settings->bools.input_sensors_enable,setting->retropad_sensor_index);
if (settings->bools.input_sensors_enable)
snprintf(s,len,"%.0f", 100.f*sensor_poll);
else
strlcpy(s, "Disabled", len);
}

#ifdef HAVE_LIBNX
static void get_string_representation_split_joycon(rarch_setting_t *setting, char *s,
Expand Down Expand Up @@ -8396,6 +8436,11 @@ static void get_string_representation_input_sensor_index(
if (string_is_empty(s))
strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_DISABLED), len);
}
static void get_string_representation_of_abs_device(
rarch_setting_t *setting, char *s, size_t len)
{
snprintf(s, len, msg_hash_to_str(MENU_ENUM_LABEL_INPUT_ABS_SOURCE),setting->retropad_sensor_index);
}
static void read_handler_audio_rate_control_delta(rarch_setting_t *setting)
{
settings_t *settings = config_get_ptr();
Expand All @@ -8416,6 +8461,7 @@ static void read_handler_audio_rate_control_delta(rarch_setting_t *setting)
}
}


static void general_read_handler(rarch_setting_t *setting)
{
settings_t *settings = config_get_ptr();
Expand Down Expand Up @@ -10034,25 +10080,68 @@ static bool setting_append_list_input_player_options(
parent_group);
(*list)[list_info->index - 1].bind_type = i + MENU_SETTINGS_BIND_BEGIN;
}
for (j = 0; j < RETROPAD_RETRO_SENSOR_LAST; j++){
//TODO Retro Sensor
if (settings->bools.input_sensors_enable){
for (j = 0; j < RETROPAD_RETRO_SENSOR_LAST; j++){
/* TODO Retro Sensor */

char label[NAME_MAX_LENGTH];
char name[NAME_MAX_LENGTH];
snprintf(label,NAME_MAX_LENGTH, "test label %d", j);
snprintf(name,NAME_MAX_LENGTH, "test name %d", j);
char label[NAME_MAX_LENGTH];
char name[NAME_MAX_LENGTH];
strlcpy(label, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_INPUT_SENSOR_FIRST+j),NAME_MAX_LENGTH);
//snprintf(label,NAME_MAX_LENGTH, input_config_sensor_map_get_desc(j),user+1);
snprintf(name,NAME_MAX_LENGTH, "tmp name sensor bind %d", j);
CONFIG_UINT_ALT(
list, list_info,
&settings->uints.input_sensor_ids[user][j],
strdup(name),
strdup(label),
user,
&group_info,
&subgroup_info,
parent_group,
general_write_handler,
general_read_handler);
(*list)[list_info->index - 1].index = user + 1;
(*list)[list_info->index - 1].index_offset = user;
(*list)[list_info->index - 1].retropad_sensor_index = j;
(*list)[list_info->index - 1].get_string_representation =
&get_string_representation_of_abs_device;
//(*list)[list_info->index - 1].action_ok = &setting_action_ok_uint;
//menu_settings_list_current_add_range(list, list_info, 0, RETROPAD_RETRO_SENSOR_LAST - 1, 1, true, true);
}

CONFIG_BIND_ALT(
list, list_info,
&input_config_binds[user][i],
user + 1,
user,
strdup(name),
strdup(label),
&defaults[i],
&group_info,
&subgroup_info,
parent_group);
//static float dummy[RETROPAD_RETRO_SENSOR_LAST];
for (j = 0; j < RETROPAD_RETRO_SENSOR_LAST; j++){
/* TODO Retro Sensor */
char name[NAME_MAX_LENGTH];
char label[NAME_MAX_LENGTH];

static float dummy[6];
snprintf(
label,
NAME_MAX_LENGTH,
msg_hash_to_str(MENU_ENUM_LABEL_INPUT_ABS_SOURCE_VALUE),
j
);
RARCH_DBG("label: %s\n",label);
snprintf(name,NAME_MAX_LENGTH, "tmp name sensor poll %d", j);
CONFIG_FLOAT_ALT(
list, list_info,
&dummy[j],
strdup(name),
strdup(label),
0.f,
"%.3f",
&group_info,
&subgroup_info,
parent_group,
general_write_handler,
general_read_handler);
(*list)[list_info->index - 1].index = user + 1;
(*list)[list_info->index - 1].index_offset = user;
(*list)[list_info->index - 1].retropad_sensor_index = j;
(*list)[list_info->index - 1].get_string_representation =
&setting_get_string_representation_st_float_sensor_auto;
}
}
}

Expand Down
Loading

0 comments on commit 5563b32

Please sign in to comment.