dy /= nchanged;
tp_filter_motion(tp, &dx, &dy, time);
-
- /* Require at least five px scrolling to start */
- if (dy <= -5.0 || dy >= 5.0)
- tp->scroll.direction |= (1 << LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL);
-
- if (dx <= -5.0 || dx >= 5.0)
- tp->scroll.direction |= (1 << LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL);
-
- if (dy != 0.0 &&
- (tp->scroll.direction & (1 << LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL))) {
- pointer_notify_axis(&tp->device->base,
- time,
- LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL,
- dy);
- }
-
- if (dx != 0.0 &&
- (tp->scroll.direction & (1 << LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL))) {
- pointer_notify_axis(&tp->device->base,
- time,
- LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL,
- dx);
- }
-}
-
-static void
-tp_stop_scroll_events(struct tp_dispatch *tp, uint64_t time)
-{
- /* terminate scrolling with a zero scroll event */
- if (tp->scroll.direction & (1 << LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL))
- pointer_notify_axis(&tp->device->base,
- time,
- LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL,
- 0);
- if (tp->scroll.direction & (1 << LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL))
- pointer_notify_axis(&tp->device->base,
- time,
- LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL,
- 0);
-
- tp->scroll.direction = 0;
+ evdev_post_scroll(tp->device, time, dx, dy);
}
static int
}
if (nfingers_down != 2) {
- tp_stop_scroll_events(tp, time);
+ evdev_stop_scroll(tp->device, time);
return 0;
}
consumed |= tp_post_button_events(tp, time);
if (consumed) {
- tp_stop_scroll_events(tp, time);
+ evdev_stop_scroll(tp->device, time);
return;
}
}
static int
-tp_init_scroll(struct tp_dispatch *tp)
-{
- tp->scroll.direction = 0;
-
- return 0;
-}
-
-static int
tp_init_palmdetect(struct tp_dispatch *tp,
struct evdev_device *device)
{
tp->hysteresis.margin_y =
diagonal / DEFAULT_HYSTERESIS_MARGIN_DENOMINATOR;
- if (tp_init_scroll(tp) != 0)
- return -1;
-
if (tp_init_accel(tp, diagonal) != 0)
return -1;
device->fd = fd;
device->pending_event = EVDEV_NONE;
device->devname = libevdev_get_name(device->evdev);
+ device->scroll.threshold = 5.0; /* Default may be overridden */
+ device->scroll.direction = 0;
matrix_init_identity(&device->abs.calibration);
matrix_init_identity(&device->abs.usermatrix);
return 0;
}
+void
+evdev_post_scroll(struct evdev_device *device,
+ uint64_t time,
+ double dx,
+ double dy)
+{
+ if (dy <= -device->scroll.threshold || dy >= device->scroll.threshold)
+ device->scroll.direction |= (1 << LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL);
+
+ if (dx <= -device->scroll.threshold || dx >= device->scroll.threshold)
+ device->scroll.direction |= (1 << LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL);
+
+ if (dy != 0.0 &&
+ (device->scroll.direction & (1 << LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL))) {
+ pointer_notify_axis(&device->base,
+ time,
+ LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL,
+ dy);
+ }
+
+ if (dx != 0.0 &&
+ (device->scroll.direction & (1 << LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL))) {
+ pointer_notify_axis(&device->base,
+ time,
+ LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL,
+ dx);
+ }
+}
+
+void
+evdev_stop_scroll(struct evdev_device *device, uint64_t time)
+{
+ /* terminate scrolling with a zero scroll event */
+ if (device->scroll.direction & (1 << LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL))
+ pointer_notify_axis(&device->base,
+ time,
+ LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL,
+ 0);
+ if (device->scroll.direction & (1 << LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL))
+ pointer_notify_axis(&device->base,
+ time,
+ LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL,
+ 0);
+
+ device->scroll.direction = 0;
+}
+
static void
release_pressed_keys(struct evdev_device *device)
{
int dx, dy;
} rel;
+ struct {
+ double threshold;
+ uint32_t direction;
+ } scroll;
+
enum evdev_event_type pending_event;
enum evdev_device_seat_capability seat_caps;
enum evdev_device_tags tags;
enum libinput_button_state state);
void
+evdev_post_scroll(struct evdev_device *device,
+ uint64_t time,
+ double dx,
+ double dy);
+
+
+void
+evdev_stop_scroll(struct evdev_device *device, uint64_t time);
+
+void
evdev_device_remove(struct evdev_device *device);
void