Prevent short-circuit evaluation from eating some of our touch event handling

This commit is contained in:
Henrik Rydgard 2014-06-18 00:54:11 +02:00
parent 58020174b1
commit 1c93a58223

View File

@ -72,7 +72,7 @@ public class NativeGLView extends GLSurfaceView implements SensorEventListener,
public boolean onTouchEvent(final MotionEvent ev) {
boolean canReadToolType = Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH;
boolean retval = false;
int numTouchesHandled = 0;
for (int i = 0; i < ev.getPointerCount(); i++) {
int pid = ev.getPointerId(i);
int code = 0;
@ -103,10 +103,11 @@ public class NativeGLView extends GLSurfaceView implements SensorEventListener,
int tool = getToolType(ev, i);
code |= tool << 10; // We use the Android tool type codes
}
retval = retval || NativeApp.touch(ev.getX(i), ev.getY(i), code, pid);
// Can't use || due to short circuit evaluation
numTouchesHandled += NativeApp.touch(ev.getX(i), ev.getY(i), code, pid) ? 1 : 0;
}
}
return retval;
return numTouchesHandled > 0;
}
// Sensor management