GlovePIE stands for Glove Programmable Input Emulator. It is a Windows program that allows you to map one input device to another, like say, a Wiimote to the mouse or keyboard. This is the reason I installed it. Originally it was made to emulate keyboard and joystick input with the Essential Reality P5 Glove, a device I have never heard of and a fact I have stolen directly from the front page of the site. Who cares? There are two immediately awesome applications I had in mind, and some even cooler that maybe someone out there can try.

You will need a Bluetooth dongle, and the obvious.

Wiimote to Mouse

Mouse.LeftButton = Wiimote.A
Mouse.RightButton = Wiimote.B
Var.roll = Smooth(Wiimote.Roll, 20)
Var.pitch = Smooth(Wiimote.Pitch, 20)
FakeMouse.DirectInputX = EnsureMapRange(Var.roll,-90,90,-800,800)
FakeMouse.DirectInputY = EnsureMapRange(Var.pitch ,-90,90,-800,800)

The syntax of GlovePIE is amazingly simple and intuitive. Here, the left click of the mouse is emulated by the A button on the Wiimote. The movements of the Wiimote are averaged across twenty frames (to minimize jerkiness), and the result is used to move the cursor. The "FakeMouse" is used instead of the Mouse, so that the computer's "real" mouse can still be used. Roll, pitch, and yaw are equivalent to what they mean relative to a plane. You'll figure it out; it's easy. EnsureMapRange simply takes the range of motion that I can tilt the Wiimote (in degrees), or a subset thereof, and maps it to the height or width of the screen (in pixels), or a subset thereof. The "Ensure" bit (as opposed to using MapRange) makes sure that if I am out of range, it will be squeezed down and mapped properly.
How well's it work?
For one, this may not be perfectly intuitive, since it involves tilting the Wiimote instead of moving in space. It's a little harder to do the latter, and I haven't quite gotten that far yet. The smoothing function makes movement slower and slower, but it helps to be a little more precise. Even so, it's pretty hard to hit the buttons in most GUIs. You might hit X instead of Restore or Minimize. Playing games is pretty frustrating. I tested it on Interlocked, and it adds a ridiculous level of difficulty to the simplest puzzles. So it's really just a neat thing to screw around with, and not so practical.

However, it may just be a problem with my code. The reason the motion is jerky or hard to control is that the motion is being polled and translated all the time. With a traditional mouse, you can stop moving it, set it down and pick it up again. I've tried ways of copying this, but they make it even jerkier and unusable, so I won't even copy them here.

Wiimote to Keyboard

Keyboard.A = Wiimote.A
Keyboard.S = Wiimote.B
Keyboard.P = Wiimote.Plus
Keyboard.RepeatRate = 7 Hz
if (Wiimote.roll > 40) then begin
Keyboard.right = true
wait 25 ms
Keyboard.right = false
if (Wiimote.roll < -40) then begin
Keyboard.Left = true
wait 25 ms
Keyboard.Left = false
if (Wiimote.pitch > 40) then begin
Keyboard.Up = true
wait 25 ms
Keyboard.Up = false
if (Wiimote.pitch < -40) then begin
Keyboard.Down = true
wait 25 ms
Keyboard.Down = false
Okay, first off, the if statement syntax. You have a lot of options, and I just wanted to point that out, because that is cool. You can use C-style curly braces and semicolons if you want to, or begin and end (I think Ruby might use those, but I forget), or you can just say if condition then statement. But anyway, there are two main features here I think are worthy of note. Things only happen when the pitch or the roll is greater than forty degrees in either direction. Much less than twenty and it's really hard to control. The "wait 25 ms" prevents GlovePIE from hanging or breaking by briefly turning off a key press after 25 milliseconds. Otherwise, it will be totally spammed by whichever key press you're emulating at the time, and get all clogged up. The Keyboard.RepeatRate is an optional line that I think makes the control a little tighter, but it's up to you. You can tweak each of these numbers to find your ideal butter zone.
How well's it work?
Pretty damn well, I'd say. Again, tilting the Wiimote instead of moving it can be a little awkward, and control may not be quite as tight as simply using a keyboard, but I'd say this is working well enough to be fun. I've tested it on Meaty Boner. Sometimes it's a little hard to stop and face your enemy, and jumping can be tricky, but once you get the hang of it there's this great momentum that builds up.

You may prefer just having jerking motions control movement, rather than keeping the Wiimote turned. There are probably several ways to do that. Simply writing Keyboard.Up = Wiimote.SwingUp does not seem to work very well unfortunately, which is kind of sad since that would have been the most obvious solution. Here's what I've come up with:

if ( < -1.5) then begin
keyboard.up = true
wait 20 ms
keyboard.up = false

That allows you to jerk the Wiimote upwards and trigger the up arrow once. It's good for jumping, but the same technique is really bad for crouching. It isn't that great for moving side to side either, because if you swing right and return to where you started, your character will move right and then left. You can hold it right and sort of tilt the Wiimote, but then it seems a lot easier to just use the tilt detection, like in the first script.

The gx, gy, and gz variables measure acceleration in Gs. To get good results, you have to calibrate your Wiimote, which involves following a prompt and laying it on different sides. If it is lying face-up at rest, it should register 1 G on the y-axis. (Pulling it upwards gives a value lower than one because you are fighting the force of gravity.) The "wait 20 ms" bit might not still be necessary, but it doesn't seem to hurt, either.

The alert reader may ask, "Why can't I map the mouse using force?" or some easier to parse variation of that question. You definitely can, but it doesn't work quite as well as the alternative. If you're curious, it can be done basically like this:

Var.gx = Smooth(Wiimote.gx, 20) = Smooth(, 20)
FakeMouse.DirectInputX = EnsureMapRange(Var.gx, 2,-2,-800,800)
FakeMouse.DirectInputY = EnsureMapRange( ,-3,3,-800,800)

But as I said it doesn't work great like this. Maybe you can find some way to make that smoother and easier to control, but I haven't.

Guitar Hero Drums to MIDI

midi.c3 = WiiDrums.Pedal
midi.e3 = WiiDrums.Red
midi.g3 = WiiDrums.Yellow
midi.a3 = WiiDrums.Orange
midi.b3 = WiiDrums.Blue
midi.c4 = WiiDrums.Green

This is clearly the absolute easiest code so far. It is really that simple. Besides running this code in GlovePIE, you'll need MIDIYoke, a DAW or tracker, and a MIDI VST instrument. I used REAPER with Grizzly VST. Set REAPER's MIDI-in device to MIDIYoke's first out. Add the place you downloaded Grizzly to REAPER's VST Plugins path under "Preferences..." Close the dialog, right-click on the far left of the screen and choose "Insert virtual instrument on new track..." then choose Grizzly from Instruments or VSTi (you may have to right-click in this dialog and choose "Scan for new plugins", first). It will ask you if you want to add multiple tracks for routing; say no. Your new track will be armed for recording, and input monitor will be on and set to "MIDI: All Channels". You will also see Grizzly's GUI. Now all you have to do is run the GlovePIE script, and start playing! Select Kit6 from Grizzly. (It sounds the best to me). You will hear any notes you play just shortly after you play them, as there is a bit of latency involved.
How well's it work?
It works better than any script so far. The latency is something you can't really fix. Grizzly is really a sampler, so I also tried using these studio drums samples. If you try that, I recommend pressing the button at the top of each sample slot that says "velo", so that it changes to "max". You can also push "decay" so that it changes to "MIDI", but that tends to make everything sound clipped.

I'm not really a drummer at all, so I don't know if it'll suit your needs. But for the average person, it's pretty damn fun.

EEG to ?

Included here simply because it's awesome. The latest versions of GlovePIE support using the Emotiv Epoc EEG headset. (Here's an awesomely written review of this gizmo.) I do not have one of these, and unfortunately cannot write from personal experience, but here are some of the commands that GlovePIE supports:
  • Push
  • Pull
  • Lift
  • Drop
  • Excitement
  • Meditation
  • Frustration
  • EngagementBoredom
  • ExcitementLongTerm

With the first four, you're sort of trying to perform telekinesis. But not really. You train this program to recognize your thought of "push", maybe even holding your hand out and pushing the air, and then apparently hope that you're thinking correctly time and again. With the others, it can monitor your facial expressions via EEG, so I guess that should take less training, hopefully. NOTE: Again, I don't have one of these, so I don't know all of what it does or what it includes. It may provide drivers that obviate the need for GlovePIE. Here are all kinds of media and crazy things to do with one of these.

Log in or register to write something here or to contact authors.