#143696 - Jesse - Thu Oct 25, 2007 12:02 pm
I just answered an email about how to best read pressure sensitivity and thought that more people may be interested:
The pressure is read from the z1/z2 values of the touchdata structure:
The pressure needs to be calibrated for a specific NDS:
Max-pressure is per default 90 and Min-pressure 65 (note the the terminology is kind of screwed up, since harder pressure gives a lower value). These values should be calibrated for a specific NDS but the default ones seem to work on most NDS Lite.
You probably want to make sure that the pressure is evened out across frames, since it?s a bit jumpy otherwise. This is run before every frame:
You probably want to change the curve and the magic numbers into something that suits your application.
_________________
http://www.collectingsmiles.com/colors & http://www.collectingsmiles.com/hyena
The pressure is read from the z1/z2 values of the touchdata structure:
Code: |
touchPosition touchXY = touchReadXY();
int intPressure = (touchXY.x * touchXY.z2) / (64 * touchXY.z1) - touchXY.x / 64; |
The pressure needs to be calibrated for a specific NDS:
Code: |
int Range = m_MaxPressure - m_MinPressure;
if(Range <= 0) Range = 1; float TargetPressure = Clamp01(1.0f - float(intPressure - m_MinPressure) / Range); |
Max-pressure is per default 90 and Min-pressure 65 (note the the terminology is kind of screwed up, since harder pressure gives a lower value). These values should be calibrated for a specific NDS but the default ones seem to work on most NDS Lite.
You probably want to make sure that the pressure is evened out across frames, since it?s a bit jumpy otherwise. This is run before every frame:
Code: |
TargetPressure *= TargetPressure * TargetPressure;
if(TargetPressure < 0.05f) TargetPressure = 0.05f; Pressure = Pressure + (TargetPressure - Pressure) * 0.1f; |
You probably want to change the curve and the magic numbers into something that suits your application.
_________________
http://www.collectingsmiles.com/colors & http://www.collectingsmiles.com/hyena