evdev-touchpad: Implement two finger scroll
authorJonas Ådahl <jadahl@gmail.com>
Thu, 27 Sep 2012 16:40:43 +0000 (18:40 +0200)
committerKristian Høgsberg <krh@bitplanet.net>
Tue, 16 Oct 2012 00:54:43 +0000 (20:54 -0400)
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
src/evdev-touchpad.c

index 9c028de..6a3217b 100644 (file)
@@ -477,9 +477,23 @@ touchpad_update_state(struct touchpad_dispatch *touchpad, uint32_t time)
 
                filter_motion(touchpad, &dx, &dy, time);
 
 
                filter_motion(touchpad, &dx, &dy, time);
 
-               touchpad->device->rel.dx = wl_fixed_from_double(dx);
-               touchpad->device->rel.dy = wl_fixed_from_double(dy);
-               touchpad->device->pending_events |= EVDEV_RELATIVE_MOTION;
+               if (touchpad->finger_state == TOUCHPAD_FINGERS_ONE) {
+                       touchpad->device->rel.dx = wl_fixed_from_double(dx);
+                       touchpad->device->rel.dy = wl_fixed_from_double(dy);
+                       touchpad->device->pending_events |=
+                               EVDEV_RELATIVE_MOTION;
+               } else if (touchpad->finger_state == TOUCHPAD_FINGERS_TWO) {
+                       if (dx != 0.0)
+                               notify_axis(touchpad->device->seat,
+                                           time,
+                                           WL_POINTER_AXIS_HORIZONTAL_SCROLL,
+                                           wl_fixed_from_double(dx));
+                       if (dy != 0.0)
+                               notify_axis(touchpad->device->seat,
+                                           time,
+                                           WL_POINTER_AXIS_VERTICAL_SCROLL,
+                                           wl_fixed_from_double(dy));
+               }
        }
 
        if (!(touchpad->state & TOUCHPAD_STATE_MOVE) &&
        }
 
        if (!(touchpad->state & TOUCHPAD_STATE_MOVE) &&
@@ -579,19 +593,22 @@ process_key(struct touchpad_dispatch *touchpad,
                touchpad->reset = 1;
                break;
        case BTN_TOOL_FINGER:
                touchpad->reset = 1;
                break;
        case BTN_TOOL_FINGER:
-               touchpad->finger_state &= ~TOUCHPAD_FINGERS_ONE;
                if (e->value)
                        touchpad->finger_state |= TOUCHPAD_FINGERS_ONE;
                if (e->value)
                        touchpad->finger_state |= TOUCHPAD_FINGERS_ONE;
+               else
+                       touchpad->finger_state &= ~TOUCHPAD_FINGERS_ONE;
                break;
        case BTN_TOOL_DOUBLETAP:
                break;
        case BTN_TOOL_DOUBLETAP:
-               touchpad->finger_state &= ~TOUCHPAD_FINGERS_TWO;
                if (e->value)
                        touchpad->finger_state |= TOUCHPAD_FINGERS_TWO;
                if (e->value)
                        touchpad->finger_state |= TOUCHPAD_FINGERS_TWO;
+               else
+                       touchpad->finger_state &= ~TOUCHPAD_FINGERS_TWO;
                break;
        case BTN_TOOL_TRIPLETAP:
                break;
        case BTN_TOOL_TRIPLETAP:
-               touchpad->finger_state &= ~TOUCHPAD_FINGERS_THREE;
                if (e->value)
                        touchpad->finger_state |= TOUCHPAD_FINGERS_THREE;
                if (e->value)
                        touchpad->finger_state |= TOUCHPAD_FINGERS_THREE;
+               else
+                       touchpad->finger_state &= ~TOUCHPAD_FINGERS_THREE;
                break;
        }
 }
                break;
        }
 }