Announcement

Collapse
No announcement yet.

Space Navigator PE GlovePIE script

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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

  • #2
    Excellent Work !!!

    Comment


    • #3
      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
      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

      Comment


      • #4
        Does GlovePIE let you use Activex/Com objects in your code ?
        Not doing carpc anymore

        Comment


        • #5
          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

          Comment


          • #6
            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.
            Not doing carpc anymore

            Comment


            • #7
              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

              Comment


              • #8
                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.
                Not doing carpc anymore

                Comment


                • #9
                  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.

                  Comment


                  • #10
                    Works great! Thanks a bunch. Only thing I'm curious about is if there is there any way to add context switching?
                    2001 SS Camaro carputer | My solar dish project/

                    Comment


                    • #11
                      The link in the first post is not working. Anyone got another tutorial on how to install PPjoy and GlovePie?

                      Comment


                      • #12
                        Hi...I have got it working. I noticed one thing. When I tilt up and down to toggle through the list, it works. After I toggle to a song I want and press the hat to play it, everything is fine up to this point. When I toggle again it becomes volume increase and decrease.

                        Any plans to make it control volume or its already there and I did something wrong. Wonder if it would be a good idea to make use the side buttons, think that should be more straight forward.

                        BTW good job

                        Comment


                        • #13
                          Thanks =] That script is really just a quick hack i threw together in like two hours the day i got my space navigator.. All current efforot is with another application, written by people on this forum. Check out the driver dev link in my sig. You need to uninstall all the ppjoy crap and get the factory drivers back on the spacenav, but then this lil tiny app that you configure with an xml file takes over and sends commands. I have it controlling volume, play/pause, next/prev, as well as acting as a mouse. It is also able to do different things based on what screen is being displayed (im still workin on getting this setup)

                          go check it out, most importantly on the last few pages where i've posted my code.
                          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

                          Comment


                          • #14
                            Great...i'll take a look. ....I saw the code on the last page of the Driver Dev link but where do I place them?

                            Comment


                            • #15
                              download the app from the sourceforge link in cherrybombs sig, then do a search on google and download xerces-c_2_7.dll and put it in the same folder
                              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

                              Comment

                              Working...
                              X