Hi,

John Cola wrote:
> Dear All
> In the latest open source, the InputDevice.java has been modified a
> lot.
> And I cannot have a touch calibration successfully after
> "ts_calibrate".
>
> Following is the formula
>
> if (device.tInfo != null){ //system/etc/pointercal exist!!
>        reportData[j + MotionEvent.SAMPLE_X] = (device.tInfo.x1 * ??? +
>  
> device.tInfo.y1 * ??? +
>  
> device.tInfo.z1) / device.tInfo.s;
> }else
>    reportData[j + MotionEvent.SAMPLE_X] =
>                             ((reportData[j + MotionEvent.SAMPLE_X]-
> absX.minValue)
>                                 / absX.range) * w;
>
> Which parameter should be assigned for "???" ? I've tried reportData[j
> + MotionEvent.SAMPLE_X]  and reportData[j + MotionEvent.SAMPLE_Y]  but
> still unable to work.
>
> BR
> John
>
>   
Can you try this one?

Michael

-- 
unsubscribe: android-porting+unsubscr...@googlegroups.com
website: http://groups.google.com/group/android-porting
diff --git a/services/java/com/android/server/InputDevice.java b/services/java/com/android/server/InputDevice.java
index 6eb6242..f1ed013 100644
--- a/services/java/com/android/server/InputDevice.java
+++ b/services/java/com/android/server/InputDevice.java
@@ -22,6 +22,9 @@ import android.view.MotionEvent;
 import android.view.Surface;
 import android.view.WindowManagerPolicy;
 
+import java.io.FileInputStream;
+import java.util.StringTokenizer;
+
 public class InputDevice {
     static final boolean DEBUG_POINTERS = false;
     static final boolean DEBUG_HACKS = false;
@@ -29,8 +32,10 @@ public class InputDevice {
     /** Amount that trackball needs to move in order to generate a key event. */
     static final int TRACKBALL_MOVEMENT_THRESHOLD = 6;
 
+    static final String CALIBRATION_FILE = "/system/etc/pointercal";
+
     /** Maximum number of pointers we will track and report. */
-    static final int MAX_POINTERS = 10;
+    static final int MAX_POINTERS = 2;
     
     final int id;
     final int classes;
@@ -39,6 +44,7 @@ public class InputDevice {
     final AbsoluteInfo absY;
     final AbsoluteInfo absPressure;
     final AbsoluteInfo absSize;
+    final TransformInfo tInfo;
     
     long mKeyDownTime = 0;
     int mMetaKeysState = 0;
@@ -595,15 +601,29 @@ public class InputDevice {
             final AbsoluteInfo absSize = device.absSize;
             for (int i=0; i<numPointers; i++) {
                 final int j = i * MotionEvent.NUM_SAMPLE_DATA;
+                float x = reportData[j + MotionEvent.SAMPLE_X];
+                float y = reportData[j + MotionEvent.SAMPLE_Y];
             
                 if (absX != null) {
-                    reportData[j + MotionEvent.SAMPLE_X] =
-                            ((reportData[j + MotionEvent.SAMPLE_X]-absX.minValue)
-                                / absX.range) * w;
+                    if (device.tInfo != null)
+                        reportData[j + MotionEvent.SAMPLE_X] =
+                            (device.tInfo.x1 * x +
+                             device.tInfo.y1 * y +
+                             device.tInfo.z1) / device.tInfo.s;
+                    else
+                        reportData[j + MotionEvent.SAMPLE_X] =
+                                ((reportData[j + MotionEvent.SAMPLE_X]-absX.minValue)
+                                    / absX.range) * w;
                 }
                 if (absY != null) {
-                    reportData[j + MotionEvent.SAMPLE_Y] =
-                            ((reportData[j + MotionEvent.SAMPLE_Y]-absY.minValue)
+                    if (device.tInfo != null)
+                        reportData[j + MotionEvent.SAMPLE_Y] =
+                            (device.tInfo.x2 * x +
+                             device.tInfo.y2 * y +
+                             device.tInfo.z2) / device.tInfo.s;
+                        else
+                            reportData[j + MotionEvent.SAMPLE_Y] =
+                                ((reportData[j + MotionEvent.SAMPLE_Y]-absY.minValue)
                                 / absY.range) * h;
                 }
                 if (absPressure != null) {
@@ -769,7 +789,17 @@ public class InputDevice {
         int flat;
         int fuzz;
     };
-    
+
+    static class TransformInfo {
+        float x1;
+        float y1;
+        float z1;
+        float x2;
+        float y2;
+        float z2;
+        float s;
+    };
+
     InputDevice(int _id, int _classes, String _name,
             AbsoluteInfo _absX, AbsoluteInfo _absY,
             AbsoluteInfo _absPressure, AbsoluteInfo _absSize) {
@@ -780,5 +810,34 @@ public class InputDevice {
         absY = _absY;
         absPressure = _absPressure;
         absSize = _absSize;
+        TransformInfo t = null;
+        try {
+            FileInputStream is = new FileInputStream(CALIBRATION_FILE);
+            byte[] mBuffer = new byte[64];
+            int len = is.read(mBuffer);
+            is.close();
+            if (len > 0) {
+                int i;
+                for (i = 0 ; i < len ; i++) {
+                    if (mBuffer[i] == '\n' || mBuffer[i] == 0) {
+                        break;
+                    }
+                }
+                len = i;
+            }
+            StringTokenizer st = new StringTokenizer( new String(mBuffer, 0, 0, len) );
+
+            t = new TransformInfo ();
+            t.x1 = Integer.parseInt( st.nextToken() );
+            t.y1 = Integer.parseInt( st.nextToken() );
+            t.z1 = Integer.parseInt( st.nextToken() );
+            t.x2 = Integer.parseInt( st.nextToken() );
+            t.y2 = Integer.parseInt( st.nextToken() );
+            t.z2 = Integer.parseInt( st.nextToken() );
+            t.s  = Integer.parseInt( st.nextToken() );
+        } catch (java.io.FileNotFoundException e) {
+        } catch (java.io.IOException e) {
+        }
+        tInfo = t;
     }
 };
diff --git a/services/java/com/android/server/KeyInputQueue.java b/services/java/com/android/server/KeyInputQueue.java
index d68ccfa..63dbf64 100644
--- a/services/java/com/android/server/KeyInputQueue.java
+++ b/services/java/com/android/server/KeyInputQueue.java
@@ -50,13 +50,13 @@ public abstract class KeyInputQueue {
 
     static final boolean DEBUG = false;
     static final boolean DEBUG_VIRTUAL_KEYS = false;
-    static final boolean DEBUG_POINTERS = false;
+    static final boolean DEBUG_POINTERS = true;
     
     /**
      * Turn on some hacks we have to improve the touch interaction with a
      * certain device whose screen currently is not all that good.
      */
-    static final boolean BAD_TOUCH_HACK = true;
+    static final boolean BAD_TOUCH_HACK = false;
     
     private static final String EXCLUDED_DEVICES_PATH = "etc/excluded-input-devices.xml";
 
diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java
index c3aeca4..f7c12eb 100644
--- a/services/java/com/android/server/am/ActivityManagerService.java
+++ b/services/java/com/android/server/am/ActivityManagerService.java
@@ -197,7 +197,7 @@ public final class ActivityManagerService extends ActivityManagerNative implemen
     // This is the maximum number of application processes we would like
     // to have running.  Due to the asynchronous nature of things, we can
     // temporarily go beyond this limit.
-    static final int MAX_PROCESSES = 2;
+    static final int MAX_PROCESSES = 10;
 
     // Set to false to leave processes running indefinitely, relying on
     // the kernel killing them as resources are required.

Reply via email to