Revolutionary: WRX Stage 1

The training wheel project got me thinking about what more it would take to create a Wii racing rig that's as comprehensive as a traditional wheel and pedal gaming setup. The Wii Wheel provides analog control for steering, but not throttle and braking. The Wheel shell also blocks off the expansion port, so you can't use a Nunchuk's analog stick. It seemed like there was just no way to build a full set of racing controls around the Wii Wheel, but then I got my Balance Board and the wheels started turning in my head. How about a Wii Racing Xperiment?
With a few unusual exceptions, I've avoided writing racing scripts. It just never seemed like the strengths of the Wiimote could be leveraged well enough against its weaknesses to do justice to my favorite genre. What I wanted was simple enough – analog throttle and brakes to go with my motion-based analog steering. To meet my demands, the Balance Board would have to have to work like a set of analog racing pedals. Variable amounts of foot pressure would translate to variable amounts of throttle or brakes.
Testing of the board revealed that it could provide analog sensitivity, but it would take some runtime calibration to make it behave similarly on different Balance Boards. I decided to use PPJoy to get true analog control instead of emulating it through keyboard presses as I've primarily done in the past. PPJoy is supported through GlovePIE with several functions for both analog and digital control types. After you get it installed, using PPJoy in a game is as easy as selecting it as your game controller.
Keep in mind, this script is written assuming that you're connecting your Balance Board before your Wiimote. If you connect them in the opposite order, you will have to change the numbering in the script. It seems to take a moment for GlovePIE to start recording values from the Balance Board, so because we need to get an initial reading as a baseline for the rest of the script, I make GlovePIE wait a moment at the beginning of the script to give it time to start reading the Balance Board.
wait 20ms //Short wait before getting initial Balance Board values
PPjoy.Analog1 = 0 //Resets the "pedals" at the beginning of the loop
if !var.init
var.BBJy = Wiimote1.BalanceBoard.JoyX
var.init = True
EndIf
var.BBy = Wiimote1.BalanceBoard.JoyX - var.BBJy //Subtracts the initial values from the current values
Make sure the Balance Board is on a level surface and nothing is resting on it when you start this script. The values collected in the above bit of code will be used to set the input at 0, since it doesn't read as 0 to start with.
If var.BBy < 0
var.BBy = (var.BBy * 9)
EndIf
The left side of the Balance Board wasn't as responsive as the right, so I multiplied any input to the left of the center point by a factor of 9. The values coming from the BalanceBoard.Joy function were still too low to correspond directly with PPJoy.Analog, so I had to multiply it again to get the range from 0 to 1 on the right side and -1 to 0 on the left side working with me applying a comfortable amount of foot pressure to the board.
var.BBy = (var.BBy * 25) //Decrease this number if you want to press harder
PPjoy.Analog1 = var.BBy
Next I set a deadzone, so that I could lightly rest my foot on the Balance Board without a response. Increasing this number widens the deadzone for those of you with feet more leaden than my own.
If (PPjoy.Analog1 > .25 or < -.25)
PPjoy.Analog1 = PPjoy.Analog1
Else
PPjoy.Analog1 = 0
EndIf
Converting Wii controller inputs into joystick vectors can sometimes be tricky if we're dealing with motion sensing and axes, but writing the controls for Wii Wheel steering was one of the most effortless undertakings I've faced in all my GlovePIE scripting days.
PPJoy.Analog0 = maprange(Wiimote2.SmoothPitch,-80,80,-1,1) //Steering controls
PPJoy.Digital0 = Wiimote2.1 //Digital button 0
PPJoy.Digital1 = Wiimote2.2 //Digital button 1
PPJoy.Digital2 = Wiimote2.B //Digital button 2
PPJoy.Digital3 = Wiimote2.A //Digital button 3
Key.Up = Wiimote2.Right //Menu up
Key.Down = Wiimote2.Left //Menu down
Key.Left = Wiimote2.Up //Menu left
Key.Right = Wiimote2.Down //Menu right
Key.Esc = Wiimote2.Minus //Menu back
Key.Enter = Wiimote2.Plus //Menu enter
Shift + P + I + E = Any.Home //Stops script running
The Wheel, as configured above, has 160° of rotation. Turning it beyond that will not affect any greater response, unless you turn it past 90° in either direction, which will make the controller think you're turning from the other direction. So long as you have both hands on the wheel, you probably won't turn quite it that far and there shouldn't be any problems. If you want to take the Wiimote out of the Wheel shell and play Excite Truck-style, increasing the range to 170° (85 and -85) works a little better.
To see what values are being sent to PPJoy, I added a debug line.
debug = "B Board: " + PPjoy.Analog1 + ", Wheel: " + PPjoy.Analog0
I loaded up Need for Speed ProStreet, changed my controller to PPJoy and configured the controls in the game and then it was off to the races.
The Balance Board and Wii Wheel, a winning combination
It's been disappointing seeing the racing genre so under-represented on the Wii. Aside from Mario Kart Wii, there aren't many noteworthy racers on this platform, and before the Balance Board arrived, there was good cause. Now I've seen what's possible and I'm hopeful that developers will take advantage of the peripheral for racers and other unexpected game types.
This is just the first stage on the experiment. Need for Speed ProStreet has several more controls that can be mapped, and PPJoy is just begging to be mapped to them. Driving simulators also have some complex controls that can overwhelm the average steering wheel and pedal controller set, but future stages in the Wii Racing Xperiment will attempt to implement more. We wouldn't expect an actual Wii game to be made much more complicated than what's been done in this stage, but I got into writing these scripts because I wanted to push the limits. If you have any suggestions on how I could do that, feel free to share in the comments.
Every Tuesday, Mike Sylvester brings you REVOLUTIONARY, a look at the wide world of Wii possibilities. The Wii Balance Board by itself opens up a world of possibilities, and with GlovePIE, you can help make it more than just a fitness gadget. Let Revolutionary: Balance and Options introduce you to the new toy that all the scripters want to play with.









Reader Comments (Page 1 of 1)
Peter S. @ Jun 18th 2008 3:49PM
That was cool, But in a real car I'll do the driving if you don't mind. Dad
Mr Khan @ Jun 18th 2008 7:48PM
Very good. The next step is to get that working with F-Zero GX, then send the footage to Nintendo
This is actually very much how i imagine an optional racing mode for next F-Zero to be, and they need to implement it
But i couldn't imagine how to improve on that, really
Mike Sylvester @ Jun 18th 2008 7:59PM
GX had digital throttle, so it should play fine with just a button, as on the GameCube controller. I can't remember if AX (the arcade variant) had analog throttle. Do you ever really want to slow down in an F-Zero game?
Mr Khan @ Jun 18th 2008 10:04PM
I suppose not, i just remember GX coming with all kinds of ads for the logitech GC Wheel, and figured it would work out
I never found an AX console, anywhere
Waffala @ Jun 18th 2008 11:54PM
I'm dying to see how you implement gear shifts; a nunchuck might be a little akward to position, but I imagine a suitable wiimote stand could be made to function as a shifter.
brian_k2 @ Jun 19th 2008 10:36AM
Very cool. What do you think about something like this (any racing app with board support) being made playable via the Homebrew Channel or via a modded Wii? I guess I'm wondering if it would be possible to change the code for a game like Mario Kart Wii to accept the board as the gas and brake...assuming you can get access to that code, change it, and then have a modded Wii that will read the new disc.
Thanks!
CJLopez @ Jun 19th 2008 2:32PM
It can be possible, but for that, we'd need the code of the game, and I don't think Nintendo will be releasing the source code to the open source for quite a while. They hasn't released the code for mario bross on the nes.
This was possible cuz it was on the PC, on which most games have the possibility to map button from joystiqs, and here the wiimote and balance board are connected via bluethoot to the PC
Chom @ Jun 19th 2008 5:27AM
I actually didn't try the script, but, as seem in the video above, to brake is necessary to stop accelerate. Is possible in the future to step brake whitout quit foot over accelerator? (For interprete that like handbrake to skid or simply to brake)
Sorry for my english? :)
Mike Sylvester @ Jun 19th 2008 9:48AM
There's a separate handbrake control in the game, which I set to the B button on the Wii Wheel. It's possible to map both sides of the Balance Board to separate joystick axes, so you could use both brakes and throttle at the same time. I've been working on a script that did that, but I figured people going for realistic driving would only use one foot in automatic.
web design company @ Jun 19th 2008 2:33PM
Why hasn't Nintendo thought of this?
Mike Sylvester @ Jun 19th 2008 2:35PM
Maybe they have. Games take time to develop and market, while I could throw together a script in a few hours/days. E3 is coming and they'll be announcing new titles there.
brian_k2 @ Jun 19th 2008 3:33PM
What about using the "Trucha Signer" to view and change the source code?? Check it out:
http://nintendo.joystiq.com/2008/02/27/trucha-signer-opens-new-wii-hacking-possibilities/
You still would need a modded Wii to run the modified Mario Kart game, but I have one, and Mario Kart...and a Balance Board... but I also have no experience with changing code or anything like this...I might have to study up and give it a go. Any ideas? Do you think this would work? Would anyone maybe want to help me with this (provide the new code and where to put it) and I could burn the disc and give it a go....
Thanks to all of you who know more about this stuff than I do, this is pretty cool!
brian_k2 @ Jun 19th 2008 4:41PM
Ok, so apparently Trucha actually does work on Firmware 3.2, I found evidence that Manhunt 2 can be changed to show full gore...I'll try playing with this program tonight to see if I can replicate it.
http://gbatemp.net/index.php?showtopic=76509&st=60&p=1004951
BTW - 3.3 just came out, and rumor is that Trucha signatures don't work on 3.3, so don't update if you want to try this).
http://wiibrew.org/wiki/June16_update
One possible hangup for this is that the Wii sees the board as two sets of remotes, I think. Would that be a problem, or just make it a bit more complicated?
Sorry if this is getting off-topic.
Girl4God20 @ Jun 19th 2008 7:01PM
Nice! I wanna play!! =o)