Skip to content

Commit c549bef

Browse files
committed
webOS: add webOS TV version to log and system information screen
1 parent 513dd4e commit c549bef

File tree

2 files changed

+75
-1
lines changed

2 files changed

+75
-1
lines changed

frontend/drivers/platform_unix.c

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1299,6 +1299,59 @@ static enum frontend_architecture frontend_unix_get_arch(void)
12991299
return FRONTEND_ARCH_NONE;
13001300
}
13011301

1302+
#ifdef WEBOS
1303+
const char *retroarch_get_webos_version(char *s, size_t len,
1304+
int *major, int *minor)
1305+
{
1306+
static char pretty[128];
1307+
static int inited = 0;
1308+
1309+
if (!inited)
1310+
{
1311+
FILE *f = fopen("/usr/lib/os-release", "r");
1312+
if (f)
1313+
{
1314+
char line[256];
1315+
while (fgets(line, sizeof(line), f))
1316+
{
1317+
if (strncmp(line, "PRETTY_NAME=", 12) == 0)
1318+
{
1319+
char *val = line + 12;
1320+
char *nl = strchr(val, '\n');
1321+
if (nl) *nl = '\0';
1322+
if ((val[0] == '"' || val[0] == '\'')) {
1323+
size_t l = strlen(val);
1324+
if (l > 1 && val[l-1] == val[0]) {
1325+
val[l-1] = '\0';
1326+
val++;
1327+
}
1328+
}
1329+
strlcpy(pretty, val, sizeof(pretty));
1330+
}
1331+
else if (strncmp(line, "VERSION_ID=", 11) == 0)
1332+
{
1333+
char *val = line + 11;
1334+
char *nl = strchr(val, '\n');
1335+
if (nl) *nl = '\0';
1336+
char *endptr = NULL;
1337+
*major = (int)strtol(val, &endptr, 10);
1338+
if (endptr && *endptr == '.')
1339+
*minor = (int)strtol(endptr+1, NULL, 10);
1340+
else
1341+
*minor = 0;
1342+
}
1343+
}
1344+
fclose(f);
1345+
}
1346+
if (pretty[0] == '\0')
1347+
strlcpy(pretty, "webOS", sizeof(pretty));
1348+
inited = 1;
1349+
}
1350+
1351+
return strlcpy(s, pretty, len), pretty;
1352+
}
1353+
#endif
1354+
13021355
static size_t frontend_unix_get_os(char *s,
13031356
size_t len, int *major, int *minor)
13041357
{
@@ -1326,6 +1379,8 @@ static size_t frontend_unix_get_os(char *s,
13261379
_len = strlcpy(s, "BSD", len);
13271380
#elif defined(__HAIKU__)
13281381
_len = strlcpy(s, "Haiku", len);
1382+
#elif defined(WEBOS)
1383+
_len = strlcpy(s, retroarch_get_webos_version(s, len, major, minor), len);
13291384
#else
13301385
_len = strlcpy(s, "Linux", len);
13311386
#endif

retroarch.c

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7876,12 +7876,31 @@ bool retroarch_main_init(int argc, char *argv[])
78767876
if (verbosity_enabled)
78777877
{
78787878
{
7879-
char str_output[256];
7879+
char str_output[512];
78807880
const char *cpu_model = frontend_driver_get_cpu_model_name();
78817881
size_t _len = strlcpy(str_output,
78827882
"=== Build =======================================\n",
78837883
sizeof(str_output));
78847884

7885+
#ifdef WEBOS
7886+
{
7887+
char osbuf[128];
7888+
int major = 0, minor = 0;
7889+
frontend_state_t *frontend_st = frontend_state_get_ptr();
7890+
if (frontend_st)
7891+
{
7892+
frontend_ctx_driver_t *frontend = frontend_st->current_frontend_ctx;
7893+
if (frontend && frontend->get_os)
7894+
{
7895+
frontend->get_os(osbuf, sizeof(osbuf), &major, &minor);
7896+
_len += snprintf(str_output + _len, sizeof(str_output) - _len,
7897+
FILE_PATH_LOG_INFO " Running on: %s (major=%d, minor=%d)\n",
7898+
osbuf, major, minor);
7899+
}
7900+
}
7901+
}
7902+
#endif
7903+
78857904
if (!string_is_empty(cpu_model))
78867905
{
78877906
/* TODO/FIXME - localize */

0 commit comments

Comments
 (0)