import android.view.WindowManagerPolicy;
import java.io.PrintWriter;
+import java.io.FileInputStream;
+import java.util.StringTokenizer;
public class InputDevice {
static final boolean DEBUG_POINTERS = false;
private static final int JUMPY_TRANSITION_DROPS = 3;
private static final int JUMPY_DROP_LIMIT = 3;
+ static final String CALIBRATION_FILE = "/data/system/tslib/pointercal";
+
final int id;
final int classes;
final String name;
final AbsoluteInfo absY;
final AbsoluteInfo absPressure;
final AbsoluteInfo absSize;
+ final TransformInfo tInfo;
long mKeyDownTime = 0;
int mMetaKeysState = 0;
final AbsoluteInfo absY = device.absY;
final AbsoluteInfo absPressure = device.absPressure;
final AbsoluteInfo absSize = device.absSize;
+ final TransformInfo tInfo = device.tInfo;
for (int i=0; i<numPointers; i++) {
final int j = i * MotionEvent.NUM_SAMPLE_DATA;
+ final float x = reportData[j + MotionEvent.SAMPLE_X];
+ final float y = reportData[j + MotionEvent.SAMPLE_Y];
if (absX != null) {
- reportData[j + MotionEvent.SAMPLE_X] =
- ((reportData[j + MotionEvent.SAMPLE_X]-absX.minValue)
- / absX.range) * w;
+ reportData[j + MotionEvent.SAMPLE_X] = (tInfo != null) ?
+ (tInfo.x1 * x + tInfo.y1 * y + tInfo.z1) / tInfo.s
+ : ((x - absX.minValue) / absX.range) * w;
}
if (absY != null) {
- reportData[j + MotionEvent.SAMPLE_Y] =
- ((reportData[j + MotionEvent.SAMPLE_Y]-absY.minValue)
- / absY.range) * h;
+ reportData[j + MotionEvent.SAMPLE_Y] = (tInfo != null) ?
+ (tInfo.x2 * x + tInfo.y2 * y + tInfo.z2) / tInfo.s
+ : ((y - absY.minValue) / absY.range) * h;
}
if (absPressure != null) {
reportData[j + MotionEvent.SAMPLE_PRESSURE] =
}
};
+ static class TransformInfo {
+ float x1;
+ float y1;
+ float z1;
+ float x2;
+ float y2;
+ float z2;
+ float s;
+ };
+
InputDevice(int _id, int _classes, String _name,
AbsoluteInfo _absX, AbsoluteInfo _absY,
AbsoluteInfo _absPressure, AbsoluteInfo _absSize) {
absY = _absY;
absPressure = _absPressure;
absSize = _absSize;
+ TransformInfo t = null;
+ try {
+ FileInputStream is = new FileInputStream(CALIBRATION_FILE);
+ byte[] mBuffer = new byte[64];
+ int len = is.read(mBuffer);
+ is.close();
+ if (len > 0) {
+ int i;
+ for (i = 0 ; i < len ; i++) {
+ if (mBuffer[i] == '\n' || mBuffer[i] == 0) {
+ break;
+ }
+ }
+ len = i;
+ }
+ StringTokenizer st = new StringTokenizer( new String(mBuffer, 0, 0, len) );
+
+ t = new TransformInfo ();
+ t.x1 = Integer.parseInt( st.nextToken() );
+ t.y1 = Integer.parseInt( st.nextToken() );
+ t.z1 = Integer.parseInt( st.nextToken() );
+ t.x2 = Integer.parseInt( st.nextToken() );
+ t.y2 = Integer.parseInt( st.nextToken() );
+ t.z2 = Integer.parseInt( st.nextToken() );
+ t.s = Integer.parseInt( st.nextToken() );
+ } catch (java.io.FileNotFoundException e) {
+ } catch (java.io.IOException e) {
+ }
+ tInfo = t;
}
};