[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#776990: xserver-xorg-input-elographics: inverted and swapped axes don't work



Package: xserver-xorg-input-elographics
Version: 1:1.4.1-1+fh1
Severity: normal
Tags: upstream patch

Inverted and swapped axes don't work:

- priv->swap_axes is set and never used, so clearly it cannot work.

- Limits are passed to InitValuatorAxisStruct which doesn't work
  (at least) with inverted axes (min > max), see clipAxis():

    /* If a value range is defined, clip. If not, do nothing */
    if (axis->max_value <= axis->min_value)
        return;

- Both things worked in older versions (e.g. squeeze).

- The changes since then even kept a comment
  (/* I will map coordinates myself */)
  which was now wrong and misleading (and is correct again after my
  patch).

- The attached patch restores the respective code from that version.

- The patched code is tested! (Unlike the current code which was
  obviously never tested, see first point.)

- I will have access to suitable touch screens for 1-2 more weeks
  (in case you'd like me to test other changes or so).
--- src/xf86Elo.c
+++ src/xf86Elo.c
@@ -307,6 +307,46 @@
 /*
  ***************************************************************************
  *
+ * xf86EloConvert --
+ *	Convert extended valuators to x and y suitable for core motion
+ *	events. Return True if ok and False if the requested conversion
+ *	can't be done for the specified valuators.
+ *
+ ***************************************************************************
+ */
+static void
+xf86EloConvert(EloPrivatePtr			priv,
+	       int		*x,
+	       int		*y)
+{
+  int		width = priv->max_x - priv->min_x;
+  int		height = priv->max_y - priv->min_y;
+  int		input_x, input_y;
+
+  DBG(3, ErrorF("EloConvert: Screen(%d) - x(%d), y(%d)\n", priv->screen_no, *x, *y));
+
+  if (width == 0) width = 1;
+  if (height == 0) height = 1;
+
+  if (priv->swap_axes) {
+    input_x = *y;
+    input_y = *x;
+  }
+  else {
+    input_x = *x;
+    input_y = *y;
+  }
+  *x = (priv->screen_width * (input_x - priv->min_x)) / width;
+  *y = (priv->screen_height -
+	(priv->screen_height * (input_y - priv->min_y)) / height);
+
+  DBG(3, ErrorF("EloConvert: Screen(%d) - x(%d), y(%d)\n", priv->screen_no, *x, *y));
+}
+
+
+/*
+ ***************************************************************************
+ *
  * xf86EloReadInput --
  *	Read all pending report packets from the touchscreen and enqueue
  *	them.
@@ -360,6 +400,8 @@
           cur_y = WORD_ASSEMBLY(priv->packet_buf[5], priv->packet_buf[6]);
           state = priv->packet_buf[2] & 0x07;
 
+          xf86EloConvert(priv, &cur_x, &cur_y);
+
           /*
            * Send events.
            *
@@ -722,14 +764,14 @@
 	/* I will map coordinates myself */
 	InitValuatorAxisStruct(dev, 0,
 			       axis_labels[0],
-			       priv->min_x, priv->max_x,
+			       -1, -1,
 			       9500,
 			       0     /* min_res */,
 			       9500  /* max_res */,
 			       Absolute);
 	InitValuatorAxisStruct(dev, 1,
 			       axis_labels[1],
-			       priv->min_y, priv->max_y,
+			       -1, -1,
 			       10500,
 			       0     /* min_res */,
 			       10500 /* max_res */,

Reply to: