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

Related posts:

  1. MAME Project Step 1: The Basics This is a list of requirements for getting MAME going:...
  2. MAME .117+ and GlovePIE keyboard incompatibility So far my research has found that MAME versions greater...
  3. MAME Project Update Been running in to a few set backs with the...
  4. MAME Project Step 2: BlueSoleil & MSI Star Key The Widcomm drivers that come with the MSI Star Key...
  5. The MAME’ing of MediaPortal Since Carlos thinks I already spend too much time in...

10 Responses to “MAME Project Step 3: GlovePIE”
  1. vanessa says:

    hi len :-)

  2. Deborah says:

    Hi Len,
    I think you’re hot! (but don’t tell Eva)

  3. Len says:

    Geez, and I thought *I* was a nerd…

  4. Julie says:

    I’m not quite sure that I have a sweet clue what I just read.Was that like a game cheat?I do know that you have a super wife:) ! chapped lips and all.

  5. Nicole says:

    I have NO idea what you are talking about at all ! LOL
    We all think you are hot…don’t tell short stuff, cause she will get all freaky with us..

    Gonna have to come over and play rock band with me soon! :)

  6. Carole says:

    Huh???? What?……. does Eva understand this stuff???? Yikes… it is a good thing you are cute. LOL

  7. eva says:

    Ok, I’ll just pretend I didn’t see these comments!

  8. Thomas says:

    Thanks for all the info I have only one problem I cant connect a second wiiremote to my comp I keep getting the message “Operation is not successful please try again”
    help!!

  9. Len says:

    Hi Thomas,
    I did not encounter that problem you are having but here are some suggestions:
    - Please make sure you have the 5.0.5 version of BlueSoleil installed.
    - Delete any existing Wii remote devices in the Bluetooth neighborhood. This will make the devices re-create themselves on the next discovery.
    - When pairing with BlueSoleil or GlovePIE, keep pressing the 1+2 buttons on the Wii remote to keep the device in discovery mode until the pairing is complete.
    - Make sure that the Wii remote pairs with the computer through BlueSoleil first before connecting it through GlovePIE

    What type of bluetooth adapter are you using? Wiibrew.org has a list of compatible bluetooth adapters for the Wii remote. If necessary, you could try a different bluetooth stack such as Widcomm.

    I hope you are able to solve the problem.

  10. Steven says:

    Hey len this is great and all but one problem… it doesn’t work.
    I try mashing buttons and stuff but I cant get my character to move.
    Glovepie works for my other emulators but not for mame for some reason…