|
How do I exit the GUI in libwiigui? July 21, 2010 10:43PM | Registered: 15 years ago Posts: 5 |
int
main(int argc, char *argv[])
{
InitVideo(); // Initialize video
SetupPads(); // Initialize input
InitAudio(); // Initialize audio
fatInitDefault(); // Initialize file system
InitFreeType((u8*)font_ttf, font_ttf_size); // Initialize font system
InitGUIThreads(); // Initialize GUI
DefaultSettings();
MainMenu(MENU_SETTINGS);
VIDEO_Init();
WPAD_Init();
rmode = VIDEO_GetPreferredMode(NULL);
xfb = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode));
console_init(xfb,20,20,rmode->fbWidth,rmode->xfbHeight,rmode->fbWidth*VI_DISPLAY_PIX_SZ);
VIDEO_Configure(rmode);
VIDEO_SetNextFramebuffer(xfb);
VIDEO_SetBlack(FALSE);
VIDEO_Flush();
VIDEO_WaitVSync();
if(rmode->viTVMode&VI_NON_INTERLACE) VIDEO_WaitVSync();
printf("\x1b[2;0H");
printf("\n\n\n\n\n\n\nGUI Exited.\n");
printf("Press any key to exit...\n");
while(true)
{
printf(" ... ");
sleep(500);
WPAD_ScanPads();
u32 pressed = WPAD_ButtonsDown(0);
if(pressed)
exit(0);
VIDEO_WaitVSync();
}
return 0;
}|
Re: How do I exit the GUI in libwiigui? July 21, 2010 11:02PM | Moderator Registered: 16 years ago Posts: 5,075 |
|
Re: How do I exit the GUI in libwiigui? July 21, 2010 11:22PM | Registered: 15 years ago Posts: 5 |
|
Re: How do I exit the GUI in libwiigui? July 21, 2010 11:29PM | Moderator Registered: 16 years ago Posts: 5,075 |
|
Re: How do I exit the GUI in libwiigui? July 22, 2010 02:14AM | Registered: 16 years ago Posts: 234 |
|
Re: How do I exit the GUI in libwiigui? July 22, 2010 02:20AM | Registered: 15 years ago Posts: 5 |
|
Re: How do I exit the GUI in libwiigui? July 22, 2010 10:04AM | Registered: 16 years ago Posts: 161 |
|
Re: How do I exit the GUI in libwiigui? July 22, 2010 06:51PM | Registered: 15 years ago Posts: 5 |
/*
* @author: Tonyyyyyyy
*
* @summary: This file provides functions for launching DOLs.
* @origin: Based off of *cough* ripped off of *cough* geckoloader.
*
* @date: 7.19.2010
*/
#include "dol.h"
// This is from geckoloader...
// this code was contributed by shagkur of the devkitpro team, thx!
typedef struct _dolheader {
u32 text_pos[7];
u32 data_pos[11];
u32 text_start[7];
u32 data_start[11];
u32 text_size[7];
u32 data_size[11];
u32 bss_start;
u32 bss_size;
u32 entry_point;
} dolheader;
u32 load_dol_image (void *dolstart) {
u32 i;
dolheader *dolfile;
if (dolstart) {
dolfile = (dolheader *) dolstart;
for (i = 0; i < 7; i++) {
if ((!dolfile->text_size) || (dolfile->text_start < 0x100))
continue;
\
ICInvalidateRange ((void *) dolfile->text_start,
dolfile->text_size);
memmove ((void *) dolfile->text_start,
dolstart+dolfile->text_pos,
dolfile->text_size);
}
for(i = 0; i < 11; i++) {
if ((!dolfile->data_size) ||
(dolfile->data_start < 0x100))
continue;
memmove ((void*) dolfile->data_start,
dolstart+dolfile->data_pos,
dolfile->data_size);
DCFlushRangeNoSync ((void *) dolfile->data_start,
dolfile->data_size);
}
memset ((void *) dolfile->bss_start, 0, dolfile->bss_size);
DCFlushRange((void *) dolfile->bss_start, dolfile->bss_size);
return dolfile->entry_point;
}
return 0;
}
#include "launch.h"
//extern void __exception_closeall();
//extern s32 __IOS_ShutdownSubsystems();
s32 getImageType(void * addr)
{
Elf32_Ehdr *ehdr; /* Elf header structure pointer */
ehdr = (Elf32_Ehdr *) addr;
if (!IS_ELF (*ehdr))
return 0;
if (ehdr->e_type != ET_EXEC)
return -1;
if (ehdr->e_machine != EM_PPC)
return -1;
return 1;
}
int launch(char locdir[999], char filname[13])
{
/*
//Set this...
unsigned int i;
for(i = 0; i < strlen(locdir); i++)
{
if((i+1) != strlen(locdir))
locdir = locdir[i +1];
else
locdir = '/';
}
printf("%s", locdir);
sleep(5000);*/
//Variables
/*
FATFS ffs;
DIR appdir;
char filename[50+1];
char thefile[1][50];
FILINFO finfo;
FIL fp;
WORD bytes_read;
u32 bytes_read_total;
u8 *data = (u8 *)0x92000000;
*/
s32 res;
u32 level;
if(!fatInitDefault())
{
//Error handler here...
}
//ELF/DOL buffer
void * buffer;
//Entry point
void (*ep)();
char formatted[999];
sprintf(formatted, "%s/%s", locdir, filname);
//Mount FAT FS
//if(f_mount(0, &ffs) != FR_OK)
//return -1;
//res = f_opendir(&appdir, locdir);
//if(res != FR_OK)
//return -1;
FILE * inputFile;
inputFile = fopen(formatted, "rb");
/*
memset(&finfo, 0, sizeof(finfo));
f_readdir(&appdir, &finfo);
while(strlen(finfo.fname) != 0)
{
if(strtoupper(finfo.fname) == strtoupper(filname))
{
memcpy(thefile[0], finfo.fname, strlen(finfo.fname));
printf(thefile[0]);
sleep(5000);
}
f_readdir(&appdir, &finfo);
}
snprintf(filename, 50, "%s%s", locdir, filname);
//"Pre-checking" phase
if(f_stat(filename, &finfo) != FR_OK)
return -1;
if(f_open(&fp, filename, FA_READ) != FR_OK)
return -1;
*/
int pos = ftell(inputFile);
fseek(inputFile, 0, SEEK_END);
int size = ftell(inputFile);
fseek(inputFile, pos, SEEK_SET);
buffer = malloc(size);
fread(buffer, 1, size, inputFile);
//Now that we're done with our checks, let's start reading the file.
//bytes_read = bytes_read_total = 0;
res = getImageType(buffer);
if(res == 1)//ELF
{
}
else//Probably a DOL...
{
ep = (void(*)())load_dol_image(buffer);
}
fclose(inputFile);
__IOS_ShutdownSubsystems();
_CPU_ISR_Disable (level);
__exception_closeall ();
//This is it!
ep();
//And we're back.
_CPU_ISR_Restore (level);
//Successful?
return 0;
}
int test()
{
return 1;
}
|
Re: How do I exit the GUI in libwiigui? July 22, 2010 07:00PM | Moderator Registered: 17 years ago Posts: 441 |
|
Re: How do I exit the GUI in libwiigui? July 23, 2010 11:18AM | Registered: 16 years ago Posts: 161 |
|
Re: How do I exit the GUI in libwiigui? July 23, 2010 08:43PM | Registered: 15 years ago Posts: 5 |