gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS Misc > How to recognise Double-Click

#175743 - MichaelMossman - Thu Jan 27, 2011 5:02 pm

Is there any way to recognise a double tap on the screen ?

I ask because you cannot rely on the x and y being identical to the last tap because the user will probably not be this consistent with his double-tap.

I cannot find any reference in libnds for 'double-click' input.

#175744 - elhobbs - Thu Jan 27, 2011 5:34 pm

a double click is just 2 clicks within a certain timeframe. keep track of the last click time and if the new click is within that range then it is a double click.

#175751 - Dwedit - Fri Jan 28, 2011 3:07 am

Might also want to limit the second click to be up to 16 pixels away from the first click. And if the two clicks are faster than humanly possible (within 3 frames between clicks), reject it as well.
_________________
"We are merely sprites that dance at the beck and call of our button pressing overlord."

#175752 - sverx - Fri Jan 28, 2011 11:09 am

In a test I've done last year I was capturing the frame number (simply using a counter that gets incremented every loop) and the 'object' I was clicking (I was using an array of rectangles) instead of the x,y location. This way, when receiving a click, I was simply checking it against the previous click and if they both were on the same object and close enough to each other (the difference between the frame number of the two clicks was less than a given amount) that would trigger the double click.

I'm sorry I no longer have the code :|

#175754 - MichaelMossman - Fri Jan 28, 2011 11:59 am

Thank you all for your help.

It really is a nice comfortable feeling to know you can ask a relatively silly question and get so much generous response.