Help for continuous rumble (T1 code converted)

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

Help for continuous rumble (T1 code converted)

Postby ubermatress » Sat Aug 17, 2019 2:46 pm

I have a toggle in my code to swap Triangle and Circle after another R1 is pressed. I have rumbles to mark the toggle - a short rumble for toggle on and a double short rumble for toggle off.
The following code works fine on the Titan One but it starts rumbling continuously when converted for the Titan Two.
Code: Select all
 
#include <titanone.gph>
#include <ps4.gph>
#include <ps3.gph>
 
//variables
int toggle = FALSE;
int released = TRUE;
 
main {
//toggle mode
    //on
    if(toggle == FALSE && released == TRUE && get_val(PS3_R1)) {
        released = FALSE;
        toggle = TRUE;
        combo_run(onvibrate);
    }
    //off
    if(toggle == TRUE && released == TRUE && get_val(PS3_R1)) {
        released = FALSE;
        toggle = FALSE;
        combo_run(offvibrate);
    }
    //release
    if(event_release(PS3_R1)) {
        released = TRUE;
    }
    //mode
    if(toggle == TRUE){
        swap(PS3_CIRCLE,PS3_TRIANGLE);
    }
}
 
combo onvibrate {
    set_rumble(RUMBLE_B, 100);
    wait(100);
    set_rumble(RUMBLE_B, 0);
}
 
combo offvibrate {
    set_rumble(RUMBLE_B, 100);
    wait(100);
    set_rumble(RUMBLE_B, 0);
    wait(100);
    set_rumble(RUMBLE_B, 100);
    wait(100);
    set_rumble(RUMBLE_B, 0);
}
 


This is my first script for my Titan Two and my disability means that I can't play the game without this code working. Any help would be greatly appreciated. Thanks in advance.
User avatar
ubermatress
Sergeant First Class
Sergeant First Class
 
Posts: 19
Joined: Tue Nov 11, 2014 4:06 pm

Re: Help for continuous rumble (T1 code converted)

Postby Scachi » Sat Aug 17, 2019 3:15 pm

try with a wait(0); after each rumble you are setting.
the wait(0) will run the rumble command once and the next wait(100) will just wait.

the single one
Code: Select all
 
set_rumble(RUMBLE_B, 100); wait(0);
wait(100);
set_rumble(RUMBLE_B, 0);


and the other
Code: Select all
 
set_rumble(RUMBLE_B, 100); wait(0);
wait(100);
set_rumble(RUMBLE_B, 0); wait(0);
wait(100);
set_rumble(RUMBLE_B, 100); wait(0);
wait(100);
set_rumble(RUMBLE_B, 0); wait(0);
 


When setting rumbles via script the game has no access to the rumbles anymore until you call the function "reset_rumble();"
If the game shoul dbe able to rumble you may want to add this function to the end of each combo.

Here is your script written in pure gpc2/Titan Two (I hope it still works :wink: )
Code: Select all
#include <ps3.gph>
 
//variables
int toggle = FALSE;
int released = TRUE;
 
main {
//toggle mode
    //on
    if(toggle == FALSE && released == TRUE && get_val(PS3_R1)) {
        released = FALSE;
        toggle = TRUE;
        combo_run(onvibrate);
    }
    //off
    if(toggle == TRUE && released == TRUE && get_val(PS3_R1)) {
        released = FALSE;
        toggle = FALSE;
        combo_run(offvibrate);
    }
    //release
    if(event_release(PS3_R1)) {
        released = TRUE;
    }
    //mode
    if(toggle == TRUE){
        swap(PS3_CIRCLE,PS3_TRIANGLE);
    }
}
 
void swap(uint8 btn1, uint8 btn2) {
    set_val(btn1,get_actual(btn2));
    set_val(btn2,get_actual(btn1));
}
 
combo onvibrate {
    ffb_set(FFB_2, 100.0, 100);
    wait(0);wait(101);
    ffb_reset();
}
 
combo offvibrate {
    call(onvibrate);
    call(onvibrate);
}
 
User avatar
Scachi
Brigadier General
Brigadier General
 
Posts: 3044
Joined: Wed May 11, 2016 6:25 am
Location: Germany

Re: Help for continuous rumble (T1 code converted)

Postby ubermatress » Sat Aug 17, 2019 3:28 pm

Thank you so much! I'll give this a go.
User avatar
ubermatress
Sergeant First Class
Sergeant First Class
 
Posts: 19
Joined: Tue Nov 11, 2014 4:06 pm

Re: Help for continuous rumble (T1 code converted)

Postby ubermatress » Mon Aug 26, 2019 12:39 pm

Hello again,
I've only just had a chance to try this properly and, although the rumble now works properly, nothing else is working.
Code: Select all
 
#include <titanone.gph>
#include <ps4.gph>
#include <ps3.gph>
 
//remapping
remap PS3_TRIANGLE -> PS4_CIRCLE;
remap PS3_CIRCLE -> PS4_TRIANGLE;
 
//variables
int toggle = FALSE;
int released = TRUE;
 
main {
    //sensitivity
    sensitivity(PS3_RX, NOT_USE, 200);
    sensitivity(PS3_RY, NOT_USE, 200);
    sensitivity(PS3_LX, NOT_USE, 200);
    sensitivity(PS3_LY, NOT_USE, 200);
 
    //arrow buttons - hold circle then flick left thumbstick for arrow buttons
    if((get_val(PS3_CIRCLE) && get_ptime(PS3_CIRCLE) > 250)) {
        if((get_val(PS3_LY)) <= -25) {
            set_val(PS4_UP, 100);
        }
        if((get_val(PS3_LY)) >= 25) {
            set_val(PS3_DOWN, 100);
        }
        if((get_val(PS3_LX)) >= 25) {
            set_val(PS4_RIGHT, 100);
        }
        if((get_val(PS3_LX)) <= -25) {
             set_val(PS4_LEFT, 100);
        }
    }
 
    //menu1
    if(get_val(PS3_CROSS) && get_ptime(PS3_CROSS) > 3000) {
        set_val(PS3_SELECT,100);
    }
 
    //menu2
    if(get_val(PS3_CIRCLE) && get_ptime(PS3_CIRCLE) > 3000) {
        set_val(PS4_OPTIONS,100);
    }
 
    //crouch
    if(get_val(PS3_TRIANGLE)){
        set_val(PS4_R3,100);
    }
 
    //toggle mode
    //on
    if(toggle == FALSE && released == TRUE && get_val(PS3_R1)) {
        released = FALSE;
        toggle = TRUE;
        combo_run(onvibrate);
    }
    //off
    if(toggle == TRUE && released == TRUE && get_val(PS3_R1)) {
        released = FALSE;
        toggle = FALSE;
        combo_run(offvibrate);
    }
    //release
    if(event_release(PS3_R1)) {
        released = TRUE;
    }
    //mode
    if(toggle == TRUE){
        swap(PS3_CIRCLE,PS3_TRIANGLE);
        swap(PS3_CROSS,PS3_SQUARE);
    }
}
 
combo onvibrate {
    set_rumble(RUMBLE_B, 100);
    wait(0);
    wait(100);
    set_rumble(RUMBLE_B, 0);
    wait(0);
}
 
combo offvibrate {
    set_rumble(RUMBLE_B, 100);
    wait(0);
    wait(100);
    set_rumble(RUMBLE_B, 0);
    wait(0);
    wait(100);
    set_rumble(RUMBLE_B, 100);
    wait(0);
    wait(100);
    set_rumble(RUMBLE_B, 0);
    wait(0);
}
 

I hope you can follow all that. I think I may need to rewrite it for T2 rather than use the converter script but I'm not very good at that yet. Would you be very kind and help me convert it please? Hopefully I'll be able to learn from that so I don't have to ask again. Thanks.
User avatar
ubermatress
Sergeant First Class
Sergeant First Class
 
Posts: 19
Joined: Tue Nov 11, 2014 4:06 pm

Re: Help for continuous rumble (T1 code converted)

Postby Scachi » Mon Aug 26, 2019 12:58 pm

You have to stick to t1 or t2 code. using both may end up with some strange things happen in the script.

Keep only the #include <titanone.gph>
remove the other two include lines:
#include <ps3.gph>
#include <ps4.gph>

Having both may mess up the code as titanone.gph translates the buttons to other numbers than ps3 or ps4 does.
So try again with your code while using the titanone gph only.

Here it is with t2 code only:
Code: Select all
#include <ps4.gph>
#include <ps3.gph>
 
//variables
int toggle = FALSE;
int released = TRUE;
 
init {
    remapper_swap(PS3_TRIANGLE,PS4_CIRCLE); //remap PS3_TRIANGLE -> PS4_CIRCLE;
    remapper_swap(PS3_CIRCLE,PS4_TRIANGLE); //remap PS3_CIRCLE -> PS4_TRIANGLE;
}
 
main {
    //sensitivity
    sensitivity(PS3_RX, 2);
    sensitivity(PS3_RY, 2);
    sensitivity(PS3_LX, 2);
    sensitivity(PS3_LY, 2);
 
    //arrow buttons - hold circle then flick left thumbstick for arrow buttons
    if((get_val(PS3_CIRCLE) && time_active(PS3_CIRCLE) > 250)) {
        if((get_val(PS3_LY)) <= -25f) {
            set_val(PS4_UP, 100);
        }
        if((get_val(PS3_LY)) >= 25f) {
            set_val(PS3_DOWN, 100);
        }
        if((get_val(PS3_LX)) >= 25f) {
            set_val(PS4_RIGHT, 100);
        }
        if((get_val(PS3_LX)) <= -25f) {
             set_val(PS4_LEFT, 100);
        }
    }
 
    //menu1
    if(get_val(PS3_CROSS) && time_active(PS3_CROSS) > 3000) {
        set_val(PS3_SELECT,100);
    }
 
    //menu2
    if(get_val(PS3_CIRCLE) && time_active(PS3_CIRCLE) > 3000) {
        set_val(PS4_OPTIONS,100);
    }
 
    //crouch
    if(get_val(PS3_TRIANGLE)){
        set_val(PS4_R3,100);
    }
 
    //toggle mode
    //on
    if(toggle == FALSE && released == TRUE && get_val(PS3_R1)) {
        released = FALSE;
        toggle = TRUE;
        combo_run(onvibrate);
    }
    //off
    if(toggle == TRUE && released == TRUE && get_val(PS3_R1)) {
        released = FALSE;
        toggle = FALSE;
        combo_run(offvibrate);
    }
    //release
    if(event_release(PS3_R1)) {
        released = TRUE;
    }
    //mode
    if(toggle == TRUE){
        swap(PS3_CIRCLE,PS3_TRIANGLE);
        swap(PS3_CROSS,PS3_SQUARE);
    }
}
 
//  Adjust the sensitivity of a controller entry.
void sensitivity(uint8 input, int8 sens) {
    set_val(input, clamp(get_val(input) * (fix32)sens, -100.0, 100.0));
}
 
// Swap the values between two controller entries.
void swap(uint8 a, uint8 b) {
    set_val(a,get_actual(b));
    set_val(b,get_actual(a));
}
 
combo onvibrate {
    ffb_set(FFB_2, 100.0, 100); wait(0); // set rumble for 100ms once
    wait(100);            // wait for vibrate on to complete
    wait(100);              // wait while vibrate off
    ffb_reset();        // allow game to control rumbles again
}
 
 
combo offvibrate {
    call(onvibrate); // first rumble
    call(onvibrate); // second rumble
}
 
Last edited by Scachi on Mon Aug 26, 2019 2:43 pm, edited 1 time in total.
User avatar
Scachi
Brigadier General
Brigadier General
 
Posts: 3044
Joined: Wed May 11, 2016 6:25 am
Location: Germany

Re: Help for continuous rumble (T1 code converted)

Postby ubermatress » Mon Aug 26, 2019 2:37 pm

Thanks a lot. That all works fine except the sensitivity is now too high. I guess I'll just have to experiment with different values. It doesn't seem to be a percentage, is it a multiple or what? I'm struggling to understand what the value means.
User avatar
ubermatress
Sergeant First Class
Sergeant First Class
 
Posts: 19
Joined: Tue Nov 11, 2014 4:06 pm

Re: Help for continuous rumble (T1 code converted)

Postby Scachi » Mon Aug 26, 2019 2:43 pm

ubermatress wrote:Thanks a lot. That all works fine except the sensitivity is now too high. I guess I'll just have to experiment with different values. It doesn't seem to be a percentage, is it a multiple or what? I'm struggling to understand what the value means.

Oh, yes. I am sorry. It uses the value as a multiplier. Use "2" instead of "200" please.

Here. This script version allows to use decimals like "1.5" for 150% or "0.5" for 50% :
Code: Select all
#include <ps4.gph>
#include <ps3.gph>
 
//variables
int toggle = FALSE;
int released = TRUE;
 
init {
    remapper_swap(PS3_TRIANGLE,PS4_CIRCLE); //remap PS3_TRIANGLE -> PS4_CIRCLE;
    remapper_swap(PS3_CIRCLE,PS4_TRIANGLE); //remap PS3_CIRCLE -> PS4_TRIANGLE;
}
 
main {
    //sensitivity
    sensitivity(PS3_RX, 2.0);
    sensitivity(PS3_RY, 2.0);
    sensitivity(PS3_LX, 2.0);
    sensitivity(PS3_LY, 2.0);
 
    //arrow buttons - hold circle then flick left thumbstick for arrow buttons
    if((get_val(PS3_CIRCLE) && time_active(PS3_CIRCLE) > 250)) {
        if((get_val(PS3_LY)) <= -25f) {
            set_val(PS4_UP, 100);
        }
        if((get_val(PS3_LY)) >= 25f) {
            set_val(PS3_DOWN, 100);
        }
        if((get_val(PS3_LX)) >= 25f) {
            set_val(PS4_RIGHT, 100);
        }
        if((get_val(PS3_LX)) <= -25f) {
             set_val(PS4_LEFT, 100);
        }
    }
 
    //menu1
    if(get_val(PS3_CROSS) && time_active(PS3_CROSS) > 3000) {
        set_val(PS3_SELECT,100);
    }
 
    //menu2
    if(get_val(PS3_CIRCLE) && time_active(PS3_CIRCLE) > 3000) {
        set_val(PS4_OPTIONS,100);
    }
 
    //crouch
    if(get_val(PS3_TRIANGLE)){
        set_val(PS4_R3,100);
    }
 
    //toggle mode
    //on
    if(toggle == FALSE && released == TRUE && get_val(PS3_R1)) {
        released = FALSE;
        toggle = TRUE;
        combo_run(onvibrate);
    }
    //off
    if(toggle == TRUE && released == TRUE && get_val(PS3_R1)) {
        released = FALSE;
        toggle = FALSE;
        combo_run(offvibrate);
    }
    //release
    if(event_release(PS3_R1)) {
        released = TRUE;
    }
    //mode
    if(toggle == TRUE){
        swap(PS3_CIRCLE,PS3_TRIANGLE);
        swap(PS3_CROSS,PS3_SQUARE);
    }
}
 
//  Adjust the sensitivity of a controller entry.
void sensitivity(uint8 input, fix32 sens) {
    set_val(input, clamp(get_val(input) * sens, -100.0, 100.0));
}
 
// Swap the values between two controller entries.
void swap(uint8 a, uint8 b) {
    set_val(a,get_actual(b));
    set_val(b,get_actual(a));
}
 
combo onvibrate {
    ffb_set(FFB_2, 100.0, 100); wait(0); // set rumble for 100ms once
    wait(100);            // wait for vibrate on to complete
    wait(100);              // wait while vibrate off
    ffb_reset();        // allow game to control rumbles again
}
 
 
combo offvibrate {
    call(onvibrate); // first rumble
    call(onvibrate); // second rumble
}
 
User avatar
Scachi
Brigadier General
Brigadier General
 
Posts: 3044
Joined: Wed May 11, 2016 6:25 am
Location: Germany

Re: Help for continuous rumble (T1 code converted)

Postby ubermatress » Mon Aug 26, 2019 3:12 pm

Got it. All works now. Thank you so much!
User avatar
ubermatress
Sergeant First Class
Sergeant First Class
 
Posts: 19
Joined: Tue Nov 11, 2014 4:06 pm

Re: Help for continuous rumble (T1 code converted)

Postby Scachi » Mon Aug 26, 2019 3:17 pm

ubermatress wrote:Got it. All works now. Thank you so much!

You are welcome :smile0517:
User avatar
Scachi
Brigadier General
Brigadier General
 
Posts: 3044
Joined: Wed May 11, 2016 6:25 am
Location: Germany


Return to GPC2 Script Programming

Who is online

Users browsing this forum: No registered users and 135 guests