Joystick Curves made easy

GPC2 script programming for Titan Two. Code examples, questions, requests.

Joystick Curves made easy

Postby thedude » Wed Jul 31, 2019 10:44 pm

This simple function gives a nice curve, slow near the center.
Wonder if anyone had this or something similar? If not, enjoy.

Code: Select all
 
main {
    Curves(PS4_RX);
    Curves(PS4_LX);
}
void Curves (uint8 axis)
{
    fix32 R = pow(abs(get_val(axis)), 2.0) / 100.0;
    if(get_actual(axis) < 00.00 ) R = -R;
    set_val(axis, R);
 
}
 
Last edited by thedude on Thu Aug 01, 2019 5:35 pm, edited 1 time in total.
User avatar
thedude
Staff Sergeant
Staff Sergeant
 
Posts: 12
Joined: Wed Apr 10, 2019 8:09 pm

Re: Joystick Curves made easy

Postby J2Kbr » Thu Aug 01, 2019 11:17 am

Nice, thank you for sharing. If you haven't yet, please also consider publish your script on Gtuner IV Online Resources. :smile0517:
ConsoleTuner Support Team
User avatar
J2Kbr
General of the Army
General of the Army
 
Posts: 20323
Joined: Tue Mar 18, 2014 1:39 pm

Re: Joystick Curves made easy

Postby thedude » Thu Aug 01, 2019 7:52 pm

It is published as a function in my recent contribution:
https://www.consoletuner.com/greslib/?0&F&0&1&&dmlycGls

Changed the curve to use multiplication, because the power function takes so much more cpu time.

Code: Select all
 
void Curves (uint8 axis)
{
    // power works and can be used for different curves, but it is slow
    //fix32 R = pow(abs(get_val(axis)), 2.0) / 100.0;
 
    // multiplication is about 18 times faster, great if using power of 2.
    fix32 axisval = get_actual(axis);
    fix32 R = axisval * axisval / 100.0;
    if(axisval < 00.00 ) R = -R;
    set_val(axis, R);   
}
 
User avatar
thedude
Staff Sergeant
Staff Sergeant
 
Posts: 12
Joined: Wed Apr 10, 2019 8:09 pm

Re: Joystick Curves made easy

Postby J2Kbr » Wed Aug 07, 2019 11:54 am

Awesome, thank you.
ConsoleTuner Support Team
User avatar
J2Kbr
General of the Army
General of the Army
 
Posts: 20323
Joined: Tue Mar 18, 2014 1:39 pm

Re: Joystick Curves made easy

Postby teddy18 » Tue Nov 10, 2020 12:21 am

What's does do this script
User avatar
teddy18
Lieutenant
Lieutenant
 
Posts: 346
Joined: Sun Jul 19, 2015 4:18 pm

Re: Joystick Curves made easy

Postby J2Kbr » Tue Nov 10, 2020 9:43 am

It applies an exponential transformation, making the movements near the center position less sensitive and near the edges more sensitive.
ConsoleTuner Support Team
User avatar
J2Kbr
General of the Army
General of the Army
 
Posts: 20323
Joined: Tue Mar 18, 2014 1:39 pm


Return to GPC2 Script Programming

Who is online

Users browsing this forum: A pile of bricks and 198 guests