2011-09-25 19:47:02 +02:00
|
|
|
|
/****************************************************************************
|
|
|
|
|
* libwiigui Template
|
|
|
|
|
* Tantric 2009
|
|
|
|
|
*
|
|
|
|
|
* demo.cpp
|
|
|
|
|
* Basic template/demonstration of libwiigui capabilities. For a
|
|
|
|
|
* full-featured app using many more extensions, check out Snes9x GX.
|
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include <gccore.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <algorithm>
|
|
|
|
|
#include <ogcsys.h>
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
#include <wiiuse/wpad.h>
|
2012-03-14 14:11:55 +01:00
|
|
|
|
#include <dirent.h>
|
2011-09-25 19:47:02 +02:00
|
|
|
|
|
|
|
|
|
#include "filelist.h"
|
|
|
|
|
#include "FreeTypeGX.h"
|
|
|
|
|
#include "input.h"
|
|
|
|
|
#include "main.h"
|
|
|
|
|
#include "menu.h"
|
|
|
|
|
#include "libwiigui/gui.h"
|
|
|
|
|
#include "Tools/FontSystem.h"
|
|
|
|
|
#include "Tools/load.h"
|
|
|
|
|
#include "Tools/load_channel.h"
|
|
|
|
|
#include "Tools/RuntimeIOSPatch.h"
|
|
|
|
|
#include "Tools/save.h"
|
|
|
|
|
#include "Tools/SelectIos.h"
|
|
|
|
|
#include "Tools/throbber.h"
|
|
|
|
|
#include "Network/network.h"
|
|
|
|
|
#include "Network/tcp.h"
|
|
|
|
|
#include "BootHomebrew/BootHomebrew.h"
|
2012-03-14 14:11:55 +01:00
|
|
|
|
#include "BootHomebrew/dolloader.h"
|
2012-03-15 13:17:52 +01:00
|
|
|
|
#include "DiskOperations/di2.h"
|
2012-04-07 21:20:28 +02:00
|
|
|
|
#include "gecko.h"
|
|
|
|
|
#include "Network/wiiload_gecko.h"
|
2012-04-08 19:28:15 +02:00
|
|
|
|
#include "Neek/uneek_fs.h"
|
|
|
|
|
#include "Neek/boot_neek2o.h"
|
2011-09-25 19:47:02 +02:00
|
|
|
|
|
|
|
|
|
#define HAVE_AHBPROT ((*(vu32*)0xcd800064 == 0xFFFFFFFF) ? 1 : 0)
|
|
|
|
|
|
|
|
|
|
/*** Extern variables ***/
|
|
|
|
|
extern GuiWindow * mainWindow;
|
|
|
|
|
extern GuiImageData * pointer;
|
|
|
|
|
|
|
|
|
|
/*** Extern functions ***/
|
|
|
|
|
extern void ResumeGui();
|
|
|
|
|
|
|
|
|
|
std::vector<homebrew_list> vechomebrew_list_category[99];
|
|
|
|
|
std::vector<homebrew_list> vechomebrew_list_unassigned;
|
|
|
|
|
std::vector<homebrew_list> vechomebrew_list_choice;
|
|
|
|
|
std::vector<app_ios> appios;
|
|
|
|
|
|
|
|
|
|
struct SSettings Settings;
|
|
|
|
|
struct SOptions Options;
|
|
|
|
|
|
|
|
|
|
int ExitRequested = 0;
|
|
|
|
|
s8 PowerOff = -1;
|
|
|
|
|
bool boothomebrew = false;
|
|
|
|
|
bool boot_buffer = false;
|
2012-03-24 20:01:26 +01:00
|
|
|
|
bool wiiload = false;
|
2012-04-08 19:28:15 +02:00
|
|
|
|
bool goneek2o = false;
|
2012-04-07 21:20:28 +02:00
|
|
|
|
bool runaway = false;
|
|
|
|
|
bool gecko_connected;
|
2011-09-25 19:47:02 +02:00
|
|
|
|
|
|
|
|
|
// kopiere ios f<>r app in einen vector
|
|
|
|
|
void addAppIos(string foldername, int ios)
|
|
|
|
|
{
|
|
|
|
|
if(appios.size() == 0)
|
|
|
|
|
appios.push_back(app_ios(foldername, ios));
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
bool found = false;
|
|
|
|
|
int i;
|
|
|
|
|
for(i = 0; i < (signed)appios.size(); i++)
|
|
|
|
|
{
|
|
|
|
|
if(appios[i].foldername == foldername)
|
|
|
|
|
{
|
|
|
|
|
found = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(found)
|
|
|
|
|
appios[i].ios = ios;
|
|
|
|
|
if(!found)
|
2012-03-14 14:11:55 +01:00
|
|
|
|
appios.push_back(app_ios(foldername, ios));
|
2011-09-25 19:47:02 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ExitApp()
|
|
|
|
|
{
|
2012-04-07 21:20:28 +02:00
|
|
|
|
gprintf("Running ExitApp()\n");
|
2011-09-25 19:47:02 +02:00
|
|
|
|
ShutdownPads();
|
|
|
|
|
StopGX();
|
2012-04-07 21:20:28 +02:00
|
|
|
|
save();
|
|
|
|
|
UnmountAllDevices();
|
|
|
|
|
exit_uneek_fs();
|
2011-09-25 19:47:02 +02:00
|
|
|
|
ISFS_Deinitialize();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void WiiResetPressed()
|
|
|
|
|
{
|
2012-04-07 21:20:28 +02:00
|
|
|
|
gprintf("Reset button pressed \n");
|
|
|
|
|
runaway = true;
|
2011-09-25 19:47:02 +02:00
|
|
|
|
PowerOff = SYS_RETURNTOMENU;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void WiiPowerPressed()
|
|
|
|
|
{
|
2012-04-07 21:20:28 +02:00
|
|
|
|
gprintf("Power button pressed \n");
|
|
|
|
|
runaway = true;
|
2011-09-25 19:47:02 +02:00
|
|
|
|
PowerOff = SYS_POWEROFF_STANDBY;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void WiimotePowerPressed(s32 chan)
|
|
|
|
|
{
|
|
|
|
|
WiiPowerPressed();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
DefaultSettings()
|
|
|
|
|
{
|
|
|
|
|
Settings.sd_insert = SDCard_Inserted();
|
|
|
|
|
Settings.usb_insert = USBDevice_Inserted();
|
2012-03-14 14:11:55 +01:00
|
|
|
|
Settings.dvd_insert = DVD_Inserted();
|
2011-09-25 19:47:02 +02:00
|
|
|
|
Settings.category_name_all = "All";
|
|
|
|
|
sprintf (Settings.new_category_name, "New Category");
|
|
|
|
|
Settings.current_category = 0;
|
|
|
|
|
Settings.current_page = 1;
|
|
|
|
|
Settings.last_app_pos = -1;
|
|
|
|
|
Settings.checkrev = -1;
|
|
|
|
|
sprintf (Settings.code, "NULL");
|
2012-03-14 14:11:55 +01:00
|
|
|
|
|
2011-09-25 19:47:02 +02:00
|
|
|
|
Settings.Apps_from = EFFECT_SLIDE_TOP; // Apps kommen von "EFFECT_SLIDE_TOP", "EFFECT_SLIDE_BOTTOM", "EFFECT_SLIDE_RIGHT", "EFFECT_SLIDE_LEFT"
|
|
|
|
|
Settings.Apps_to = 0; // Apps geht nach "EFFECT_SLIDE_TOP", "EFFECT_SLIDE_BOTTOM", "EFFECT_SLIDE_RIGHT", "EFFECT_SLIDE_LEFT"
|
|
|
|
|
Settings.grid = false;
|
|
|
|
|
Settings.system = 1;
|
|
|
|
|
Settings.device = "sd1";
|
|
|
|
|
Settings.device_dat = "sd1";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
DefaultOptions()
|
|
|
|
|
{
|
|
|
|
|
sprintf (Options.theme, tr("STANDARD"));
|
|
|
|
|
sprintf (Options.language, tr("STANDARD"));
|
|
|
|
|
sprintf (Options.font, tr("STANDARD"));
|
|
|
|
|
sprintf (Options.temp_code, "NULL");
|
2012-03-14 14:11:55 +01:00
|
|
|
|
|
2011-09-25 19:47:02 +02:00
|
|
|
|
Options.slide_effect = 1;
|
|
|
|
|
Options.last_category = 1;
|
2012-03-19 09:46:10 +01:00
|
|
|
|
Options.apps = 4;
|
|
|
|
|
Options.quick_start = 0;
|
|
|
|
|
Options.show_all = 1;
|
|
|
|
|
Options.navigation = 0;
|
2011-09-25 19:47:02 +02:00
|
|
|
|
Options.temp_network = 0;
|
|
|
|
|
Options.temp_newrevtext = 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
main(int argc, char *argv[])
|
|
|
|
|
{
|
2012-03-17 21:15:38 +01:00
|
|
|
|
|
2012-04-07 21:20:28 +02:00
|
|
|
|
gecko_connected = InitGecko();
|
2011-09-25 19:47:02 +02:00
|
|
|
|
|
|
|
|
|
InitVideo(); // Initialize video
|
|
|
|
|
SetupPads(); // Initialize input
|
|
|
|
|
InitGUIThreads(); // Initialize GUI
|
2012-04-07 21:20:28 +02:00
|
|
|
|
|
|
|
|
|
init_uneek_fs(ISFS_OPEN_READ|ISFS_OPEN_WRITE);
|
|
|
|
|
|
2011-09-25 19:47:02 +02:00
|
|
|
|
MountAllDevices();
|
|
|
|
|
InitNetworkThread(); // Initialize Network
|
|
|
|
|
InitTcpThread();
|
2012-04-07 21:20:28 +02:00
|
|
|
|
|
|
|
|
|
if (gecko_connected)
|
|
|
|
|
InitGeckoThread();
|
|
|
|
|
|
2011-09-25 19:47:02 +02:00
|
|
|
|
InitThrobberThread(); // Initialize Throbber
|
|
|
|
|
ISFS_Initialize(); // Initialize Nand
|
|
|
|
|
|
|
|
|
|
LoadHBF();
|
2012-03-14 14:11:55 +01:00
|
|
|
|
|
2011-09-25 19:47:02 +02:00
|
|
|
|
DefaultSettings();
|
|
|
|
|
DefaultOptions();
|
|
|
|
|
DefaultTheme();
|
|
|
|
|
|
|
|
|
|
load();
|
2012-04-07 21:20:28 +02:00
|
|
|
|
|
2011-09-25 19:47:02 +02:00
|
|
|
|
if(Options.network)
|
|
|
|
|
ResumeNetworkThread();
|
2012-04-07 21:20:28 +02:00
|
|
|
|
if (gecko_connected)
|
|
|
|
|
ResumeGeckoThread();
|
2011-09-25 19:47:02 +02:00
|
|
|
|
|
|
|
|
|
SetFont();
|
2012-03-14 14:11:55 +01:00
|
|
|
|
|
2012-04-07 21:20:28 +02:00
|
|
|
|
SYS_SetResetCallback(WiiResetPressed);
|
|
|
|
|
SYS_SetPowerCallback(WiiPowerPressed);
|
|
|
|
|
WPAD_SetPowerButtonCallback(WiimotePowerPressed);
|
|
|
|
|
|
2011-09-25 19:47:02 +02:00
|
|
|
|
#ifdef HW_RVL
|
|
|
|
|
pointer = new GuiImageData(Theme.player_point);
|
|
|
|
|
#endif
|
2012-03-14 14:11:55 +01:00
|
|
|
|
|
2011-09-25 19:47:02 +02:00
|
|
|
|
mainWindow = new GuiWindow(screenwidth, screenheight);
|
2012-03-14 14:11:55 +01:00
|
|
|
|
|
2011-09-25 19:47:02 +02:00
|
|
|
|
GuiTrigger trigA;
|
|
|
|
|
trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);
|
2012-03-14 14:11:55 +01:00
|
|
|
|
|
2011-09-25 19:47:02 +02:00
|
|
|
|
ResumeGui();
|
|
|
|
|
stretch(Settings.top, Settings.bottom, Settings.left, Settings.right);
|
2012-03-14 14:11:55 +01:00
|
|
|
|
|
2012-04-07 21:20:28 +02:00
|
|
|
|
if(HAVE_AHBPROT)
|
|
|
|
|
{
|
2011-09-25 19:47:02 +02:00
|
|
|
|
runtimePatchApply();
|
2012-04-07 21:20:28 +02:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
gprintf("ERROR no AHBPROT\n");
|
|
|
|
|
}
|
2012-03-14 14:11:55 +01:00
|
|
|
|
|
2012-03-20 12:22:36 +01:00
|
|
|
|
DI2_Init(); // Init DVD
|
|
|
|
|
|
2011-09-25 19:47:02 +02:00
|
|
|
|
if(strstr(Options.language, tr("STANDARD")))
|
|
|
|
|
translate();
|
2012-03-14 14:11:55 +01:00
|
|
|
|
|
2011-09-25 19:47:02 +02:00
|
|
|
|
AvailableCategory.categories[0] = tr(Settings.category_name_all);
|
|
|
|
|
check_device();
|
2012-03-14 14:11:55 +01:00
|
|
|
|
|
2012-04-07 18:50:06 +02:00
|
|
|
|
MainMenu(MENU_NONE);
|
2012-03-14 14:11:55 +01:00
|
|
|
|
|
2011-09-25 19:47:02 +02:00
|
|
|
|
if(boothomebrew)
|
|
|
|
|
{
|
2012-04-07 21:20:28 +02:00
|
|
|
|
/*if(SelectedIOS() != IOS_GetVersion())
|
|
|
|
|
IOS_ReloadIOS(SelectedIOS());*/
|
2012-03-14 14:11:55 +01:00
|
|
|
|
|
2012-03-17 21:15:38 +01:00
|
|
|
|
if(strstr(Settings.forwarder_path.c_str(), ":/apps/") != 0)
|
|
|
|
|
BootHomebrew();
|
|
|
|
|
else if(strstr(Settings.forwarder_path.c_str(), ":/gc_apps/") != 0)
|
|
|
|
|
BootGameCubeHomebrew();
|
|
|
|
|
}
|
2011-09-25 19:47:02 +02:00
|
|
|
|
else if(boot_buffer)
|
2012-03-24 20:01:26 +01:00
|
|
|
|
if(wiiload)
|
|
|
|
|
BootHomebrew();
|
2012-03-14 14:11:55 +01:00
|
|
|
|
|
2011-09-25 19:47:02 +02:00
|
|
|
|
if(get_bootmii() == 2)
|
2012-04-07 21:20:28 +02:00
|
|
|
|
{
|
|
|
|
|
if(!check_uneek_fs())
|
|
|
|
|
{
|
|
|
|
|
IOS_ReloadIOS(254);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
//we can't launch bootmii from within neek2o I assume
|
|
|
|
|
//so we should do something else
|
|
|
|
|
SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-03-14 14:11:55 +01:00
|
|
|
|
|
|
|
|
|
if(get_nandemu() == 2)
|
|
|
|
|
{
|
2012-03-17 08:39:46 +01:00
|
|
|
|
if (opendir(check_path("sd1:/apps/NANDEmu-Boot").c_str()) != NULL)
|
2012-03-14 15:58:26 +01:00
|
|
|
|
{
|
|
|
|
|
LoadHomebrew ("sd1:/apps/NANDEmu-Boot/boot.dol");
|
|
|
|
|
BootHomebrew ();
|
|
|
|
|
}
|
|
|
|
|
else if (opendir(check_path("usb1:/apps/NANDEmu-Boot").c_str()) != NULL)
|
|
|
|
|
{
|
|
|
|
|
LoadHomebrew ("usb1:/apps/NANDEmu-Boot/boot.dol");
|
2012-03-14 16:05:44 +01:00
|
|
|
|
BootHomebrew ();
|
2012-03-14 15:58:26 +01:00
|
|
|
|
}
|
2012-03-14 14:11:55 +01:00
|
|
|
|
}
|
|
|
|
|
|
2012-03-17 22:43:01 +01:00
|
|
|
|
if(get_priiloader() == 2)
|
|
|
|
|
{
|
|
|
|
|
*(vu32*)0x8132FFFB = 0x4461636f;
|
|
|
|
|
DCFlushRange((void*)0x8132FFFB, 4);
|
2012-04-07 21:20:28 +02:00
|
|
|
|
//ExitApp();
|
2012-03-17 22:43:01 +01:00
|
|
|
|
SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
|
|
|
|
|
}
|
|
|
|
|
|
2012-04-08 19:28:15 +02:00
|
|
|
|
if(goneek2o)
|
|
|
|
|
{
|
|
|
|
|
//ExitApp();
|
|
|
|
|
boot_neek2o();
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-17 22:43:01 +01:00
|
|
|
|
if(PowerOff == SYS_RETURNTOMENU)
|
|
|
|
|
{
|
|
|
|
|
*(vu32*)0x8132FFFB = 0x50756E65;
|
|
|
|
|
DCFlushRange((void*)0x8132FFFB, 4);
|
2012-04-07 21:20:28 +02:00
|
|
|
|
//ExitApp();
|
2012-03-17 22:43:01 +01:00
|
|
|
|
SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
|
|
|
|
|
}
|
|
|
|
|
else if(PowerOff != -1)
|
2012-04-07 21:20:28 +02:00
|
|
|
|
//ExitApp();
|
2011-09-25 19:47:02 +02:00
|
|
|
|
SYS_ResetSystem(PowerOff, 0, 0);
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|