Trigger to analog stick remap for driving games

GPC1 script programming for Titan One. Code examples, questions, requests.

Trigger to analog stick remap for driving games

Postby berumsey » Fri Jun 13, 2014 10:14 pm

I need to map ps4 controller r2 to left stick y axis 0 - -100 and l2 to left stick y axis 0 - 100. In other words, left analog up is throttle and left analog down is brake. Any ideas for scripting? Also could use a ~10 deadband.
User avatar
berumsey
Corporal
Corporal
 
Posts: 4
Joined: Fri Jun 13, 2014 8:33 pm

Re: Trigger to analog stick remap for driving games

Postby CypherNova139 » Sat Jun 14, 2014 8:21 pm

Easy enough, you'd want to set up in the main, if LY is greater than 20 (deadzone) then press R2, otherwise press L2 etc.

Here's a section from my sixaxis remapper script that you should find useful, with a few tweaks it will work for you. ;)
(I'm sure you can figure out the rest).


Code: Select all
 if(get_val(PS3_LY) > 20) {
        //down
        set_val(PS3_ACCY, get_val(StickY));
        set_val(PS3_LY, 0);
    } else {
        set_val(PS3_ACCY, get_val(StickY));
        set_val(PS3_LY, 0);
    }
User avatar
CypherNova139
Staff Sergeant
Staff Sergeant
 
Posts: 13
Joined: Sat May 10, 2014 5:11 am

Re: Trigger to analog stick remap for driving games

Postby berumsey » Sun Jun 15, 2014 4:00 am

Thank you for the tip!

My script is:
Code: Select all
unmap PS4_RX;
unmap PS4_RY;
remap PS4_RX -> PS4_LX;
remap PS4_RY -> PS4_LY;
unmap PS4_ACCX;
unmap PS4_ACCY;
unmap PS4_ACCZ;


main {
//up
     if(get_val(PS4_LY) > -10) {
            set_val(PS4_R2, 0);
        } else {
            set_val(PS4_R2, inv(get_val(PS4_LY)));
        }
//down
     if(get_val(PS4_LY) < 10) {
            set_val(PS4_L2, 0);
        } else {
            set_val(PS4_L2, get_val(PS4_LY));
        }

}


Works great!
User avatar
berumsey
Corporal
Corporal
 
Posts: 4
Joined: Fri Jun 13, 2014 8:33 pm

Re: Trigger to analog stick remap for driving games

Postby CypherNova139 » Mon Jun 16, 2014 11:34 pm

Nice! Glad to see ya figured out how to get it to work! But what is all the remap codes for?

Btw, You got me curious enough that I redid my sixaxis script after posting my first post on this thread, you might try this out too. Its a bit more complex but you can switch which stick is remapped on the fly.
User avatar
CypherNova139
Staff Sergeant
Staff Sergeant
 
Posts: 13
Joined: Sat May 10, 2014 5:11 am

Re: Trigger to analog stick remap for driving games

Postby berumsey » Thu Jun 19, 2014 8:18 pm

Had to remap the controller right stick to work the left stick output. Not only does it give me steering on right stick in nfs rivals, but menu control since the left stick y axis is now R2-L2 "gas and brake". The unmap rx and ry makes it so right stick movement doesn't output both sticks. The acc* unmaps make it ignore gyroscope input, which I would assume makes the cpu load on the cm lower and therefore run "probably imperceptibly" cooler. Make sense?
User avatar
berumsey
Corporal
Corporal
 
Posts: 4
Joined: Fri Jun 13, 2014 8:33 pm

Re: Trigger to analog stick remap for driving games

Postby CypherNova139 » Sat Jun 21, 2014 1:47 am

Ah, didn't know you were using the right stick as well, makes sense now.

FYI:
Just tested in Device Monitor the CPU load of no scripts running, and a script with JUST the sixaxis unmaps. Both kept CPU load at 9%, no perceptible difference.

But I tested the same with your script, running it, then commenting out the unmaps, then running it again..
Without the comments (aka sixaxis disabled) I got the CPU load to randomly pop to 9% instead of the usual 10%. Commented version stayed at 10%.

As far as my scripts, they average 11-15%, going to 20% occasionally if you are running the customization features. After using those scripts the CM produces about as much heat as I'd expect from a little dongle with a CPU inside. So its up to you whether you believe there is a heat difference or not from CPU load.
User avatar
CypherNova139
Staff Sergeant
Staff Sergeant
 
Posts: 13
Joined: Sat May 10, 2014 5:11 am

Re: Trigger to analog stick remap for driving games

Postby marioxb » Mon Sep 30, 2024 3:55 pm

Is anyone able to do the reverse? I want the L2 and R2 buttons to function as the left (or right) analog stick. L2 being down and R2 being up, while retaining full analog functionality. My goal is to be able to have analog pedals for Nintendo Switch games and this is the only way to do so (Logictech USB steering wheel).
User avatar
marioxb
Corporal
Corporal
 
Posts: 4
Joined: Wed Feb 28, 2024 6:30 pm


Return to GPC1 Script Programming

Who is online

Users browsing this forum: No registered users and 28 guests