Tap twice to activate button, hold to activate second button

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

Tap twice to activate button, hold to activate second button

Postby Pietu » Wed May 05, 2021 5:22 am

Hello,

Could someone make an usb hid script so when tapped spacebar twice within timelimit 250ms will activate keyboard button (x) and when holding left shift for 250ms or tapping left shift twice within 250ms will activate keyboard button (m)
User avatar
Pietu
Corporal
Corporal
 
Posts: 5
Joined: Thu Oct 08, 2020 6:11 am

Re: Tap twice to activate button, hold to activate second bu

Postby Mad » Thu May 06, 2021 1:17 am

Code: Select all
#include <keyboard.gph>
 
init {
    const uint8 map[] = {
        KEY_LEFTSHIFT, BUTTON_1,
        KEY_SPACEBAR,  BUTTON_2,
    };
    mouse_passthru();
    keymapping(map);
 
    mousemapping();
}
 
main{
    mouse_passthru();
    key_passthru();
 
    if(event_active(BUTTON_1) && time_release(BUTTON_1) < 250) {
        key_set(KEY_M, 1);
    }
    else if(check_active(BUTTON_1, 250)) {
        key_set(KEY_M, 1);
    }
 
    if(event_active(BUTTON_2) && time_release(BUTTON_2) < 250) {
        key_set(KEY_X, 1);
    }
}
ConsoleTuner Support Team || ConsoleTuner Discord || InputSense Discord (2K / FPS)
Mad
Major General
Major General
 
Posts: 4533
Joined: Wed May 22, 2019 5:39 am

Re: Tap twice to activate button, hold to activate second bu

Postby Pietu » Fri May 07, 2021 2:55 am

Works perfectly, thanks Mad.
User avatar
Pietu
Corporal
Corporal
 
Posts: 5
Joined: Thu Oct 08, 2020 6:11 am


Return to GPC2 Script Programming

Who is online

Users browsing this forum: No registered users and 102 guests