To keep from polluting the Space nav driver developmen thread with my glovepie scripting, i decided to make my own thread..
If you want to get your Space nav working as something that sends key commands, follow the directions here http://blog.ifallacy.com/ to get PPjoy and GlovePIE installed. Then load up my attached script in glovepie below..
Since i use roadrunner, here are some snippets from my ini file's to get it working with the mp3 player..
execTBL.ini:
Code:
"SN_RT","RRNEXT"
"SN_LT","RRPREV"
"SN_UP","VOL+"
"SN_DN","VOL-"
"SN_1","PLAY"
and keyTBL:
Code:
6038,"SN_UP"
6040,"SN_DN"
6037,"SN_LT"
6039,"SN_RT"
6049,"SN_1"
For those of you not using RR, the keymappings are ctrl + alt + (numer 1, and the four directional arrow keys)
Edit your files accordingly, and then load up my script in GlovePIE and have some fun 
as it is, press down on the hat to play/pause (ctrl + alt + 1)
tilt left and right to skip forewards/backwards through songs (ctrl + alt + (left/right arrow))
tilt up and down to toggle through the list, just liek you were pressing the up and down arrow keys..
script:
Code:
//ver 1.0 by inh
//Routine to determine which axis is being acted upong the most due to it being
//inevitable that more than one axis will change at a time
//this checks all values after a specified time and determines which one changed the most
//get a position reading from all axises
var.roll.1 = MapRange(Joystick1.roll, -1,1, 0,1)
var.yaw.1 = MapRange(Joystick1.yaw, -1,1, 0,1)
var.pitch.1 = MapRange(Joystick1.pitch, -1,1, 0,1)
var.x.1 = MapRange(Joystick1.x, -1,1, 0,1)
var.y.1 = MapRange(Joystick1.y, -1,1, 0,1)
var.z.1 = MapRange(Joystick1.z, -1,1, 0,1)
//wait a bit, then get positions again
wait 200ms
var.roll.2 = MapRange(Joystick1.roll, -1,1, 0,1)
var.yaw.2 = MapRange(Joystick1.yaw, -1,1, 0,1)
var.pitch.2 = MapRange(Joystick1.pitch, -1,1, 0,1)
var.x.2 = MapRange(Joystick1.x, -1,1, 0,1)
var.y.2 = MapRange(Joystick1.y, -1,1, 0,1)
var.z.2 = MapRange(Joystick1.z, -1,1, 0,1)
//compare second reading to first usign subtraction, then use th absolute function so that even negative values
//return whole numbers. the greated var.whatever.diff value will be the axis that has changed the most
var.roll.diff = abs(var.roll.2 - var.roll.1)
var.yaw.diff = abs(var.yaw.2 - var.yaw.1)
var.pitch.diff = abs(var.pitch.2 - var.pitch.1)
var.x.diff = abs(var.x.2 - var.x.1)
var.y.diff = abs(var.y.2 - var.y.1)
var.z.diff = abs(var.z.2 - var.z.1)
//Filter to filter out very slight movements of the hat (it must cause an increas (or decrease) of more than 0.04 to continue...)
if ((var.roll.diff >= 0.04) or (var.yaw.diff >= 0.04) or (var.pitch.diff >= 0.04) or (var.x.diff >= 0.04) or (var.y.diff >= 0.04) or (var.z.diff >= 0.04))
//super-sloppy if tree to figure out which var.*.diff is the greatest, and then act accordingly..
//as of now it just spits out which axis is being acted upon up in the debug bar at the top
//of the scripting window..
if ((var.roll.diff > var.yaw.diff) and (var.roll.diff > var.pitch.diff) and (var.roll.diff > var.x.diff) and (var.roll.diff > var.y.diff) and (var.roll.diff > var.z.diff))
var.roll.dir = sign(var.roll.2 - var.roll.1)
if (var.roll.dir = -1)
debug = "Roll (Twist Left)"
key.ctrl = 1
key.alt = 1
key.down = 1
wait 100ms
key.ctrl = 0
key.alt = 0
key.down = 0
elseif (var.roll.dir = 1)
debug = "Roll (Twist Right)"
key.ctrl = 1
key.alt = 1
key.up = 1
wait 100ms
key.ctrl = 0
key.alt = 0
key.up = 0
endif
else if ((var.yaw.diff > var.roll.diff) and (var.yaw.diff > var.pitch.diff) and (var.yaw.diff > var.x.diff) and (var.yaw.diff > var.y.diff) and (var.yaw.diff > var.z.diff))
var.yaw.dir = sign(var.yaw.2 - var.yaw.1)
if (var.yaw.dir = -1)
debug = "Yaw (Tilt Right)"
key.ctrl = 1
key.alt = 1
key.right = 1
wait 600ms
key.ctrl = 0
key.alt = 0
key.right = 0
elseif (var.yaw.dir = 1)
debug = "Yaw (Tilt Left)"
key.ctrl = 1
key.alt = 1
key.left = 1
wait 600ms
key.ctrl = 0
key.alt = 0
key.left = 0
endif
else if ((var.pitch.diff > var.roll.diff) and (var.pitch.diff > var.yaw.diff) and (var.pitch.diff > var.x.diff) and (var.pitch.diff > var.y.diff) and (var.pitch.diff > var.z.diff))
var.pitch.dir = sign(var.pitch.2 - var.pitch.1)
if (var.pitch.dir = -1)
debug = "Pitch (Tilt Forewards)"
key.up = 1
wait 100ms
key.up = 0
elseif (var.pitch.dir = 1)
debug = "Pitch (Tilt Backwards)"
key.down = 1
wait 100ms
key.down = 0
endif
elseif ((var.x.diff > var.yaw.diff) and (var.x.diff > var.pitch.diff) and (var.x.diff > var.roll.diff) and (var.x.diff > var.y.diff) and (var.x.diff > var.z.diff))
var.x.dir = sign(var.x.2 - var.x.1)
if (var.x.dir = -1)
debug = "X (Slide Left)"
elseif (var.x.dir = 1)
debug = "X (Slide Right)"
endif
else if ((var.y.diff > var.roll.diff) and (var.y.diff > var.pitch.diff) and (var.y.diff > var.x.diff) and (var.y.diff > var.yaw.diff) and (var.y.diff > var.z.diff))
var.y.dir = sign(var.y.2 - var.y.1)
if (var.y.dir = -1)
debug = "Y (Slide Forewards)"
elseif (var.y.dir = 1)
debug = "Y (Slide Backwards)"
endif
else if ((var.z.diff > var.roll.diff) and (var.z.diff > var.yaw.diff) and (var.z.diff > var.x.diff) and (var.z.diff > var.y.diff) and (var.z.diff > var.pitch.diff))
var.z.dir = sign(var.z.2 - var.z.1)
if (var.z.dir = -1)
debug = "Z (Pull Up)"
elseif (var.z.dir = 1)
debug = "Z (Push Down)"
key.1 = 1
key.ctrl = 1
key.alt = 1
wait 500ms
key.1 = 0
key.ctrl = 1
key.alt = 1
endif
else
debug = " "
endif
else
debug = "Press harder/longer girly-man"
endif
var.roll.1 = 0
var.yaw.1 = 0
var.pitch.1 = 0
var.x.1 = 0
var.y.1 = 0
var.z.1 = 0
var.roll.2 = 0
var.yaw.2 = 0
var.pitch.2 = 0
var.x.2 = 0
var.y.2 = 0
var.z.2 = 0
Bookmarks