Improve handling of size and orientation.

Some touch device drivers report the range of
ABS_MT_ORIENTATION as [0,1].  The Linux multitouch protocol
spec says that the 0 value should always be considered vertical.

Add a new 'box' calibration mode for size to handle the case
where width and height are being provided.  The 'diameter'
calibration mode is inadequate because it drops one of these
components.

Change-Id: I7bd744fdff95acd4044d295efe8bd7186dbe8061
This commit is contained in:
Jeff Brown
2012-06-25 17:31:23 -07:00
parent 88c997a5ab
commit 037f727f49
2 changed files with 15 additions and 8 deletions

View File

@@ -2620,7 +2620,6 @@ void TouchInputMapper::dump(String8& dump) {
dump.appendFormat(INDENT4 "GeometricScale: %0.3f\n", mGeometricScale);
dump.appendFormat(INDENT4 "PressureScale: %0.3f\n", mPressureScale);
dump.appendFormat(INDENT4 "SizeScale: %0.3f\n", mSizeScale);
dump.appendFormat(INDENT4 "OrientationCenter: %0.3f\n", mOrientationCenter);
dump.appendFormat(INDENT4 "OrientationScale: %0.3f\n", mOrientationScale);
dump.appendFormat(INDENT4 "DistanceScale: %0.3f\n", mDistanceScale);
dump.appendFormat(INDENT4 "HaveTilt: %s\n", toString(mHaveTilt));
@@ -3051,7 +3050,6 @@ void TouchInputMapper::configureSurface(nsecs_t when, bool* outResetNeeded) {
}
// Orientation
mOrientationCenter = 0;
mOrientationScale = 0;
if (mHaveTilt) {
mOrientedRanges.haveOrientation = true;
@@ -3067,10 +3065,13 @@ void TouchInputMapper::configureSurface(nsecs_t when, bool* outResetNeeded) {
if (mCalibration.orientationCalibration
== Calibration::ORIENTATION_CALIBRATION_INTERPOLATED) {
if (mRawPointerAxes.orientation.valid) {
mOrientationCenter = avg(mRawPointerAxes.orientation.minValue,
mRawPointerAxes.orientation.maxValue);
mOrientationScale = M_PI / (mRawPointerAxes.orientation.maxValue -
mRawPointerAxes.orientation.minValue);
if (mRawPointerAxes.orientation.maxValue > 0) {
mOrientationScale = M_PI_2 / mRawPointerAxes.orientation.maxValue;
} else if (mRawPointerAxes.orientation.minValue < 0) {
mOrientationScale = -M_PI_2 / mRawPointerAxes.orientation.minValue;
} else {
mOrientationScale = 0;
}
}
}
@@ -3284,6 +3285,8 @@ void TouchInputMapper::parseCalibration() {
out.sizeCalibration = Calibration::SIZE_CALIBRATION_GEOMETRIC;
} else if (sizeCalibrationString == "diameter") {
out.sizeCalibration = Calibration::SIZE_CALIBRATION_DIAMETER;
} else if (sizeCalibrationString == "box") {
out.sizeCalibration = Calibration::SIZE_CALIBRATION_BOX;
} else if (sizeCalibrationString == "area") {
out.sizeCalibration = Calibration::SIZE_CALIBRATION_AREA;
} else if (sizeCalibrationString != "default") {
@@ -3404,6 +3407,9 @@ void TouchInputMapper::dumpCalibration(String8& dump) {
case Calibration::SIZE_CALIBRATION_DIAMETER:
dump.append(INDENT4 "touch.size.calibration: diameter\n");
break;
case Calibration::SIZE_CALIBRATION_BOX:
dump.append(INDENT4 "touch.size.calibration: box\n");
break;
case Calibration::SIZE_CALIBRATION_AREA:
dump.append(INDENT4 "touch.size.calibration: area\n");
break;
@@ -3954,6 +3960,7 @@ void TouchInputMapper::cookPointerData() {
switch (mCalibration.sizeCalibration) {
case Calibration::SIZE_CALIBRATION_GEOMETRIC:
case Calibration::SIZE_CALIBRATION_DIAMETER:
case Calibration::SIZE_CALIBRATION_BOX:
case Calibration::SIZE_CALIBRATION_AREA:
if (mRawPointerAxes.touchMajor.valid && mRawPointerAxes.toolMajor.valid) {
touchMajor = in.touchMajor;
@@ -4050,7 +4057,7 @@ void TouchInputMapper::cookPointerData() {
switch (mCalibration.orientationCalibration) {
case Calibration::ORIENTATION_CALIBRATION_INTERPOLATED:
orientation = (in.orientation - mOrientationCenter) * mOrientationScale;
orientation = in.orientation * mOrientationScale;
break;
case Calibration::ORIENTATION_CALIBRATION_VECTOR: {
int32_t c1 = signExtendNybble((in.orientation & 0xf0) >> 4);

View File

@@ -1162,6 +1162,7 @@ protected:
SIZE_CALIBRATION_NONE,
SIZE_CALIBRATION_GEOMETRIC,
SIZE_CALIBRATION_DIAMETER,
SIZE_CALIBRATION_BOX,
SIZE_CALIBRATION_AREA,
};
@@ -1294,7 +1295,6 @@ private:
float mSizeScale;
float mOrientationCenter;
float mOrientationScale;
float mDistanceScale;