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 development > Touchscreen Pressure

#46605 - headspin - Tue Jun 28, 2005 12:12 am

Hi, I am a little confused by the setup in NDSLib regarding the pressure of the pen.

How can I get a percentage of pen pressure from 0-100%?
_________________
Warhawk DS | Manic Miner: The Lost Levels | The Detective Game

#46623 - Mollusk - Tue Jun 28, 2005 8:24 am

From what I tested, the pressure isn't really pressure, but rather the size of the touching zone... So the pressure doesn't realy change if you press harder/softer, but changes a lot if you use finger/stylus/anything else...

#46625 - josath - Tue Jun 28, 2005 9:07 am

headspin wrote:
Hi, I am a little confused by the setup in NDSLib regarding the pressure of the pen.

How can I get a percentage of pen pressure from 0-100%?


no one has found a formula that works reliably on all DS's.

and its not like pressure on a wacom tablet where its very smooth, it's much courser. like all you can really tell is hard vs soft, or finger vs stylus.

#46680 - headspin - Wed Jun 29, 2005 1:25 am

Has there been any progress in Natrium's code for calculating a pen down event to avoid the random jumps?

Darkain mentioned in this thread that it's unreliable because of the variations of pressure readings between touchpads.

What's the best code we have at the moment to prevent these jumps, still Natrium's code...?

Code:
int TouchPad::touchPressed()
{
   uint16 touchZ1 = IPC->touchZ1;
   uint16 touchZ2 = IPC->touchZ2;
   uint16 touchX = IPC->touchX;

   uint16 pressure = (touchX * touchZ2) / (64 * touchZ1) - touchX / 64;

   if( pressure > 0 && pressure < MAX_PRESSURE )
      return 1;
   else
      return 0;
}

_________________
Warhawk DS | Manic Miner: The Lost Levels | The Detective Game

#46682 - josath - Wed Jun 29, 2005 1:40 am

I think you can eliminate the 'jumping pen' effect without even using pressure. There are various calculations that can be done.

one example:
For each X,Y you read from the touchpad, check if it is more than N pixels away from the previous reading, then don't use that value.