Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WiiFlow compatibility for autolauch games. (FIX94) #98

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 28 additions & 9 deletions main/main_gc-menu2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ void (*fBGetFrameBufferInfo)(void *p) = NULL;
// Read PAD format from Classic if available
u16 readWPAD(void);

void load_config(char *loaded_path) {
void load_config(const char *loaded_path) {
//config stuff
fileBrowser_file configFile_file;
char prefix[16];
Expand Down Expand Up @@ -285,6 +285,12 @@ int main(int argc, char* argv[]) {
DVD_Init();
#endif
MenuContext *menu = new MenuContext(vmode);
if(argc > 2 && argv[1] != NULL && argv[2] != NULL)
{
menu->Autoboot = true;
strncpy(menu->AutobootPath, argv[1], sizeof(menu->AutobootPath));
strncpy(menu->AutobootROM, argv[2], sizeof(menu->AutobootROM));
}
VIDEO_SetPostRetraceCallback (ScanPADSandReset);

// Default Settings
Expand Down Expand Up @@ -341,18 +347,31 @@ int main(int argc, char* argv[]) {

#ifdef HW_RVL
load_config(&argv[0][0]);
// Handle options passed in through arguments
int i;
for(i=1; i<argc; ++i){
handleConfigPair(argv[i]);
if(argc != 0 && argv != 0)
{
load_config(&argv[0][0]);
// Handle options passed in through arguments
int i;
for(i=1; i<argc; ++i){
handleConfigPair(argv[i]);
}
}
#else
load_config("sd");
else
#endif
//Switch to MiniMenu if active
load_config("sd");

if (miniMenuActive)
{

menu->setUseMiniMenu(true);

if (menu->Autoboot)
{
menu->setActiveFrame(MenuContext::FRAME_LOADROM);
menu->Autoboot = false;
}
else if (miniMenuActive)
{
//Switch to MiniMenu if active
menu->setActiveFrame(MenuContext::FRAME_MAIN);
}
while (menu->isRunning()) {}
Expand Down
14 changes: 12 additions & 2 deletions menu/FileBrowserFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ void fileBrowserFrame_LoadFile(int i)
// We must select this file
int ret = loadROM( &dir_entries[i] );

if(!ret){ // If the read succeeded.
if(!ret && !pMenuContext->Autoboot){ // If the read succeeded.
strcpy(feedback_string, "Loaded ");
strncat(feedback_string, filenameFromAbsPath(dir_entries[i].name), 36-7);

Expand Down Expand Up @@ -513,7 +513,7 @@ void fileBrowserFrame_LoadFile(int i)

menu::MessageBox::getInstance().setMessage(RomInfo);
}
else // If not.
else if(ret) // If not.
{
switch(ret) {
case ROM_CACHE_ERROR_READ:
Expand Down Expand Up @@ -562,3 +562,13 @@ void fileBrowserFrame_LoadFile(int i)
if(hasLoadedROM) Func_SetPlayGame();
}
}


void fileBrowserFrame_AutoBootFile()
{
int i;
for(i = 0; i < num_entries - 1; i++)
if(strcasestr(dir_entries[i].name, pMenuContext->AutobootROM) != NULL)
break;
fileBrowserFrame_LoadFile(i);
}
2 changes: 2 additions & 0 deletions menu/FileBrowserFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,6 @@ class FileBrowserFrame : public menu::Frame
#endif
};

void fileBrowserFrame_AutoBootFile();

#endif
30 changes: 27 additions & 3 deletions menu/LoadRomFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,15 @@ void Func_LoadFromSD()
romFile_init( romFile_topLevel );

pMenuContext->setActiveFrame(MenuContext::FRAME_FILEBROWSER);
fileBrowserFrame_OpenDirectory(romFile_topLevel);

if(pMenuContext->Autoboot)
{
strncpy(romFile_topLevel->name, pMenuContext->AutobootPath, sizeof(romFile_topLevel->name));
fileBrowserFrame_OpenDirectory(romFile_topLevel);
fileBrowserFrame_AutoBootFile();
}
else
fileBrowserFrame_OpenDirectory(romFile_topLevel);
}

void Func_LoadFromDVD()
Expand All @@ -146,7 +154,15 @@ void Func_LoadFromDVD()
romFile_init( romFile_topLevel );

pMenuContext->setActiveFrame(MenuContext::FRAME_FILEBROWSER);
fileBrowserFrame_OpenDirectory(romFile_topLevel);

if(pMenuContext->Autoboot)
{
strncpy(romFile_topLevel->name, pMenuContext->AutobootPath, sizeof(romFile_topLevel->name));
fileBrowserFrame_OpenDirectory(romFile_topLevel);
fileBrowserFrame_AutoBootFile();
}
else
fileBrowserFrame_OpenDirectory(romFile_topLevel);
}

void Func_LoadFromUSB()
Expand All @@ -166,7 +182,15 @@ void Func_LoadFromUSB()
romFile_init( romFile_topLevel );

pMenuContext->setActiveFrame(MenuContext::FRAME_FILEBROWSER);
fileBrowserFrame_OpenDirectory(romFile_topLevel);

if(pMenuContext->Autoboot)
{
strncpy(romFile_topLevel->name, pMenuContext->AutobootPath, sizeof(romFile_topLevel->name));
fileBrowserFrame_OpenDirectory(romFile_topLevel);
fileBrowserFrame_AutoBootFile();
}
else
fileBrowserFrame_OpenDirectory(romFile_topLevel);
#endif
}

Expand Down
3 changes: 3 additions & 0 deletions menu/LoadRomFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,7 @@ class LoadRomFrame : public menu::Frame

};

void Func_LoadFromSD();
void Func_LoadFromUSB();

#endif
2 changes: 2 additions & 0 deletions menu/MainFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,8 @@ void Func_PlayGame()
void Func_SetPlayGame()
{
FRAME_BUTTONS[5].buttonString = FRAME_STRINGS[5];
if(pMenuContext->Autoboot)
Func_PlayGame();
}

void Func_SetResumeGame()
Expand Down
9 changes: 9 additions & 0 deletions menu/MenuContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ MenuContext::MenuContext(GXRModeObj *vmode)
menu::Gui::getInstance().addFrame(configurePaksFrame);
menu::Gui::getInstance().addFrame(configureButtonsFrame);

Autoboot = false;

menu::Focus::getInstance().setFocusActive(true);
setActiveFrame(FRAME_MAIN);
}
Expand Down Expand Up @@ -174,6 +176,13 @@ void MenuContext::setActiveFrame(int frameIndex)

if(currentActiveFrame)
{
if(currentActiveFrame == loadRomFrame && Autoboot)
{
if(strcasestr(AutobootPath,"sd:/") != NULL)
Func_LoadFromSD();
else
Func_LoadFromUSB();
}
currentActiveFrame->showFrame();
menu::Focus::getInstance().setCurrentFrame(currentActiveFrame);
menu::Cursor::getInstance().setCurrentFrame(currentActiveFrame);
Expand Down
3 changes: 3 additions & 0 deletions menu/MenuContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ class MenuContext
MenuContext(GXRModeObj *vmode);
~MenuContext();
bool isRunning();
bool Autoboot;
char AutobootROM[1024];
char AutobootPath[1024];
void setUseMiniMenu(bool setUseMiniMenu);
void setActiveFrame(int frameIndex);
void setActiveFrame(int frameIndex, int submenu);
Expand Down