Hi all,
Purpose of the app:
A simple app that draws a circle for every touch recognised on the screen and follows the touch events. On a 'high pressure reading' getPressure (int pointerIndex)
the colour of the circle will change and the radius will increase. Additionally the touch ID with getPointerId (int pointerIndex)
, x- and y-coordinates and pressure are shown next to the finger touch.
Following a code snipplet of the important part (please forgive me it is not the nicest code ;) I know)
protected void onDraw(Canvas canvas){
//draw circle only when finger(s) is on screen and moves
if(iTouchAction == (MotionEvent.ACTION_MOVE)){
int x,y;
float pressure;
//Draw circle for every touch
for (int i = 0; i < touchEvent.getPointerCount(); i++){
x = (int)touchEvent.getX(i);
y = (int)touchEvent.getY(i);
pressure = touchEvent.getPressure(i);
//High pressure
if (pressure > 0.25){
canvas.drawCircle(x, y, z+30, pressureColor);
canvas.drawText(""+touchEvent.getPointerId(i)+" | "+x+"/"+y, x+90, y-80, touchColor);
canvas.drawText(""+pressure, x+90, y-55, pressureColor);
}else{ //normal touch event
canvas.drawCircle(x, y, z, touchColor);
canvas.drawText(""+touchEvent.getPointerId(i)+" | "+x+"/"+y, x+60, y-50, touchColor);
canvas.drawText(""+pressure, x+60, y-25, pressureColor);
}
}
}
}
The problem:
A HTC Desire running Android 2.1 is the test platform. The app works fine and tracks two finger without a problem. But it seems that the two touch points interfere with each other when they get t0o close -- it looks like they circles 'snap'to a shared x and y axle. Sometimes they even swap the input coordinates of the other touch event. Another problem is that even though getPressure (int pointerIndex)
refers to an PointerID both touch event have the same pressure reading.
As this is all a bit abstract, find a video here: http://www.youtube.com/watch?v=bFxjFexrclU
My question:
- Is my code just simply wrong?
- Does Android 2.1 not handle the touch events well enough get things mixed up?
- Is this a hardware problem and has nothing to do with 1) and 2)?
Thank you for answers and/or relinks to other thread (sorry could find one that address this problem).
Chris