Now that the MSI Star Key 2.0 and BlueSoleil are working, getting the Wii remote to connect to the PC should be a snap. Double-click your fancy new “Bluetooth Places” icon and you will see an icon for “Search Devices”. Before double-clicking this icon, push the 1 & 2 buttons on your Wii remote(s) and the 4 LEDs on the remotes will start to blink – this puts the Wii remote in to bluetooth discovery mode. Now click the “Search Devices” icon and your Wii remote(s) should come up right away as a blue joystick icon. This means your devices were found but they are not yet connected. Now right-click the joystick icon, click connect and the joystick should turn green meaning your Wii remote is now connected. Please note that you have to connect the device while the remote still has the LEDs blinking. If the LEDs stop blinking before the device is connecting, simply press 1 & 2 again. You can poke around on the device status to view signal strength which can be handy if your PC will be out of sight, much like it is for my Mediaportal setup.
So now how to make the PC accept input from the Wii remote? The answer to that is GlovePIE. In essence, GlovePIE (Glove Programmable Interface Emulator) acts as a bridge between various non-standard controllers and virtual reality devices and translates those actions to keyboard, mouse or joystick actions on the computer. GlovePIE is pretty magical based on two aspects:
1) It can send and receive data to the Wii remote and many other controllers. In a basic form, it can read the button states from the controls, i.e.: up, down, button 1, button 2. In a more advanced form, it can also read the more advanced sensors from the Wii remote, i.e.; tilt sensor, accelerometer. Since it can also send commands back to the remote, it can enable the rumble or change the LEDs to on or off. It also works with the Wii classic controller, nunchuk and even guitar.
2) It can emulate mouse, keyboard or joystick input to the PC. The PC will do what GlovePIE tells it to do.
Hopefully you see the magic now… GlovePIE will send commands to the PC based on what input it receives from the Wii remote. So if you hold left on the control pad, GlovePIE will emulate the left arrow key being held down on the keyboard…and so on and so forth. If you want to take it a step further, you can perform other commands based on the motion sensors of the Wii remote. Let’s say you are playing Punch-Out for NES. You could map swinging the nunchuck to a left-hook button and swinging the wii remote to a right-hook. Neat, huh?
On top of all this, GlovePIE is fully scriptable so you can extend it and make it suit whatever your needs are. In my case, I want to map all the MAME controls to my Wii remotes. This is done via a script. I won’t get in to the dirty details of the script but it is fairly straight forward. You can read more about the scripting syntax and the Wii specific features over at WiiLi.org.
All you need to do at this point is make sure your Wii remote is connected to BlueSoleil, start GlovePIE, load a script and click Run. GlovePIE comes with a couple of good test scripts: WiimoteScripts/Wiimote3d.pie and OldScriptsTestWiimote.pie. Wiimote3d.pie will display a 3d representation of your Wii remote and adjust it depending on the remote’s tilt….very cool. TestWiimote.pie will give text representations of your sensors and also let you test some input. Run the TestWiimote.pie and then start notepad, give notepad focus and by pressing 1, 2, A or B on the Wii remote, you should see those characters appear in notepad. If everything works, you are good to go.
At this point you have your Wii remote connected to the PC and you have GlovePIE translating remote commands to PC input. Now all we need to do is map the remote buttons to the commands MAME is expecting. I will include a script that I wrote for this purpose at the bottom of this post. The script will work with four wii remotes connected and map the directional pad and buttons to the default keys MAME is expecting. These controls are consistent across all four remotes:
D-Pad: Directional controls
Button 1 & 2: Primary and secondary action button
+ button: Insert coin
A button: Start game
Home button: Pause MAME
- button: Enter on keyboard (useful if navigating MAME with the remote)
+ & – together: Soft reset the ROM
B & A together: Quit MAME
You might find that the remote lights continue to blink after connecting them to your PC. Once the GlovePIE script below is loaded, you can press the + button on the remote to stop the blinking and the corresponding light on the Wii remote will light up to indicate which player remote it is – just like on a Wii itself. I’ll try to make this more automated in the future but it is still a work in progress.
Now your remote(s) should be mapped to all the default MAME keys. Fire up MAME with your favourite ROM and give it a test. Please note that I’ve have the most success with MAME32 v.117. Versions above this (tested through to .123) give an error about the Wii controller and the input doesn’t work. Not sure why this happens but I’ll figure it out later.
One last sidenote, the main reason I am using the BlueSoleil software is because GlovePIE can automatically connect your Wii remotes through BlueSoleil without any manual intervention. It’s actually quite easy, make sure BlueSoleil is setup and working correctly first with your remotes. Make sure GlovePIE is running. Now pressing 1 & 2 on your Wii remote(s) and GlovePIE will automatically sync the remotes. I’m finding that this often takes three or four tries to actually get each remote synced. However since this is an automatic process, it is good for a home theatre PC setup. Remember to press the + button to make sure the remote is synced and have the player number LED light up. For full automation, I will start GlovePIE and my script when the computer boots.
One last last sidenote, You can turn off the remote by holding down the power button for a couple seconds too. As always, resync by pressing 1 & 2 together.
Here is the script I am currently using – you can copy and paste this to a local file for your own use. One Classic controller is supported at this point:
// Len's Wii Remote script for MAME32
// Supports 1 - 4 players
// Basic directional control and button assignments.
// Player 1
key.Up = Wiimote1.Right // Up
key.Down = Wiimote1.Left // Down
key.Left = Wiimote1.Up // Left
key.Right = Wiimote1.Down // Right
key.LeftCtrl = Wiimote1.One // Button 1
key.LeftAlt = Wiimote1.Two // Button 2
key.5 = Wiimote1.Plus // Insert Coin
key.1 = Wiimote1.A // Player 1 Start
key.Enter = Wiimote1.Minus // Enter
key.P = Wiimote1.Home // Pause
key.1 = Wiimote1.A // Player 1 Start
Wiimote1.Led1 = 1 // Light the Remote 1 LED
key.F3 = Wiimote1.Plus + Wiimote1.Minus // Soft Reset
ESC = Wiimote1.B + Wiimote1.A // Exit MAME
// Player 2
key.R = Wiimote2.Right // Up
key.F = Wiimote2.Left // Down
key.D = Wiimote2.Up // Left
key.G = Wiimote2.Down // Right
key.A = Wiimote2.One // Button 1
key.S = Wiimote2.Two // Button 2
key.6 = Wiimote2.Plus // Insert Coin
key.2 = Wiimote2.A // Player 2 Start
key.Enter = Wiimote2.Minus // Enter
key.P = Wiimote2.Home // Pause
Wiimote2.Led2 = 1 // Light the Remote 2 LED
key.F3 = Wiimote2.Plus + Wiimote2.Minus // Soft Reset
ESC = Wiimote2.B + Wiimote2.A // Exit MAME
// Player 3
key.I = Wiimote3.Right // Up
key.K = Wiimote3.Left // Down
key.J = Wiimote3.Up // Left
key.L = Wiimote3.Down // Right
key.RightControl = Wiimote3.One // Button 1
key.RightShift = Wiimote3.Two // Button 2
key.7 = Wiimote3.Plus // Insert Coin
key.3 = Wiimote3.A // Player 3 Start
key.Enter = Wiimote3.Minus // Enter
key.P = Wiimote3.Home // Pause
Wiimote3.Led3 = 1 // Light the Remote 2 LED
key.F3 = Wiimote3.Plus + Wiimote3.Minus // Soft Reset
ESC = Wiimote3.B + Wiimote3.A // Exit MAME
// Player 4
key.NUMPAD8 = Wiimote4.Right // Up
key.NUMPAD2 = Wiimote4.Left // Down
key.NUMPAD6 = Wiimote4.Up // Left
key.NUMPAD4 = Wiimote4.Down // Right
key.NUMPAD0 = Wiimote4.One // Button 1
key.NumPadDot = Wiimote4.Two // Button 2
key.8 = Wiimote4.Plus // Insert Coin
key.4 = Wiimote4.A // Player 4 Start
key.Enter = Wiimote4.Minus // Enter
key.P = Wiimote4.Home // Pause
Wiimote4.Led4 = 1 // Light the Remote 2 LED
key.F3 = Wiimote4.Plus + Wiimote4.Minus // Soft Reset
ESC = Wiimote4.B + Wiimote4.A // Exit MAME
// Vibrate when inserting a coin
if (Wiimote1.Plus) then
Wiimote1.Rumble = 1
wait 100ms
Wiimote1.Rumble = 0
wait 500ms
end if
if (Wiimote2.Plus) then
Wiimote2.Rumble = 1
wait 100ms
Wiimote2.Rumble = 0
wait 500ms
end if
if (Wiimote3.Plus) then
Wiimote3.Rumble = 1
wait 100ms
Wiimote3.Rumble = 0
wait 500ms
end if
if (Wiimote4.Plus) then
Wiimote4.Rumble = 1
wait 100ms
Wiimote4.Rumble = 0
wait 500ms
end if
// Player 1 Classic Controller
Key.Up = Wiimote1.Classic.Up; // Down
Key.Down = Wiimote1.Classic.Down; // Up
Key.Left = Wiimote1.Classic.Left; // Left
Key.Right = Wiimote1.Classic.Right; // Right
Key.Up = Wiimote1.Classic.Joy1Y <= -25%
Key.Down = Wiimote1.Classic.Joy1Y >= 25%
Key.Left = Wiimote1.Classic.Joy1X <= -25%
Key.Right = Wiimote1.Classic.Joy1X >= 25%
Key.LeftControl = Wiimote1.Classic.y; // Button 1
Key.LeftAlt = Wiimote1.Classic.b; // Button 2
Key.Space = Wiimote1.Classic.x; // Button 3
Key.LeftShift = Wiimote1.Classic.a; // Button 4
Key.Z = Wiimote1.Classic.L; // Button 5
Key.X = Wiimote1.Classic.R; // Button 6
key.5 = Wiimote1.Classic.Plus // Insert Coin
key.1 = Wiimote1.Classic.Minus // Player 1 Start
key.P = Wiimote1.Classic.Home // Pause