Help getting anywhere with this idea?

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

Help getting anywhere with this idea?

Postby Redo » Wed May 30, 2018 3:52 am

Hello, I'm new in several senses. First time around these forums, first time owning my Titan One device, and first time doing any kind of scripting whatsoever.

I figured I'd ask for help considering my lack of experience: I use the Hori Fighting Commander 4 (The PS3/4 one) for all my fighting game needs, since I grew up with pads and could never get used to arcade controllers. I also play Super Smash Bros., but that's done with a different controller, for the obvious reason that mine lacks any kind of stick. It does have a right and left stick function however, but since they're mapped to the D-Pad, using the pad with games that use the sticks and their sensibility is kind of impossible. Not that I'm complaining too much, since the pad was designed with 2D fighting games in mind and all, but Smash Bros. is a 2D fighting game (to most) that I can't fully enjoy with it, as pressing in a direction will always result in a stick 100% pressed in the direction, with no ability to walk at all.

So I was wondering if it was somehow possible to set the Fighting Commander's left stick to only 50% by default, and to 100% after double-tapping in the desired direction, within a certain limit of frames or miliseconds, all through a script. Also if it can be done through the visual scripting tool provided by Gtuner Pro, as I'm unsure if to even give manual scripting a shot until I'm familiar enough with visual scripting.

I'd rather be given pointers than solutions, since I'd like to learn how to script for real. That said... if someone has already done something like what I had in mind, I'd love to be pointed in the direction of said script.

Thanks beforehand! Any help is really appreciated.
User avatar
Redo
Private First Class
Private First Class
 
Posts: 3
Joined: Wed May 30, 2018 3:14 am

Re: Help getting anywhere with this idea?

Postby J2Kbr » Wed May 30, 2018 12:52 pm

Welcome to our forums.

What you are requesting is not possible with Visual Scripting (specially because the double tapping detection) due the limitations of this interface, so coding a script is needed to achieve what you are looking for.

Redo wrote:So I was wondering if it was somehow possible to set the Fighting Commander's left stick to only 50% by default, and to 100% after double-tapping in the desired direction, within a certain limit of frames or miliseconds, all through a script.

the first part is easy, to limit the left stick to 50% can be done with this script:
Code: Select all
main {
    if(get_val(PS4_LX) > 50) {
        set_val(PS4_LX, 50);
    } else if(get_val(PS4_LX) < -50) {
        set_val(PS4_LX, -50);
    }
    if(get_val(PS4_LY) > 50) {
        set_val(PS4_LY, 50);
    } else if(get_val(PS4_LY) < -50) {
        set_val(PS4_LY, -50);
    }
}

Extending the script to detect double tap (only to left direction by now):
Code: Select all
int lx_val;
int ly_val;
 
int dt_left_state;
int dt_left_time;
int dt_left_detected;
 
main {
    lx_val = get_val(PS4_LX);
    ly_val = get_val(PS4_LY);
 
    // set the Fighting Commander's left stick to only 50% by default
    if(lx_val > 50) {
        set_val(PS4_LX, 50);
    } else if(lx_val < -50) {
        set_val(PS4_LX, -50);
    }
    if(ly_val > 50) {
        set_val(PS4_LY, 50);
    } else if(ly_val < -50) {
        set_val(PS4_LY, -50);
    }
 
    // and to 100% after double-tapping in the desired direction
 
    // DETECT DOUBLE TAP TO LEFT DIRECTION
    if(dt_left_detected) {
        if(lx_val < 95) {
            dt_left_detected = FALSE;
        } else {
            set_val(PS4_LX, 100);
        }
    } else if(dt_left_state == 0) {
        if(lx_val >= 95) dt_left_state = 1;
    } else if(dt_left_state == 1) {
        if(lx_val <  95) { dt_left_time = 0; dt_left_state = 2; }
    } else if(dt_left_state == 2) {
        if(lx_val >= 95) { dt_left_state = 1; dt_left_detected = TRUE; }
        dt_left_time = dt_left_time + get_rtime();
        if(dt_left_time > 100) dt_left_state = 0;
    }
 
}
 

Please let me know if this script works as you want (50% limit, and double tap to left direction), if yes I will then finish the double tap detection to all 3 remaining directions. :smile0517:
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 getting anywhere with this idea?

Postby Redo » Sat Jun 02, 2018 6:07 pm

Thank you! Sorry for replying late, I didn't get a notification for your response.

It works! Only problem is that it's set to work when holding the "stick" to the right, not to the left. And that's honestly really weird because I can somewhat understand the script you wrote and you very clearly wrote "left" and not "right" in there, so I'm not sure what's wrong there specifically.

Tried to quickly mess with it but it doesn't seem to have changed a single thing. Left double tap still doesn't work, right one still does. Hmmm.

Code: Select all
int lx_val;
int ly_val;
 
int dt_left_state;
int dt_left_time;
int dt_left_detected;
 
int dt_right_state;
int dt_right_time;
int dt_right_detected;
 
main {
    lx_val = get_val(PS4_LX);
    ly_val = get_val(PS4_LY);
 
    // set the Fighting Commander's left stick to only 50% by default
    if(lx_val > 50) {
        set_val(PS4_LX, 50);
    } else if(lx_val < -50) {
        set_val(PS4_LX, -50);
    }
    if(ly_val > 50) {
        set_val(PS4_LY, 50);
    } else if(ly_val < -50) {
        set_val(PS4_LY, -50);
    }
 
    // and to 100% after double-tapping in the desired direction
 
    // DETECT DOUBLE TAP TO LEFT DIRECTION
    if(dt_left_detected) {
        if(lx_val < 95) {
            dt_left_detected = FALSE;
        } else {
            set_val(PS4_LX, 100);
        }
    } else if(dt_left_state == 0) {
        if(lx_val >= 95) dt_left_state = 1;
    } else if(dt_left_state == 1) {
        if(lx_val <  95) { dt_left_time = 0; dt_left_state = 2; }
    } else if(dt_left_state == 2) {
        if(lx_val >= 95) { dt_left_state = 1; dt_left_detected = TRUE; }
        dt_left_time = dt_left_time + get_rtime();
        if(dt_left_time > 100) dt_left_state = 0;
    }
 
        // DETECT DOUBLE TAP TO RIGHT DIRECTION
    if(dt_right_detected) {
        if(lx_val < -95) {
            dt_right_detected = FALSE;
        } else {
            set_val(PS4_LX, -100);
        }
    } else if(dt_right_state == 0) {
        if(lx_val >= -95) dt_right_state = 1;
    } else if(dt_right_state == 1) {
        if(lx_val <  -95) { dt_right_time = 0; dt_right_state = 2; }
    } else if(dt_right_state == 2) {
        if(lx_val >= -95) { dt_right_state = 1; dt_right_detected = TRUE; }
        dt_right_time = dt_right_time + get_rtime();
        if(dt_right_time > -100) dt_right_state = 0;
    }
 
}


I'm not sure what the mistake is here.
User avatar
Redo
Private First Class
Private First Class
 
Posts: 3
Joined: Wed May 30, 2018 3:14 am

Re: Help getting anywhere with this idea?

Postby J2Kbr » Mon Jun 04, 2018 10:21 am

Cool, thank you for confirming the script is working.
Below the code extended for both left and right double tap (also fixed the left direction bug).
Code: Select all
int lx_val;
int ly_val;
 
int dt_right_state;
int dt_right_time;
int dt_right_detected;
 
int dt_left_state;
int dt_left_time;
int dt_left_detected;
 
main {
    lx_val = get_val(PS4_LX);
    ly_val = get_val(PS4_LY);
 
    // set the Fighting Commander's left stick to only 50% by default
    if(lx_val > 50) {
        set_val(PS4_LX, 50);
    } else if(lx_val < -50) {
        set_val(PS4_LX, -50);
    }
    if(ly_val > 50) {
        set_val(PS4_LY, 50);
    } else if(ly_val < -50) {
        set_val(PS4_LY, -50);
    }
 
    // and to 100% after double-tapping in the desired direction
 
    // DETECT DOUBLE TAP TO LEFT DIRECTION
    if(dt_left_detected) {
        if(lx_val > -95) {
            dt_left_detected = FALSE;
        } else {
            set_val(PS4_LX, -100);
        }
    } else if(dt_left_state == 0) {
        if(lx_val <= -95) dt_left_state = 1;
    } else if(dt_left_state == 1) {
        if(lx_val >  95) { dt_left_time = 0; dt_left_state = 2; }
    } else if(dt_left_state == 2) {
        if(lx_val <= -95) { dt_left_state = 1; dt_left_detected = TRUE; }
        dt_left_time = dt_left_time + get_rtime();
        if(dt_left_time > 100) dt_left_state = 0;
    }
 
    // DETECT DOUBLE TAP TO RIGHT DIRECTION
    if(dt_right_detected) {
        if(lx_val < 95) {
            dt_right_detected = FALSE;
        } else {
            set_val(PS4_LX, 100);
        }
    } else if(dt_right_state == 0) {
        if(lx_val >= 95) dt_right_state = 1;
    } else if(dt_right_state == 1) {
        if(lx_val <  95) { dt_right_time = 0; dt_right_state = 2; }
    } else if(dt_right_state == 2) {
        if(lx_val >= 95) { dt_right_state = 1; dt_right_detected = TRUE; }
        dt_right_time = dt_right_time + get_rtime();
        if(dt_right_time > 100) dt_right_state = 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 getting anywhere with this idea?

Postby Redo » Tue Jun 19, 2018 3:31 am

This is giving me a headache, it kind of worked at first but then it didn't anymore. Double tap to the right works normally, but to the left it doesn't work unless I mash left and right quickly. Then it gets stuck as if I was holding the "stick" to the left all the time, and that's obviously not convenient.

Again, I'm not sure what's wrong. It seems to be something that should work, yet it doesn't.

As soon as this is working, is there any chance to make it so that:
1.- Up direction isn't affected by the 50% limiter? It's not needed since the game allows me to jump with an actual button.
2.- Double tap works for the down direction? This should allow for the controller to crouch on pass-through platforms AND passing through (if I choose to double tap).
2.- The limiter doesn't reset if I immediately change my input to another direction? This is so this configuration allows for Dash Dancing.

Dash Dancing example and explaination.
User avatar
Redo
Private First Class
Private First Class
 
Posts: 3
Joined: Wed May 30, 2018 3:14 am

Re: Help getting anywhere with this idea?

Postby J2Kbr » Tue Jun 19, 2018 2:55 pm

Added a define at the beginning of the code where you can configure the threshold for the double tapping (it is already lowered to allow easy recognition of double taping). Hope this helps.

Code: Select all
define DTAP_THRESHOLD = 85;
 
int lx_val;
int ly_val;
 
int dt_right_state;
int dt_right_time;
int dt_right_detected;
 
int dt_left_state;
int dt_left_time;
int dt_left_detected;
 
main {
    lx_val = get_val(PS4_LX);
    ly_val = get_val(PS4_LY);
 
    // set the Fighting Commander's left stick to only 50% by default
    if(lx_val > 50) {
        set_val(PS4_LX, 50);
    } else if(lx_val < -50) {
        set_val(PS4_LX, -50);
    }
    if(ly_val > 50) {
        set_val(PS4_LY, 50);
    } else if(ly_val < -50) {
        set_val(PS4_LY, -50);
    }
 
    // and to 100% after double-tapping in the desired direction
 
    // DETECT DOUBLE TAP TO LEFT DIRECTION
    if(dt_left_detected) {
        if(lx_val > -DTAP_THRESHOLD) {
            dt_left_detected = FALSE;
        } else {
            set_val(PS4_LX, -100);
        }
    } else if(dt_left_state == 0) {
        if(lx_val <= -DTAP_THRESHOLD) dt_left_state = 1;
    } else if(dt_left_state == 1) {
        if(lx_val >  DTAP_THRESHOLD) { dt_left_time = 0; dt_left_state = 2; }
    } else if(dt_left_state == 2) {
        if(lx_val <= -DTAP_THRESHOLD) { dt_left_state = 1; dt_left_detected = TRUE; }
        dt_left_time = dt_left_time + get_rtime();
        if(dt_left_time > 100) dt_left_state = 0;
    }
 
    // DETECT DOUBLE TAP TO RIGHT DIRECTION
    if(dt_right_detected) {
        if(lx_val < DTAP_THRESHOLD) {
            dt_right_detected = FALSE;
        } else {
            set_val(PS4_LX, 100);
        }
    } else if(dt_right_state == 0) {
        if(lx_val >= DTAP_THRESHOLD) dt_right_state = 1;
    } else if(dt_right_state == 1) {
        if(lx_val <  DTAP_THRESHOLD) { dt_right_time = 0; dt_right_state = 2; }
    } else if(dt_right_state == 2) {
        if(lx_val >= DTAP_THRESHOLD) { dt_right_state = 1; dt_right_detected = TRUE; }
        dt_right_time = dt_right_time + get_rtime();
        if(dt_right_time > 100) dt_right_state = 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


Return to GPC1 Script Programming

Who is online

Users browsing this forum: No registered users and 138 guests