|
It is currently Tue Feb 19, 2019 3:29 pm
|
|
Page 1 of 1
|
[ 13 posts ] |
|
GlovePIE to FreePIE script conversion
Author |
Message |
Mars
One Eyed Hopeful
Joined: Tue May 14, 2013 3:49 pm Posts: 39
|
Hi again, I've been using the following GlovePIE script to map the mini joystick axis on my Logitech G940 as mouse (the Logitech profiler software allows mapping the mini-stick button as mouse button): Code: mouse.DirectInputX = mouse.DirectInputX + 30*deadzone(joystick.dial) mouse.DirectInputY = mouse.DirectInputY + 30*deadzone(joystick.slider) I'd like to convert this into its FreePIE equivalent so I can incorporate it into my Zeiss Cinemizer Headtracking script so I don't have to run both GlovePIE & FreePIE. Looked at all the examples but not quite sure what I should be using for this. Regards Mars
|
Sat Aug 17, 2013 3:48 am |
|
 |
CyberVillain
Petrif-Eyed
Joined: Mon Jun 22, 2009 8:36 am Posts: 2160 Location: Stockholm, Sweden
|
Mars wrote: Hi again, I've been using the following GlovePIE script to map the mini joystick axis on my Logitech G940 as mouse (the Logitech profiler software allows mapping the mini-stick button as mouse button): Code: mouse.DirectInputX = mouse.DirectInputX + 30*deadzone(joystick.dial) mouse.DirectInputY = mouse.DirectInputY + 30*deadzone(joystick.slider) I'd like to convert this into its FreePIE equivalent so I can incorporate it into my Zeiss Cinemizer Headtracking script so I don't have to run both GlovePIE & FreePIE. Looked at all the examples but not quite sure what I should be using for this. Regards Mars Something like this maybe? You will have to test with different values for deadZone and deltaFactor Code: if starting: deadZone = 10 deltaFactor = 50
mouse.deltaX = filters.deadband(joystick[0].sliders[0], deadZone) / deltaFactor Dial maybe is a slider[1] you will have to test, I do not have a joystick test with right now
_________________FreePIEMy blog
|
Sat Aug 17, 2013 4:24 am |
|
 |
Mars
One Eyed Hopeful
Joined: Tue May 14, 2013 3:49 pm Posts: 39
|
Thanks!
|
Sat Aug 17, 2013 10:06 am |
|
 |
Mars
One Eyed Hopeful
Joined: Tue May 14, 2013 3:49 pm Posts: 39
|
The following works except the Y axis constantly drifts down and does not center after the ministick is used: Code: mouse.deltaX = filters.deadband(joystick[0].sliders[1], deadZone) / deltaFactor mouse.deltaY = filters.deadband(joystick[0].sliders[0], deadZone) / deltaFactor
|
Tue Aug 20, 2013 3:45 pm |
|
 |
CyberVillain
Petrif-Eyed
Joined: Mon Jun 22, 2009 8:36 am Posts: 2160 Location: Stockholm, Sweden
|
Mars wrote: The following works except the Y axis constantly drifts down and does not center after the ministick is used: Code: mouse.deltaX = filters.deadband(joystick[0].sliders[1], deadZone) / deltaFactor mouse.deltaY = filters.deadband(joystick[0].sliders[0], deadZone) / deltaFactor increased deadzone? maybe you will have to have different deadzones for the two axis, if they differ to much in drift edit: this worked perfect for my Logitech Rumblepad Code: if starting: deadZone = 100 deltaFactor = 1000
mouse.deltaX = filters.deadband(joystick[0].x, deadZone) / deltaFactor mouse.deltaY = filters.deadband(joystick[0].y, deadZone) / deltaFactor
_________________FreePIEMy blog
|
Tue Aug 20, 2013 4:14 pm |
|
 |
Mars
One Eyed Hopeful
Joined: Tue May 14, 2013 3:49 pm Posts: 39
|
Yes it simply needed higher values:
deadZone = 200 deltaFactor = 500
Cheers!
|
Tue Aug 20, 2013 11:05 pm |
|
 |
Cyborg11
One Eyed Hopeful
Joined: Tue Sep 17, 2013 4:40 pm Posts: 3
|
Hello guys, sorry for highjacking this thread but I thought I don't need to open a new thread only for one question. What is the FreePIE equivalent to this GlovePIE code? Code: PPJoy1.analog2 = (MapRange(-Joystick.Z, -1, 1, 0, 1)) I need a solution for VJoy. Thanks in Advance. 
|
Tue Sep 17, 2013 4:48 pm |
|
 |
Ideka
One Eyed Hopeful
Joined: Tue Sep 17, 2013 8:49 pm Posts: 1
|
FreePIE may have a function for that built in already, but I wouldn't know so here you go, put this function somewhere: Code: def map_range(n, lu, hu, lm, hm): return lm + (hm - lm) * float(n - lu) / (hu - lu) And then you can probably do something like: Code: ppJoy[0].setAxis(AxisTypes.X, map_range(-joystick[0].sliders[0], -1, 1, 0, 1)) Not sure about that. The function should work though.
|
Tue Sep 17, 2013 8:58 pm |
|
 |
CyberVillain
Petrif-Eyed
Joined: Mon Jun 22, 2009 8:36 am Posts: 2160 Location: Stockholm, Sweden
|
There is no generic util function built in as of current version (Will fix for next release). But both the ppJoy, Joystick plugin has its own range functions so you could do Code: if starting: joystick[0].setRange(min, max) ppJoy[0].setRange(min, max) If you are usign vJoy you have to get a little more creative because it does not have a setRange function. The range of the vJoy SDK is int16 so do Code: from System import Int16
if starting: joystick[0].setRange(Int16.MinValue, Int16.MaxValue) edit: btw, ther i a 5 minute time limit in current version of Vjoy SDK use this dll to disable that https://github.com/AndersMalmgren/FreeP ... y/VJoy.dll
_________________FreePIEMy blog
|
Wed Sep 18, 2013 1:16 am |
|
 |
Cyborg11
One Eyed Hopeful
Joined: Tue Sep 17, 2013 4:40 pm Posts: 3
|

@Ideka: Thanks for your map_range function. It works great even with vJoy. @CyberVillain: Thanks for the dll. How does the setRange function work? I can't specify an axis with this command so does that mean that all axis are mapped to this range? Maybe I missunderstood this function.  I'm using the function provided by Ideka for my script and the axis is mapped correct. But it doesn't update because the function is in the starting block of the script but I didn't find a way to update the vjoy like other devices such as freetrack.update, etc. Code: def map_range(n, lu, hu, lm, hm): return lm + (hm - lm) * float(n - lu) / (hu - lu)
if starting: vJoy[0].z = map_range(joystick[0].z, 1000, -1000, 0, 1000) diagnostics.watch(vJoy[0].z) Personally I would use a while loop as long as the script runs but is there a better way to do that in Python / FreePie? I'm new at Python but have experience in Java. EDIT: This loop works but my vJoy doesn't update: Code: def map_range(n, lu, hu, lm, hm): return lm + (hm - lm) * float(n - lu) / (hu - lu)
def update(): while (1) : vJoy[0].z = map_range(joystick[0].z, 1000, -1000, 0, 1000)
if starting: update
diagnostics.watch(vJoy[0].z) diagnostics.watch(joystick[0].z)
|
Wed Sep 18, 2013 5:29 am |
|
 |
CyberVillain
Petrif-Eyed
Joined: Mon Jun 22, 2009 8:36 am Posts: 2160 Location: Stockholm, Sweden
|
vJoy is a write only plugin so no update, and joystick uses polling under the hood so now update event there either. So you need to use old fashion polling. The problem with your script is that you use the if starting block. Remove that and it willl work. if starting is only fired the first time and not for the rest. You do not need a while loop since thats taken care of by FreePie. Jus tremove the starting and your set. And yes setRange is for all axis. Your example above with 1000 wont work very well for vJoy since it expects small int (Int16) This script should work Code: from System import Int16
if starting: joystick[0].setRange(Int16.MinValue, Int16.MaxValue)
vJoy[0].z = joystick[0].z
Or with Ideka map range Code: from System import Int16
vJoy[0].z = map_range(joystick[0].z, -1000, 1000, Int16.MinValue, Int16.MaxValue)
you cant use while loops like that, it will make FreePIE script thread hang.
_________________FreePIEMy blog
|
Wed Sep 18, 2013 5:40 am |
|
 |
CyberVillain
Petrif-Eyed
Joined: Mon Jun 22, 2009 8:36 am Posts: 2160 Location: Stockholm, Sweden
|
filters.mapRange added to FreePIE source, will be in next version https://github.com/AndersMalmgren/FreeP ... 0b41b73fd1
_________________FreePIEMy blog
|
Wed Sep 18, 2013 5:58 am |
|
 |
Cyborg11
One Eyed Hopeful
Joined: Tue Sep 17, 2013 4:40 pm Posts: 3
|
Thanks for your help.  It's very good to have an better alternative to GlovePIE. 
|
Wed Sep 18, 2013 6:09 am |
|
 |
|
|
Page 1 of 1
|
[ 13 posts ] |
|
Who is online |
Users browsing this forum: No registered users and 3 guests |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum
|
|