am 7a1c32e7: Merge "Add support for detecting finger orientation." into honeycomb
* commit '7a1c32e719725787acda4885ad7bd8031975e8c7': Add support for detecting finger orientation.
This commit is contained in:
@@ -300,6 +300,17 @@ public class PointerLocationView extends View {
|
|||||||
mPaint.setARGB(255, pressureLevel, 128, 255 - pressureLevel);
|
mPaint.setARGB(255, pressureLevel, 128, 255 - pressureLevel);
|
||||||
drawOval(canvas, ps.mCoords.x, ps.mCoords.y, ps.mCoords.toolMajor,
|
drawOval(canvas, ps.mCoords.x, ps.mCoords.y, ps.mCoords.toolMajor,
|
||||||
ps.mCoords.toolMinor, ps.mCoords.orientation, mPaint);
|
ps.mCoords.toolMinor, ps.mCoords.orientation, mPaint);
|
||||||
|
|
||||||
|
// Draw the orientation arrow.
|
||||||
|
mPaint.setARGB(255, pressureLevel, 255, 0);
|
||||||
|
float orientationVectorX = (float) (Math.sin(-ps.mCoords.orientation)
|
||||||
|
* ps.mCoords.toolMajor * 0.7);
|
||||||
|
float orientationVectorY = (float) (Math.cos(-ps.mCoords.orientation)
|
||||||
|
* ps.mCoords.toolMajor * 0.7);
|
||||||
|
canvas.drawLine(
|
||||||
|
ps.mCoords.x - orientationVectorX, ps.mCoords.y - orientationVectorY,
|
||||||
|
ps.mCoords.x + orientationVectorX, ps.mCoords.y + orientationVectorY,
|
||||||
|
mPaint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -80,6 +80,10 @@ inline static float pythag(float x, float y) {
|
|||||||
return sqrtf(x * x + y * y);
|
return sqrtf(x * x + y * y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline static int32_t signExtendNybble(int32_t value) {
|
||||||
|
return value >= 8 ? value - 16 : value;
|
||||||
|
}
|
||||||
|
|
||||||
static inline const char* toString(bool value) {
|
static inline const char* toString(bool value) {
|
||||||
return value ? "true" : "false";
|
return value ? "true" : "false";
|
||||||
}
|
}
|
||||||
@@ -1917,6 +1921,8 @@ void TouchInputMapper::parseCalibration() {
|
|||||||
out.orientationCalibration = Calibration::ORIENTATION_CALIBRATION_NONE;
|
out.orientationCalibration = Calibration::ORIENTATION_CALIBRATION_NONE;
|
||||||
} else if (orientationCalibrationString == "interpolated") {
|
} else if (orientationCalibrationString == "interpolated") {
|
||||||
out.orientationCalibration = Calibration::ORIENTATION_CALIBRATION_INTERPOLATED;
|
out.orientationCalibration = Calibration::ORIENTATION_CALIBRATION_INTERPOLATED;
|
||||||
|
} else if (orientationCalibrationString == "vector") {
|
||||||
|
out.orientationCalibration = Calibration::ORIENTATION_CALIBRATION_VECTOR;
|
||||||
} else if (orientationCalibrationString != "default") {
|
} else if (orientationCalibrationString != "default") {
|
||||||
LOGW("Invalid value for touch.orientation.calibration: '%s'",
|
LOGW("Invalid value for touch.orientation.calibration: '%s'",
|
||||||
orientationCalibrationString.string());
|
orientationCalibrationString.string());
|
||||||
@@ -2152,6 +2158,9 @@ void TouchInputMapper::dumpCalibration(String8& dump) {
|
|||||||
case Calibration::ORIENTATION_CALIBRATION_INTERPOLATED:
|
case Calibration::ORIENTATION_CALIBRATION_INTERPOLATED:
|
||||||
dump.append(INDENT4 "touch.orientation.calibration: interpolated\n");
|
dump.append(INDENT4 "touch.orientation.calibration: interpolated\n");
|
||||||
break;
|
break;
|
||||||
|
case Calibration::ORIENTATION_CALIBRATION_VECTOR:
|
||||||
|
dump.append(INDENT4 "touch.orientation.calibration: vector\n");
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
assert(false);
|
assert(false);
|
||||||
}
|
}
|
||||||
@@ -2567,6 +2576,19 @@ void TouchInputMapper::dispatchTouch(nsecs_t when, uint32_t policyFlags,
|
|||||||
case Calibration::ORIENTATION_CALIBRATION_INTERPOLATED:
|
case Calibration::ORIENTATION_CALIBRATION_INTERPOLATED:
|
||||||
orientation = in.orientation * mLocked.orientationScale;
|
orientation = in.orientation * mLocked.orientationScale;
|
||||||
break;
|
break;
|
||||||
|
case Calibration::ORIENTATION_CALIBRATION_VECTOR: {
|
||||||
|
int32_t c1 = signExtendNybble((in.orientation & 0xf0) >> 4);
|
||||||
|
int32_t c2 = signExtendNybble(in.orientation & 0x0f);
|
||||||
|
if (c1 != 0 || c2 != 0) {
|
||||||
|
orientation = atan2f(c1, c2) * 0.5f;
|
||||||
|
float minorAxisScale = (16.0f - pythag(c1, c2)) / 16.0f;
|
||||||
|
toolMinor *= minorAxisScale;
|
||||||
|
touchMinor *= minorAxisScale;
|
||||||
|
} else {
|
||||||
|
orientation = 0;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
orientation = 0;
|
orientation = 0;
|
||||||
}
|
}
|
||||||
@@ -2586,7 +2608,6 @@ void TouchInputMapper::dispatchTouch(nsecs_t when, uint32_t policyFlags,
|
|||||||
case DISPLAY_ORIENTATION_180: {
|
case DISPLAY_ORIENTATION_180: {
|
||||||
x = mLocked.surfaceWidth - x;
|
x = mLocked.surfaceWidth - x;
|
||||||
y = mLocked.surfaceHeight - y;
|
y = mLocked.surfaceHeight - y;
|
||||||
orientation = - orientation;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DISPLAY_ORIENTATION_270: {
|
case DISPLAY_ORIENTATION_270: {
|
||||||
|
|||||||
@@ -680,6 +680,7 @@ protected:
|
|||||||
ORIENTATION_CALIBRATION_DEFAULT,
|
ORIENTATION_CALIBRATION_DEFAULT,
|
||||||
ORIENTATION_CALIBRATION_NONE,
|
ORIENTATION_CALIBRATION_NONE,
|
||||||
ORIENTATION_CALIBRATION_INTERPOLATED,
|
ORIENTATION_CALIBRATION_INTERPOLATED,
|
||||||
|
ORIENTATION_CALIBRATION_VECTOR,
|
||||||
};
|
};
|
||||||
|
|
||||||
OrientationCalibration orientationCalibration;
|
OrientationCalibration orientationCalibration;
|
||||||
|
|||||||
Reference in New Issue
Block a user