From d08779adf039d16f94a1e80aa08207c23af827b8 Mon Sep 17 00:00:00 2001 From: radius Date: Thu, 11 Apr 2019 18:51:27 -0500 Subject: [PATCH] [subsystem] add a function to get the friendly name --- content.h | 3 +++ tasks/task_content.c | 22 ++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/content.h b/content.h index 20ff9cd9aa..fb44c05e21 100644 --- a/content.h +++ b/content.h @@ -112,6 +112,9 @@ char* content_get_subsystem_rom(unsigned index); /* Sets the subsystem by name */ bool content_set_subsystem_by_name(const char* subsystem_name); +/* Get the current subsystem "friendly name" */ +void content_get_subsystem_friendly_name(const char* subsystem_name, char* subsystem_friendly_name, size_t len); + RETRO_END_DECLS #endif diff --git a/tasks/task_content.c b/tasks/task_content.c index 348cf524e2..ccbdb42a3d 100644 --- a/tasks/task_content.c +++ b/tasks/task_content.c @@ -1982,6 +1982,28 @@ bool content_set_subsystem_by_name(const char* subsystem_name) return false; } +void content_get_subsystem_friendly_name(const char* subsystem_name, char* subsystem_friendly_name, size_t len) +{ + rarch_system_info_t *system = runloop_get_system_info(); + const struct retro_subsystem_info *subsystem; + unsigned i = 0; + + /* Core fully loaded, use the subsystem data */ + if (system->subsystem.data) + subsystem = system->subsystem.data; + /* Core not loaded completely, use the data we peeked on load core */ + else + subsystem = subsystem_data; + + for (i = 0; i < subsystem_current_count; i++, subsystem++) + { + if (string_is_equal(subsystem_name, subsystem->ident)) + strlcpy(subsystem_friendly_name, subsystem->desc, len); + } + + return; +} + /* Add a rom to the subsystem rom buffer */ void content_add_subsystem(const char* path) {