Page 1 of 2 12 LastLast
Results 1 to 10 of 19

Thread: Space Navigator PE GlovePIE script

  1. #1
    inh
    inh is offline
    Maximum Bitrate
    Join Date
    Jan 2007
    Location
    Fort Riley KS
    Posts
    515

    Space Navigator PE GlovePIE script

    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

  2. #2
    Newbie
    Join Date
    Jul 2006
    Location
    Plano, TX
    Posts
    48
    Excellent Work !!!

  3. #3
    inh
    inh is offline
    Maximum Bitrate
    Join Date
    Jan 2007
    Location
    Fort Riley KS
    Posts
    515
    Thanks I hope some other people took the time to get glovepie setup for use with the space nav.. i cant wait till we have a dedicated drive released, this thing is AWESOME for working with roadrunner

  4. #4
    Maximum Bitrate
    Join Date
    Oct 2003
    Location
    Copenhagen, Denmark
    Posts
    747
    Does GlovePIE let you use Activex/Com objects in your code ?
    Transflective Lilliput 8", LV-677DC Core Duo 1,83Ghz, , Mpegbox uSDC20D, Shuttle Express, HQCT, PG XS6600 http://carpc.boyakasha.dk

  5. #5
    inh
    inh is offline
    Maximum Bitrate
    Join Date
    Jan 2007
    Location
    Fort Riley KS
    Posts
    515
    not sure, why would you need to?
    cashtexts - Earn money for receiving text messaged offers
    cashtexts review not a scam
    Space Navigator - 6 Axis input device: Take it apart - Driver App
    RRCam - Video/webcam capture, text overlay, and recording: 2.0 Stable

  6. #6
    Maximum Bitrate
    Join Date
    Oct 2003
    Location
    Copenhagen, Denmark
    Posts
    747
    I was thinking of doing maybe some different functions other than keypress when a certain skin in RR is started like my GPS which has no keyboard shortcuts or API yet. If we can call the RR SDK we could get information from RR about what screen is active, maybe there is another way of doing this, i don't know.
    Transflective Lilliput 8", LV-677DC Core Duo 1,83Ghz, , Mpegbox uSDC20D, Shuttle Express, HQCT, PG XS6600 http://carpc.boyakasha.dk

  7. #7
    inh
    inh is offline
    Maximum Bitrate
    Join Date
    Jan 2007
    Location
    Fort Riley KS
    Posts
    515
    ah ok gotcha.. take a look around the glovepie scripting, though i dont think it is able to do what ya want =[ why not implement keycombos in your gps? or is it not your gps app.. =[
    cashtexts - Earn money for receiving text messaged offers
    cashtexts review not a scam
    Space Navigator - 6 Axis input device: Take it apart - Driver App
    RRCam - Video/webcam capture, text overlay, and recording: 2.0 Stable

  8. #8
    Maximum Bitrate
    Join Date
    Oct 2003
    Location
    Copenhagen, Denmark
    Posts
    747
    Will look through GlovePie site
    I can't implement keyboard shortcuts in my gps appl. it's simply not supported, so i am thinking of doing a mouse emulation when RR starts my GPS, for this i would want to have RR send me window messages about current screen.
    Transflective Lilliput 8", LV-677DC Core Duo 1,83Ghz, , Mpegbox uSDC20D, Shuttle Express, HQCT, PG XS6600 http://carpc.boyakasha.dk

  9. #9
    Newbie
    Join Date
    Feb 2007
    Posts
    1
    I'm not sure I am in the good forum to expose my problem, but someone with glovepie/spacenavigator knowledge might have a solution. My situation is as follow; I got the space navigator device from 3d connexion. Having installed PPjoy and 3dxppjoy, I m sending midi messages to music programs through Midi yoke.
    Here is an example of the very basic "script"

    midi.BankSelectLevel = MapRange(Joystick2.x, -1,1, 0,127)/127
    midi.ModWheel = MapRange(Joystick2.y, -1,1, 0,127)/127
    midi.Breath = MapRange(Joystick2.z, -1,1, 0,127)/127
    midi.Control3 = MapRange(Joystick2.pitch, -1,1, 0,127)/127
    midi.FootPedal = MapRange(Joystick2.yaw, -1,1, 0,127)/127
    midi.PortamentoTime = MapRange(Joystick2.roll, -1,1, 0,127)/127

    Well, the data is sent and read with no problem from external music app, except for a very annoying detail: normally midi data consist of integrated numbers between 0 - 127. Well, in my case the data received by all tested applications shows that it is going beyond these limits. The result being that when for example a knob gets to its maximum, it "virtually" continues to increase above 127. It is very annoying as afterwards, the knob's value won t decrease before it gets back to 127 (which, depending on how long u held it, could take some time).
    Is there anyway of preventing this by, let's say, limiting the output data threshold?

    Thanks in advance for any suggestions

    P.S. I have also tried to use EnsureMap, and EnsureRangeMap with no success.

  10. #10
    Variable Bitrate
    Join Date
    Aug 2006
    Location
    Central PA
    Posts
    246
    Works great! Thanks a bunch. Only thing I'm curious about is if there is there any way to add context switching?

Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 6
    Last Post: 06-02-2006, 09:20 AM
  2. space cadets
    By lez in forum Off Topic
    Replies: 2
    Last Post: 12-11-2005, 11:45 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •