Analog Stick Toggle w/ button press

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

Analog Stick Toggle w/ button press

Postby Migs » Sun Jun 09, 2019 2:50 am

Hey guys,

I've just build an analog arcade stick and its working great with the Titan Two.

But I'm looking to add some functionality by having one of my buttons toggle the stick being used.

Example:

The Button is Button_15.

I want to hit and hold Button_15 and have that change my stick from the left stick to the right stick while I'm holding that button. Once Button_15 is released its back to being the left stick.

Any help would be super appreciated!
User avatar
Migs
Corporal
Corporal
 
Posts: 4
Joined: Sun Jun 09, 2019 2:45 am

Re: Analog Stick Toggle w/ button press

Postby Mad » Sun Jun 09, 2019 3:18 am

Give this a go

Code: Select all
main {
    if(event_active(BUTTON_15)) {
        remapper_swap(STICK_1_X, STICK_2_X);
        remapper_swap(STICK_1_Y, STICK_2_Y);
    }
    else if(event_release(BUTTON_15)) { remapper_reset(); }
}
ConsoleTuner Support Team || ConsoleTuner Discord || InputSense Discord (2K / FPS)
Mad
Major General
Major General
 
Posts: 4532
Joined: Wed May 22, 2019 5:39 am

Re: Analog Stick Toggle w/ button press

Postby J2Kbr » Sun Jun 09, 2019 11:08 am

Thank you Mad for helping here. Appreciated.
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: Analog Stick Toggle w/ button press

Postby Mad » Sun Jun 09, 2019 11:22 am

You're welcome. Thanks for the new role :smile0517:
ConsoleTuner Support Team || ConsoleTuner Discord || InputSense Discord (2K / FPS)
Mad
Major General
Major General
 
Posts: 4532
Joined: Wed May 22, 2019 5:39 am

Re: Analog Stick Toggle w/ button press

Postby Migs » Sun Jun 09, 2019 3:20 pm

Thanks so much for your help on this Mad, the script works great!

The one problem I'm encountering is having it work with my input translator settings. If I load the GPC Script by itself into a memory slot it works, but stacking it in another memory slot with my input translator settings it wont work.

Thanks again for your help, I appreciate your time.
User avatar
Migs
Corporal
Corporal
 
Posts: 4
Joined: Sun Jun 09, 2019 2:45 am

Re: Analog Stick Toggle w/ button press

Postby Scachi » Sun Jun 09, 2019 4:07 pm

Try this:

Code: Select all
main {
    if(get_actual(BUTTON_15)) {
            set_val(STICK_1_X,get_actual(STICK_2_X));
            set_val(STICK_1_Y,get_actual(STICK_2_Y));
 
            set_val(STICK_2_X,get_actual(STICK_1_X));
            set_val(STICK_2_Y,get_actual(STICK_1_Y));
    }
}
 
User avatar
Scachi
Brigadier General
Brigadier General
 
Posts: 3044
Joined: Wed May 11, 2016 6:25 am
Location: Germany

Re: Analog Stick Toggle w/ button press

Postby Migs » Sun Jun 09, 2019 4:20 pm

Thanks Scachi, unfortunately this doesn't seem to work.

The new mapping with Input Translator for the button is Button_21.

Thanks for all the help on this guys!
User avatar
Migs
Corporal
Corporal
 
Posts: 4
Joined: Sun Jun 09, 2019 2:45 am

Re: Analog Stick Toggle w/ button press

Postby Scachi » Sun Jun 09, 2019 4:42 pm

Normal buttons:
BUTTON_15 PS4:"Circle", XB:"B"
BUTTON_16 PS4:"Cross", XB:"A"

When you have a mapping done via the input translator it will still work.
Example, Input Translator that maps : BUTTON_15 <-> BUTTON_16
Having this Input Translator active...
you press PS4:CROSS button, but the Titan Two will now read it as button PS4:CIRCLE
result: you now have to hold button CROSS to have the sticks swapping active.

If you need this on a different button number change BUTTON_15 in the code I have posted to your button you want to use stick swap for.
Hit F1 in GTuner IV and take a look at the GPC Input Reference.
User avatar
Scachi
Brigadier General
Brigadier General
 
Posts: 3044
Joined: Wed May 11, 2016 6:25 am
Location: Germany

Re: Analog Stick Toggle w/ button press

Postby Migs » Sun Jun 09, 2019 5:42 pm

i rewrote your scripts like this:
Code: Select all
 
main {
    if(get_actual(BUTTON_21)) {
            set_val(STICK_1_X,get_actual(STICK_2_X));
            set_val(STICK_1_Y,get_actual(STICK_2_Y));
 
            set_val(STICK_2_X,get_actual(STICK_1_X));
            set_val(STICK_2_Y,get_actual(STICK_1_Y));
    }
}



and it's working!

Thanks for all the help on this from all you guys.

This project has come together quite nicely.
User avatar
Migs
Corporal
Corporal
 
Posts: 4
Joined: Sun Jun 09, 2019 2:45 am


Return to GPC2 Script Programming

Who is online

Users browsing this forum: No registered users and 127 guests

cron