Need Help With DoubleTap and SingleTap Input for Analog #s

Titan One general support. Questions, firmware update, feature request.

Need Help With DoubleTap and SingleTap Input for Analog #s

Postby Arkade789 » Sun Feb 03, 2019 2:34 am

Hello,

I am trying to make a code that involves making a fight stick play Smash Brothers Ultimate similar to how a Wii Remote plays Brawl for the Wii. The function I am referring to is its Double tap to smash/run feature, and Single tap to tilt/walk. In this case, the Switch Controller has analog values of X and Y between -100 and 100, Left and Right/ Up and Down respectively. I was hoping to make the stick's movement buttons/switches to serve two different values:

if I were to single tap right on the fight stick, I get a Switch LS analog value of 75 (tilt)

and

if I were to double tap right on the fight stick, I get a Switch LS analog value of 100 (smash)

As of so far, I have NO clue how to make a double tap instance into an analog value. Can anyone help?
User avatar
Arkade789
Private First Class
Private First Class
 
Posts: 2
Joined: Sun Feb 03, 2019 2:21 am

Re: Need Help With DoubleTap and SingleTap Input for Analog

Postby J2Kbr » Mon Feb 04, 2019 12:45 pm

Welcome to our forums, please try this:
Code: Select all
int left_s, left_t, left_v;
int right_s, right_t, right_v;
 
main {
    if(left_s == 0) {
        if(get_val(SWITCH_LX) <= -95) left_s = 1;
        left_v = 0;
    } else if(left_s == 1) {
        if(get_val(SWITCH_LX) >  -95) { left_t = 0; left_s = 2; }
    } else if(left_s == 2) {
        if(get_val(SWITCH_LX) <= -95) { left_s = 1; left_v = 1; }
        left_t = left_t + get_rtime();
        if(left_t > 100) left_s = 0;
    }
    if(get_val(SWITCH_LX) <= -75) {
        if(left_v) set_val(SWITCH_LX, -100);
        else set_val(SWITCH_LX, -75);
    }
 
    if(right_s == 0) {
        if(get_val(SWITCH_LX) >= 95) right_s = 1;
        right_v = 0;
    } else if(right_s == 1) {
        if(get_val(SWITCH_LX)95) { right_t = 0; right_s = 2; }
    } else if(right_s == 2) {
        if(get_val(SWITCH_LX) >= 95) { right_s = 1; right_v = 1; }
        right_t = right_t + get_rtime();
        if(right_t > 100) right_s = 0;
    }
    if(get_val(SWITCH_LX) >= 75) {
        if(right_v) set_val(SWITCH_LX, 100);
        else set_val(SWITCH_LX, 75);
    }
}
 
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: Need Help With DoubleTap and SingleTap Input for Analog

Postby Arkade789 » Mon Feb 04, 2019 7:21 pm

Holy snap, you're wonderful! Thanks so much!

I've even modified the code to include vertical taps and smashes. Looking at this from scratch, it makes sense!
User avatar
Arkade789
Private First Class
Private First Class
 
Posts: 2
Joined: Sun Feb 03, 2019 2:21 am


Return to Titan One Device

Who is online

Users browsing this forum: No registered users and 68 guests