Welcome! Log In Create A New Profile

Advanced

Wiimote Rumble Question [Solved]

Posted by RazorChrist 
Wiimote Rumble Question [Solved]
March 09, 2009 06:42AM
Hi, I've having a bit of trouble getting the rumble on my menu selections working correctly. It works, however, it doesn't stop rumbling until you make a selection or the pointer is no longer hovering over a selection. For example:
if pointer is highlighting an option = rumble, but doesn't stop
if pointer is highlighting an option + press A = rumble stop
if pointer not highlighting any option = no rumble
My question is, how do I get it to only rumble for 1 second, then stop, when an option is highlighted? I've looked over several threads about this here, and I didn't really find anything that helped.



Edited 2 time(s). Last edit at 03/14/2009 05:21PM by RazorChrist.
Re: Wiimote Rumble Question
March 09, 2009 07:20AM
Getting the controller to rumble for a set period of time is quite simply if you have a timer at your disposal. Whenever you enable the rumble just make sure to save the current time + the time you want the controller to rumble somewhere. Now simply add a check to your controller update routine that compares the current time with the desired rumble ending time. If the current time is greater than the ending time, simply stop the rumble motor.

To make sure that the controller doesn't continuously rumble if you highlight anything, you need to keep track of what is currently highlighted and what has been highlighted last. This should be easy enough by using two chars or integers. If the currently highlighted option is not the same as the last highlighted option, start the rumble and set the last highlighted option to the current one.

If you have any problems with setting up a timer, I suggest taking a look at this post.
http://forum.wiibrew.org/read.php?11,11264,11416#msg-11416

Sorry for not having any example code at the moment. If you need some, just tell me and I'll make something later.
Re: Wiimote Rumble Question
March 09, 2009 11:40AM
Botskiz, the timer Ive successfully used is far simpler than that. I'll post the code as soon as I get to a computer.

The code:

int rumbletime = 0;

if(conditions_are_met){
rumbletime = 1;
WPAD_Rumble(WPAD_CHAN_0, 1);
}

In your main loop:
if(rumbletime == 7){
rumbletime = 0;
WPAD_Rumble(WPAD_CHAN_0, 0);
}

if(rumbletime >= 1)
rumbletime++;

Thats almost the exact code I've used in Wii Shooting Gallery, WiiBreaker, and The HOMEbrew Menu Standard Library. Well its not a true timer like botskitz suggested, it works fine for a simple, quick, half a second rumble.



Edited 1 time(s). Last edit at 03/09/2009 09:00PM by Arikado.
Re: Wiimote Rumble Question
March 09, 2009 11:49PM
Okay, sorry, I'm a bit of a noob on Wii programming. Let me post my code and see if I have it in the right place, cus right now, I'm getting compiling errors.

Defined at top of pointer.c file:
int rumbletime = 0
Rumble function in pointer.c:
if (selection != last_selection && selection != 0) {
	rumble_time = 1;
	WPAD_Rumble(WPAD_CHAN_0, 1);
}
Not exactly sure where to put this, but tried putting it in menu_loop(), in my menu.c file:
if(rumbletime == 7){
	rumbletime = 0;
	WPAD_Rumble(WPAD_CHAN_0, 0);
}

if(rumbletime >= 1)
rumbletime++;
When I try to compile, I get the following errors:
In file included from c:/projects/wii/source/pointer.c:3:
c:/projects/wii/source/pointer.c: In function 'void dorumble(int)':
c:/projects/wii/source/pointer.c:45: error: 'rumbletime' was not declared in this scope
make[1]: *** [pointer.o] Error 1
"make": *** [build] Error 2

EDIT: Wait, I might have gotten it to work, as I compiled with zero errors this time. I'll test it on the Wii here in a bit, and if it's still not working right, I'll edit this post.

EDIT: Okay, well I tested it, but when I load the game, the screen just goes black and the Wii becomes unresponsive. I have to manually power it off and reboot it. Any ideas?

FINAL EDIT: Okay, I'm a dee dee dee. I figured it out. Apparently the Wii is really picky on how it wants rumble code to work. Here was the problem:
if (selection != last_selection && selection != 0) {
	rumble_time = 1;
	WPAD_Rumble(WPAD_CHAN_0, 1);
}
Which caused it to ALWAYS rumble. I got it to rumble for only 1 second by changing it to this:
if (selection != last_selection && selection != 0) {

	if (rumble_count <= rumble_time) {
		WPAD_Rumble(WPAD_CHAN_0, 1);
		rumble_count++;
	}
}
Yay, go me. Thanks for all the help guys!



Edited 5 time(s). Last edit at 03/10/2009 02:02PM by RazorChrist.
Re: Wiimote Rumble Question
March 10, 2009 04:55PM
The one glaring error I see in your code is that you use the variables rumbletime and rumble_time. Thats two variables, you should only be using one.

If you're getting a black screen, thats from something else in your program and not my rumble code. So I dont think I can help you with that, sorry.
Re: Wiimote Rumble Question
March 10, 2009 05:48PM
Quote
Arikado
The one glaring error I see in your code is that you use the variables rumbletime and rumble_time. Thats two variables, you should only be using one.

Yeah that was a typo that was fixed in the code.

Quote
Arikado
If you're getting a black screen, thats from something else in your program and not my rumble code. So I dont think I can help you with that, sorry.

This was due to me trying to change the screen resolution in GRRLIB from 640x480 to 800x600. Course, that was before I found out that 800x600 isn't really supported. At least, I haven't found anyone that's gotten it to work in GRRLIB. So I gave up trying to change it and went back to just 640x480.

All in all, the rumble is working the way I wanted it to now. I'm OCD on things like that. Now to get started on the actual game engine.



Edited 1 time(s). Last edit at 03/10/2009 05:49PM by RazorChrist.
Sorry, only registered users may post in this forum.

Click here to login