Detecting a double-tap..
Moderator: InsideQC Admins
11 posts
• Page 1 of 1
Detecting a double-tap..
Trying to make an interface to detect double-taps for any key, as the PSP has a limited control scheme.
Any ideas as far as it could be done?
I was thinking about modifying this struct:
to have a time value as well, that would be set to like time + .1 when the initial keypress is detected, then if it hasn't expired by the time the second keypress is detected, perform an alternate binding?
Is there a better way? I'm sure you people that have been modding Quake for years could think of a better way.
EDIT: I also have no clue if this is used for button presses or an on-screen-keyboard.
Any ideas as far as it could be done?
I was thinking about modifying this struct:
- Code: Select all
typedef struct
{
int down[2]; // key nums holding it down
int state; // low bit is down state
} kbutton_t;
to have a time value as well, that would be set to like time + .1 when the initial keypress is detected, then if it hasn't expired by the time the second keypress is detected, perform an alternate binding?
Is there a better way? I'm sure you people that have been modding Quake for years could think of a better way.
EDIT: I also have no clue if this is used for button presses or an on-screen-keyboard.
-

Downsider - Posts: 621
- Joined: Tue Sep 16, 2008 1:35 am
It's in the engine programming subforum for a reason, Avirox =O
I added the commands binddt and unbinddt and essentially copied over a bunch of the code in key.c with minor alterations to suit the double-tap array of commands assigned to keys. Then I simply had a global variable for the last pressed key and the time it was pressed, compared, and if it was within .3 "time" ago (I have no clue at the scale which Quake does time so I'll refer to it as "time" instead of seconds), I Cbuf_Addtext'd the command that the key was bound to.
For instance, in my game, I want the character to sprint when he double tapped triangle, this is what the config reads as:
Works perfectly fine. When you single tap, it just does the normal walk forward.
I added the commands binddt and unbinddt and essentially copied over a bunch of the code in key.c with minor alterations to suit the double-tap array of commands assigned to keys. Then I simply had a global variable for the last pressed key and the time it was pressed, compared, and if it was within .3 "time" ago (I have no clue at the scale which Quake does time so I'll refer to it as "time" instead of seconds), I Cbuf_Addtext'd the command that the key was bound to.
For instance, in my game, I want the character to sprint when he double tapped triangle, this is what the config reads as:
- Code: Select all
bind "TRIANGLE" "+forward"
binddt "TRIANGLE" "+forward; qcf A_Sprint;"
Works perfectly fine. When you single tap, it just does the normal walk forward.
-

Downsider - Posts: 621
- Joined: Tue Sep 16, 2008 1:35 am
Possibly another useful related idea, the idea of holding the button down for more than a second or two has an alternate function.
One possible example, alter jump so the jump occurs on key release but if the button is held more than a couple of seconds it is a forward lunge attack that knocks enemies out of the way.
Nice idea downsider on thinking how to reuse existing controls.
One possible example, alter jump so the jump occurs on key release but if the button is held more than a couple of seconds it is a forward lunge attack that knocks enemies out of the way.
Nice idea downsider on thinking how to reuse existing controls.
The night is young. How else can I annoy the world before sunsrise?
Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
-

Baker - Posts: 3666
- Joined: Tue Mar 14, 2006 5:15 am
I know it's a different engine, but you could see how this is done in Alien Arena - http://svn.icculus.org/alienarena/
Bulk of it is in p_client.c in Clientthink().
Bulk of it is in p_client.c in Clientthink().
http://red.planetarena.org - Alien Arena and the CRX engine
- Irritant
- Posts: 250
- Joined: Mon May 19, 2008 2:54 pm
- Location: Maryland
11 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest