summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2014-11-18 11:38:38 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2014-11-20 08:18:10 +1000
commit805f482423b5cc11a65818ff6adfcbddad8d2228 (patch)
tree6d4ae2f6c1bfd47c6883c013fb5272f5a4d59a12
parent044b11ec3595d88b2dd762bea95dcb8fbd53a86e (diff)
downloadlibinput-805f482423b5cc11a65818ff6adfcbddad8d2228.tar.gz
evdev: enable natural scrolling for all pointer devices
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
-rw-r--r--src/evdev.c51
-rw-r--r--src/evdev.h2
2 files changed, 34 insertions, 19 deletions
diff --git a/src/evdev.c b/src/evdev.c
index d0ddc374..bd742a6b 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -525,12 +525,25 @@ evdev_process_absolute_motion(struct evdev_device *device,
}
}
+static void
+evdev_notify_axis(struct evdev_device *device,
+ uint64_t time,
+ enum libinput_pointer_axis axis,
+ double value)
+{
+ if (device->scroll.natural_scrolling_enabled)
+ value *= -1;
+
+ pointer_notify_axis(&device->base,
+ time,
+ axis,
+ value);
+}
+
static inline void
evdev_process_relative(struct evdev_device *device,
struct input_event *e, uint64_t time)
{
- struct libinput_device *base = &device->base;
-
switch (e->code) {
case REL_X:
if (device->pending_event != EVDEV_RELATIVE_MOTION)
@@ -546,16 +559,16 @@ evdev_process_relative(struct evdev_device *device,
break;
case REL_WHEEL:
evdev_flush_pending_event(device, time);
- pointer_notify_axis(
- base,
+ evdev_notify_axis(
+ device,
time,
LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL,
-1 * e->value * DEFAULT_AXIS_STEP_DISTANCE);
break;
case REL_HWHEEL:
evdev_flush_pending_event(device, time);
- pointer_notify_axis(
- base,
+ evdev_notify_axis(
+ device,
time,
LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL,
e->value * DEFAULT_AXIS_STEP_DISTANCE);
@@ -1037,6 +1050,9 @@ fallback_dispatch_create(struct libinput_device *device)
return NULL;
}
+ if (evdev_device->scroll.natural_scrolling_enabled)
+ evdev_init_natural_scroll(evdev_device);
+
evdev_init_calibration(evdev_device, dispatch);
evdev_init_sendevents(evdev_device, dispatch);
@@ -1388,6 +1404,8 @@ evdev_configure_device(struct evdev_device *device)
/* want left-handed config option */
device->buttons.want_left_handed = true;
+ /* want natural-scroll config option */
+ device->scroll.natural_scrolling_enabled = true;
}
if (has_rel && has_button) {
@@ -1712,11 +1730,6 @@ evdev_post_scroll(struct evdev_device *device,
{
double trigger_horiz, trigger_vert;
- if (device->scroll.natural_scrolling_enabled) {
- dx = -dx;
- dy = -dy;
- }
-
if (!evdev_is_scrolling(device,
LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL))
device->scroll.buildup_vertical += dy;
@@ -1759,19 +1772,19 @@ evdev_post_scroll(struct evdev_device *device,
if (dy != 0.0 &&
evdev_is_scrolling(device,
LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL)) {
- pointer_notify_axis(&device->base,
- time,
- LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL,
- dy);
+ evdev_notify_axis(device,
+ time,
+ LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL,
+ dy);
}
if (dx != 0.0 &&
evdev_is_scrolling(device,
LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL)) {
- pointer_notify_axis(&device->base,
- time,
- LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL,
- dx);
+ evdev_notify_axis(device,
+ time,
+ LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL,
+ dx);
}
}
diff --git a/src/evdev.h b/src/evdev.h
index b8191cce..35da3195 100644
--- a/src/evdev.h
+++ b/src/evdev.h
@@ -117,6 +117,8 @@ struct evdev_device {
double buildup_horizontal;
struct libinput_device_config_natural_scroll config_natural;
+ /* set during device init if we want natural scrolling,
+ * used at runtime to enable/disable the feature */
bool natural_scrolling_enabled;
} scroll;