Hi again,

I find the mouse emulation code for synaptics touch pads in your patch 
really weird. I've tried to understand what it does, and why it
behaves badly for me on the first tap (move the pointer in the upper
right direction every time), but I fail to understand the logic.

So I've written a different code which produces better results and is
simpler to understand. It computes relative motion events
after the 2nd one, and sends any event with relative motion or button
state changes.

This is a diff against the pms.c resulting of your previous patch to tech@

--- pms.c.as    Sun May  8 10:49:02 2011
+++ pms.c       Sun May  8 11:14:05 2011
@@ -73,11 +73,10 @@
        /* Compat mode */
        int wsmode;
        int old_x, old_y;
+       u_int old_buttons;
        int count;
-#define SYNAPTICS_COUNT                2
 #define SYNAPTICS_SCALE                4
 #define SYNAPTICS_PRESSURE     30
-#define SYNAPTICS_MAXSPEED     30
 
        int dev_pt_attach;
 };
@@ -912,36 +911,23 @@
                    WSMOUSE_INPUT_ABSOLUTE_X | WSMOUSE_INPUT_ABSOLUTE_Y |
                    WSMOUSE_INPUT_ABSOLUTE_Z | WSMOUSE_INPUT_ABSOLUTE_W);
        } else {
-               if (syn->count < SYNAPTICS_COUNT) {
-                       syn->old_x += x;
-                       syn->old_y += y;
-                       syn->count++;
-                       return;
+               dx = dy = 0;
+               if (syn->count != 0) {
+                       dx = x - syn->old_x;
+                       dy = y - syn->old_y;
+                       dx /= SYNAPTICS_SCALE;
+                       dy /= SYNAPTICS_SCALE;
                }
-
-               syn->old_x /= SYNAPTICS_COUNT;
-               syn->old_y /= SYNAPTICS_COUNT;
-               dx = x - syn->old_x;
-               dy = y - syn->old_y;
-               syn->old_x = (dx % SYNAPTICS_SCALE) * SYNAPTICS_COUNT;
-               syn->old_y = (dy % SYNAPTICS_SCALE) * SYNAPTICS_COUNT;
-               dx /= SYNAPTICS_SCALE;
-               dy /= SYNAPTICS_SCALE;
-               syn->count = 0;
-
-               if (z < SYNAPTICS_PRESSURE) {
-                       dx = dy = 0;
-                       syn->old_x = syn->old_y = 0;
+               if (z < SYNAPTICS_PRESSURE)
                        syn->count = 0;
-               }
-
-               if (abs(dx) > SYNAPTICS_MAXSPEED)
-                       dx = SYNAPTICS_MAXSPEED * dx / abs(dx);
-               if (abs(dy) > SYNAPTICS_MAXSPEED)
-                       dy = SYNAPTICS_MAXSPEED * dy / abs(dy);
-
-               wsmouse_input(sc->sc_wsmousedev, buttons, dx, dy, 0, 0,
-                   WSMOUSE_INPUT_DELTA);
+               else
+                       syn->count++;
+               if (dx || dy || buttons != syn->old_buttons) 
+                       wsmouse_input(sc->sc_wsmousedev, buttons, dx, dy, 0, 0,
+                           WSMOUSE_INPUT_DELTA);
+               syn->old_x = x;
+               syn->old_y = y;
+               syn->old_buttons = buttons;
        }
 }
 

-- 
Matthieu Herrb

Reply via email to