Merge pull request #10073 from eadmaster/patch-1

added GET_STATUS network command
This commit is contained in:
Twinaphex 2020-01-28 23:57:01 +01:00 committed by GitHub
commit 255790b664
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3745,6 +3745,37 @@ 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* 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;
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 %s %s,%s,crc32=%x\n", status, 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 +3784,7 @@ static bool command_write_ram(const char *arg);
static const struct cmd_action_map action_map[] = {
{ "SET_SHADER", command_set_shader, "<shader path>" },
{ "VERSION", command_version, "No argument"},
{ "GET_STATUS", command_get_status, "No argument" },
#if defined(HAVE_CHEEVOS)
{ "READ_CORE_RAM", command_read_ram, "<address> <number of bytes>" },
{ "WRITE_CORE_RAM", command_write_ram, "<address> <byte1> <byte2> ..." },