How to identify signle, double tap and long hold separately?
5 posts
• Page 1 of 1
How to identify signle, double tap and long hold separately?
Hello guys, I am trying to utilize the function of a single bottom as much as possible,
So i wish to detect single, double tap and long hold separately, how can i do that?
I know i can use
Something like this to detect a bouble tap, but how can i distinguish it with a simple single tap?
So i wish to detect single, double tap and long hold separately, how can i do that?
I know i can use
- Code: Select all
if (event_active(BUTTON_2) && time_release(BUTTON_2)<=200){
Something like this to detect a bouble tap, but how can i distinguish it with a simple single tap?
-
DrNefario - Master Sergeant
- Posts: 35
- Joined: Sun Dec 30, 2018 12:04 pm
Re: How to identify signle, double tap and long hold separat
Here is an example on how you can implement this.
- Code: Select all
#define BUTTON BUTTON_2
#define ACTION_NONE 0
#define ACTION_HOLD 1
#define ACTION_SINGLE_TAP 2
#define ACTION_DOUBLE_TAP 3
uint8 triggered_action;
uint8 process_action;
main {
if(!process_action) {
if(event_active(BUTTON)) {
triggered_action = ACTION_SINGLE_TAP;
if(time_release(BUTTON) < 150) {
triggered_action = ACTION_DOUBLE_TAP;
process_action = TRUE;
}
}
if(triggered_action == ACTION_SINGLE_TAP) {
if(check_release(BUTTON, 175)) {
process_action = TRUE;
}
}
if(check_active(BUTTON, 200)) {
triggered_action = ACTION_HOLD;
process_action = TRUE;
}
} else if(check_release(BUTTON, 250)) {
process_action = FALSE;
}
if(process_action) {
switch(triggered_action) {
case ACTION_HOLD: {
//
// TODO Hold action
//
} break;
case ACTION_SINGLE_TAP: {
//
// TODO Single-tap action
//
} break;
case ACTION_DOUBLE_TAP: {
//
// TODO Double-tap action
//
} break;
}
triggered_action = ACTION_NONE;
}
}
ConsoleTuner Support Team
-
J2Kbr - General of the Army
- Posts: 20323
- Joined: Tue Mar 18, 2014 1:39 pm
Re: How to identify signle, double tap and long hold separat
J2Kbr wrote:Here is an example on how you can implement this.
- Code: Select all
#define BUTTON BUTTON_2
#define ACTION_NONE 0
#define ACTION_HOLD 1
#define ACTION_SINGLE_TAP 2
#define ACTION_DOUBLE_TAP 3
uint8 triggered_action;
uint8 process_action;
main {
if(!process_action) {
if(event_active(BUTTON)) {
triggered_action = ACTION_SINGLE_TAP;
if(time_release(BUTTON) < 150) {
triggered_action = ACTION_DOUBLE_TAP;
process_action = TRUE;
}
}
if(triggered_action == ACTION_SINGLE_TAP) {
if(check_release(BUTTON, 175)) {
process_action = TRUE;
}
}
if(check_active(BUTTON, 200)) {
triggered_action = ACTION_HOLD;
process_action = TRUE;
}
} else if(check_release(BUTTON, 250)) {
process_action = FALSE;
}
if(process_action) {
switch(triggered_action) {
case ACTION_HOLD: {
//
// TODO Hold action
//
} break;
case ACTION_SINGLE_TAP: {
//
// TODO Single-tap action
//
} break;
case ACTION_DOUBLE_TAP: {
//
// TODO Double-tap action
//
} break;
}
triggered_action = ACTION_NONE;
}
}
Thank you so much! BTW, i have updated my anti-recoil algorithm, it is really good!
Check this link if you are interested. I have uploaded the source code in the comment.
viewtopic.php?f=23&t=16612&start=10
Thanks again for all the help!
-
DrNefario - Master Sergeant
- Posts: 35
- Joined: Sun Dec 30, 2018 12:04 pm
Re: How to identify signle, double tap and long hold separat
Is it possible to get a T1 version of this code? Would be helpful
-
Kidd23 - Sergeant First Class
- Posts: 16
- Joined: Wed Dec 19, 2018 6:50 pm
Re: How to identify signle, double tap and long hold separat
Can I use this script for joy con
I want to map button to keyboard keys
If prese Button Y. Get Key R
If I hold Button Y get key. f
I want to map button to keyboard keys
If prese Button Y. Get Key R
If I hold Button Y get key. f
-
teddy18 - Lieutenant
- Posts: 346
- Joined: Sun Jul 19, 2015 4:18 pm
5 posts
• Page 1 of 1
Return to GPC2 Script Programming
Who is online
Users browsing this forum: kubawaz and 111 guests