This doesn't have to solve his problem.

You need to know what the ABS_X and ABS_Y values you are getting from
the touchscreen, then you'll know if you need to calibrate your
touchscreen.

On Jun 22, 9:31 pm, Elvis Dowson <elvis.dow...@gmail.com> wrote:
> Hi,       Try applying this patch.
>
> diff --git a/services/java/com/android/server/InputDevice.java
> b/services/java/com/android/server/InputDevice.java
> index 7b8a2a4..d9304c1 100644
> --- a/services/java/com/android/server/InputDevice.java
> +++ b/services/java/com/android/server/InputDevice.java
> @@ -21,10 +21,15 @@ import android.view.Display;
>  import android.view.MotionEvent;
>  import android.view.Surface;
>  import android.view.WindowManagerPolicy;
> +import java.io.FileInputStream;
> +import java.util.StringTokenizer;
>
>  public class InputDevice {
>      /** Amount that trackball needs to move in order to generate a key
> event. */
>      static final int TRACKBALL_MOVEMENT_THRESHOLD = 6;
> +
> +    /** Touchscreen calibration file. */
> +    static final String CALIBRATION_FILE = "/etc/pointercal";
>
>      final int id;
>      final int classes;
> @@ -33,6 +38,7 @@ public class InputDevice {
>      final AbsoluteInfo absY;
>      final AbsoluteInfo absPressure;
>      final AbsoluteInfo absSize;
> +    final TransformInfo tInfo;
>
>      long mDownTime = 0;
>      int mMetaKeysState = 0;
> @@ -86,12 +92,24 @@ public class InputDevice {
>                      h = tmp;
>                  }
>                  if (device.absX != null) {
> -                    scaledX = ((scaledX-device.absX.minValue)
> -                                / device.absX.range) * w;
> +     if (device.tInfo != null)
> +                     scaledX = (device.tInfo.x1 * x +
> +                                  device.tInfo.y1 * y +
> +                                   device.tInfo.z1)
> +   / device.tInfo.s;
> +    else
> +                     scaledX = ((scaledX-device.absX.minValue)
> +                                    / device.absX.range) * w;
>                  }
>                  if (device.absY != null) {
> -                    scaledY = ((scaledY-device.absY.minValue)
> -                                / device.absY.range) * h;
> +    if (device.tInfo != null)
> +                     scaledY = (device.tInfo.x2 * x +
> +                                  device.tInfo.y2 * y +
> +                                   device.tInfo.z2)
> +   / device.tInfo.s;
> +    else
> +                     scaledY = ((scaledY-device.absY.minValue)
> +                                    / device.absY.range) * h;
>                  }
>                  if (device.absPressure != null) {
>                      scaledPressure =
> @@ -199,6 +217,16 @@ public class InputDevice {
>          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) {
> @@ -209,5 +237,38 @@ 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;
> +
>      }
>  };
>
> Elvis
--~--~---------~--~----~------------~-------~--~----~
unsubscribe: android-porting+unsubscr...@googlegroups.com
website: http://groups.google.com/group/android-porting
-~----------~----~----~----~------~----~------~--~---

Reply via email to