How to remove duplicate (<100ms) presses from broken button

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

Moderators: The_Rabid_Taco, pablosscripts, bonefisher, Baby Cham, Elvish

How to remove duplicate (<100ms) presses from broken button

Postby randyrandy » Sat Feb 28, 2015 4:01 am

Is there a way to prevent a button from being pressed twice within a certain period? Pressing my jump button once occasionally activates it twice, and in Advanced Warfare this causes him to do double jump. I would like to 'disable' the second jump.
User avatar
randyrandy
Private First Class
Private First Class
 
Posts: 2
Joined: Sat Feb 28, 2015 3:54 am

Re: How to remove duplicate (<100ms) presses from broken but

Postby perfecthuntr » Sun Mar 01, 2015 6:33 am

This should do the job:

Code: Select all
int timer, stop;

main {
    // Timer - Countdown function
    if (timer > 0) {
        timer = timer - get_rtime();
    }

    // Timer - Detection of the first tap
    if (event_press(PS4_CROSS)) {
        timer = fTapTimer(timer);
        if (timer == 0) { // If a second tap was detected
            stop = TRUE;
        }
    }

    if (stop) { // If the second tap was detected, stop the PS4_CROSS button for 100 ms
        combo_run(test);
    }
}

combo test {
    set_val(PS4_CROSS, 0);
    wait(100);
    stop = FALSE;
}

// Timer function for multi-taps
function fTapTimer(timer) {
    if (timer <= 0) {
        timer = 100;             // Start the timer
    }
    // Timer - Detection of next tap within 100 ms
    else {
        timer = 0;
    }
    return timer;
}
ConsoleTuner Support Team
User avatar
perfecthuntr
Major
Major
 
Posts: 897
Joined: Wed Jan 14, 2015 8:35 am
Location: Tennessee

Re: How to remove duplicate (<100ms) presses from broken but

Postby randyrandy » Sun Mar 01, 2015 8:11 pm

Wow, it works perfectly! Thank you so much! :smile0202:
User avatar
randyrandy
Private First Class
Private First Class
 
Posts: 2
Joined: Sat Feb 28, 2015 3:54 am

Re: How to remove duplicate (<100ms) presses from broken but

Postby J2Kbr » Sun Mar 01, 2015 9:28 pm

:innocent_smile_1: Incredible !! A Script that fixes a broken controller!! :joia:
ConsoleTuner Support Team
User avatar
J2Kbr
General of the Army
General of the Army
 
Posts: 17267
Joined: Tue Mar 18, 2014 1:39 pm

Re: How to remove duplicate (<100ms) presses from broken but

Postby perfecthuntr » Mon Mar 02, 2015 6:57 am

Yea, that's a new idea there. Fixing a busted controller. Cheers! :joia: :innocent_smile_1: :joia:
ConsoleTuner Support Team
User avatar
perfecthuntr
Major
Major
 
Posts: 897
Joined: Wed Jan 14, 2015 8:35 am
Location: Tennessee

Re: How to remove duplicate (<100ms) presses from broken but

Postby Crunkstar » Mon Mar 02, 2015 4:16 pm

awesome dude !!!
User avatar
Crunkstar
Sergeant Major
Sergeant Major
 
Posts: 71
Joined: Tue Dec 23, 2014 10:18 pm
Location: Germany

Enabling a blink switch....

Postby SpecialEffect » Fri Jun 12, 2015 4:23 pm

This is a brilliant script. I'm looking for help in adapting it for a man who can only use a blink switch as his input device.

Can anyone help, please with this...?

1. The blink sensor looks into your eye. When you close your eye shut, you complete a circuit that holds the A button down in an adapted Xbox 360 joypad. Open your eye to release the A button.

2. This brilliant script enables me to filter out accidental blinks vs deliberate blinks.

3. I need to find a way to invert the A-button. Press button A = nothing. Release button A = held on. A basic no filtering script would be handy, but to implement the filtering would be brilliant.

This means the man can rest his eyes, listening to spoken prompts by the computer. When he wants to select a choice (e.g. a word or letter), he opens his eyes for a second or two to choose.

It would mean the world if anyone could help me with this. I grasp the basics of this, but I'm not great with the logic.

Barrie
SpecialEffect.org.uk
User avatar
SpecialEffect
Command Sergeant Major
Command Sergeant Major
 
Posts: 147
Joined: Mon Apr 07, 2014 3:26 pm

Re: How to remove duplicate (<100ms) presses from broken but

Postby UK_Wildcats_Fans » Fri Jun 12, 2015 5:22 pm

My mom had ALS and was immobilized for the last year of her life. She only had eye movement, some basic facial expressions, and very crude grunt sounds (which was difficult). Very rarely she could move a finger. Therefore, I understand fully the value of being able to find a means to communicate even for the most basic of needs - i.e. food, water, tired, itch.

We will definitely make it doable, we just have to define the logic well enough.

Is the adapted 360 joypad being plugged into a XB360 or computer? Just curious here.

Let me start with some basics for you, the scripts can handle various types of logic for button actions. See the below examples,

event_press: trigger actions once a button is initially pressed
event_release: trigger actions once a button is finally released
get_val: trigger actions while a button is being pressed
We can even invert values.

Therefore, we can definitely write combos (actions) that are triggered once the A button is released. Let me see if I have the sequence right. Let's assume no blinks for now to get this sequence correct.

1. Eyes closes which causes the circuit to close and the adapted 360 presses the "A" button
2. Script recognizes the "A" button pressed but keeps the "A" value at OFF
3. Eyes open which causes the circuit to open and the adapted 360 releases the "A" button
4. Script recognizes the "A" button release and then provides an actual "A" button value to the console/computer/etc.
5. "A" button value is held ON until the eye closes again and the circuit closes

Is this basic sequence correct? This would mean that the "A" button value would be ON while the eyes are open and OFF while the eyes are closed.

Blink filtering would need to be applied to step 1, 3 & 5 of the sequence above.

The script would also be modified so that it only gives an "A" button value if the eyes are held shut for a minimum certain period of time. For example, "A" button would only be triggered if eyes are shut for 1/2 second or longer. We could also make the "A" button last only for a certain duration too.
User avatar
UK_Wildcats_Fans
Brigadier General
Brigadier General
 
Posts: 2068
Joined: Thu Jan 08, 2015 6:53 pm
Location: San Diego, California USA

Re: How to remove duplicate (<100ms) presses from broken but

Postby SpecialEffect » Fri Jun 12, 2015 6:41 pm

Thanks so much for getting back on this. It seems that you understand completely from personal experience and from what I've tried to explain.

The Xbox 360 joypad will be connected to the Titan One then into a PC. The profile button will allow us to have 9 different configurations, very conveniently (likely a mix of different filter values and normal or inverted "A" function).

Of those it would be great to cover a way for me to easily tweak script values for the following....

1. Filter out "bounced" or non-deliberate blinks.
2. Optionally invert the A button (push-to-make or push-to-break a contact).
3. Optionally allow triggered "A" events to be a short on-off. Alternatively react on a 1:1 basis.

Huge thanks for any help you can offer on this. We'll gladly share the findings for anyone else to work with. Could be useful for a range of switch users including muscle switches, tongue switches and so on.

Barrie
User avatar
SpecialEffect
Command Sergeant Major
Command Sergeant Major
 
Posts: 147
Joined: Mon Apr 07, 2014 3:26 pm

Re: How to remove duplicate (<100ms) presses from broken but

Postby UK_Wildcats_Fans » Fri Jun 12, 2015 8:37 pm

Let's move all future discussions on this to your other topic, so they are all in one.

http://www.consoletuner.com/forum/viewtopic.php?f=6&t=1795
User avatar
UK_Wildcats_Fans
Brigadier General
Brigadier General
 
Posts: 2068
Joined: Thu Jan 08, 2015 6:53 pm
Location: San Diego, California USA


Return to GPC Script Programming (Titan One)

Who is online

Users browsing this forum: No registered users and 6 guests