Archive for the ‘Glovepie Code’ Category


I Was Wrong!

September 15, 2008

Ok, I’m not going to skip to my loo to Java quite yet. After looking at some tutorials, and being completely overwhelmed by the massive amounts of knowledge I will need to pick through, there is no way in hell I could figure out how to do what I want in less than a few months.


So, that being said: I recruited my best friend who, among other things, worked for Microsoft at one point, and knows Java like the back of his own hand. Sometime soon he’ll be spending a weekend or two at my house so we can get together and work on my little project. He even said he’d help make a graphic UI for me! Wee!


Therefore until that weekend happens, I am stuck with what I know, and I’m coming back on my hands and knees with GlovePIE for another week.


On the good side of this I did find a script for GP that lets you:

1) Put a Wiimote in your pocket

2) Start jogging

3) GP recognizes that you are jogging!

It also recognizes walking. So I can use this as my ‘running script’ for creating movement in game. I’d like to thank Rhys Legault for his awesome script creation of magical shinyness! Now if I could only figure out a turning script with the same Wiimote (if you can’t tell by this point, I’m not too bright in the realm of programming) Actually, just thinking about it, it might not be that hard!


Here is the running script that I found on Friday (oh and if you can’t tell, I don’t blog on the weekend because I have a life hehe)


/*                  Wii R Walking v1.0
*                 Created by Rhys Legault                 *
*                        *
*             Last Modified: February 19th, 2007          *
*  Feel free to use, modify and redistribute this script  *
*  About:
*  This script identifies if you are still, walking or running
*  Requirements: 1 Wiimote
*  Directions:
*  Throw the wiimote into you pocket and start walking or running
*  This can be around the room or on the spot it doesn’t matter.
*  Just don’t run into anything!
*  The debug window will show that you are either still, walking or running
*  If required, adjust the threshold values to suit your needs.
*  If you want to use this script inside of another script use the
*  Search->Replace tool and replace all Wiimote values to Wiimote2
*  You won’t be able to use any of the buttons the Wiimote while it’s
*  in your pocket so you will require another Wiimote for any button
*  assignments
*  Notes:
*  To protect your Wiimote you can put it into the original plastic packaging
*  of an additional Wiimote (not the Wiimote’s packaging in the Wii bundle)
*  It fits perfectly & the buttons will not be pressed while you’re running

//Amount of time between calculating movement status
//1 = 25ms, 4 = 100ms, 5 = 125ms, 10 = 250ms, 20 = 500ms, 40 = 1000ms
var.Timing = 20

//Threshold values for Walking & Running
var.WalkingThreshold = 20
var.RunningThreshold  = 60

//Sets the maximum forces applied to the wiimote
if abs(Wiimote.RelAccX) > var.MaxAccX then var.MaxAccX = abs(Wiimote.RelAccX)
if abs(Wiimote.RelAccY) > var.MaxAccY then var.MaxAccY = abs(Wiimote.RelAccY)
if abs(Wiimote.RelAccZ) > var.MaxAccZ then var.MaxAccZ = abs(Wiimote.RelAccZ)

//Adust var.Timing if you want to change how often the TotalForce is calculated
if (PIE.Frame % 40) % var.Timing = 0
   //Calculates the total of the max forces applied to the wiimote
   var.TotalForce = var.MaxAccX + var.MaxAccY + var.MaxAccZ

   //Resets the max forces applied to the Wiimote
   var.MaxAccX = 0
   var.MaxAccY = 0
   var.MaxAccZ = 0

//Displays movement status
if var.TotalForce < var.WalkingThreshold
   debug = “Still”
elseif var.WalkingThreshold < var.TotalForce < var.RunningThreshold
   debug = “Walking”
   debug = “Running”

If I could get a decent Mouselook script going, then I would have a perfect Movement/Vision script and at least that portion would be finished. I think this is what I’m going to work on tonight!


Exergaming FTW

September 11, 2008

Another night of updating the code, and fixing a few small bugs. After restarting the ‘Swing Recognition’ script that I wrote, I’ve had better success, but for some reason it won’t trigger if, say, you swing a Wiimote left for 45 ms.


Here is an example of the code I wrote for the Down swing.

//Swing script Sept 10

//Amount of time allowed between sequence actions
PIE.SeqReadGap = 50ms

//Amount of accelation required for action to occur
var.AccelerationThreshold = 1.5

//Amount of time between a flick action
var.ActionGap = 150ms

//Amount of time to hold key press
//Used in example functionality (Delete if unused in custom functionality)
var.HoldKey = 50ms

if var.WiimoteFlick = false

//Swing Down
If Wiimote.RawAccY <= -29 m per s per s and Wiimote.Roll < 45 and Wiimote.Roll > -45 then
var.WiimoteFlick = true

//Custom script functionality starts here
say “Wiimote down”
wait var.HoldKey
//Custom script functionality ends here

wait var.ActionGap
var.WiimoteFlick = false

Basically, what it does is checks to see if the Wiimote is not tilted more than 45 degrees in either direction from the face-up position, and if it’s Y Acceleration is going down (is negative). As far as I know, there is no temporal function in GlovePIE aside from detecting velocity since the last script frame. Because GlovePIE is not a linear programming language (which means, I think: it simply repeats itself over and over as fast as it can) it can’t read something like “If Wiimote does X movement, for Y amount of time, then execute Z.”


Is that correct? Do any of you programming/coding people want to comment? I’m lost with that one. I mean I’d love to figure out how to do Gesture Recognition, because then I could implement it into other programs like World of Warcraft where you have like 30 separate battle skills. So if you traced a circle shape in the air, you would use the Intercept ability (or whatever).


I don’t think you can achieve accurate gesture recognition with GlovePIE unfortunately.


Tonight I’ll work on the Diagonally Up Swings that you receive at later levels. I actually could run around Hyborea last night and do some rudimentary swings fairly effectively (albeit awkwardly), but I think if someone got used to this, it would be possible.


Obviously as I mentioned before, some things would be extremely difficult such as selling/buying at the auction house.

Off-Topic: Check out what this guy did with the Wii Balance Board! This would be pretty cool to use. Too bad it’s all in a different language.


Ok so, update from last night. I got the movement script for the Dance Pad finished. I’d really like it if you ran in place your character would move, like the video, but that would be difficult to do (I think) with a DDR pad and I don’t own a Wii Fit. Maybe I could write a script that makes your character run by jogging with a Wiimote in your pocket? Once again, any suggestions of coding/scripting would be helpful, the last time I wrote any script before this was when I was 8 on my mom’s commodore 64!

Oh yes, and I’d like to add I found this little gem on Youtube. Very interesting idea, but a treadmill is kind of expensive and takes up a huge amount of space. Plus, what if you wanted to stop fast?



September 9, 2008

Ok, so after looking at Glovepie, and then looking at how to calculate certain swings, I realize the only way I can do this is by using Calculus (I got an A in it in college…10 years ago!) or simply switch to writing this script in Java and figure out how to combine the efforts of:


Wiigee Gesture Recognition Library




Oh yeah, and then I simply need to teach myself how to use the Java programming language!


That’s all…no big deal… /sigh/


Oh well, I guess innovative creations are never spawned with ease.


Anyone know basic Java out there?


The Script Version 1.0 (early Beta…or whatever)

September 8, 2008

My apologies for not posting in the past few days, alas I forgot my Flash memory at work so I didn’t have any copy of what I was writing for the weekend. Now that I have access again, I’ll post parts of my script and describe how each part functions. If you have any suggestions with how to add/change the script, I’m all ears:


There ya go! 

Ok, with that massive amount of crap being copy/pasted from my computer I will say this. It does not work yet!


The swing script doesn’t work properly, the mouselook is really screwed up, and for some reason lost my ‘old’ dancepad script so I have to go back and look at which PPJoy Virtual Joystick Buttons represent the four corners of the Dance Pad so I can script those commands in.


It doesn’t help that I joined a raiding guild on Thog now, and we did Vistrix last night (it was freaking AWESOME!) and we’re doing Kylikki (sp) and some wurm tonight. I’ll try to get some script fixed before raids start though. The whole thing is looking promising, and it is going to be funny once I actually get my bokken and gladius, which should be in the mail and arriving by the end of this week.


Yes, yes I know…”You’re gonna put yer eye out with that kid!” heh we’ll see!


Oh yes, and if you shop at Game Stop, check this out.


I watched all 90 minutes of it (like 3 episodes), and it cracked me up. Well done sir! (Even if it was a shameless copy of ZeroPunctuation’s Yahtzee)



Initial Glovepie Script Description

September 3, 2008

So the initial code I have been working on efficiently uses the buttons and motions available with each Wiimote. Here is the set up I have currently:



Dpad = Action keys 1,2,3,4 going clockwise from the far left

A Button = Sheath/Unsheath weapon

B Button = Alt key

Minus Button = Prev Target

Home Button = Nearest Target

Plus Button = Next Target

One Button = Sprint or Ctrl

Two Button = Jump



Dpad = Action keys 5,6,7,8 going clockwise from the far left

A Button = Mouse Right Click

B Button = Shift

Minus Button = Health Pot

Home Button = Mouse Left Click

Plus Button = Stam Pot

One Button = Mouse Middle

Two Button = Change Weapon



And on the Dance pad, I have the front, AND back right & left buttons acting as Turning. While directly Left and Right strafes. Also, the select button is Rest, and Start is Horse (because you usually aren’t moving when you do these actions)


The swings are trickier to describe without either scanning in my drawings or doing something retarded-looking in MS-Paint.


Basically, you hold the Wiimote with the front facing yourself, and when you swing, the buttons will slowly face left, right, or down/left or down/right depending on which way you swing it. The Glovepie code detects whether the Pitch and Roll are below/above a certain amount while specific acceleration forces are active. This is as close to gesture recognition as I can get.