<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<title>How do I exit the GUI in libwiigui?</title>
<description> How can I exit the GUI, to go to the console?
For example, I&amp;#039;m trying to implement ELF/DOL launching, and to do that, I need to exit the GUI, call the launch function, and then restart the GUI.

Also, when I exit, I want to print &quot;Exiting&quot; to the screen.
However, when I exit, the screen turns black for a second, and returns to the Homebrew Channel.

Code:

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-&amp;gt;fbWidth,rmode-&amp;gt;xfbHeight,rmode-&amp;gt;fbWidth*VI_DISPLAY_PIX_SZ);

VIDEO_Configure(rmode);

VIDEO_SetNextFramebuffer(xfb);

VIDEO_SetBlack(FALSE);

VIDEO_Flush();

VIDEO_WaitVSync();
if(rmode-&amp;gt;viTVMode&amp;VI_NON_INTERLACE) VIDEO_WaitVSync();

printf(&quot;\x1b[2;0H&quot;);

printf(&quot;\n\n\n\n\n\n\nGUI Exited.\n&quot;);
printf(&quot;Press any key to exit...\n&quot;);

while(true)
{
printf(&quot; ... &quot;);
sleep(500);

WPAD_ScanPads();

u32 pressed = WPAD_ButtonsDown(0);

if(pressed)
exit(0);

VIDEO_WaitVSync();
}

return 0;
}
</description><link>http://forum.wiibrew.org/read.php?11,56448,56448#msg-56448</link><lastBuildDate>Sun, 13 Sep 2026 14:12:42 +0200</lastBuildDate>
<generator>Phorum 5.2.23</generator>
<item>
<guid>http://forum.wiibrew.org/read.php?11,56448,56539#msg-56539</guid>
<title>Re: How do I exit the GUI in libwiigui?</title><link>http://forum.wiibrew.org/read.php?11,56448,56539#msg-56539</link><description><![CDATA[ AH!<br />That&#039;s a very good idea!<br />I&#039;ve been trying to exit the GUI by shutting down audio and video, and it didn&#039;t seem to be working. :P<br />I&#039;ll try it with threads, and I&#039;ll get back to you.]]></description>
<dc:creator>Tonyyyyyyy</dc:creator>
<category>Coding</category><pubDate>Fri, 23 Jul 2010 20:43:16 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,56448,56524#msg-56524</guid>
<title>Re: How do I exit the GUI in libwiigui?</title><link>http://forum.wiibrew.org/read.php?11,56448,56524#msg-56524</link><description><![CDATA[ In fact, Your sound is lagging because you are playing the sound, loading the dol and display the UI in the same thread.<br />This is a very bad idea. I think you must play the sound and load the doal in a different Thread.<br /><br />Then when the dol is ready to launch (ie loaded into the wii memory), in the UI thread, close all and start the dol.]]></description>
<dc:creator>arasium</dc:creator>
<category>Coding</category><pubDate>Fri, 23 Jul 2010 11:18:52 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,56448,56493#msg-56493</guid>
<title>Re: How do I exit the GUI in libwiigui?</title><link>http://forum.wiibrew.org/read.php?11,56448,56493#msg-56493</link><description><![CDATA[ Well, first of all you can&#039;t do what you&#039;re doing in main:<br /><br />starting video, input, sound.<br />launch gui<br />start video, input, and bring up a console.<br /><br /><br />See a problem here? You can&#039;t just reinit the video and input like that. The advice to stay within the GUI is the right one. If you want to debug the DOL loading code, start by putting it in a separate app with ONLY a console and make sure you understand how it works and that it doesn&#039;t crash.]]></description>
<dc:creator>Tantric</dc:creator>
<category>Coding</category><pubDate>Thu, 22 Jul 2010 19:00:47 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,56448,56491#msg-56491</guid>
<title>Re: How do I exit the GUI in libwiigui?</title><link>http://forum.wiibrew.org/read.php?11,56448,56491#msg-56491</link><description><![CDATA[ Well, I tried to launch a DOL...and the bg music on libwiigui started "lagging", like<br />ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ<br /><br />I don&#039;t really know how to explain it. O_O<br />I also need the console to debug my load function, so I&#039;ll know what&#039;s wrong.<br /><br />Is there a problem with my code?<br /><br />dol.c<br /><pre class="bbcode"> 
 /*
  * @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 &lt; 7; i++) {
			if ((!dolfile-&gt;text_size<i>) || (dolfile-&gt;text_start<i> &lt; 0x100))
                continue;
\
			ICInvalidateRange ((void *) dolfile-&gt;text_start<i>,
                                                    dolfile-&gt;text_size<i>);
			memmove ((void *) dolfile-&gt;text_start<i>,
                                 dolstart+dolfile-&gt;text_pos<i>,
                                 dolfile-&gt;text_size<i>);
		}

		for(i = 0; i &lt; 11; i++) {
			if ((!dolfile-&gt;data_size<i>) ||
                            (dolfile-&gt;data_start<i> &lt; 0x100))
                                continue;

			memmove ((void*) dolfile-&gt;data_start<i>,
                                 dolstart+dolfile-&gt;data_pos<i>,
                                 dolfile-&gt;data_size<i>);
			DCFlushRangeNoSync ((void *) dolfile-&gt;data_start<i>,
                                            dolfile-&gt;data_size<i>);
		}
		
		memset ((void *) dolfile-&gt;bss_start, 0, dolfile-&gt;bss_size);
		DCFlushRange((void *) dolfile-&gt;bss_start, dolfile-&gt;bss_size);

        return dolfile-&gt;entry_point;
	}

    return 0;
}
</i></i></i></i></i></i></i></i></i></i></i></i></i></i></pre><br /><pre class="bbcode">
#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-&gt;e_type != ET_EXEC)
        return -1;

    if (ehdr-&gt;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 &lt; strlen(locdir); i++)
	{
		if((i+1) != strlen(locdir))
			locdir<i> = locdir[i +1];
		else
			locdir<i> = &#039;/&#039;;
	}
	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&#039;re done with our checks, let&#039;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&#039;re back.
	_CPU_ISR_Restore (level);
	
	//Successful?
	return 0;
}

int test()
{
	return 1;
}
</i></i></pre>]]></description>
<dc:creator>Tonyyyyyyy</dc:creator>
<category>Coding</category><pubDate>Thu, 22 Jul 2010 18:51:31 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,56448,56475#msg-56475</guid>
<title>Re: How do I exit the GUI in libwiigui?</title><link>http://forum.wiibrew.org/read.php?11,56448,56475#msg-56475</link><description><![CDATA[ I think the better way is to display the "Exiting" into Libwiigui and not into a console.<br /><br />Generally, you mustn&#039;t mix Console and GUI application.]]></description>
<dc:creator>arasium</dc:creator>
<category>Coding</category><pubDate>Thu, 22 Jul 2010 10:04:12 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,56448,56467#msg-56467</guid>
<title>Re: How do I exit the GUI in libwiigui?</title><link>http://forum.wiibrew.org/read.php?11,56448,56467#msg-56467</link><description><![CDATA[ I don&#039;t need to???<br />But I still want to exit to the console...]]></description>
<dc:creator>Tonyyyyyyy</dc:creator>
<category>Coding</category><pubDate>Thu, 22 Jul 2010 02:20:35 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,56448,56466#msg-56466</guid>
<title>Re: How do I exit the GUI in libwiigui?</title><link>http://forum.wiibrew.org/read.php?11,56448,56466#msg-56466</link><description><![CDATA[ why do you need to exit the gui to load a dol? the 2 things are completely unrelated. and then you want to start up the gui again? this makes no sense.]]></description>
<dc:creator>giantpune</dc:creator>
<category>Coding</category><pubDate>Thu, 22 Jul 2010 02:14:42 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,56448,56459#msg-56459</guid>
<title>Re: How do I exit the GUI in libwiigui?</title><link>http://forum.wiibrew.org/read.php?11,56448,56459#msg-56459</link><description><![CDATA[ Sorry, can&#039;t help there, I don&#039;t know much about coding. :P]]></description>
<dc:creator>SifJar</dc:creator>
<category>Coding</category><pubDate>Wed, 21 Jul 2010 23:29:13 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,56448,56456#msg-56456</guid>
<title>Re: How do I exit the GUI in libwiigui?</title><link>http://forum.wiibrew.org/read.php?11,56448,56456#msg-56456</link><description><![CDATA[ <blockquote class="bbcode"><div><small>Quote<br /></small><strong>SifJar</strong><br />Please use <pre class="bbcode"> tags in future.</pre></div></blockquote><br />Thanks for editing, but unfortunately, that doesn&#039;t solve my question. :P]]></description>
<dc:creator>Tonyyyyyyy</dc:creator>
<category>Coding</category><pubDate>Wed, 21 Jul 2010 23:22:03 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,56448,56452#msg-56452</guid>
<title>Re: How do I exit the GUI in libwiigui?</title><link>http://forum.wiibrew.org/read.php?11,56448,56452#msg-56452</link><description><![CDATA[ Please use <pre class="bbcode"> tags in future.</pre>]]></description>
<dc:creator>SifJar</dc:creator>
<category>Coding</category><pubDate>Wed, 21 Jul 2010 23:02:35 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,56448,56448#msg-56448</guid>
<title>How do I exit the GUI in libwiigui?</title><link>http://forum.wiibrew.org/read.php?11,56448,56448#msg-56448</link><description><![CDATA[ How can I exit the GUI, to go to the console?<br />For example, I&#039;m trying to implement ELF/DOL launching, and to do that, I need to exit the GUI, call the launch function, and then restart the GUI.<br /><br />Also, when I exit, I want to print "Exiting" to the screen.<br />However, when I exit, the screen turns black for a second, and returns to the Homebrew Channel.<br /><br />Code:<br /><pre class="bbcode">
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-&gt;fbWidth,rmode-&gt;xfbHeight,rmode-&gt;fbWidth*VI_DISPLAY_PIX_SZ);

	VIDEO_Configure(rmode);

	VIDEO_SetNextFramebuffer(xfb);
	
	VIDEO_SetBlack(FALSE);

	VIDEO_Flush();

	VIDEO_WaitVSync();
	if(rmode-&gt;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;
}
</pre>]]></description>
<dc:creator>Tonyyyyyyy</dc:creator>
<category>Coding</category><pubDate>Wed, 21 Jul 2010 22:43:14 +0200</pubDate></item>
</channel>
</rss>