• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Aucun tag

Frequently used words (click to add to your profile)

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

frameworks/base


Commit MetaInfo

Révision8b3ef0923b08854d1593b91637c304e2f28a45ea (tree)
l'heure2012-01-01 21:32:46
AuteurChih-Wei Huang <cwhuang@linu...>
CommiterChih-Wei Huang

Message de Log

InputReader: add 5-point calibration

Change Summary

Modification

--- a/services/input/InputReader.cpp
+++ b/services/input/InputReader.cpp
@@ -2481,6 +2481,16 @@ void TouchInputMapper::parseCalibration() {
24812481 orientationCalibrationString.string());
24822482 }
24832483 }
2484+
2485+ // Get 5-point calibration parameters
2486+ FILE *file = fopen("/data/system/tslib/pointercal", "r");
2487+ int *p = out.fiveCal;
2488+ if (file) {
2489+ fscanf(file, "%d %d %d %d %d %d %d", &p[0], &p[1], &p[2], &p[3], &p[4], &p[5], &p[6]);
2490+ fclose(file);
2491+ } else {
2492+ p[6] = 0;
2493+ }
24842494 }
24852495
24862496 void TouchInputMapper::resolveCalibration() {
@@ -3191,33 +3201,47 @@ void TouchInputMapper::prepareTouches(int32_t* outEdgeFlags,
31913201 orientation = 0;
31923202 }
31933203
3204+ float x_temp = float(in.x - mRawAxes.x.minValue);
3205+ float y_temp = float(in.y - mRawAxes.y.minValue);
3206+ float x_cal, y_cal;
3207+ int *p = mCalibration.fiveCal;
3208+ if (p[6]) {
3209+ // Apply 5-point calibration algorithm
3210+ x_cal = (x_temp * p[0] + y_temp * p[1] + p[2] ) / p[6];
3211+ y_cal = (x_temp * p[3] + y_temp * p[4] + p[5] ) / p[6];
3212+ LOGV("5cal: x_temp=%f y_temp=%f x_cal=%f y_cal=%f", x_temp, y_temp, x_cal, y_cal);
3213+ } else {
3214+ x_cal = x_temp * mLocked.xScale;
3215+ y_cal = y_temp * mLocked.yScale;
3216+ }
3217+
31943218 // X and Y
31953219 // Adjust coords for surface orientation.
31963220 float x, y;
31973221 switch (mLocked.surfaceOrientation) {
31983222 case DISPLAY_ORIENTATION_90:
3199- x = float(in.y - mRawAxes.y.minValue) * mLocked.yScale;
3200- y = float(mRawAxes.x.maxValue - in.x) * mLocked.xScale;
3223+ x = y_cal;
3224+ y = mLocked.surfaceWidth - x_cal;
32013225 orientation -= M_PI_2;
32023226 if (orientation < - M_PI_2) {
32033227 orientation += M_PI;
32043228 }
32053229 break;
32063230 case DISPLAY_ORIENTATION_180:
3207- x = float(mRawAxes.x.maxValue - in.x) * mLocked.xScale;
3208- y = float(mRawAxes.y.maxValue - in.y) * mLocked.yScale;
3231+ x = mLocked.surfaceWidth - x_cal;
3232+ y = mLocked.surfaceHeight - y_cal;
32093233 break;
32103234 case DISPLAY_ORIENTATION_270:
3211- x = float(mRawAxes.y.maxValue - in.y) * mLocked.yScale;
3212- y = float(in.x - mRawAxes.x.minValue) * mLocked.xScale;
3235+ x = mLocked.surfaceHeight - y_cal;
3236+ y = x_cal;
32133237 orientation += M_PI_2;
32143238 if (orientation > M_PI_2) {
32153239 orientation -= M_PI;
32163240 }
32173241 break;
32183242 default:
3219- x = float(in.x - mRawAxes.x.minValue) * mLocked.xScale;
3220- y = float(in.y - mRawAxes.y.minValue) * mLocked.yScale;
3243+ x = x_cal;
3244+ y = y_cal;
32213245 break;
32223246 }
32233247
--- a/services/input/InputReader.h
+++ b/services/input/InputReader.h
@@ -873,6 +873,9 @@ protected:
873873 };
874874
875875 OrientationCalibration orientationCalibration;
876+
877+ // 5-point calibration parameters
878+ int fiveCal[7];
876879 } mCalibration;
877880
878881 // Raw axis information from the driver.