frameworks/base
修订版 | edcd7bd19e561768440f2b6debabedeeeaa9dbae (tree) |
---|---|
时间 | 2014-08-27 19:18:43 |
作者 | Chih-Wei Huang <cwhuang@linu...> |
Commiter | Chih-Wei Huang |
InputReader: add 5-point calibration
Updated for kitkat-x86.
@@ -3479,6 +3479,16 @@ void TouchInputMapper::parseCalibration() { | ||
3479 | 3479 | coverageCalibrationString.string()); |
3480 | 3480 | } |
3481 | 3481 | } |
3482 | + | |
3483 | + // Get 5-point calibration parameters | |
3484 | + FILE *file = fopen("/data/system/tslib/pointercal", "r"); | |
3485 | + int *p = out.fiveCal; | |
3486 | + if (file) { | |
3487 | + fscanf(file, "%d %d %d %d %d %d %d", &p[0], &p[1], &p[2], &p[3], &p[4], &p[5], &p[6]); | |
3488 | + fclose(file); | |
3489 | + } else { | |
3490 | + p[6] = 0; | |
3491 | + } | |
3482 | 3492 | } |
3483 | 3493 | |
3484 | 3494 | void TouchInputMapper::resolveCalibration() { |
@@ -4249,13 +4259,27 @@ void TouchInputMapper::cookPointerData() { | ||
4249 | 4259 | break; |
4250 | 4260 | } |
4251 | 4261 | |
4262 | + float x_temp = float(in.x - mRawPointerAxes.x.minValue); | |
4263 | + float y_temp = float(in.y - mRawPointerAxes.y.minValue); | |
4264 | + float x_cal, y_cal; | |
4265 | + int *p = mCalibration.fiveCal; | |
4266 | + if (p[6]) { | |
4267 | + // Apply 5-point calibration algorithm | |
4268 | + x_cal = (x_temp * p[0] + y_temp * p[1] + p[2] ) / p[6]; | |
4269 | + y_cal = (x_temp * p[3] + y_temp * p[4] + p[5] ) / p[6]; | |
4270 | + ALOGV("5cal: x_temp=%f y_temp=%f x_cal=%f y_cal=%f", x_temp, y_temp, x_cal, y_cal); | |
4271 | + } else { | |
4272 | + x_cal = x_temp * mXScale; | |
4273 | + y_cal = y_temp * mYScale; | |
4274 | + } | |
4275 | + | |
4252 | 4276 | // X, Y, and the bounding box for coverage information |
4253 | 4277 | // Adjust coords for surface orientation. |
4254 | 4278 | float x, y, left, top, right, bottom; |
4255 | 4279 | switch (mSurfaceOrientation) { |
4256 | 4280 | case DISPLAY_ORIENTATION_90: |
4257 | - x = float(in.y - mRawPointerAxes.y.minValue) * mYScale + mYTranslate; | |
4258 | - y = float(mRawPointerAxes.x.maxValue - in.x) * mXScale + mXTranslate; | |
4281 | + x = y_cal + mYTranslate; | |
4282 | + y = mSurfaceWidth - x_cal + mXTranslate; | |
4259 | 4283 | left = float(rawTop - mRawPointerAxes.y.minValue) * mYScale + mYTranslate; |
4260 | 4284 | right = float(rawBottom- mRawPointerAxes.y.minValue) * mYScale + mYTranslate; |
4261 | 4285 | bottom = float(mRawPointerAxes.x.maxValue - rawLeft) * mXScale + mXTranslate; |
@@ -4266,8 +4290,8 @@ void TouchInputMapper::cookPointerData() { | ||
4266 | 4290 | } |
4267 | 4291 | break; |
4268 | 4292 | case DISPLAY_ORIENTATION_180: |
4269 | - x = float(mRawPointerAxes.x.maxValue - in.x) * mXScale + mXTranslate; | |
4270 | - y = float(mRawPointerAxes.y.maxValue - in.y) * mYScale + mYTranslate; | |
4293 | + x = mSurfaceWidth - x_cal + mXTranslate; | |
4294 | + y = mSurfaceHeight - y_cal + mYTranslate; | |
4271 | 4295 | left = float(mRawPointerAxes.x.maxValue - rawRight) * mXScale + mXTranslate; |
4272 | 4296 | right = float(mRawPointerAxes.x.maxValue - rawLeft) * mXScale + mXTranslate; |
4273 | 4297 | bottom = float(mRawPointerAxes.y.maxValue - rawTop) * mYScale + mYTranslate; |
@@ -4278,8 +4302,8 @@ void TouchInputMapper::cookPointerData() { | ||
4278 | 4302 | } |
4279 | 4303 | break; |
4280 | 4304 | case DISPLAY_ORIENTATION_270: |
4281 | - x = float(mRawPointerAxes.y.maxValue - in.y) * mYScale + mYTranslate; | |
4282 | - y = float(in.x - mRawPointerAxes.x.minValue) * mXScale + mXTranslate; | |
4305 | + x = mSurfaceHeight - y_cal + mYTranslate; | |
4306 | + y = x_cal + mXTranslate; | |
4283 | 4307 | left = float(mRawPointerAxes.y.maxValue - rawBottom) * mYScale + mYTranslate; |
4284 | 4308 | right = float(mRawPointerAxes.y.maxValue - rawTop) * mYScale + mYTranslate; |
4285 | 4309 | bottom = float(rawRight - mRawPointerAxes.x.minValue) * mXScale + mXTranslate; |
@@ -4290,8 +4314,8 @@ void TouchInputMapper::cookPointerData() { | ||
4290 | 4314 | } |
4291 | 4315 | break; |
4292 | 4316 | default: |
4293 | - x = float(in.x - mRawPointerAxes.x.minValue) * mXScale + mXTranslate; | |
4294 | - y = float(in.y - mRawPointerAxes.y.minValue) * mYScale + mYTranslate; | |
4317 | + x = x_cal + mXTranslate; | |
4318 | + y = y_cal + mYTranslate; | |
4295 | 4319 | left = float(rawLeft - mRawPointerAxes.x.minValue) * mXScale + mXTranslate; |
4296 | 4320 | right = float(rawRight - mRawPointerAxes.x.minValue) * mXScale + mXTranslate; |
4297 | 4321 | bottom = float(rawBottom - mRawPointerAxes.y.minValue) * mYScale + mYTranslate; |
@@ -1290,6 +1290,9 @@ protected: | ||
1290 | 1290 | *outSize = 0; |
1291 | 1291 | } |
1292 | 1292 | } |
1293 | + | |
1294 | + // 5-point calibration parameters | |
1295 | + int fiveCal[7]; | |
1293 | 1296 | } mCalibration; |
1294 | 1297 | |
1295 | 1298 | // Raw pointer axis information from the driver. |