From b86a95e517b387c0f2a827c242264d435ef70c1f Mon Sep 17 00:00:00 2001 From: "fix94.1" Date: Sat, 19 Oct 2013 15:31:08 +0000 Subject: [PATCH] -added experimental autoboot function for source menu buttons, just add autoboot=ID for channel, wii and gc game buttons or autoboot=TITLE for plugin and homebrew buttons. Replace ID/TITLE with the game ID/Title you want to boot when clicking on the button of course. --- source/menu/menu.cpp | 2 ++ source/menu/menu.hpp | 2 ++ source/menu/menu_main.cpp | 36 ++++++++++++++++++++++++++++++++++++ source/menu/menu_source.cpp | 34 ++++++++++++++++++++++++++++++++++ 4 files changed, 74 insertions(+) diff --git a/source/menu/menu.cpp b/source/menu/menu.cpp index 6d5eae1e..02c1e9a4 100644 --- a/source/menu/menu.cpp +++ b/source/menu/menu.cpp @@ -156,6 +156,8 @@ CMenu::CMenu() m_init_ftp = false; /* screensaver */ no_input_time = 0; + /* Autoboot stuff */ + m_source_autoboot = false; } void CMenu::init() diff --git a/source/menu/menu.hpp b/source/menu/menu.hpp index 22667892..1821e906 100644 --- a/source/menu/menu.hpp +++ b/source/menu/menu.hpp @@ -1040,6 +1040,8 @@ private: public: void directlaunch(const char *GameID); private: + dir_discHdr m_autoboot_hdr; + bool m_source_autoboot; bool m_use_wifi_gecko; bool m_use_sd_logging; bool init_network; diff --git a/source/menu/menu_main.cpp b/source/menu/menu_main.cpp index 10505737..4f402ded 100644 --- a/source/menu/menu_main.cpp +++ b/source/menu/menu_main.cpp @@ -199,6 +199,42 @@ void CMenu::LoadView(void) _createSFList(); else _loadList(); + + if(m_source_autoboot == true) + { /* search for the requested file */ + bool game_found = false; + for(vector::iterator element = m_gameList.begin(); element != m_gameList.end(); ++element) + { + switch(m_autoboot_hdr.type) + { + case TYPE_CHANNEL: + case TYPE_WII_GAME: + case TYPE_GC_GAME: + if(strcmp(m_autoboot_hdr.id, element->id) == 0) + game_found = true; + break; + case TYPE_HOMEBREW: + case TYPE_PLUGIN: + if(wcsncmp(m_autoboot_hdr.title, element->title, 63) == 0) + game_found = true; + break; + default: + break; + } + if(game_found == true) + { + memcpy(&m_autoboot_hdr, &(*(element)), sizeof(dir_discHdr)); + break; + } + } + if(game_found == true) + { + gprintf("Game found, autobooting...\n"); + _launch(&m_autoboot_hdr); + } + /* fail */ + m_source_autoboot = false; + } _showMain(); _initCF(); _loadCFLayout(m_cfg.getInt(_domainFromView(), "last_cf_mode", 1)); diff --git a/source/menu/menu_source.cpp b/source/menu/menu_source.cpp index e8890039..abe73821 100644 --- a/source/menu/menu_source.cpp +++ b/source/menu/menu_source.cpp @@ -670,6 +670,40 @@ bool CMenu::_Source() } } } + /* autoboot */ + const char *autoboot = m_source.getString(btn_selected, "autoboot", "").c_str(); + if(autoboot != NULL && autoboot[0] != '\0') + { + m_source_autoboot = true; + memset(&m_autoboot_hdr, 0, sizeof(dir_discHdr)); + if(source == "emunand" || source == "realnand") + { + m_autoboot_hdr.type = TYPE_CHANNEL; + memcpy(m_autoboot_hdr.id, autoboot, 4); + } + else if(source == "wii") + { + m_autoboot_hdr.type = TYPE_WII_GAME; + memcpy(m_autoboot_hdr.id, autoboot, 6); + } + else if(source == "dml") + { + m_autoboot_hdr.type = TYPE_GC_GAME; + memcpy(m_autoboot_hdr.id, autoboot, 6); + } + else if(source == "homebrew") + { + m_autoboot_hdr.type = TYPE_HOMEBREW; + mbstowcs(m_autoboot_hdr.title, autoboot, 63); + } + else if(source == "plugin") + { + m_autoboot_hdr.type = TYPE_PLUGIN; + mbstowcs(m_autoboot_hdr.title, autoboot, 63); + } + else + m_source_autoboot = false; + } break; } else