• R/O
  • HTTP
  • SSH
  • HTTPS

提交

标签
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

frameworks/base


Commit MetaInfo

修订版edcd7bd19e561768440f2b6debabedeeeaa9dbae (tree)
时间2014-08-27 19:18:43
作者Chih-Wei Huang <cwhuang@linu...>
CommiterChih-Wei Huang

Log Message

InputReader: add 5-point calibration

Updated for kitkat-x86.

更改概述

差异

--- a/services/input/InputReader.cpp
+++ b/services/input/InputReader.cpp
@@ -3479,6 +3479,16 @@ void TouchInputMapper::parseCalibration() {
34793479 coverageCalibrationString.string());
34803480 }
34813481 }
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+ }
34823492 }
34833493
34843494 void TouchInputMapper::resolveCalibration() {
@@ -4249,13 +4259,27 @@ void TouchInputMapper::cookPointerData() {
42494259 break;
42504260 }
42514261
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+
42524276 // X, Y, and the bounding box for coverage information
42534277 // Adjust coords for surface orientation.
42544278 float x, y, left, top, right, bottom;
42554279 switch (mSurfaceOrientation) {
42564280 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;
42594283 left = float(rawTop - mRawPointerAxes.y.minValue) * mYScale + mYTranslate;
42604284 right = float(rawBottom- mRawPointerAxes.y.minValue) * mYScale + mYTranslate;
42614285 bottom = float(mRawPointerAxes.x.maxValue - rawLeft) * mXScale + mXTranslate;
@@ -4266,8 +4290,8 @@ void TouchInputMapper::cookPointerData() {
42664290 }
42674291 break;
42684292 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;
42714295 left = float(mRawPointerAxes.x.maxValue - rawRight) * mXScale + mXTranslate;
42724296 right = float(mRawPointerAxes.x.maxValue - rawLeft) * mXScale + mXTranslate;
42734297 bottom = float(mRawPointerAxes.y.maxValue - rawTop) * mYScale + mYTranslate;
@@ -4278,8 +4302,8 @@ void TouchInputMapper::cookPointerData() {
42784302 }
42794303 break;
42804304 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;
42834307 left = float(mRawPointerAxes.y.maxValue - rawBottom) * mYScale + mYTranslate;
42844308 right = float(mRawPointerAxes.y.maxValue - rawTop) * mYScale + mYTranslate;
42854309 bottom = float(rawRight - mRawPointerAxes.x.minValue) * mXScale + mXTranslate;
@@ -4290,8 +4314,8 @@ void TouchInputMapper::cookPointerData() {
42904314 }
42914315 break;
42924316 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;
42954319 left = float(rawLeft - mRawPointerAxes.x.minValue) * mXScale + mXTranslate;
42964320 right = float(rawRight - mRawPointerAxes.x.minValue) * mXScale + mXTranslate;
42974321 bottom = float(rawBottom - mRawPointerAxes.y.minValue) * mYScale + mYTranslate;
--- a/services/input/InputReader.h
+++ b/services/input/InputReader.h
@@ -1290,6 +1290,9 @@ protected:
12901290 *outSize = 0;
12911291 }
12921292 }
1293+
1294+ // 5-point calibration parameters
1295+ int fiveCal[7];
12931296 } mCalibration;
12941297
12951298 // Raw pointer axis information from the driver.