Buttons combinations

GPC script programming for Titan Two device. Code examples, how to, questions, requests.

Moderators: The_Rabid_Taco, pablosscripts, bonefisher

Buttons combinations

Postby Kakyo » Tue Oct 08, 2019 8:37 am

Hi!!

I try to make a script (my first script :whistling: ) for a simple combination
I want to make a combination of DS4 (Square + Circle) when i press the button 14 on my X52 pro
I want that the button 14 on my x52 pro don't have any key assignement of the DS4
Code: Select all
#pragma METAINFO("combination", 1, 0, "<author_name>")
#include <ps4.gph>
 
main {
 
    if(get_actual(BUTTON_14)) {
        set_val(PS4_CIRCLE, 100);
        set_val(PS4_SQUARE, 100);
    }
}

but when I press the button 14 of my x52 pro combination is done on the x52 pro and not on the DS4

gtuner.png
gtuner.png (188.02 KiB) Viewed 129 times

what's is wrong? :cry:

how to tell the difference between the buttons of the x52 pro and the ds4?

Thanks a lot!!
User avatar
Kakyo
Sergeant
Sergeant
 
Posts: 8
Joined: Mon Oct 07, 2019 3:43 pm

Re: Buttons combinations

Postby Scachi » Tue Oct 08, 2019 9:29 am

but when I press the button 14 of my x52 pro combination is done on the x52 pro and not on the DS4

Not sure if I understand that correctly or how you can tell the difference...the combination is done on the output of the T2.
The T2 can't tell where the button pressed is coming from at the moment. There are some feature requests to add an option to check where the input where the button pressed is send from, but it is not implemented yet.

You can use an input translator as a work around. The input translator can be assigned to a specific input port only.
So create one that uses the checkbox where your x52 is connected to, uncheck the other ones.
Use the input translator to map your x52 button 14 to some input that the ds4 and x52 isn't using. Accel_2_X could work.

The result is when you press button_14 on your x52 the output will be on Accel_2_X
Now check Accel_2_X in your code instead of button_14
Code: Select all
main {
    if(get_actual(ACCEL_2_X)) {
        set_val(BUTTON_15, 100); // ps4 circle
        set_val(BUTTON_17, 100); // ps4 square
    }
}
 
User avatar
Scachi
Brigadier General
Brigadier General
 
Posts: 2239
Joined: Wed May 11, 2016 6:25 am
Location: Germany

Re: Buttons combinations

Postby Kakyo » Tue Oct 08, 2019 1:22 pm

Accel_2_X stay always press. I don’t know why....

there is no solution or script so that when I press button 14 of my x52 pro the combination of square and circle is done on the ds4?

Thx a lot
User avatar
Kakyo
Sergeant
Sergeant
 
Posts: 8
Joined: Mon Oct 07, 2019 3:43 pm

Re: Buttons combinations

Postby Scachi » Tue Oct 08, 2019 3:13 pm

Kakyo wrote:Hi!!
...
but when I press the button 14 of my x52 pro combination is done on the x52 pro and not on the DS4

Why do you think that button combination it is done on the x52pro ?
Take a look at your screenshot again.
The left side is the input side. The right side is the output side. The Output side is what gets send to the console.
Your screenshot shows that you are only pressing BUTTON_14 (left side) on one of your devices connected to the Titan Two "Input-A" or "Input-B" ports and that the output (right side) is button_14+button_15+button_17.

So it is working correctly.
What is the result you are expecting ?
User avatar
Scachi
Brigadier General
Brigadier General
 
Posts: 2239
Joined: Wed May 11, 2016 6:25 am
Location: Germany

Re: Buttons combinations

Postby Kakyo » Tue Oct 08, 2019 6:43 pm

Ha ok... i don't see this like that :whistling:
Do you know how to delete in the output the button_14 for only have button_15+button_17?
By putting a tempo?

Thx u very much!!
User avatar
Kakyo
Sergeant
Sergeant
 
Posts: 8
Joined: Mon Oct 07, 2019 3:43 pm

Re: Buttons combinations

Postby Scachi » Tue Oct 08, 2019 7:15 pm

For your script you can do it like this, but this will stop the normal button_14 from getting pressed then:
Code: Select all
 
#include <ps4.gph>
main {
    if(get_actual(BUTTON_14)) {
            set_val(BUTTON_14, 0);
            set_val(PS4_CIRCLE, 100);
            set_val(PS4_SQUARE, 100);
    }
}
 


What you can do is change it so a double tap will press both buttons and a normal tap presses button_14 or the other way around. A fast double tap of button_14 with keeping it pressed after the second tap will let the script press both buttons:
Code: Select all
 
#include <ps4.gph>
#define TAPTIME    100
 
bool doubleTap=FALSE;
 
main {
    if (event_active(BUTTON_14) && time_release(BUTTON_14)<TAPTIME) doubleTap=TRUE;
    if (event_release(BUTTON_14)) doubleTap=FALSE;
    inhibit(BUTTON_14,TAPTIME);
 
    if(get_actual(BUTTON_14) && doubleTap) {
            set_val(BUTTON_14, 0);
            set_val(PS4_CIRCLE, 100);
            set_val(PS4_SQUARE, 100);
    }
}
 


Does your x52 pro joystick support mapping of buttons to key presses and does it store this information in the memory of the stick so it doesn't require pc software for the mapping to work ?

This would allow you to use this script. Requires a button mapped to keypress T in your joysticks memory:
Code: Select all
#include <ps4.gph>
#include <keyboard.gph>
 
main {
    if (key_status(KEY_T)) {
        set_val(PS4_CIRCLE, 100);
        set_val(PS4_SQUARE, 100);
    }
}
 
User avatar
Scachi
Brigadier General
Brigadier General
 
Posts: 2239
Joined: Wed May 11, 2016 6:25 am
Location: Germany

Re: Buttons combinations

Postby Kakyo » Tue Oct 08, 2019 8:48 pm

I think it’s not possible. The X52 pro don’t have internal memory....

Thx very much you save my mind
User avatar
Kakyo
Sergeant
Sergeant
 
Posts: 8
Joined: Mon Oct 07, 2019 3:43 pm

Re: Buttons combinations

Postby Kakyo » Wed Oct 09, 2019 7:34 am

the script work perfectly!

Thank you!!!
User avatar
Kakyo
Sergeant
Sergeant
 
Posts: 8
Joined: Mon Oct 07, 2019 3:43 pm

Re: Buttons combinations

Postby Scachi » Wed Oct 09, 2019 8:40 am

You can try this version. It allows a short single tap of button_14 to work..the previous script didn't allow that:
Code: Select all
#include <ps4.gph>
#define TAPTIME    100
 
bool doubleTap=FALSE;
uint32 holdTime;
 
main {
    if (event_release(BUTTON_14)) {
        holdTime=time_active(BUTTON_14);
        if (holdTime < TAPTIME) combo_run(cTap);
        doubleTap=FALSE;
    }
 
    if (event_active(BUTTON_14) && time_release(BUTTON_14)<TAPTIME) {
        combo_stop(cTap);
        doubleTap=TRUE;
    }
    inhibit(BUTTON_14,TAPTIME);
 
    if(get_actual(BUTTON_14) && doubleTap) {
            set_val(BUTTON_14, 0);
            set_val(PS4_CIRCLE, 100);
            set_val(PS4_SQUARE, 100);
    }
}
 
combo cTap {
    wait(TAPTIME);
    set_val(BUTTON_14,100);
    wait(holdTime);
}
 
User avatar
Scachi
Brigadier General
Brigadier General
 
Posts: 2239
Joined: Wed May 11, 2016 6:25 am
Location: Germany


Return to GPC Script Programming (Titan Two)

Who is online

Users browsing this forum: No registered users and 5 guests