<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<title>Switch-Case inputs</title>
<description> I want to read an Wiimote input (a held button):

u16 buttonsHeld = WPAD_ButtonsHeld(0);

Now I know how to read what button is being held with if:

if (buttonsHeld &amp; WPAD_BUTTON_A ) { 
printf(&quot;Button A is being held down.\n&quot;);
}
else {
if (buttonsHeld &amp; WPAD_BUTTON_1){
printf(&quot;Button 1 is being held down.\n&quot;);
}
}

How can I read what button is held with a Switch-Cause statement?

Thanks in advance,
SJ</description><link>http://forum.wiibrew.org/read.php?11,4873,4873#msg-4873</link><lastBuildDate>Wed, 22 Apr 2026 22:55:58 +0200</lastBuildDate>
<generator>Phorum 5.2.23</generator>
<item>
<guid>http://forum.wiibrew.org/read.php?11,4873,5134#msg-5134</guid>
<title>Re: Switch-Case inputs</title><link>http://forum.wiibrew.org/read.php?11,4873,5134#msg-5134</link><description><![CDATA[ Is there a good Docu / API reference for WPAD?<br />I only found one for wiiuse.]]></description>
<dc:creator>daniel_c_w</dc:creator>
<category>Coding</category><pubDate>Tue, 16 Dec 2008 14:34:07 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,4873,5127#msg-5127</guid>
<title>Re: Switch-Case inputs</title><link>http://forum.wiibrew.org/read.php?11,4873,5127#msg-5127</link><description><![CDATA[ <blockquote class="bbcode"><div><small>Quote<br /></small><strong>ekeeke</strong><br />Personnaly, I use a simple sleep() to delay after WPAD_Init before reading wiimote input<br /><br />but maybe something like that might help you:<br /><pre class="bbcode">

 u32 exp;
 while (WPAD_Probe(0, &exp) != WPAD_ERR_NONE);
</pre></div></blockquote><br />Just tried this and it works! Thanks a lot.]]></description>
<dc:creator>SpaceJump</dc:creator>
<category>Coding</category><pubDate>Tue, 16 Dec 2008 09:00:59 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,4873,5122#msg-5122</guid>
<title>Re: Switch-Case inputs</title><link>http://forum.wiibrew.org/read.php?11,4873,5122#msg-5122</link><description><![CDATA[ <blockquote class="bbcode"><div><small>Quote<br /></small><strong>Arikado</strong><br /><blockquote class="bbcode"><div><small>Quote<br /></small><strong>Tantric</strong><br />That won&#039;t work at all. If you want to "slow down" you can try sleep() or usleep(). But this still wouldn&#039;t help you with what you&#039;re trying to do.</div></blockquote>
Funny, I&#039;ve gotten it work in some of my past games. Usually 150 ends up being some insane number though, but it definitely works.</div></blockquote>sleep() or usleep() is a better method though unless you need a very small delay (e.g. when interfacing with hardware that wants precise timing), as it lets the CPU idle, whereas your method pegs it at 100% usage. Less CPU usage means less heat, and is even more important on handhelds where it means longer battery life, and on multithreaded systems where it means the whole system isn&#039;t slowed down to a ridiculous extent.]]></description>
<dc:creator>HyperHacker</dc:creator>
<category>Coding</category><pubDate>Tue, 16 Dec 2008 08:02:52 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,4873,5119#msg-5119</guid>
<title>Re: Switch-Case inputs</title><link>http://forum.wiibrew.org/read.php?11,4873,5119#msg-5119</link><description><![CDATA[ <blockquote class="bbcode"><div><small>Quote<br /></small><strong>bushing</strong><br /><blockquote class="bbcode"><div><small>Quote<br /></small><strong>SpaceJump</strong><br />This didn&#039;t help:<br /><br /><pre class="bbcode">
for(int pause = 0; pause &lt; 150; pause++){
}</pre><br />What exactly does WPAD_GetStatus() return? When I try to printf it, I get errors.</div></blockquote><br />"errors"?</div></blockquote><br />Sorry, I meant Code Dumps.]]></description>
<dc:creator>SpaceJump</dc:creator>
<category>Coding</category><pubDate>Tue, 16 Dec 2008 07:34:48 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,4873,5118#msg-5118</guid>
<title>Re: Switch-Case inputs</title><link>http://forum.wiibrew.org/read.php?11,4873,5118#msg-5118</link><description><![CDATA[ <blockquote class="bbcode"><div><small>Quote<br /></small><strong>SpaceJump</strong><br />This didn&#039;t help:<br /><br /><pre class="bbcode">
for(int pause = 0; pause &lt; 150; pause++){
}</pre><br />What exactly does WPAD_GetStatus() return? When I try to printf it, I get errors.</div></blockquote><br />"errors"?]]></description>
<dc:creator>bushing</dc:creator>
<category>Coding</category><pubDate>Tue, 16 Dec 2008 07:32:22 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,4873,5117#msg-5117</guid>
<title>Re: Switch-Case inputs</title><link>http://forum.wiibrew.org/read.php?11,4873,5117#msg-5117</link><description><![CDATA[ This didn&#039;t help:<br /><br /><pre class="bbcode">
for(int pause = 0; pause &lt; 150; pause++){
}</pre><br />What exactly does WPAD_GetStatus() return? When I try to printf it, I get errors.]]></description>
<dc:creator>SpaceJump</dc:creator>
<category>Coding</category><pubDate>Tue, 16 Dec 2008 07:12:22 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,4873,5089#msg-5089</guid>
<title>Re: Switch-Case inputs</title><link>http://forum.wiibrew.org/read.php?11,4873,5089#msg-5089</link><description><![CDATA[ Personnaly, I use a simple sleep() to delay after WPAD_Init before reading wiimote input<br /><br />but maybe something like that might help you:<br /><pre class="bbcode">

 u32 exp;
 while (WPAD_Probe(0, &exp) != WPAD_ERR_NONE);
</pre>]]></description>
<dc:creator>ekeeke</dc:creator>
<category>Coding</category><pubDate>Mon, 15 Dec 2008 20:27:15 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,4873,5086#msg-5086</guid>
<title>Re: Switch-Case inputs</title><link>http://forum.wiibrew.org/read.php?11,4873,5086#msg-5086</link><description><![CDATA[ <blockquote class="bbcode"><div><small>Quote<br /></small><strong>Arikado</strong><br /><blockquote class="bbcode"><div><small>Quote<br /></small><strong>Tantric</strong><br />That won&#039;t work at all. If you want to "slow down" you can try sleep() or usleep(). But this still wouldn&#039;t help you with what you&#039;re trying to do.</div></blockquote>
Funny, I&#039;ve gotten it work in some of my past games. Usually 150 ends up being some insane number though, but it definitely works.</div></blockquote><br />My guess would be, that some compilers might optimize<br />for(int pause = 0; pause &lt; 150; pause++)<br />to do nothing.]]></description>
<dc:creator>daniel_c_w</dc:creator>
<category>Coding</category><pubDate>Mon, 15 Dec 2008 18:01:13 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,4873,5085#msg-5085</guid>
<title>Re: Switch-Case inputs</title><link>http://forum.wiibrew.org/read.php?11,4873,5085#msg-5085</link><description><![CDATA[ <blockquote class="bbcode"><div><small>Quote<br /></small><strong>Tantric</strong><br />That won&#039;t work at all. If you want to "slow down" you can try sleep() or usleep(). But this still wouldn&#039;t help you with what you&#039;re trying to do.</div></blockquote>
Funny, I&#039;ve gotten it work in some of my past games. Usually 150 ends up being some insane number though, but it definitely works.<br /><br />Better suggestion though:<br /><br /><pre class="bbcode">
while(wiimotes are not initialized){

}</pre>
Not sure what wiimotes not initialized would be I don&#039;t have libogc in front of me at the moment. There is something for it though.]]></description>
<dc:creator>Arikado</dc:creator>
<category>Coding</category><pubDate>Mon, 15 Dec 2008 17:32:21 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,4873,5078#msg-5078</guid>
<title>Re: Switch-Case inputs</title><link>http://forum.wiibrew.org/read.php?11,4873,5078#msg-5078</link><description><![CDATA[ I have no environment to test it and I find no WPAD documentation, but<br />doesn&#039;t any of the functions like WPAD_GetStatus() give you the value of connected Wiimotes?<br /><br />Your program could wait, until it&#039;s &gt; 0.]]></description>
<dc:creator>daniel_c_w</dc:creator>
<category>Coding</category><pubDate>Mon, 15 Dec 2008 14:28:56 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,4873,5073#msg-5073</guid>
<title>Re: Switch-Case inputs</title><link>http://forum.wiibrew.org/read.php?11,4873,5073#msg-5073</link><description><![CDATA[ Any other idea how I can archieve this?]]></description>
<dc:creator>SpaceJump</dc:creator>
<category>Coding</category><pubDate>Mon, 15 Dec 2008 08:02:55 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,4873,5071#msg-5071</guid>
<title>Re: Switch-Case inputs</title><link>http://forum.wiibrew.org/read.php?11,4873,5071#msg-5071</link><description><![CDATA[ Solving timing issue by adding a random delay is not the solution.]]></description>
<dc:creator>henke37</dc:creator>
<category>Coding</category><pubDate>Mon, 15 Dec 2008 07:30:36 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,4873,5065#msg-5065</guid>
<title>Re: Switch-Case inputs</title><link>http://forum.wiibrew.org/read.php?11,4873,5065#msg-5065</link><description><![CDATA[ <blockquote class="bbcode"><div><small>Quote<br /></small><strong>Arikado</strong><br /><pre class="bbcode">
WPAD_Init();

for(int pause = 0; pause &lt; 150; pause++){

}

//Check for button press</pre><br />Try this, it&#039;ll slow everything down for a tiny bit. Modify 150 if necessary.</div></blockquote><br />That won&#039;t work at all. If you want to "slow down" you can try sleep() or usleep(). But this still wouldn&#039;t help you with what you&#039;re trying to do.]]></description>
<dc:creator>Tantric</dc:creator>
<category>Coding</category><pubDate>Mon, 15 Dec 2008 03:55:21 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,4873,4954#msg-4954</guid>
<title>Re: Switch-Case inputs</title><link>http://forum.wiibrew.org/read.php?11,4873,4954#msg-4954</link><description><![CDATA[ <pre class="bbcode">
WPAD_Init();

for(int pause = 0; pause &lt; 150; pause++){

}

//Check for button press</pre><br />Try this, it&#039;ll slow everything down for a tiny bit. Modify 150 if necessary.]]></description>
<dc:creator>Arikado</dc:creator>
<category>Coding</category><pubDate>Mon, 15 Dec 2008 00:55:47 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,4873,4953#msg-4953</guid>
<title>Re: Switch-Case inputs</title><link>http://forum.wiibrew.org/read.php?11,4873,4953#msg-4953</link><description><![CDATA[ Because when the app loads I want it to do something when no button is being held, and something else if button A is held.]]></description>
<dc:creator>SpaceJump</dc:creator>
<category>Coding</category><pubDate>Mon, 15 Dec 2008 00:30:59 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,4873,4952#msg-4952</guid>
<title>Re: Switch-Case inputs</title><link>http://forum.wiibrew.org/read.php?11,4873,4952#msg-4952</link><description><![CDATA[ <blockquote class="bbcode"><div><small>Quote<br /></small><strong>SpaceJump</strong><br />[basically I want to check if a certain button is help when the program is loaded]</div></blockquote><br />Why exactly do you want to do this?]]></description>
<dc:creator>comex</dc:creator>
<category>Coding</category><pubDate>Mon, 15 Dec 2008 00:20:05 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,4873,4951#msg-4951</guid>
<title>Re: Switch-Case inputs</title><link>http://forum.wiibrew.org/read.php?11,4873,4951#msg-4951</link><description><![CDATA[ WPAD_init is the first function I call, and directly after the call I want to check if a button is held [basically I want to check if a certain button is help when the program is loaded]. But upon loading the app I see that the Wiimote flashes to late and the point of the button check is already past.]]></description>
<dc:creator>SpaceJump</dc:creator>
<category>Coding</category><pubDate>Mon, 15 Dec 2008 00:10:42 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,4873,4948#msg-4948</guid>
<title>Re: Switch-Case inputs</title><link>http://forum.wiibrew.org/read.php?11,4873,4948#msg-4948</link><description><![CDATA[ What I think they are trying to say is that the function is blocking and will not return until the job is done.]]></description>
<dc:creator>henke37</dc:creator>
<category>Coding</category><pubDate>Sun, 14 Dec 2008 22:21:35 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,4873,4947#msg-4947</guid>
<title>Re: Switch-Case inputs</title><link>http://forum.wiibrew.org/read.php?11,4873,4947#msg-4947</link><description><![CDATA[ WPAD_Init() should be the first thing you do (unless you want DVD, in which case DI_Init() should happen first). Assuming you run it this early, your program shouldn&#039;t have to wait.]]></description>
<dc:creator>Tantric</dc:creator>
<category>Coding</category><pubDate>Sun, 14 Dec 2008 22:18:17 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,4873,4945#msg-4945</guid>
<title>Re: Switch-Case inputs</title><link>http://forum.wiibrew.org/read.php?11,4873,4945#msg-4945</link><description><![CDATA[ Unless your using some sort of a thread, your program SHOULD not do anything until initialization is complete.]]></description>
<dc:creator>Arikado</dc:creator>
<category>Coding</category><pubDate>Sun, 14 Dec 2008 22:13:22 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,4873,4944#msg-4944</guid>
<title>Re: Switch-Case inputs</title><link>http://forum.wiibrew.org/read.php?11,4873,4944#msg-4944</link><description><![CDATA[ When I call WPAD_Init(); to initialise the Wiimote, how can I make my program wait until initialising is finished?]]></description>
<dc:creator>SpaceJump</dc:creator>
<category>Coding</category><pubDate>Sun, 14 Dec 2008 21:27:44 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,4873,4877#msg-4877</guid>
<title>Re: Switch-Case inputs</title><link>http://forum.wiibrew.org/read.php?11,4873,4877#msg-4877</link><description><![CDATA[ I want to them to have a different effect (one button held at a time).<br /><br />Thanks for your answers.]]></description>
<dc:creator>SpaceJump</dc:creator>
<category>Coding</category><pubDate>Fri, 12 Dec 2008 16:00:08 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,4873,4876#msg-4876</guid>
<title>Re: Switch-Case inputs</title><link>http://forum.wiibrew.org/read.php?11,4873,4876#msg-4876</link><description><![CDATA[ @SpaceJump:<br />When 2 buttons are pressed do you want them to have the same effect as if they were pressed separately?<br />(example: A: shoot, B: jump, A+B: shoot and jump)<br /><br />Then use a lot of IFs in the right places. Check for the A button where it makes sense in your code, and check for the B button, where it makes sense.<br /><br /><br /><br />Or do you want them to have a different effect?<br />(example: A: shoot, B: jump, A+B: open menu)<br /><br />Then use whodare&#039;s code examples.]]></description>
<dc:creator>daniel_c_w</dc:creator>
<category>Coding</category><pubDate>Fri, 12 Dec 2008 15:22:30 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,4873,4874#msg-4874</guid>
<title>Re: Switch-Case inputs</title><link>http://forum.wiibrew.org/read.php?11,4873,4874#msg-4874</link><description><![CDATA[ <pre class="bbcode">
 switch( buttonsHeld )
 {
  case WPAD_BUTTON_1:
   break;
  case WPAD_BUTTON_2:
   break;
 }</pre><br />Edit: D&#039;oh sorry, that will only work if only 1 button is down at a time...<br /><br />Edit 2: You can&#039;t do a switch if there&#039;s the possibility of several outcomes. If the user presses 1 and 2, unless you add<br /><pre class="bbcode">
  case WPAD_BUTTON_1 | WPAD_BUTTON_2:
   break;
</pre>]]></description>
<dc:creator>whodares</dc:creator>
<category>Coding</category><pubDate>Fri, 12 Dec 2008 13:35:10 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,4873,4873#msg-4873</guid>
<title>Switch-Case inputs</title><link>http://forum.wiibrew.org/read.php?11,4873,4873#msg-4873</link><description><![CDATA[ I want to read an Wiimote input (a held button):<br /><pre class="bbcode">
u16 buttonsHeld = WPAD_ButtonsHeld(0);</pre><br />Now I know how to read what button is being held with if:<br /><pre class="bbcode">
if (buttonsHeld & WPAD_BUTTON_A ) { 
        printf("Button A is being held down.\n");
}
else {
  if (buttonsHeld & WPAD_BUTTON_1){
	printf("Button 1 is being held down.\n");
  }
}</pre><br />How can I read what button is held with a Switch-Cause statement?<br /><br />Thanks in advance,<br />SJ]]></description>
<dc:creator>SpaceJump</dc:creator>
<category>Coding</category><pubDate>Fri, 12 Dec 2008 13:27:26 +0100</pubDate></item>
</channel>
</rss>