From a440fb6252e0807602e48437c47222ae92d824db Mon Sep 17 00:00:00 2001 From: SP193 Date: Wed, 16 Jan 2019 23:48:45 +0800 Subject: [PATCH] APPSSUPPORT: apps will now always have the full path printed for the startup path, new format will always have the device containing the app checked first for art assets (before other devices). --- include/opl.h | 3 +-- src/appsupport.c | 47 +++++++++++++++++++++++++++++++++++++---------- src/opl.c | 28 +++++++++++++++++++++------- 3 files changed, 59 insertions(+), 19 deletions(-) diff --git a/include/opl.h b/include/opl.h index 233a8972e..b5750f870 100644 --- a/include/opl.h +++ b/include/opl.h @@ -64,8 +64,7 @@ #define OPL_VMODE_CHANGE_CONFIRMATION_TIMEOUT_MS 10000 int oplPath2Mode(const char *path); -char *oplGetModeText(int mode); -int oplGetAppImage(char *folder, int isRelative, char *value, char *suffix, GSTEXTURE *resultTex, short psm); +int oplGetAppImage(const char *device, char *folder, int isRelative, char *value, char *suffix, GSTEXTURE *resultTex, short psm); int oplScanApps(int (*callback)(const char *path, config_set_t *appConfig, void *arg), void *arg); void setErrorMessage(int strId); diff --git a/src/appsupport.c b/src/appsupport.c index e0499928f..b963ce1ea 100644 --- a/src/appsupport.c +++ b/src/appsupport.c @@ -51,6 +51,32 @@ static char *appGetELFName(char *name) return name; } +static char *appGetBoot(char *device, int max, char *path) +{ + char *pos, *filenamesep; + int len; + + // Looking for the boot device & filename from the path + pos = strrchr(path, ':'); + if (pos != NULL) { + len = (int)(pos + 1 - path); + if (len + 1 > max) + len = max - 1; + strncpy(device, path, len); + device[len] = '\0'; + } + + filenamesep = strchr(path, '/'); + if (filenamesep != NULL) + return filenamesep + 1; + + if (pos) { + return pos + 1; + } + + return path; +} + void appInit(void) { LOG("APPSUPPORT Init\n"); @@ -253,22 +279,19 @@ static int appGetItemNameLength(int id) return CONFIG_KEY_NAME_LEN; } +/* appGetItemStartup() is called to get the startup path for display & for the art assets. + The path is used immediately, before a subsequent call to appGetItemStartup(). */ static char *appGetItemStartup(int id) { + static char itemStartupPath[APP_PATH_MAX + APP_BOOT_MAX + 1 + 1]; + if (appsList[id].legacy) { struct config_value_t *cur = appGetConfigValue(id); return cur->val; } else { - int mode; - - mode = oplPath2Mode(appsList[id].path); - if (mode < 0) { - LOG("APPSUPPORT: cannot find mode for path: %s\n", appsList[id].path); - return ""; - } - - return oplGetModeText(mode); + snprintf(itemStartupPath, sizeof(itemStartupPath), "%s/%s", appsList[id].path, appsList[id].boot); + return itemStartupPath; } } @@ -369,7 +392,11 @@ static config_set_t *appGetConfig(int id) static int appGetImage(char *folder, int isRelative, char *value, char *suffix, GSTEXTURE *resultTex, short psm) { - return oplGetAppImage(folder, isRelative, appGetELFName(value), suffix, resultTex, psm); + char device[8], *startup; + + startup = appGetBoot(device, sizeof(device), value); + + return oplGetAppImage(device, folder, isRelative, startup, suffix, resultTex, psm); } //This may be called, even if appInit() was not. diff --git a/src/opl.c b/src/opl.c index 231a2b24f..095f296f9 100644 --- a/src/opl.c +++ b/src/opl.c @@ -353,11 +353,6 @@ static void deinitAllSupport(int exception, int modeSelected) moduleCleanup(&list_support[APP_MODE], exception, modeSelected); } -char *oplGetModeText(int mode) -{ - return(list_support[mode].support->textId == -1 ? list_support[mode].support->text : _l(list_support[mode].support->textId)); -} - //For resolving the mode, given an app's path int oplPath2Mode(const char *path) { @@ -386,12 +381,28 @@ int oplPath2Mode(const char *path) return -1; } -int oplGetAppImage(char *folder, int isRelative, char *value, char *suffix, GSTEXTURE *resultTex, short psm) +int oplGetAppImage(const char *device, char *folder, int isRelative, char *value, char *suffix, GSTEXTURE *resultTex, short psm) { - int i, remaining; + int i, remaining, elfbootmode; char priority; item_list_t *listSupport; + elfbootmode = -1; + if (device != NULL) + { + elfbootmode = oplPath2Mode(device); + if (elfbootmode >= 0) + { + listSupport = list_support[elfbootmode].support; + + if ((listSupport != NULL) && (listSupport->enabled)) + { + if (listSupport->itemGetImage(folder, isRelative, value, suffix, resultTex, psm) >= 0) + return 0; + } + } + } + // We search on ever devices from fatest to slowest. for (remaining = MODE_COUNT,priority = 0; remaining > 0 && priority < 4; priority++) { @@ -399,6 +410,9 @@ int oplGetAppImage(char *folder, int isRelative, char *value, char *suffix, GSTE { listSupport = list_support[i].support; + if (i == elfbootmode) + continue; + if ((listSupport != NULL) && (listSupport->enabled) && (listSupport->appsPriority == priority)) { if (listSupport->itemGetImage(folder, isRelative, value, suffix, resultTex, psm) >= 0)