diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2015-01-13 13:02:38 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2015-01-15 13:12:36 +1000 |
commit | 2348a6812a3cc575d729bee1d14a19d0a9b88651 (patch) | |
tree | 8cc48a96417d67beac8bcedbb7483652730d05b0 | |
parent | 0c4eaf5480168b468547cdb3bd8ce5247b5a5378 (diff) |
Fix for new libinput APIs
Scroll events carry multiple axes.
Left-handed config was renamed to drop the "button" bit
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | src/libinput.c | 59 |
2 files changed, 40 insertions, 21 deletions
diff --git a/configure.ac b/configure.ac index 485bd56..ed84fd6 100644 --- a/configure.ac +++ b/configure.ac @@ -45,7 +45,7 @@ XORG_DEFAULT_OPTIONS # Obtain compiler/linker options from server and required extensions PKG_CHECK_MODULES(XORG, [xorg-server >= 1.10] xproto [inputproto >= 2.2]) -PKG_CHECK_MODULES(LIBINPUT, [libinput >= 0.7.0]) +PKG_CHECK_MODULES(LIBINPUT, [libinput >= 0.8.0]) # Define a configure option for an alternate input module directory AC_ARG_WITH(xorg-module-dir, diff --git a/src/libinput.c b/src/libinput.c index aaede78..3df2932 100644 --- a/src/libinput.c +++ b/src/libinput.c @@ -59,9 +59,9 @@ /* libinput scales wheel events by DEFAULT_AXIS_STEP_DISTANCE, which is - currently 10. + currently 15. */ -#define DEFAULT_LIBINPUT_AXIS_STEP_DISTANCE 10 +#define DEFAULT_LIBINPUT_AXIS_STEP_DISTANCE 15 struct xf86libinput_driver { struct libinput *libinput; @@ -263,8 +263,8 @@ LibinputApplyConfig(DeviceIntPtr dev) driver_data->options.matrix[6], driver_data->options.matrix[7], driver_data->options.matrix[8]); - if (libinput_device_config_buttons_set_left_handed(device, - driver_data->options.left_handed) != LIBINPUT_CONFIG_STATUS_SUCCESS) + if (libinput_device_config_left_handed_set(device, + driver_data->options.left_handed) != LIBINPUT_CONFIG_STATUS_SUCCESS) xf86IDrvMsg(pInfo, X_ERROR, "Failed to set LeftHanded to %d\n", driver_data->options.left_handed); @@ -718,19 +718,38 @@ xf86libinput_handle_axis(InputInfoPtr pInfo, struct libinput_event_pointer *even DeviceIntPtr dev = pInfo->dev; struct xf86libinput *driver_data = pInfo->private; ValuatorMask *mask = driver_data->valuators; - int axis; double value; + enum libinput_pointer_axis axis; + enum libinput_pointer_axis_source source; - if (libinput_event_pointer_get_axis(event) == - LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL) - axis = 3; - else - axis = 2; + valuator_mask_zero(mask); - value = libinput_event_pointer_get_axis_value(event) / DEFAULT_LIBINPUT_AXIS_STEP_DISTANCE; + source = libinput_event_pointer_get_axis_source(event); + switch(source) { + case LIBINPUT_POINTER_AXIS_SOURCE_FINGER: + case LIBINPUT_POINTER_AXIS_SOURCE_WHEEL: + case LIBINPUT_POINTER_AXIS_SOURCE_CONTINUOUS: + break; + default: + return; + } - valuator_mask_zero(mask); - valuator_mask_set_double(mask, axis, value); + axis = LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL; + if (libinput_event_pointer_has_axis(event, axis)) { + if (source == LIBINPUT_POINTER_AXIS_SOURCE_WHEEL) + value = libinput_event_pointer_get_axis_value_discrete(event, axis); + else + value = libinput_event_pointer_get_axis_value(event, axis); + valuator_mask_set_double(mask, 3, value); + } + axis = LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL; + if (libinput_event_pointer_has_axis(event, axis)) { + if (source == LIBINPUT_POINTER_AXIS_SOURCE_WHEEL) + value = libinput_event_pointer_get_axis_value_discrete(event, axis); + else + value = libinput_event_pointer_get_axis_value(event, axis); + valuator_mask_set_double(mask, 2, value); + } xf86PostMotionEventM(dev, Relative, mask); } @@ -1036,17 +1055,17 @@ xf86libinput_parse_options(InputInfoPtr pInfo, } } - if (libinput_device_config_buttons_has_left_handed(device)) { + if (libinput_device_config_left_handed_is_available(device)) { BOOL left_handed = xf86SetBoolOption(pInfo->options, "LeftHanded", - libinput_device_config_buttons_get_left_handed(device)); - if (libinput_device_config_buttons_set_left_handed(device, - left_handed) != + libinput_device_config_left_handed_get(device)); + if (libinput_device_config_left_handed_set(device, + left_handed) != LIBINPUT_CONFIG_STATUS_SUCCESS) { xf86IDrvMsg(pInfo, X_ERROR, "Failed to set LeftHanded to %d\n", left_handed); - left_handed = libinput_device_config_buttons_get_left_handed(device); + left_handed = libinput_device_config_left_handed_get(device); } driver_data->options.left_handed = left_handed; } @@ -1469,7 +1488,7 @@ LibinputSetPropertyLeftHanded(DeviceIntPtr dev, data = (BOOL*)val->data; if (checkonly) { - int supported = libinput_device_config_buttons_has_left_handed(device); + int supported = libinput_device_config_left_handed_is_available(device); int left_handed = *data; if (!supported && left_handed) @@ -1702,7 +1721,7 @@ LibinputInitProperty(DeviceIntPtr dev) } - if (libinput_device_config_buttons_has_left_handed(device)) { + if (libinput_device_config_left_handed_is_available(device)) { BOOL left_handed = driver_data->options.left_handed; prop_left_handed = MakeAtom(PROP_LEFT_HANDED, |