Merge pull request #2436 from lakkatv/master

Implement core assignation switching
This commit is contained in:
Twinaphex 2015-11-20 07:09:36 +01:00
commit 2ac9390a21
4 changed files with 96 additions and 8 deletions

View File

@ -558,6 +558,18 @@ core_info_t *core_info_find(core_info_list_t *list,
return NULL;
}
core_info_t *core_info_get(core_info_list_t *list, size_t i)
{
core_info_t *info = (core_info_t*)&list->list[i];
printf("%zu\n", i);
if (!info)
return NULL;
if (!info->path)
return NULL;
return info;
}
static int core_info_firmware_cmp(const void *a_, const void *b_)
{
const core_info_firmware_t *a = (const core_info_firmware_t*)a_;

View File

@ -111,6 +111,8 @@ bool core_info_get_display_name(const char *path, char *s, size_t len);
void core_info_get_name(const char *path, char *s, size_t len);
core_info_t *core_info_get(core_info_list_t *list, size_t i);
#ifdef __cplusplus
}
#endif

View File

@ -302,11 +302,48 @@ static int action_left_video_resolution(unsigned type, const char *label,
static int playlist_association_left(unsigned type, const char *label,
bool wraparound)
{
unsigned idx = type - MENU_SETTINGS_PLAYLIST_ASSOCIATION_START;
rarch_system_info_t *system = rarch_system_info_get_ptr();
int i, next, found, current = 0;
char core_path[PATH_MAX_LENGTH] = {0};
global_t *global = global_get_ptr();
settings_t *settings = config_get_ptr();
const char *path = path_basename(label);
char new_playlist_cores[PATH_MAX_LENGTH] = {0};
(void)idx;
(void)system;
core_info_list_t *list = (global->core_info.list) ? global->core_info.list : NULL;
if (!list)
return NULL;
struct string_list *stnames = string_split(settings->playlist_names, ";");
struct string_list *stcores = string_split(settings->playlist_cores, ";");
if (!menu_playlist_find_associated_core(path, core_path, sizeof(core_path)))
strlcpy(core_path, "DETECT", sizeof(core_path));
for (i = 0; i < list->count; i++)
{
core_info_t *info = core_info_get(list, i);
if (!strcmp(info->path, core_path))
current = i;
}
next = current - 1;
if (next < 0)
{
if (wraparound)
next = list->count;
else
next = 0;
}
core_info_t *info = core_info_get(list, next);
found = string_list_find_elem(stnames, path);
if (found)
string_list_set(stcores, found-1, info->path);
string_list_join_concat(new_playlist_cores, sizeof(new_playlist_cores), stcores, ";");
strlcpy(settings->playlist_cores, new_playlist_cores, sizeof(settings->playlist_cores));
return 0;
}

View File

@ -327,11 +327,48 @@ static int action_right_video_resolution(unsigned type, const char *label,
static int playlist_association_right(unsigned type, const char *label,
bool wraparound)
{
unsigned idx = type - MENU_SETTINGS_PLAYLIST_ASSOCIATION_START;
rarch_system_info_t *system = rarch_system_info_get_ptr();
int i, next, found, current = 0;
char core_path[PATH_MAX_LENGTH] = {0};
global_t *global = global_get_ptr();
settings_t *settings = config_get_ptr();
const char *path = path_basename(label);
char new_playlist_cores[PATH_MAX_LENGTH] = {0};
(void)system;
(void)idx;
core_info_list_t *list = (global->core_info.list) ? global->core_info.list : NULL;
if (!list)
return NULL;
struct string_list *stnames = string_split(settings->playlist_names, ";");
struct string_list *stcores = string_split(settings->playlist_cores, ";");
if (!menu_playlist_find_associated_core(path, core_path, sizeof(core_path)))
strlcpy(core_path, "DETECT", sizeof(core_path));
for (i = 0; i < list->count; i++)
{
core_info_t *info = core_info_get(list, i);
if (!strcmp(info->path, core_path))
current = i;
}
next = current + 1;
if (next >= list->count)
{
if (wraparound)
next = list->count-1;
else
next = 0;
}
core_info_t *info = core_info_get(list, next);
found = string_list_find_elem(stnames, path);
if (found)
string_list_set(stcores, found-1, info->path);
string_list_join_concat(new_playlist_cores, sizeof(new_playlist_cores), stcores, ";");
strlcpy(settings->playlist_cores, new_playlist_cores, sizeof(settings->playlist_cores));
return 0;
}