Hold and double tap
8 posts
• Page 1 of 1
Hold and double tap
how do i run a combo when i hold A and double tap spacebar? i cant get it to work
-
fdg0d - Sergeant Major
- Posts: 83
- Joined: Thu May 12, 2016 3:16 pm
Re: Hold and double tap
The spacebar is mapped to a controller button? if yes please let me know to which button (X, Y, etc) because in this case would be very simple detect the double tap.
ConsoleTuner Support Team
-
J2Kbr - General of the Army
- Posts: 20323
- Joined: Tue Mar 18, 2014 1:39 pm
Re: Hold and double tap
no im using the USB multi interface HID
-
fdg0d - Sergeant Major
- Posts: 83
- Joined: Thu May 12, 2016 3:16 pm
Re: Hold and double tap
Okay, so we need implement the double tap detection with script code, this will do for spacebar:
- Code: Select all
#include <keyboard.gph>
bool spacebar_prev;
uint32 spacebar_active_ts;
uint32 spacebar_release_ts;
main {
if(key_status(KEY_SPACEBAR)) {
if(!spacebar_prev) {
spacebar_active_ts = system_time();
spacebar_prev = TRUE;
// Check double tap
if(system_time() - spacebar_release_ts <= 200) {
//
// Run combo from here
//
}
}
} else {
if(spacebar_prev) {
spacebar_release_ts = system_time();
spacebar_prev = FALSE;
}
}
}
ConsoleTuner Support Team
-
J2Kbr - General of the Army
- Posts: 20323
- Joined: Tue Mar 18, 2014 1:39 pm
Re: Hold and double tap
its working but how can i make it so when i hold the KEY_A on my keyboard and double press space to run the combo
-
fdg0d - Sergeant Major
- Posts: 83
- Joined: Thu May 12, 2016 3:16 pm
Re: Hold and double tap
ive got this but now the doulbe tap doesnt work anymore
- Code: Select all
#include <keyboard.gph>
#include <mouse.gph>
bool DASH;
bool spacebar_prev;
bool event_press_l;
uint32 spacebar_active_ts;
uint32 spacebar_release_ts;
init {
mousemapping();
}
main {
mouse_passthru();
key_passthru();
if(key_status(KEY_L)) {
if(!event_press_l) {
event_press_l = TRUE;
DASH = !DASH;
}
} else event_press_l = FALSE;
if(DASH) {
if(key_status(KEY_D) && key_status(KEY_SPACEBAR)) {
if(!spacebar_prev) {
spacebar_active_ts = system_time();
spacebar_prev = TRUE;
// Check double tap
if(system_time() - spacebar_release_ts <= 200) {
//
combo_run(right);
//
}
}
} else {
if(spacebar_prev) {
spacebar_release_ts = system_time();
spacebar_prev = FALSE;
}
}
if(key_status(KEY_A) && key_status(KEY_SPACEBAR)) {
if(!spacebar_prev) {
spacebar_active_ts = system_time();
spacebar_prev = TRUE;
// Check double tap
if(system_time() - spacebar_release_ts <= 200) {
//
combo_run(left);
//
}
}
} else {
if(spacebar_prev) {
spacebar_release_ts = system_time();
spacebar_prev = FALSE;
}
}
}
}
combo right {
mouse_set(MOUSE_X, 100);
wait(109);
key_set(KEY_LEFTSHIFT, 1);
wait(40);
key_set(KEY_LEFTSHIFT, 0);
wait(10);
mouse_set(MOUSE_X, -100);
wait(129);
key_set(KEY_LEFTSHIFT, 0);
}
combo left {
mouse_set(MOUSE_X, -100);
wait(109);
key_set(KEY_LEFTSHIFT, 1);
wait(40);
key_set(KEY_LEFTSHIFT, 0);
wait(10);
mouse_set(MOUSE_X, 100);
wait(129);
key_set(KEY_LEFTSHIFT, 0);
}
-
fdg0d - Sergeant Major
- Posts: 83
- Joined: Thu May 12, 2016 3:16 pm
Re: Hold and double tap
You can't use the space doubletap code twice or you will always reset the doubletap check if you are not pressing d+space and a+space at the same time.
You can put the space check at the first check and set a dblspace flag and use that flag in multiple checks like this:
You can put the space check at the first check and set a dblspace flag and use that flag in multiple checks like this:
- Code: Select all
#include <keyboard.gph>
#include <mouse.gph>
bool DASH;
bool spacebar_prev;
bool dblspace = FALSE;
bool event_press_l;
uint32 spacebar_active_ts;
uint32 spacebar_release_ts;
init {
mousemapping();
}
main {
mouse_passthru();
key_passthru();
if(key_status(KEY_SPACEBAR)) {
if(!spacebar_prev) {
spacebar_active_ts = system_time();
spacebar_prev = TRUE;
// Check double tap
if(system_time() - spacebar_release_ts <= 200) {
//
dblspace = TRUE;
//
}
}
} else {
if(spacebar_prev) {
spacebar_release_ts = system_time();
spacebar_prev = FALSE;
}
dblspace = FALSE;
}
if(key_status(KEY_L)) {
if(!event_press_l) {
event_press_l = TRUE;
DASH = !DASH;
printf("dash flag changed");
}
} else event_press_l = FALSE;
if(DASH) {
if(key_status(KEY_D) && dblspace) {
combo_run(right);
}
if(key_status(KEY_A) && dblspace ) {
combo_run(left);
}
}
}
combo right {
printf("right");
wait(0);
mouse_set(MOUSE_X, 100);
wait(109);
key_set(KEY_LEFTSHIFT, 1);
wait(40);
key_set(KEY_LEFTSHIFT, 0);
wait(10);
mouse_set(MOUSE_X, -100);
wait(129);
key_set(KEY_LEFTSHIFT, 0);
}
combo left {
printf("left");
wait(0);
mouse_set(MOUSE_X, -100);
wait(109);
key_set(KEY_LEFTSHIFT, 1);
wait(40);
key_set(KEY_LEFTSHIFT, 0);
wait(10);
mouse_set(MOUSE_X, 100);
wait(129);
key_set(KEY_LEFTSHIFT, 0);
}
-
Scachi - Brigadier General
- Posts: 3044
- Joined: Wed May 11, 2016 6:25 am
- Location: Germany
Re: Hold and double tap
TY that works!
-
fdg0d - Sergeant Major
- Posts: 83
- Joined: Thu May 12, 2016 3:16 pm
8 posts
• Page 1 of 1
Return to GPC2 Script Programming
Who is online
Users browsing this forum: Baidu [Spider] and 114 guests