(Menu) Add menu driver selection

This commit is contained in:
twinaphex 2014-01-27 01:32:05 +01:00
parent 3d944fd485
commit 580e05fc0f
6 changed files with 60 additions and 1 deletions

View File

@ -2030,6 +2030,9 @@ void menu_populate_entries(void *data, unsigned menu_type)
#endif
#ifdef HAVE_LOCATION
file_list_push(rgui->selection_buf, "Location driver", RGUI_SETTINGS_DRIVER_LOCATION, 0);
#endif
#ifdef HAVE_MENU
file_list_push(rgui->selection_buf, "Menu driver", RGUI_SETTINGS_DRIVER_MENU, 0);
#endif
break;
case RGUI_SETTINGS:

View File

@ -126,6 +126,7 @@ typedef enum
RGUI_SETTINGS_DRIVER_INPUT,
RGUI_SETTINGS_DRIVER_CAMERA,
RGUI_SETTINGS_DRIVER_LOCATION,
RGUI_SETTINGS_DRIVER_MENU,
RGUI_SETTINGS_SCREENSHOT,
RGUI_SETTINGS_GPU_SCREENSHOT,
RGUI_SCREENSHOT_DIR_PATH,

View File

@ -47,6 +47,39 @@ const menu_ctx_driver_t *menu_ctx_find_driver(const char *ident)
return NULL;
}
static int find_menu_driver_index(const char *driver)
{
unsigned i;
for (i = 0; menu_ctx_drivers[i]; i++)
if (strcasecmp(driver, menu_ctx_drivers[i]->ident) == 0)
return i;
return -1;
}
void find_prev_menu_driver(void)
{
int i = find_menu_driver_index(g_settings.menu.driver);
if (i > 0)
{
strlcpy(g_settings.menu.driver, menu_ctx_drivers[i - 1]->ident, sizeof(g_settings.menu.driver));
menu_ctx = menu_ctx_drivers[i - 1];
}
else
RARCH_WARN("Couldn't find any previous menu driver (current one: \"%s\").\n", g_settings.menu.driver);
}
void find_next_menu_driver(void)
{
int i = find_menu_driver_index(g_settings.menu.driver);
if (i >= 0 && menu_ctx_drivers[i + 1])
{
strlcpy(g_settings.menu.driver, menu_ctx_drivers[i + 1]->ident, sizeof(g_settings.menu.driver));
menu_ctx = menu_ctx_drivers[i + 1];
}
else
RARCH_WARN("Couldn't find any next menu driver (current one: \"%s\").\n", g_settings.menu.driver);
}
bool menu_ctx_init_first(const menu_ctx_driver_t **driver, void **data)
{
unsigned i;
@ -62,10 +95,10 @@ bool menu_ctx_init_first(const menu_ctx_driver_t **driver, void **data)
{
*driver = menu_ctx_drivers[i];
*handle = (rgui_handle_t*)h;
strlcpy(g_settings.menu.driver, menu_ctx_drivers[i]->ident, sizeof(g_settings.menu.driver));
return true;
}
}
return false;
}

View File

@ -46,5 +46,7 @@ extern const menu_ctx_driver_t menu_ctx_rgui;
const menu_ctx_driver_t *menu_ctx_find_driver(const char *ident); // Finds driver with ident. Does not initialize.
bool menu_ctx_init_first(const menu_ctx_driver_t **driver, void **handle); // Finds first suitable driver and initializes.
void find_prev_menu_driver(void);
void find_next_menu_driver(void);
#endif

View File

@ -1055,6 +1055,14 @@ int menu_set_settings(void *data, unsigned setting, unsigned action)
else if (action == RGUI_ACTION_RIGHT)
find_next_location_driver();
break;
#endif
#ifdef HAVE_MENU
case RGUI_SETTINGS_DRIVER_MENU:
if (action == RGUI_ACTION_LEFT)
find_prev_menu_driver();
else if (action == RGUI_ACTION_RIGHT)
find_next_menu_driver();
break;
#endif
case RGUI_SETTINGS_VIDEO_GAMMA:
if (action == RGUI_ACTION_START)
@ -1687,6 +1695,11 @@ void menu_set_settings_label(char *type_str, size_t type_str_size, unsigned *w,
case RGUI_SETTINGS_DRIVER_LOCATION:
strlcpy(type_str, g_settings.location.driver, type_str_size);
break;
#endif
#ifdef HAVE_MENU
case RGUI_SETTINGS_DRIVER_MENU:
strlcpy(type_str, g_settings.menu.driver, type_str_size);
break;
#endif
case RGUI_SETTINGS_VIDEO_REFRESH_RATE_AUTO:
{

View File

@ -179,6 +179,13 @@ struct settings
bool allow_rotate;
} video;
#ifdef HAVE_MENU
struct
{
char driver[32];
} menu;
#endif
#ifdef HAVE_CAMERA
struct
{