Game Development Community

Prelim Wii Integration

by Vinh Tran · in Torque Game Engine · 04/02/2007 (8:44 pm) · 19 replies

Been out of town for a bit so I haven't had a chance to get this out like I wanted.

This is just some prelim work. The Code currently supports all buttons (wiimote + chuck) and the acceleration of the wiimote in the x,y,z. It will return this as a Calibrated Value. -X to X, with 0 being no force. Gravity counts as a force, btw.

This particular integration modifies the Torque 1.5 starter.racing example game just to show what can be done quickly.

You should be able to tilt the remote towards you and use the [1] and [2] buttons for accel/brake. Turning the remote like a steering wheel will turn the car.

You will need some sort of USB bluetooth adapter and your wiimote needs to be connected to it before running the racing demo. I won't go over how to do this (its pretty easy) because there are many different adapters available.

My goal is to fully integrate and then do some development.

My todo list includes IR, Chuck Accel, Speaker, LEDs, and Port stuff.

I love discussions on the topic, feedback, or just general interest. I'm also open to PC Wii gameplay ideas to integrate. Hit me up at tranvv@gmail.com

----

Usage:

There are 4 new files to add to the project in the platformWin32 directory:

hiddevice.cpp/.h
wiimote.cpp/.h

These files come from Kevin Forbes (http://simulatedcomicproduct.com) and have been flagged as public domain.

I've included Diffs of all my code changes in PDF format. This should make it a ton easier to integrate. You should be able to copy and paste from Adobe Reader.

I've also included the 4 new files, remember to add them to your project.

New file Source and Diffs (temp, need mirror):
www.damnwesuck.com/brain/prelim_wii_integ.zip

#1
04/02/2007 (10:30 pm)
Thanks
#2
04/03/2007 (9:41 am)
Rock on! I'm looking forward to digging into this -- thanks so much!

As far as game ideas to show off the Wiimote, I think a side-scrolling (or 3d) tunnel-flying game could be a lot of fun. Something like Pitfall, but sideways (there was a Flash version of this floating around a year or two ago that sucked lots of my time). One thing that I thought could be neat, is that the plane is always falling, and you need to act in order to keep it in the air. In the Flash game, this was accomplished by holding the mouse down. When you held the mouse down, you rose. When you let go of the mouse, you fell. I wouldn't want the Wii game to be that the plane is simply following the vector that the Wiimote is pointing -- that would be too easy. Instead, I thought it could be interesting if you're always "pulling up" in order to raise the plane. What you could do is something like this:
// In the control update/physics section of your game loop...

  planeForce.Z = gravity; // Apply gravity to the player ship

  currentZ = WiiMote.getZAccel(); // Or whatever the function call would look like
  if (currentZ > lastZ) // If the Z accelleration is greater than it was the last time through the loop
  { // Then we know that they are "pulling up" on the wiimote
     planeForce.Z += (currentZ - lastZ); // Add whatever upward force they are applying on the Wiimote to the plane
  }

  lastZ = currentZ; // Store this Z for use next time through the loop

  // Do rest of plane physics/collision down here

So basically, I'm picturing that you need to flick your wrist upwards in order to keep the plane in the air, but downward force you apply on the wiimote won't affect the plane -- gravity pulls it down, and you pull it up.

Anyways, you were asking for ideas, and there's one of the ones I've been rolling around in my head for a while. :)

Cheers!

--clint
#3
04/04/2007 (1:22 am)
OMG, this is really exciting! I'll see what I can do as well!

Thanks!
Jean-Pierre
#4
05/21/2007 (7:12 am)
IS there any news about this release ?

Especially the IR state of the Wiimote ?

Thanks for it.

Nicolas
#5
07/24/2007 (9:53 am)
Hey Vinh,

I'm anticipating gearing up to do some more development with a Wiimote/nunchuck, and was interested in possibly using this resource.

Have things progressed past this point? I was just wondering if I should start with this resource, or if you had gotten any further.

Thanks!

Respectfully,
clint
#6
08/20/2007 (4:33 am)
I tried to follow your instructions for starter.racing game. Acceleration and braking worked fine but steering is a nightmare and control was rather impossible. I also integrated it to starter.fps but the effects were same. Looking around was horrible. I also tried to change the sensitivity but didn't work.

Thanks for it

Joe Coder
#7
10/06/2007 (3:19 pm)
Thank you very much for the Wiimote Integration.

I got a problem when running the Torque with wiimote connected.

The Torque do not run up if I connected the wiimote. Or It will hang immediately if I connect the wiimote after running the Torque. Would you please give me some hints on where the problem may come from??

I have checked the code and find no difference with the code you provided.

Thank you very much for the help.

Thomas
#8
10/18/2007 (12:13 pm)
Hey, is it still being updated/supported? How stable is it? I intend to use that to start a prototype for Wii using TGE 1.5.
#9
10/22/2007 (1:23 pm)
Check to see what bluetooth stack you are using. I know it works with toshiba bluetooth stacks. I've had reports of it acting wierd with a couple...
#10
10/22/2007 (3:27 pm)
I'm a big fan of the Bluesoleil stack. This has worked fine for me and my USB Bluetooth adapter.

Great work on the resource Vinh. I've gotten the entire feature set of the Wiimote (chuck, IR, acceleration, LED, rumble, speaker, yada yada), so let me know if you have some questions or find something really neat to share =)
#11
05/03/2008 (6:20 am)
Hey guys. I'm trying to add multiple Wiimotes to this resource, do you have any pointers? I'm especially looking at:

bool cWiiMote::ConnectToDevice(int index)
{
	Init();
	const bool retval = mHIDDevice.Connect(mDeviceID,mVendorID,index) && 
						SetReportMode(REPORT_MODE_MOTION_CHUCK_IR) && 
						UpdateOutput() &&
						ReadCalibrationData();

	if (retval)
	{
		InitNunchuck();
	}
	return retval;
}

Will the mHIDDevice.connect call connect to the first free wiimote, so I can just call connectToDevice again to get the second? Or is it more complicated than that?

Cheers,
Ian
#12
10/02/2008 (1:30 pm)
Hi,

I'm trying to get the files but the link seems to be broken.
Is there another place where i can get them ?

Thanks
#13
10/04/2008 (10:18 am)
Hey, had a few people contact me recently for these so I guess that means their old location is no longer working. Here is another location but this is definitely temporary. If someone could mirror these on a more stable FTP I would appreciate it!

Thanks

www.damnwesuck.com/brain/prelim_wii_integ.zip
#14
10/04/2008 (10:27 am)
Thank you very much for re-upload the resources.

I mirror the files here:
www.hiniyana.com/others/prelim_wii_integ.zip

I own the site so I will keep the files very long time.
#15
10/05/2008 (10:53 am)
All is well explained.
Great resource, thanks a lot for sharing.

But i have a single question.
Because we have a hardware independant machine and i think we should need a constant render speed.
So we don't need an interpolation in your rendering, because we just have a constant frame rate.

So do we need a modification over the game loop ?
#16
10/14/2008 (1:08 pm)
I'm having a lag problem with the wiimote's buttons.
When I press them they doesn't respond immediately.

At the menu of my game there's no lag. But when I enter the game
there's a really disturbing lag.

Anyone can help me ?!

Thanks
#17
01/24/2010 (12:42 am)
This Wiimote integration resource looks great, but the mirror links above are now dead. Is anybody currently hosting this resource, or would anybody consider sending it to me? I'd really appreciate your help.
#18
05/16/2010 (9:21 am)
Just thought I'd check on this again. The links for downloading this resource are all dead. Could anybody help me find this excellent resource for integrating the Wiimote with Torque?
#19
05/16/2010 (10:28 am)
Try here:
http://www.macauplus.net/hiniyana/others/prelim_wii_integ.zip


This isn't my site; it's a variation of the link that Seng Hin Mak posted.