Curves

Official forum for open source FreePIE discussion and development.
Post Reply
frl
One Eyed Hopeful
Posts: 8
Joined: Sat Jul 12, 2014 5:54 pm

Curves

Post by frl »

Hi all,

I'm new to FreePIE so sorry if this is a very basic question.

I'm trying to use FreePIE to tweak the axis curves on my joystick (a Saitek x52 Pro) by reading in the raw values from the stick and presenting modified values to a vJoy virtual stick.

The issue I'm having is that the curved value will not go negative. In the example below, my "rawsl0" value ranges from -1000 to +1000, but my "curvesl0" value ranges only from 0 to +1000. I have added a curve (CurveDefault) and have played around with the curve in the GUI but no matter what I do I cannot get the curved value to go negative. The result is my curved axis only works in one direction off centre on the axis.

Code: Select all

from System import Int16

rawsl0 = (joystick[3].sliders[0])
curvesl0 = CurveDefault.getY(rawsl0)
   
diagnostics.watch(rawsl0)
diagnostics.watch(curvesl0)
Am I doing something really dumb?

Cheers,
frl
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: Curves

Post by CyberVillain »

It was a long time since I was doing any curve coding in FreePIE but I think you can only use positive values both for x and y axis. What you can do is to subtract from the output from getY. So if getY outputs from 0 to 2000 subtract 1000 and it will output from - 1000 to 1000
frl
One Eyed Hopeful
Posts: 8
Joined: Sat Jul 12, 2014 5:54 pm

Re: Curves

Post by frl »

Thanks for the quick reply CyberVillain!

That makes sense, thanks :)

Kudos to you and anyone else involved in FreePIE - I've spent a couple of days trying various other apps to achieve what I wanted without success. A couple of hours with FreePIE and I've got it sorted AND it's given me some other options to think about as well :)

Thanks again!
frl
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: Curves

Post by CyberVillain »

Thanks, glad it works for you!
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: Curves

Post by CyberVillain »

I dont have ppJoy installed but vJoy and it works

Code: Select all

from System import Int16

if starting:
	joystick[1].setRange(0, 2000)   
	
x = myCurve.getY(joystick[1].x)
y = myCurve.getY(joystick[1].y)

vJoy[0].x = filters.mapRange(x, 0, 2000, -Int16.MaxValue, Int16.MaxValue)
vJoy[0].y = filters.mapRange(y, 0, 2000, -Int16.MaxValue, Int16.MaxValue)
First I setRange on my real gamepad to 0 - 2000 using setRange, then I send it through the curve wich outputs between 0 - 2000

Then I use filters.mapRange to map to vJoy values, you should replace Int16.MaxValue with 1000 i think
frl
One Eyed Hopeful
Posts: 8
Joined: Sat Jul 12, 2014 5:54 pm

Re: Curves

Post by frl »

Ah, joystick[1].setRange, I didn't realise that existed :)

After your previous post and with a bit of playing around, I came up with the following, which also works nicely. Once the input values are all positive, the curve works nicely :)

Code: Select all

rawslider0 = (joystick[3].sliders[0])
filterslider0 = filters.mapRange(rawslider0, -1000, 1000, -16384, 0)
I increased the overall range from 2000 to 16384 as this seemed to be required to provide full axis travel in the vJoy virtual stick.

Thanks again for the help - and of course for FreePIE!
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: Curves

Post by CyberVillain »

Yes vJoy axis ranges from -Int16.MaxValue to +Int16.MaxValue
frl
One Eyed Hopeful
Posts: 8
Joined: Sat Jul 12, 2014 5:54 pm

Re: Curves

Post by frl »

Got it - thanks!
Billhelm
One Eyed Hopeful
Posts: 14
Joined: Fri Oct 11, 2013 7:01 pm

Re: Curves

Post by Billhelm »

I'm also trying to do exactly this, but I've not been successful. I wasn't able to reverse engineer a solution using the code posted in this thread. Would someone be willing to post the entire block of required code?
frl
One Eyed Hopeful
Posts: 8
Joined: Sat Jul 12, 2014 5:54 pm

Re: Curves

Post by frl »

It's been a little while since I looked at this, what is it exactly that you are trying to do?
Billhelm
One Eyed Hopeful
Posts: 14
Joined: Fri Oct 11, 2013 7:01 pm

Re: Curves

Post by Billhelm »

Thanks for the reply. I'm trying to create a script that based on the input of a physical joystick, decreases the sensitivity of vJoy towards the center, and increases sensitivity towards the outside. The joystick's minimum/maximum values should be unmodified. What I'm trying to describe is exactly like the 'expo' feature on an RC transmitter.
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: Curves

Post by CyberVillain »

A curve like this

Image

And my code above should do it

hmm, I should probaly add one more control point for these kind of scenarios
Billhelm
One Eyed Hopeful
Posts: 14
Joined: Fri Oct 11, 2013 7:01 pm

Re: Curves

Post by Billhelm »

That's exactly it. Thanks for the help. I was failing because I was:

a) Not defining a curve.
b) After defining the curve, not making the end of the curve 2000,2000

Also, yes, an extra point, or even the ability to define the number of points would be splendid. I'm trying to add a curve that changes directions in the middle, so I need an end point, a mid point, and two points before, and two points after the mid point.
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: Curves

Post by CyberVillain »

Yes, thats in the pipeline, what you can do until that feature is released is to add your points manually

open %appdata%\FreePIE\settings.xml

Add how many points you like to the curve

Code: Select all

    <Curve>
      <Name>myCurve</Name>
      <Points>
        <Point>
          <X>0</X>
          <Y>0</Y>
        </Point>
        <Point>
          <X>400</X>
          <Y>400</Y>
        </Point>
        <Point>
          <X>500</X>
          <Y>500</Y>
        </Point>
        <Point>
          <X>920.24789329980945</X>
          <Y>871.60737451808018</Y>
        </Point>
        <Point>
          <X>950</X>
          <Y>950</Y>
        </Point>
        <Point>
          <X>1000</X>
          <Y>1000</Y>
        </Point>
        <Point>
          <X>1162.2483254434383</X>
          <Y>1058.5283853167425</Y>
        </Point>
        <Point>
          <X>2000</X>
          <Y>2000</Y>
        </Point>
      </Points>
    </Curve>
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: Curves

Post by CyberVillain »

Improved curve editor in next version, you can select min axis value and max plus nr of points

Image
Post Reply

Return to “FreePIE”