Welcome! Log In Create A New Profile


Guitar Hero Controller

Posted by icefire 
Guitar Hero Controller
December 03, 2008 01:42AM
Here is my code:

if( (buttonsHeld & WPAD_BUTTON_PLUS) || (buttonsHeld & WPAD_CLASSIC_BUTTON_PLUS) || (buttonsHeld & WPAD_GUITAR_HERO_3_BUTTON_PLUS) )
        printf("%d\n", ++i); 
	WPAD_Rumble(WPAD_CHAN_0, 1);

As is obvious, buttonsHeld is the return value of WPAD_ButtonsHeld(0);

It works with the Wiimote (I don't have a classic controller to test), but not with the Guitar...any idea why?
Re: Guitar Hero Controller
December 03, 2008 06:02AM
Ur doin it rong.
Go look at wpad.h, it should help you out a bit TD
Re: Guitar Hero Controller
December 03, 2008 08:03AM
Could you explain? I'm new to C and Wii programming so i could use some newbie level help :)..

I could not understand what it means by (0x001<<16) in wpad.h

Re: Guitar Hero Controller
December 03, 2008 10:44AM
your code seems fine to me

problem is, with expansion controllers, you generally need to plug it only once your application has started (or once the HBC has started, not sure) to make it detected, this is a known "bug"

unplug/plug the controller generaly fix it
Re: Guitar Hero Controller
December 05, 2008 05:08PM
Your code looks fine to me as well.

I could not understand what it means by (0x001<<16) in wpad.h

a << b means take the bit representation of 'a' and shift that bit pattern to the left 'b' times. For example, 1 << 1 = 2, the bit pattern for 1 is '0001', and shifting that to the left 1 times gives you, '0010', which is a decimal 2.

Mathematically, a << b, is equivalent to a*2^b, or in other words, 1 left shit multiplies 'a' by 2, 2 left shifts multiplies by 4, etc.

The question you might have is why does wpad.h use this notation, when they could have just written in a single decimal number in place of the a<<b notation? The reason is a<<b is a very expressive and convenient notation, when you're working with numbers one bit at a time.

For example, if I want to have a number that has the 5th bit set to 1, I could either write out the decimal number this corresponds to, 32, or I could write 1<<5. Writing 32 is perfectly fine, but writing 1<<5 can indicate to the reader of your code that you were more interested in the 5th bit being set, rather than the number being 32.

You may have noticed that the routine WPAD_ButtonsHeld() returns a single 32-bit value that represents the buttons held at that instance. Since it's possible to have more than one button held at a time, this 32-bit value must somehow represent multiple buttons being held. The way it represents multiple buttons is to map each bit of the return value, to a specific button on your controller. So bit 0 might represent button A, bit 1 button B, etc.

In the code you posted, you're testing for these bits being set. The way you test for a bit being set is to and, &, the return value you get, with the bit pattern that represents the button you're testing for. The and operator looks at each bit of your two values, and if both bits are set, the corresponding bit in the final value is set.

One last thing, the notation "0x" and then some number, is the way you write hexadecimal numbers in C, so 0xff would be 255 decimal.

I hope this helps.
Re: Guitar Hero Controller
December 06, 2008 07:42AM
Thanks a lot :).

The helpfullness of everyone here is what I like about wii homebrew :).
Sorry, only registered users may post in this forum.

Click here to login