Help to convert this script from T1>T2 (solved)

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

Help to convert this script from T1>T2 (solved)

Postby Psebcool » Thu Sep 13, 2018 5:30 pm

Hi,

I bought T2 and just received it.

I use until now this script with T1 for Xbox controllers to PS4:


Code: Select all
int authcount;
int NOTIFY=2; // 1=30secs ; 2=1min ; 3=1m30secs and so on up to 16.
 
main {  // PS4 Cross Over Gaming Section
    if(get_console()==PIO_PS4  && get_controller()!=PIO_PS4){
        authcount=ps4_authtimeout();
//--------------------------------------------------       
        swap(1,27);                                 // Swap "View/Share" with "Touchpad Press".
//--------------------------------------------------       
        if(get_val(8) && get_val(27)){              // Hold Left-Stick "LS/L3" and press "View/Share" to activate Share.
            set_val(27,0);
            set_val(1,100);
        }
//--------------------------------------------------     
        if(get_val(8) && get_val(6)){               // Hold Left-Stick "LS/L3" and press "LB/L1" to press Left Touchpad.
            set_val(6,0);
            ps4_set_touchpad(-90, 0);
            set_val(27,100);
        }
 
        if(get_val(8) && get_val(3)){               // Hold Left-Stick "LS/L3" and press "RB/R1" to press Right Touchpad.
            set_val(3,0);
            ps4_set_touchpad(90, 0);
            set_val(27,100);
        }
 
        if(get_val(8) && get_val(5)){               // Hold Left-Stick "LS/L3" and press "RS/R3" to press Touchpad.
            set_val(5,0);
            set_val(27,100);
        }
 
        if(get_val(8)){                             // Hold Left-Stick "LS/L3" to use Right-Stick Axis (RX & RY) for Swipe Touchpad.
 
            if(abs(get_val(10)) > 20 || abs(get_val(9)) > 20){
                ps4_set_touchpad(get_val(9), get_val(10));
            }
        set_val(10, 0);
        set_val(9, 0);
        }
//--------------------------------------------------           
        if(get_val(8)){                             // Hold Left-Stick "LS/L3" and Press "Menu/Options" to reset Auth Timeout.
            if(event_press(2)){
                output_reconnection();
            }
            set_val(2,0);
        }
        if(authcount <=NOTIFY+1){
            combo_run(notify);
        }
    }   
}       // PS4 Cross Over Gaming Section End
 
combo notify{
    set_rumble(RUMBLE_A,100);
    set_rumble(RUMBLE_B,100);
    wait(150);
    reset_rumble();
    wait(250*authcount);
 
}


I would like to continue using this (awesome) script with T2, keeping the same functions with the same combos, however without the combo notify timeout (for re-authentification) that has become useless with the T2.

Can someone help me please ? Thank you very much :smile0517:
Last edited by Psebcool on Wed Sep 19, 2018 2:50 pm, edited 4 times in total.
Psebcool
Sergeant Major
Sergeant Major
 
Posts: 73
Joined: Mon Jun 22, 2015 7:41 pm

Re: Help to convert this script from T1 to T2

Postby J2Kbr » Fri Sep 14, 2018 9:35 am

The Titan Two has back compatibility with scripts from Titan One. Just include the titanone.gph header file at the very beginning of the code:
Code: Select all
#include <titanone.gph>
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: Help to convert this script from T1 to T2

Postby Psebcool » Fri Sep 14, 2018 12:45 pm

J2Kbr wrote:The Titan Two has back compatibility with scripts from Titan One. Just include the titanone.gph header file at the very beginning of the code:
Code: Select all
#include <titanone.gph>


Ty, I will try this evening :smile0517:
Psebcool
Sergeant Major
Sergeant Major
 
Posts: 73
Joined: Mon Jun 22, 2015 7:41 pm

Re: Help to convert this script from T1 to T2

Postby Psebcool » Mon Sep 17, 2018 1:46 pm

Okay, I tried and seems not works :/

Here my "converted" script:
Code: Select all
#pragma METAINFO("<author_name>", 1, 0, "")
 
#include <titanone.gph>
 
 
main {  // PS4 Cross Over Gaming Section
 
    if(get_console()==PIO_PS4  && get_controller()!=PIO_PS4){
 
//--------------------------------------------------       
        swap(1,27);                                 // Swap "View/Share" with "Touchpad Press".
//--------------------------------------------------       
        if(get_val(8) && get_val(27)){              // Hold Left-Stick "LS/L3" and press "View/Share" to activate Share.
            set_val(27,0);
            set_val(1,100);
        }
//--------------------------------------------------     
        if(get_val(8) && get_val(6)){               // Hold Left-Stick "LS/L3" and press "LB/L1" to press Left Touchpad.
            set_val(6,0);
            ps4_set_touchpad(-90, 0);
            set_val(27,100);
        }
 
        if(get_val(8) && get_val(3)){               // Hold Left-Stick "LS/L3" and press "RB/R1" to press Right Touchpad.
            set_val(3,0);
            ps4_set_touchpad(90, 0);
            set_val(27,100);
        }
 
        if(get_val(8) && get_val(5)){               // Hold Left-Stick "LS/L3" and press "RS/R3" to press Touchpad.
            set_val(5,0);
            set_val(27,100);
        }
 
        if(get_val(8)){                             // Hold Left-Stick "LS/L3" to use Right-Stick Axis (RX & RY) for Swipe Touchpad.
 
            if(abs(get_val(10)) > 20 || abs(get_val(9)) > 20){
                ps4_set_touchpad(get_val(9), get_val(10));
            }
        set_val(10, 0);
        set_val(9, 0);
        }
 
//--------------------------------------------------       
    }   
}       // PS4 Cross Over Gaming Section End
 


I use this table for API identifiers (buttons) in this script.

But even with "#include <titanone.gph>" header, the script seems not working. Example, when I tried to use combo LS + L1 (to get Left Touchpad function), the script open me the Share window.

Works like a charm with T1 but not with T2.

Have I placed the "titanone.gph" header correctly ?
Psebcool
Sergeant Major
Sergeant Major
 
Posts: 73
Joined: Mon Jun 22, 2015 7:41 pm

Re: Help to convert this script from T1 to T2 (update reques

Postby J2Kbr » Mon Sep 17, 2018 3:50 pm

You did correctly, I have not noticed the I/O functions were using numeric value. To fix please replace with the GPC designators based on the table you linked, for example:
Code: Select all
get_val(8)
to
Code: Select all
get_val(PS4_L3)

this must be done to all get_val() and set_val().
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: Help to convert this script from T1 to T2 (update reques

Postby Psebcool » Mon Sep 17, 2018 5:55 pm

Thanks, it works !

I had to replace this:
Code: Select all
swap(1,27)

to
Code: Select all
        if(get_val(PS4_SHARE)) {
            set_val(PS4_SHARE, 0);
            set_val(PS4_TOUCH, 100);
        }


All is fine now. :smile0517:
Psebcool
Sergeant Major
Sergeant Major
 
Posts: 73
Joined: Mon Jun 22, 2015 7:41 pm

Re: Help to convert this script from T1 to T2 (update reques

Postby J2Kbr » Mon Sep 17, 2018 6:46 pm

Awesome!! :)
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: Help to convert this script from T1 to T2 (update reques

Postby Psebcool » Tue Sep 18, 2018 7:03 pm

New problem Houston !

The script with "#include <titanone.gph>" header seems not works with Xbox reicever on T2 (I want to use my controller wirelessly).

:cry:

I guess unfortunately It need to be a native T2 script for the use of wireless receiver ?

Ideally, it would be to convert this script that I "shortened":

Code: Select all
#pragma METAINFO("T2", 1, 0, "PS4 Crossover Gaming Script T2 v12bis Light Edition")
 
#include <titanone.gph>
 
 
main {  // PS4 Cross Over Gaming Section
 
    if(get_console()==PIO_PS4  && get_controller()!=PIO_PS4){
 
//--------------------------------------------------       
        if(get_val(PS4_SHARE)) {                                                // Swap "View/Share" with "Touchpad Press".
            set_val(PS4_SHARE, 0);
            set_val(PS4_TOUCH, 100);
        }
//--------------------------------------------------       
        if(get_val(PS4_L3) && get_val(PS4_TOUCH)){                              // Hold Left-Stick "LS/L3" and press "View/Share" to activate Share.
            set_val(PS4_TOUCH,0);
            set_val(PS4_SHARE,100);
        }
//--------------------------------------------------             
        if(get_val(PS4_L3) && get_val(PS4_R3)){                                   // Hold Left-Stick "LS/L3" and press "RS/R3" to press Touchpad.
            set_val(PS4_R3,0);
            set_val(PS4_TOUCH,100);
        }
 
        if(get_val(PS4_L3)){                                                     // Hold Left-Stick "LS/L3" to use Right-Stick Axis (RX & RY) for Swipe Touchpad.
 
            if(abs(get_val(PS4_RY)) > 20 || abs(get_val(PS4_RX)) > 20){
                ps4_set_touchpad(get_val(PS4_RX), get_val(PS4_RY));
            }
        set_val(PS4_RY, 0);
        set_val(PS4_RX, 0);
        }
 
//--------------------------------------------------       
    }   
}       // PS4 Cross Over Gaming Section End
 
Psebcool
Sergeant Major
Sergeant Major
 
Posts: 73
Joined: Mon Jun 22, 2015 7:41 pm

Re: Help to convert this script from T1>T2 (new update reque

Postby J2Kbr » Wed Sep 19, 2018 10:48 am

The best is indeed have the script in native Titan Two code. Please also not the share <-> touch swap is not needed with the Titan Two as this is the default mapping. Give a try:
Code: Select all
#pragma METAINFO("PS4 Crossover Gaming Script T2 v12bis Light Edition", 1, 0, "Psebcool ")
 
#include <xb1.gph>
#include <ps4.gph>
 
main {
    // Hold Left-Stick "LS/L3" and press "View/Share" to activate Share.
    if(get_val(XB1_LS) && get_val(XB1_VIEW)) {
        set_val(XB1_VIEW, 0.0);
        set_val(PS4_SHARE, 100.0);
    }
 
    // Hold Left-Stick "LS/L3" and press "RS/R3" to press Touchpad.
    if(get_val(XB1_LS) && get_val(XB1_RS)) {
        set_val(XB1_RS, 0.0);
        set_val(PS4_TOUCH, 100.0);
    }
 
    // Hold Left-Stick "LS/L3" to use Right-Stick Axis (RX & RY) for Swipe Touchpad.
    if(get_val(XB1_LS)) {
        if(is_active(XB1_RY) || is_active(XB1_RX)) {
            set_val(PS4_TOUCH1, 100.0);
            set_val(PS4_TOUCH1X, get_val(XB1_RX));
            set_val(PS4_TOUCH1Y, get_val(XB1_RY));
        }
        set_val(XB1_RY, 0.0);
        set_val(XB1_RX, 0.0);
    }
}
 
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: Help to convert this script from T1>T2 (new update reque

Postby Psebcool » Wed Sep 19, 2018 2:26 pm

Awesome,

All works wirelessy now !

Thank you so much ;)
Psebcool
Sergeant Major
Sergeant Major
 
Posts: 73
Joined: Mon Jun 22, 2015 7:41 pm


Return to GPC2 Script Programming

Who is online

Users browsing this forum: No registered users and 56 guests