From 7867b09a0e8cd89d6797ca08c491936fadc3801b Mon Sep 17 00:00:00 2001 From: eadmaster <925171+eadmaster@users.noreply.github.com> Date: Mon, 27 Jan 2020 20:10:35 +0100 Subject: [PATCH 1/3] added GET_STATUS network command (#9483) will return a string with the name of the current core running, the content name and crc32 --- retroarch.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/retroarch.c b/retroarch.c index dc50c86ff7..f387c037e5 100644 --- a/retroarch.c +++ b/retroarch.c @@ -3745,6 +3745,35 @@ static bool command_version(const char* arg) return true; } +static bool command_get_status(const char* arg) +{ + char reply[4096] = {0}; + + bool contentless = false; + bool is_inited = false; + content_get_status(&contentless, &is_inited); + + if(!is_inited) { + snprintf(reply, sizeof(reply), "GET_STATUS CONTENTLESS"); + } else { + // add some content info + //char* content_name = load_content_info->content->elems[0].data; // full path + const char* content_name = path_basename(path_get(RARCH_PATH_BASENAME)); // filename only without ext + int content_crc32 = content_get_crc(); + const char* system_id = NULL; + core_info_t *core_info = NULL; + core_info_get_current_core(&core_info); + if (core_info) system_id = core_info->system_id; + if (!system_id) system_id = runloop_system.info.library_name; + + snprintf(reply, sizeof(reply), "GET_STATUS RUNNING %s,%s,crc32=%x\n", system_id, content_name, content_crc32); + } + + command_reply(reply, strlen(reply)); + + return true; +} + #if defined(HAVE_CHEEVOS) static bool command_read_ram(const char *arg); static bool command_write_ram(const char *arg); @@ -3753,6 +3782,7 @@ static bool command_write_ram(const char *arg); static const struct cmd_action_map action_map[] = { { "SET_SHADER", command_set_shader, "" }, { "VERSION", command_version, "No argument"}, + { "GET_STATUS", command_get_status, "No argument" }, #if defined(HAVE_CHEEVOS) { "READ_CORE_RAM", command_read_ram, "
" }, { "WRITE_CORE_RAM", command_write_ram, "
..." }, From 7e7429cadd1fda78e6f4f8600297cd97d667af7a Mon Sep 17 00:00:00 2001 From: eadmaster <925171+eadmaster@users.noreply.github.com> Date: Mon, 27 Jan 2020 23:35:11 +0100 Subject: [PATCH 2/3] fixed comments style --- retroarch.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/retroarch.c b/retroarch.c index f387c037e5..e5d0ddd36d 100644 --- a/retroarch.c +++ b/retroarch.c @@ -3756,9 +3756,9 @@ static bool command_get_status(const char* arg) if(!is_inited) { snprintf(reply, sizeof(reply), "GET_STATUS CONTENTLESS"); } else { - // add some content info - //char* content_name = load_content_info->content->elems[0].data; // full path - const char* content_name = path_basename(path_get(RARCH_PATH_BASENAME)); // filename only without ext + /* add some content info */ + /* char* content_name = load_content_info->content->elems[0].data; */ /* full path */ + const char* content_name = path_basename(path_get(RARCH_PATH_BASENAME)); /* filename only without ext */ int content_crc32 = content_get_crc(); const char* system_id = NULL; core_info_t *core_info = NULL; From 491c0457a6148319285fe7ef1e29106e66c91210 Mon Sep 17 00:00:00 2001 From: eadmaster <925171+eadmaster@users.noreply.github.com> Date: Tue, 28 Jan 2020 21:40:56 +0100 Subject: [PATCH 3/3] added detection of paused state --- retroarch.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/retroarch.c b/retroarch.c index e5d0ddd36d..739a7420e9 100644 --- a/retroarch.c +++ b/retroarch.c @@ -3758,6 +3758,8 @@ static bool command_get_status(const char* arg) } else { /* add some content info */ /* char* content_name = load_content_info->content->elems[0].data; */ /* full path */ + const char* status = "RUNNING"; + if( runloop_paused ) status = "PAUSED"; const char* content_name = path_basename(path_get(RARCH_PATH_BASENAME)); /* filename only without ext */ int content_crc32 = content_get_crc(); const char* system_id = NULL; @@ -3766,7 +3768,7 @@ static bool command_get_status(const char* arg) if (core_info) system_id = core_info->system_id; if (!system_id) system_id = runloop_system.info.library_name; - snprintf(reply, sizeof(reply), "GET_STATUS RUNNING %s,%s,crc32=%x\n", system_id, content_name, content_crc32); + snprintf(reply, sizeof(reply), "GET_STATUS %s %s,%s,crc32=%x\n", status, system_id, content_name, content_crc32); } command_reply(reply, strlen(reply));