Skip to content

Commit

Permalink
APPSSUPPORT: apps will now always have the full path printed for the …
Browse files Browse the repository at this point in the history
…startup path, new format will always have the device containing the app checked first for art assets (before other devices).
  • Loading branch information
sp193 committed Jan 16, 2019
1 parent aa33bbe commit a440fb6
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 19 deletions.
3 changes: 1 addition & 2 deletions include/opl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
47 changes: 37 additions & 10 deletions src/appsupport.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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;
}
}

Expand Down Expand Up @@ -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.
Expand Down
28 changes: 21 additions & 7 deletions src/opl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -386,19 +381,38 @@ 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++)
{
for (i = 0; i < MODE_COUNT; i++)
{
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)
Expand Down

0 comments on commit a440fb6

Please sign in to comment.