(menu_setting) Refactor this macro mess

This commit is contained in:
twinaphex 2015-11-21 16:32:22 +01:00
parent 892d99b3a6
commit aa1e8dc543
5 changed files with 2461 additions and 1810 deletions

View File

@ -130,6 +130,12 @@ enum
RECORD_NULL RECORD_NULL
}; };
#ifdef GEKKO
#define MAX_GAMMA_SETTING 2
#else
#define MAX_GAMMA_SETTING 1
#endif
#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES) || defined(__CELLOS_LV2__) #if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES) || defined(__CELLOS_LV2__)
#define VIDEO_DEFAULT_DRIVER VIDEO_GL #define VIDEO_DEFAULT_DRIVER VIDEO_GL
#elif defined(GEKKO) #elif defined(GEKKO)

View File

@ -28,6 +28,7 @@
#include "../string_list_special.h" #include "../string_list_special.h"
#ifdef HAVE_MENU #ifdef HAVE_MENU
#include "../menu/menu_hash.h"
#include "../menu/menu_setting.h" #include "../menu/menu_setting.h"
#endif #endif
@ -1162,43 +1163,54 @@ static void video_monitor_adjust_system_rates(void)
RARCH_LOG("Game FPS > Monitor FPS. Cannot rely on VSync.\n"); RARCH_LOG("Game FPS > Monitor FPS. Cannot rely on VSync.\n");
} }
void video_driver_menu_settings(void *data, void *subgroup_data, const char *parent_group) void video_driver_menu_settings(void **list_data, void *list_info_data,
void *group_data, void *subgroup_data, const char *parent_group)
{ {
#ifdef HAVE_MENU #ifdef HAVE_MENU
rarch_setting_group_info_t *group_info = (rarch_setting_group_info_t*)data; rarch_setting_t **list = (rarch_setting_t**)list_data;
rarch_setting_info_t *list_info = (rarch_setting_info_t*)list_info_data;
rarch_setting_group_info_t *group_info = (rarch_setting_group_info_t*)group_data;
rarch_setting_group_info_t *subgroup_info = (rarch_setting_group_info_t*)subgroup_data; rarch_setting_group_info_t *subgroup_info = (rarch_setting_group_info_t*)subgroup_data;
global_t *global = global_get_ptr();
(void)list;
(void)list_info;
(void)group_info; (void)group_info;
(void)subgroup_info; (void)subgroup_info;
(void)global;
#if defined(GEKKO) || defined(__CELLOS_LV2__) #if defined(GEKKO) || defined(__CELLOS_LV2__)
CONFIG_ACTION( CONFIG_ACTION(
list, list_info,
menu_hash_to_str(MENU_LABEL_SCREEN_RESOLUTION), menu_hash_to_str(MENU_LABEL_SCREEN_RESOLUTION),
menu_hash_to_str(MENU_LABEL_VALUE_SCREEN_RESOLUTION), menu_hash_to_str(MENU_LABEL_VALUE_SCREEN_RESOLUTION),
group_info->name, group_info,
subgroup_info->name, subgroup_info,
parent_group); parent_group);
#endif #endif
#if defined(__CELLOS_LV2__) #if defined(__CELLOS_LV2__)
CONFIG_BOOL( CONFIG_BOOL(
list, list_info,
&global->console.screen.pal60_enable, &global->console.screen.pal60_enable,
menu_hash_to_str(MENU_LABEL_PAL60_ENABLE), menu_hash_to_str(MENU_LABEL_PAL60_ENABLE),
menu_hash_to_str(MENU_LABEL_VALUE_PAL60_ENABLE), menu_hash_to_str(MENU_LABEL_VALUE_PAL60_ENABLE),
false, false,
menu_hash_to_str(MENU_VALUE_OFF), menu_hash_to_str(MENU_VALUE_OFF),
menu_hash_to_str(MENU_VALUE_ON), menu_hash_to_str(MENU_VALUE_ON),
group_info->name, group_info,
subgroup_info->name, subgroup_info,
parent_group, parent_group,
general_write_handler, general_write_handler,
general_read_handler); general_read_handler);
#endif #endif
#if defined(HW_RVL) || defined(_XBOX360) #if defined(HW_RVL) || defined(_XBOX360)
CONFIG_UINT( CONFIG_UINT(
global->console.screen.gamma_correction, list, list_info,
&global->console.screen.gamma_correction,
menu_hash_to_str(MENU_LABEL_VIDEO_GAMMA), menu_hash_to_str(MENU_LABEL_VIDEO_GAMMA),
menu_hash_to_str(MENU_LABEL_VALUE_VIDEO_GAMMA), menu_hash_to_str(MENU_LABEL_VALUE_VIDEO_GAMMA),
0, 0,
group_info->name, group_info,
subgroup_info->name, subgroup_info,
parent_group, parent_group,
general_write_handler, general_write_handler,
general_read_handler); general_read_handler);
@ -1218,14 +1230,15 @@ void video_driver_menu_settings(void *data, void *subgroup_data, const char *par
#endif #endif
#if defined(_XBOX1) || defined(HW_RVL) #if defined(_XBOX1) || defined(HW_RVL)
CONFIG_BOOL( CONFIG_BOOL(
list, list_info,
&global->console.softfilter_enable, &global->console.softfilter_enable,
menu_hash_to_str(MENU_LABEL_VIDEO_SOFT_FILTER), menu_hash_to_str(MENU_LABEL_VIDEO_SOFT_FILTER),
menu_hash_to_str(MENU_LABEL_VALUE_VIDEO_SOFT_FILTER), menu_hash_to_str(MENU_LABEL_VALUE_VIDEO_SOFT_FILTER),
false, false,
menu_hash_to_str(MENU_VALUE_OFF), menu_hash_to_str(MENU_VALUE_OFF),
menu_hash_to_str(MENU_VALUE_ON), menu_hash_to_str(MENU_VALUE_ON),
group_info->name, group_info,
subgroup_info->name, subgroup_info,
parent_group, parent_group,
general_write_handler, general_write_handler,
general_read_handler); general_read_handler);
@ -1236,12 +1249,13 @@ void video_driver_menu_settings(void *data, void *subgroup_data, const char *par
#endif #endif
#ifdef _XBOX1 #ifdef _XBOX1
CONFIG_UINT( CONFIG_UINT(
settings->video.swap_interval, list, list_info,
&settings->video.swap_interval,
menu_hash_to_str(MENU_LABEL_VIDEO_FILTER_FLICKER), menu_hash_to_str(MENU_LABEL_VIDEO_FILTER_FLICKER),
menu_hash_to_str(MENU_LABEL_VALUE_VIDEO_FILTER_FLICKER), menu_hash_to_str(MENU_LABEL_VALUE_VIDEO_FILTER_FLICKER),
0, 0,
group_info.name, group_info,
subgroup_info.name, subgroup_info,
parent_group, parent_group,
general_write_handler, general_write_handler,
general_read_handler); general_read_handler);

View File

@ -434,7 +434,8 @@ void video_driver_cached_frame_set_ptr(const void *data);
void video_driver_cached_frame_get(const void **data, unsigned *width, void video_driver_cached_frame_get(const void **data, unsigned *width,
unsigned *height, size_t *pitch); unsigned *height, size_t *pitch);
void video_driver_menu_settings(void *data, void *subgroup_data, const char *parent_group); void video_driver_menu_settings(void **list_data, void *list_info_data,
void *group_data, void *subgroup_data, const char *parent_group);
/** /**
* video_viewport_get_scaled_integer: * video_viewport_get_scaled_integer:

File diff suppressed because it is too large Load Diff

View File

@ -21,6 +21,10 @@
#include <stdlib.h> #include <stdlib.h>
#include <boolean.h> #include <boolean.h>
#include "../command_event.h"
#include "../libretro.h"
#include "../input/input_driver.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
@ -97,86 +101,177 @@ enum setting_list_flags
typedef struct rarch_setting_group_info rarch_setting_group_info_t; typedef struct rarch_setting_group_info rarch_setting_group_info_t;
typedef struct rarch_setting rarch_setting_t; typedef struct rarch_setting rarch_setting_t;
typedef struct rarch_setting_info rarch_setting_info_t;
typedef void (*change_handler_t )(void *data);
typedef int (*action_left_handler_t )(void *data, bool wraparound);
typedef int (*action_right_handler_t )(void *data, bool wraparound);
typedef int (*action_up_handler_t )(void *data);
typedef int (*action_down_handler_t )(void *data);
typedef int (*action_start_handler_t )(void *data);
typedef int (*action_cancel_handler_t )(void *data);
typedef int (*action_ok_handler_t )(void *data, bool wraparound);
typedef int (*action_select_handler_t )(void *data, bool wraparound);
typedef void (*get_string_representation_t )(void *data, char *s, size_t len);
rarch_setting_t setting_group_setting(enum setting_type type, const char* name,
const char *parent_group);
/**
* setting_action_setting:
* @name : Name of setting.
* @short_description : Short description of setting.
* @group : Group that the setting belongs to.
* @subgroup : Subgroup that the setting belongs to.
*
* Initializes a setting of type ST_ACTION.
*
* Returns: setting of type ST_ACTION.
**/
rarch_setting_t setting_action_setting(const char* name,
const char* short_description,
const char *group, const char *subgroup,
const char *parent_group);
#define SL_FLAG_SETTINGS_GROUP_ALL (SL_FLAG_SETTINGS_ALL - SL_FLAG_MAIN_MENU) #define SL_FLAG_SETTINGS_GROUP_ALL (SL_FLAG_SETTINGS_ALL - SL_FLAG_MAIN_MENU)
#define START_GROUP(group_info, NAME, parent_group) \ bool START_GROUP(rarch_setting_t **list, rarch_setting_info_t *list_info,
do{ \ rarch_setting_group_info_t *group_info,
group_info.name = NAME; \ const char *name, const char *parent_group);
if (!(menu_settings_list_append(list, list_info, setting_group_setting (ST_GROUP, NAME, parent_group)))) return false; \
}while(0)
#define END_GROUP(list, list_info, parent_group) \ bool END_GROUP(rarch_setting_t **list, rarch_setting_info_t *list_info,
do{ \ const char *parent_group);
if (!(menu_settings_list_append(list, list_info, setting_group_setting (ST_END_GROUP, 0, parent_group)))) return false; \
}while(0)
#define START_SUB_GROUP(list, list_info, NAME, group_info, subgroup_info, parent_group) \ bool START_SUB_GROUP(rarch_setting_t **list,
do{ \ rarch_setting_info_t *list_info, const char *name,
subgroup_info.name = NAME; \ rarch_setting_group_info_t *group_info,
if (!(menu_settings_list_append(list, list_info, setting_subgroup_setting (ST_SUB_GROUP, NAME, group_info, parent_group)))) return false; \ rarch_setting_group_info_t *subgroup_info,
}while(0) const char *parent_group);
#define END_SUB_GROUP(list, list_info, parent_group) \ bool END_SUB_GROUP(
do{ \ rarch_setting_t **list,
if (!(menu_settings_list_append(list, list_info, setting_group_setting (ST_END_SUB_GROUP, 0, parent_group)))) return false; \ rarch_setting_info_t *list_info,
}while(0) const char *parent_group);
#define CONFIG_ACTION(NAME, SHORT, group_info, subgroup_info, parent_group) \ bool CONFIG_ACTION(
do{ \ rarch_setting_t **list,
if (!menu_settings_list_append(list, list_info, setting_action_setting (NAME, SHORT, group_info, subgroup_info, parent_group))) return false; \ rarch_setting_info_t *list_info,
}while(0) const char *name, const char *SHORT,
rarch_setting_group_info_t *group_info,
rarch_setting_group_info_t *subgroup_info,
const char *parent_group);
#define CONFIG_BOOL(TARGET, NAME, SHORT, DEF, OFF, ON, group_info, subgroup_info, parent_group, CHANGE_HANDLER, READ_HANDLER) \ bool CONFIG_BOOL(
do{ \ rarch_setting_t **list,
if (!menu_settings_list_append(list, list_info, setting_bool_setting (NAME, SHORT, TARGET, DEF, OFF, ON, group_info, subgroup_info, parent_group, CHANGE_HANDLER, READ_HANDLER)))return false; \ rarch_setting_info_t *list_info,
}while(0) bool *target,
const char *name, const char *SHORT,
bool default_value,
const char *off, const char *on,
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);
#define CONFIG_INT(TARGET, NAME, SHORT, DEF, group_info, subgroup_info, parent_group, CHANGE_HANDLER, READ_HANDLER) \ bool CONFIG_INT(
do{ \ rarch_setting_t **list,
if (!(menu_settings_list_append(list, list_info, setting_int_setting (NAME, SHORT, &TARGET, DEF, group_info, subgroup_info, parent_group, CHANGE_HANDLER, READ_HANDLER)))) return false; \ rarch_setting_info_t *list_info,
}while(0) int *target,
const char *name, const char *SHORT,
int default_value,
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);
#define CONFIG_UINT(TARGET, NAME, SHORT, DEF, group_info, subgroup_info, parent_group, CHANGE_HANDLER, READ_HANDLER) \ bool CONFIG_UINT(
do{ \ rarch_setting_t **list,
if (!(menu_settings_list_append(list, list_info, setting_uint_setting (NAME, SHORT, &TARGET, DEF, group_info, subgroup_info, parent_group, CHANGE_HANDLER, READ_HANDLER)))) return false; \ rarch_setting_info_t *list_info,
}while(0) unsigned int *target,
const char *name, const char *SHORT,
unsigned int default_value,
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);
#define CONFIG_FLOAT(TARGET, NAME, SHORT, DEF, ROUNDING, group_info, subgroup_info, parent_group, CHANGE_HANDLER, READ_HANDLER) \ bool CONFIG_FLOAT(
do{ \ rarch_setting_t **list,
if (!(menu_settings_list_append(list, list_info, setting_float_setting (NAME, SHORT, &TARGET, DEF, ROUNDING, group_info, subgroup_info, parent_group, CHANGE_HANDLER, READ_HANDLER)))) return false; \ rarch_setting_info_t *list_info,
}while(0) 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);
#define CONFIG_PATH(TARGET, NAME, SHORT, DEF, group_info, subgroup_info, parent_group, CHANGE_HANDLER, READ_HANDLER) \ bool CONFIG_PATH(
do{ \ rarch_setting_t **list,
if (!(menu_settings_list_append(list, list_info, setting_string_setting(ST_PATH, NAME, SHORT, TARGET, sizeof(TARGET), DEF, "", group_info, subgroup_info, parent_group, CHANGE_HANDLER, READ_HANDLER)))) return false; \ rarch_setting_info_t *list_info,
}while(0) char *target, size_t len,
const char *name, const char *SHORT,
const char *default_value,
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);
#define CONFIG_DIR(TARGET, NAME, SHORT, DEF, EMPTY, group_info, subgroup_info, parent_group, CHANGE_HANDLER, READ_HANDLER) \ bool CONFIG_DIR(
do{ \ rarch_setting_t **list,
if (!(menu_settings_list_append(list, list_info, setting_string_setting(ST_DIR, NAME, SHORT, TARGET, sizeof(TARGET), DEF, EMPTY, group_info, subgroup_info, parent_group, CHANGE_HANDLER, READ_HANDLER)))) return false; \ rarch_setting_info_t *list_info,
}while(0) char *target, size_t len,
const char *name, const char *SHORT,
const char *default_value, const char *empty,
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);
#define CONFIG_STRING(TARGET, NAME, SHORT, DEF, group_info, subgroup_info, parent_group, CHANGE_HANDLER, READ_HANDLER) \ bool CONFIG_STRING(
do{ \ rarch_setting_t **list,
if (!(menu_settings_list_append(list, list_info, setting_string_setting(ST_STRING, NAME, SHORT, TARGET, sizeof(TARGET), DEF, "", group_info, subgroup_info, parent_group, CHANGE_HANDLER, READ_HANDLER)))) return false; \ rarch_setting_info_t *list_info,
}while(0) char *target, size_t len,
const char *name, const char *SHORT,
const char *default_value,
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);
#define CONFIG_STRING_OPTIONS(TARGET, NAME, SHORT, DEF, OPTS, group_info, subgroup_info, parent_group, CHANGE_HANDLER, READ_HANDLER) \ bool CONFIG_STRING_OPTIONS(
do{ \ rarch_setting_t **list,
if (!(menu_settings_list_append(list, list_info, setting_string_setting_options(ST_STRING_OPTIONS, NAME, SHORT, TARGET, sizeof(TARGET), DEF, "", OPTS, group_info, subgroup_info, parent_group, CHANGE_HANDLER, READ_HANDLER)))) return false; \ rarch_setting_info_t *list_info,
}while(0) char *target, size_t len,
const char *name, const char *SHORT,
const char *default_value, const char *values,
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);
#define CONFIG_HEX(TARGET, NAME, SHORT, DEF, group_info, subgroup_info, parent_group, CHANGE_HANDLER, READ_HANDLER) \ bool CONFIG_HEX(
do{ \ rarch_setting_t **list,
if (!(menu_settings_list_append(list, list_info, setting_hex_setting(NAME, SHORT, &TARGET, DEF, group_info, subgroup_info, parent_group, CHANGE_HANDLER, READ_HANDLER)))) return false; \ rarch_setting_info_t *list_info,
}while(0) unsigned int *target,
const char *name, const char *SHORT,
unsigned int default_value,
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);
/* Please strdup() NAME and SHORT */ /* Please strdup() NAME and SHORT */
#define CONFIG_BIND(TARGET, PLAYER, PLAYER_OFFSET, NAME, SHORT, DEF, group_info, subgroup_info, parent_group) \ bool CONFIG_BIND(
do{ \ rarch_setting_t **list,
if (!(menu_settings_list_append(list, list_info, setting_bind_setting (NAME, SHORT, &TARGET, PLAYER, PLAYER_OFFSET, DEF, group_info, subgroup_info, parent_group)))) return false; \ rarch_setting_info_t *list_info,
}while(0) struct retro_keybind *target,
uint32_t player, uint32_t player_offset,
const char *name, const char *SHORT,
const struct retro_keybind *default_value,
rarch_setting_group_info_t *group_info,
rarch_setting_group_info_t *subgroup_info,
const char *parent_group);
int menu_setting_generic(rarch_setting_t *setting, bool wraparound); int menu_setting_generic(rarch_setting_t *setting, bool wraparound);
@ -283,6 +378,26 @@ bool menu_setting_action_right(rarch_setting_t *setting, bool wraparound);
void menu_settings_list_increment(rarch_setting_t **list); void menu_settings_list_increment(rarch_setting_t **list);
void general_write_handler(void *data);
void general_read_handler(void *data);
void menu_settings_list_current_add_cmd(
rarch_setting_t **list,
rarch_setting_info_t *list_info,
enum event_command values);
void menu_settings_list_current_add_range(
rarch_setting_t **list,
rarch_setting_info_t *list_info,
float min, float max, float step,
bool enforce_minrange_enable, bool enforce_maxrange_enable);
void settings_data_list_current_add_flags(
rarch_setting_t **list,
rarch_setting_info_t *list_info,
unsigned values);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif