Compare commits

...

14 Commits

Author SHA1 Message Date
Peter Hutterer
7b3b04b518 xf86-input-libinput 0.8.0
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-03-06 15:32:58 +10:00
Boyan Ding
4ac531bdf6 Initialize variable 'path' to NULL to silence warning
CC       libinput.lo
libinput.c: In function 'xf86libinput_pre_init':
libinput.c:1222:2: warning: 'path' may be used uninitialized in this
function [-Wmaybe-uninitialized]
  free(path);
  ^

Signed-off-by: Boyan Ding <boyan.j.ding@gmail.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-03-06 14:50:38 +10:00
Peter Hutterer
7ec0bf7ae2 Up the scroll dist value for touchpads
For source FINGER and CONTINUOUS, the axis value is the same as relative
motion - but scrolling in X usually doesn't have the same speed as finger
movement, it's a lot coarser.

We don't know ahead of time where we'll get the scroll events from. Set a
default scroll distance of 15 and multiply any wheel clicks we get by this
value.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-03-05 19:07:28 +10:00
Peter Hutterer
2ffd8d14be Apply the configuration before initalizing the property
Otherwise the property contains the device defaults, rather than the xorg.conf
options.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-03-02 10:43:07 +10:00
Peter Hutterer
e9a0ee69cb Don't unref the device until we're done with it in DEVICE_INIT
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-03-02 10:42:03 +10:00
Peter Hutterer
fb6506f5ee Add properties to change the click method (#89332)
X.Org Bug 89332 <http://bugs.freedesktop.org/show_bug.cgi?id=89332>

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-02-26 17:06:10 +10:00
Peter Hutterer
275c712866 Split out property init into helper functions
Makes the code less messy. Only functional change is that if one property
fails to initialize we'll now continue with the others. Previously the first
failed property would prevent any other property init.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-02-26 16:54:54 +10:00
Peter Hutterer
2455f0d03b Use the new libinput_device_pointer_has_button
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-02-26 16:09:50 +10:00
Olivier Fourdan
98ae01b9ae Ignore property changes if the device is disabled
If the device is present but disabled, the server will still call into
SetProperty. We don't have a libinput device to back it up in this case,
causing a null-pointer dereference.

This is a bug specific to this driver that cannot easily be fixed. All
other drivers can handle property changes even if no device is present,
here we rely on libinput to make the final call. But without a device
path/fd we don't have a libinput reference.

The protocol doesn't mention this case, so let's pick BadMatch as the
least wrong error code. And put a warning in the log, this needs a
workaround in the client.

Also, if we get here and the device is on, then that's definitely a bug,
warn about that.

https://bugs.freedesktop.org/show_bug.cgi?id=89296

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-02-26 08:10:24 +10:00
Peter Hutterer
2600a4a352 Fix off-by-one error in buttonmap initialization (#89300)
X.Org Bug 89300 <http://bugs.freedesktop.org/show_bug.cgi?id=89300>

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-02-25 07:50:45 +10:00
Peter Hutterer
278a685c5a xf86-input-libinput 0.7.0
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-02-24 14:45:12 +10:00
Peter Hutterer
875f1696b7 Only apply left-handed/scroll button configuration when it's available
https://bugs.freedesktop.org/show_bug.cgi?id=88961

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-02-04 14:14:13 +10:00
Friedrich Schöller
45e9b6c64b Reapply configuration at DEVICE_ON
The driver ignored my xorg configuration. Maybe I am doing something wrong,
but I tried to track down the error and came up with this solution.

The device is closed after DEVICE_INIT so we need to apply configuration
options at DEVICE_ON.

Signed-off-by: Friedrich Schöller <code@schoeller.se>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-01-30 09:47:22 +10:00
Peter Hutterer
dcdf1e24c8 Formatting fix
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-01-30 09:47:19 +10:00
4 changed files with 486 additions and 187 deletions

View File

@@ -23,7 +23,7 @@
# Initialize Autoconf
AC_PREREQ([2.60])
AC_INIT([xf86-input-libinput],
[0.6.0],
[0.8.0],
[https://bugs.freedesktop.org/enter_bug.cgi?product=xorg],
[xf86-input-libinput])
AC_CONFIG_SRCDIR([Makefile.am])
@@ -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.8.0])
PKG_CHECK_MODULES(LIBINPUT, [libinput >= 0.11.0])
# Define a configure option for an alternate input module directory
AC_ARG_WITH(xorg-module-dir,

View File

@@ -58,4 +58,12 @@
/* Scroll button for button scrolling: 32-bit int, 1 value */
#define LIBINPUT_PROP_SCROLL_BUTTON "libinput Button Scrolling Button"
/* Click method: BOOL read-only, 2 values in order buttonareas, clickfinger
shows available click methods */
#define LIBINPUT_PROP_CLICK_METHODS_AVAILABLE "libinput Click Methods Available"
/* Click method: BOOL, 2 values in order buttonareas, clickfinger
only one enabled at a time at max */
#define LIBINPUT_PROP_CLICK_METHOD_ENABLED "libinput Click Method Enabled"
#endif /* _LIBINPUT_PROPERTIES_H_ */

View File

@@ -53,6 +53,14 @@ A string of 9 space-separated floating point numbers.
Sets the calibration matrix to the 3x3 matrix where the first row is (abc),
the second row is (def) and the third row is (ghi).
.TP 7
.BI "Option \*qClickMethod\*q \*q" string \*q
Enables a click method. Permitted values are
.BI none,
.BI buttonareas,
.BI clickfinger.
Not all devices support all methods, if an option is unsupported, the
default click method for this device is used.
.TP 7
.BI "Option \*qLeftHanded\*q \*q" bool \*q
Enables left-handed button orientation, i.e. swapping left and right buttons.
.TP 7

View File

@@ -94,6 +94,7 @@ struct xf86libinput {
float speed;
float matrix[9];
enum libinput_config_scroll_method scroll_method;
enum libinput_config_click_method click_method;
} options;
};
@@ -259,7 +260,8 @@ LibinputApplyConfig(DeviceIntPtr dev)
driver_data->options.matrix[6], driver_data->options.matrix[7],
driver_data->options.matrix[8]);
if (libinput_device_config_left_handed_set(device,
if (libinput_device_config_left_handed_is_available(device) &&
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",
@@ -283,11 +285,30 @@ LibinputApplyConfig(DeviceIntPtr dev)
method);
}
scroll_button = btn_xorg2linux(driver_data->options.scroll_button);
if (libinput_device_config_scroll_set_button(device, scroll_button) != LIBINPUT_CONFIG_STATUS_SUCCESS)
if (libinput_device_config_scroll_get_methods(device) & LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN) {
scroll_button = btn_xorg2linux(driver_data->options.scroll_button);
if (libinput_device_config_scroll_set_button(device, scroll_button) != LIBINPUT_CONFIG_STATUS_SUCCESS)
xf86IDrvMsg(pInfo, X_ERROR,
"Failed to set ScrollButton to %d\n",
driver_data->options.scroll_button);
}
if (libinput_device_config_click_set_method(device,
driver_data->options.click_method) != LIBINPUT_CONFIG_STATUS_SUCCESS) {
const char *method;
switch (driver_data->options.click_method) {
case LIBINPUT_CONFIG_CLICK_METHOD_NONE: method = "none"; break;
case LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS: method = "buttonareas"; break;
case LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER: method = "clickfinger"; break;
default:
method = "unknown"; break;
}
xf86IDrvMsg(pInfo, X_ERROR,
"Failed to set ScrollButton to %d\n",
driver_data->options.scroll_button);
"Failed to set click method to %s\n",
method);
}
}
static int
@@ -326,6 +347,8 @@ xf86libinput_on(DeviceIntPtr dev)
driver_context.device_enabled_count++;
dev->public.on = TRUE;
LibinputApplyConfig(dev);
return Success;
}
@@ -367,7 +390,7 @@ init_button_map(unsigned char *btnmap, size_t size)
int i;
memset(btnmap, 0, size);
for (i = 0; i <= size; i++)
for (i = 0; i < size; i++)
btnmap[i] = i;
}
@@ -414,7 +437,7 @@ xf86libinput_init_pointer(InputInfoPtr pInfo)
Atom axislabels[TOUCHPAD_NUM_AXES];
for (i = BTN_BACK; i >= BTN_SIDE; i--) {
if (libinput_device_has_button(driver_data->device, i)) {
if (libinput_device_pointer_has_button(driver_data->device, i)) {
nbuttons += i - BTN_SIDE + 1;
break;
}
@@ -462,7 +485,7 @@ xf86libinput_init_pointer_absolute(InputInfoPtr pInfo)
Atom axislabels[TOUCHPAD_NUM_AXES];
for (i = BTN_BACK; i >= BTN_SIDE; i--) {
if (libinput_device_has_button(driver_data->device, i)) {
if (libinput_device_pointer_has_button(driver_data->device, i)) {
nbuttons += i - BTN_SIDE + 1;
break;
}
@@ -609,13 +632,14 @@ xf86libinput_init(DeviceIntPtr dev)
if (libinput_device_has_capability(device, LIBINPUT_DEVICE_CAP_TOUCH))
xf86libinput_init_touch(pInfo);
LibinputApplyConfig(dev);
LibinputInitProperty(dev);
XIRegisterPropertyHandler(dev, LibinputSetProperty, NULL, NULL);
/* unref the device now, because we'll get a new ref during
DEVICE_ON */
libinput_device_unref(device);
LibinputInitProperty(dev);
XIRegisterPropertyHandler(dev, LibinputSetProperty, NULL, NULL);
return 0;
}
@@ -732,18 +756,22 @@ xf86libinput_handle_axis(InputInfoPtr pInfo, struct libinput_event_pointer *even
axis = LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL;
if (libinput_event_pointer_has_axis(event, axis)) {
if (source == LIBINPUT_POINTER_AXIS_SOURCE_WHEEL)
if (source == LIBINPUT_POINTER_AXIS_SOURCE_WHEEL) {
value = libinput_event_pointer_get_axis_value_discrete(event, axis);
else
value *= driver_data->scroll_vdist;
} 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)
if (source == LIBINPUT_POINTER_AXIS_SOURCE_WHEEL) {
value = libinput_event_pointer_get_axis_value_discrete(event, axis);
else
value *= driver_data->scroll_hdist;
} else {
value = libinput_event_pointer_get_axis_value(event, axis);
}
valuator_mask_set_double(mask, 2, value);
}
@@ -943,6 +971,7 @@ xf86libinput_parse_options(InputInfoPtr pInfo,
struct libinput_device *device)
{
uint32_t scroll_methods;
uint32_t click_methods;
if (libinput_device_config_tap_get_finger_count(device) > 0) {
BOOL tap = xf86SetBoolOption(pInfo->options,
@@ -1113,16 +1142,42 @@ xf86libinput_parse_options(InputInfoPtr pInfo,
driver_data->options.scroll_button = scroll_button;
}
click_methods = libinput_device_config_click_get_methods(device);
if (click_methods != LIBINPUT_CONFIG_CLICK_METHOD_NONE) {
enum libinput_config_click_method m;
char *method = xf86SetStrOption(pInfo->options,
"ClickMethod",
NULL);
if (!method)
m = libinput_device_config_click_get_method(device);
else if (strncasecmp(method, "buttonareas", 11) == 0)
m = LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS;
else if (strncasecmp(method, "clickfinger", 11) == 0)
m = LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER;
else if (strncasecmp(method, "none", 4) == 0)
m = LIBINPUT_CONFIG_CLICK_METHOD_NONE;
else {
xf86IDrvMsg(pInfo, X_ERROR,
"Unknown click method '%s'. Using default.\n",
method);
m = libinput_device_config_click_get_method(device);
}
driver_data->options.click_method = m;
free(method);
}
}
static int xf86libinput_pre_init(InputDriverPtr drv,
InputInfoPtr pInfo,
int flags)
static int
xf86libinput_pre_init(InputDriverPtr drv,
InputInfoPtr pInfo,
int flags)
{
struct xf86libinput *driver_data = NULL;
struct libinput *libinput = NULL;
struct libinput_device *device;
char *path;
char *path = NULL;
pInfo->type_name = 0;
pInfo->device_control = xf86libinput_device_control;
@@ -1138,8 +1193,8 @@ static int xf86libinput_pre_init(InputDriverPtr drv,
if (!driver_data->valuators)
goto fail;
driver_data->scroll_vdist = 1;
driver_data->scroll_hdist = 1;
driver_data->scroll_vdist = 15;
driver_data->scroll_hdist = 15;
path = xf86SetStrOption(pInfo->options, "Device", NULL);
if (!path)
@@ -1281,12 +1336,34 @@ static Atom prop_left_handed;
static Atom prop_scroll_methods_available;
static Atom prop_scroll_method_enabled;
static Atom prop_scroll_button;
static Atom prop_click_methods_available;
static Atom prop_click_method_enabled;
/* general properties */
static Atom prop_float;
static Atom prop_device;
static Atom prop_product_id;
static inline BOOL
xf86libinput_check_device (DeviceIntPtr dev,
Atom atom)
{
InputInfoPtr pInfo = dev->public.devicePrivate;
struct xf86libinput *driver_data = pInfo->private;
struct libinput_device *device = driver_data->device;
if (device == NULL) {
BUG_WARN(dev->public.on);
xf86IDrvMsg(pInfo, X_INFO,
"SetProperty on %d called but device is disabled.\n"
"This driver cannot change properties on a disabled device\n",
atom);
return FALSE;
}
return TRUE;
}
static inline int
LibinputSetPropertyTap(DeviceIntPtr dev,
Atom atom,
@@ -1306,6 +1383,9 @@ LibinputSetPropertyTap(DeviceIntPtr dev,
if (*data != 0 && *data != 1)
return BadValue;
if (!xf86libinput_check_device (dev, atom))
return BadMatch;
if (libinput_device_config_tap_get_finger_count(device) == 0)
return BadMatch;
} else {
@@ -1337,6 +1417,9 @@ LibinputSetPropertyCalibration(DeviceIntPtr dev,
data[8] != 1)
return BadValue;
if (!xf86libinput_check_device (dev, atom))
return BadMatch;
if (!libinput_device_config_calibration_has_matrix(device))
return BadMatch;
} else {
@@ -1368,6 +1451,9 @@ LibinputSetPropertyAccel(DeviceIntPtr dev,
if (*data < -1 || *data > 1)
return BadValue;
if (!xf86libinput_check_device (dev, atom))
return BadMatch;
if (libinput_device_config_accel_is_available(device) == 0)
return BadMatch;
} else {
@@ -1397,6 +1483,9 @@ LibinputSetPropertyNaturalScroll(DeviceIntPtr dev,
if (*data != 0 && *data != 1)
return BadValue;
if (!xf86libinput_check_device (dev, atom))
return BadMatch;
if (libinput_device_config_scroll_has_natural_scroll(device) == 0)
return BadMatch;
} else {
@@ -1429,9 +1518,12 @@ LibinputSetPropertySendEvents(DeviceIntPtr dev,
modes |= LIBINPUT_CONFIG_SEND_EVENTS_DISABLED_ON_EXTERNAL_MOUSE;
if (checkonly) {
uint32_t supported =
libinput_device_config_send_events_get_modes(device);
uint32_t supported;
if (!xf86libinput_check_device (dev, atom))
return BadMatch;
supported = libinput_device_config_send_events_get_modes(device);
if ((modes | supported) != supported)
return BadValue;
@@ -1459,9 +1551,13 @@ LibinputSetPropertyLeftHanded(DeviceIntPtr dev,
data = (BOOL*)val->data;
if (checkonly) {
int supported = libinput_device_config_left_handed_is_available(device);
int supported;
int left_handed = *data;
if (!xf86libinput_check_device (dev, atom))
return BadMatch;
supported = libinput_device_config_left_handed_is_available(device);
if (!supported && left_handed)
return BadValue;
} else {
@@ -1496,11 +1592,15 @@ LibinputSetPropertyScrollMethods(DeviceIntPtr dev,
modes |= LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN;
if (checkonly) {
uint32_t supported = libinput_device_config_scroll_get_methods(device);
uint32_t supported;
if (__builtin_popcount(modes) > 1)
return BadValue;
if (!xf86libinput_check_device (dev, atom))
return BadMatch;
supported = libinput_device_config_scroll_get_methods(device);
if (modes && (modes & supported) == 0)
return BadValue;
} else {
@@ -1528,9 +1628,13 @@ LibinputSetPropertyScrollButton(DeviceIntPtr dev,
if (checkonly) {
uint32_t button = *data;
uint32_t supported = libinput_device_has_button(device,
btn_xorg2linux(button));
uint32_t supported;
if (!xf86libinput_check_device (dev, atom))
return BadMatch;
supported = libinput_device_pointer_has_button(device,
btn_xorg2linux(button));
if (button && !supported)
return BadValue;
} else {
@@ -1540,6 +1644,48 @@ LibinputSetPropertyScrollButton(DeviceIntPtr dev,
return Success;
}
static inline int
LibinputSetPropertyClickMethod(DeviceIntPtr dev,
Atom atom,
XIPropertyValuePtr val,
BOOL checkonly)
{
InputInfoPtr pInfo = dev->public.devicePrivate;
struct xf86libinput *driver_data = pInfo->private;
struct libinput_device *device = driver_data->device;
BOOL* data;
uint32_t modes = 0;
if (val->format != 8 || val->size != 2 || val->type != XA_INTEGER)
return BadMatch;
data = (BOOL*)val->data;
if (data[0])
modes |= LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS;
if (data[1])
modes |= LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER;
if (checkonly) {
uint32_t supported;
if (__builtin_popcount(modes) > 1)
return BadValue;
if (!xf86libinput_check_device(dev, atom))
return BadMatch;
supported = libinput_device_config_click_get_methods(device);
if (modes && (modes & supported) == 0)
return BadValue;
} else {
driver_data->options.click_method = modes;
}
return Success;
}
static int
LibinputSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val,
BOOL checkonly)
@@ -1567,6 +1713,10 @@ LibinputSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val,
rc = LibinputSetPropertyScrollMethods(dev, atom, val, checkonly);
else if (atom == prop_scroll_button)
rc = LibinputSetPropertyScrollButton(dev, atom, val, checkonly);
else if (atom == prop_click_methods_available)
return BadAccess; /* read-only */
else if (atom == prop_click_method_enabled)
rc = LibinputSetPropertyClickMethod(dev, atom, val, checkonly);
else if (atom == prop_device || atom == prop_product_id)
return BadAccess; /* read-only */
else
@@ -1579,196 +1729,240 @@ LibinputSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val,
}
static void
LibinputInitProperty(DeviceIntPtr dev)
LibinputInitTapProperty(DeviceIntPtr dev,
struct xf86libinput *driver_data,
struct libinput_device *device)
{
InputInfoPtr pInfo = dev->public.devicePrivate;
struct xf86libinput *driver_data = pInfo->private;
struct libinput_device *device = driver_data->device;
const char *device_node;
CARD32 product[2];
uint32_t scroll_methods;
uint32_t sendevent_modes;
BOOL tap = driver_data->options.tapping;
int rc;
prop_float = XIGetKnownProperty("FLOAT");
if (libinput_device_config_tap_get_finger_count(device) == 0)
return;
if (libinput_device_config_tap_get_finger_count(device) > 0) {
BOOL tap = driver_data->options.tapping;
prop_tap = MakeAtom(LIBINPUT_PROP_TAP, strlen(LIBINPUT_PROP_TAP), TRUE);
rc = XIChangeDeviceProperty(dev, prop_tap, XA_INTEGER, 8,
PropModeReplace, 1, &tap, FALSE);
if (rc != Success)
return;
XISetDevicePropertyDeletable(dev, prop_tap, FALSE);
}
prop_tap = MakeAtom(LIBINPUT_PROP_TAP, strlen(LIBINPUT_PROP_TAP), TRUE);
rc = XIChangeDeviceProperty(dev, prop_tap, XA_INTEGER, 8,
PropModeReplace, 1, &tap, FALSE);
if (rc != Success)
return;
XISetDevicePropertyDeletable(dev, prop_tap, FALSE);
}
static void
LibinputInitCalibrationProperty(DeviceIntPtr dev,
struct xf86libinput *driver_data,
struct libinput_device *device)
{
float calibration[9];
int rc;
if (!libinput_device_config_calibration_has_matrix(device))
return;
/* We use a 9-element matrix just to be closer to the X server's
transformation matrix which also has the full matrix */
if (libinput_device_config_calibration_has_matrix(device)) {
float calibration[9];
libinput_device_config_calibration_get_matrix(device, calibration);
calibration[6] = 0;
calibration[7] = 0;
calibration[8] = 1;
libinput_device_config_calibration_get_matrix(device, calibration);
calibration[6] = 0;
calibration[7] = 0;
calibration[8] = 1;
prop_calibration = MakeAtom(LIBINPUT_PROP_CALIBRATION,
strlen(LIBINPUT_PROP_CALIBRATION),
TRUE);
prop_calibration = MakeAtom(LIBINPUT_PROP_CALIBRATION,
strlen(LIBINPUT_PROP_CALIBRATION),
TRUE);
rc = XIChangeDeviceProperty(dev, prop_calibration, prop_float, 32,
PropModeReplace, 9, calibration, FALSE);
if (rc != Success)
return;
XISetDevicePropertyDeletable(dev, prop_calibration, FALSE);
}
rc = XIChangeDeviceProperty(dev, prop_calibration, prop_float, 32,
PropModeReplace, 9, calibration, FALSE);
if (rc != Success)
return;
XISetDevicePropertyDeletable(dev, prop_calibration, FALSE);
}
if (libinput_device_config_accel_is_available(device)) {
float speed = driver_data->options.speed;
static void
LibinputInitAccelProperty(DeviceIntPtr dev,
struct xf86libinput *driver_data,
struct libinput_device *device)
{
float speed = driver_data->options.speed;
int rc;
prop_accel = MakeAtom(LIBINPUT_PROP_ACCEL, strlen(LIBINPUT_PROP_ACCEL), TRUE);
rc = XIChangeDeviceProperty(dev, prop_accel, prop_float, 32,
PropModeReplace, 1, &speed, FALSE);
if (rc != Success)
return;
XISetDevicePropertyDeletable(dev, prop_accel, FALSE);
}
if (!libinput_device_config_accel_is_available(device))
return;
if (libinput_device_config_scroll_has_natural_scroll(device)) {
BOOL natural_scroll = driver_data->options.natural_scrolling;
prop_accel = MakeAtom(LIBINPUT_PROP_ACCEL, strlen(LIBINPUT_PROP_ACCEL), TRUE);
rc = XIChangeDeviceProperty(dev, prop_accel, prop_float, 32,
PropModeReplace, 1, &speed, FALSE);
if (rc != Success)
return;
XISetDevicePropertyDeletable(dev, prop_accel, FALSE);
}
prop_natural_scroll = MakeAtom(LIBINPUT_PROP_NATURAL_SCROLL,
strlen(LIBINPUT_PROP_NATURAL_SCROLL),
TRUE);
rc = XIChangeDeviceProperty(dev, prop_natural_scroll, XA_INTEGER, 8,
PropModeReplace, 1, &natural_scroll, FALSE);
if (rc != Success)
return;
XISetDevicePropertyDeletable(dev, prop_natural_scroll, FALSE);
}
static void
LibinputInitNaturalScrollProperty(DeviceIntPtr dev,
struct xf86libinput *driver_data,
struct libinput_device *device)
{
BOOL natural_scroll = driver_data->options.natural_scrolling;
int rc;
if (!libinput_device_config_scroll_has_natural_scroll(device))
return;
prop_natural_scroll = MakeAtom(LIBINPUT_PROP_NATURAL_SCROLL,
strlen(LIBINPUT_PROP_NATURAL_SCROLL),
TRUE);
rc = XIChangeDeviceProperty(dev, prop_natural_scroll, XA_INTEGER, 8,
PropModeReplace, 1, &natural_scroll, FALSE);
if (rc != Success)
return;
XISetDevicePropertyDeletable(dev, prop_natural_scroll, FALSE);
}
static void
LibinputInitSendEventsProperty(DeviceIntPtr dev,
struct xf86libinput *driver_data,
struct libinput_device *device)
{
uint32_t sendevent_modes;
uint32_t sendevents;
BOOL modes[2] = {FALSE};
int rc;
sendevent_modes = libinput_device_config_send_events_get_modes(device);
if (sendevent_modes != LIBINPUT_CONFIG_SEND_EVENTS_ENABLED) {
uint32_t sendevents;
BOOL modes[2] = {FALSE};
if (sendevent_modes == LIBINPUT_CONFIG_SEND_EVENTS_ENABLED)
return;
if (sendevent_modes & LIBINPUT_CONFIG_SEND_EVENTS_DISABLED)
modes[0] = TRUE;
if (sendevent_modes & LIBINPUT_CONFIG_SEND_EVENTS_DISABLED_ON_EXTERNAL_MOUSE)
modes[1] = TRUE;
if (sendevent_modes & LIBINPUT_CONFIG_SEND_EVENTS_DISABLED)
modes[0] = TRUE;
if (sendevent_modes & LIBINPUT_CONFIG_SEND_EVENTS_DISABLED_ON_EXTERNAL_MOUSE)
modes[1] = TRUE;
prop_sendevents_available = MakeAtom(LIBINPUT_PROP_SENDEVENTS_AVAILABLE,
strlen(LIBINPUT_PROP_SENDEVENTS_AVAILABLE),
TRUE);
rc = XIChangeDeviceProperty(dev, prop_sendevents_available,
XA_INTEGER, 8,
PropModeReplace, 2, modes, FALSE);
if (rc != Success)
return;
XISetDevicePropertyDeletable(dev, prop_sendevents_available, FALSE);
prop_sendevents_available = MakeAtom(LIBINPUT_PROP_SENDEVENTS_AVAILABLE,
strlen(LIBINPUT_PROP_SENDEVENTS_AVAILABLE),
TRUE);
rc = XIChangeDeviceProperty(dev, prop_sendevents_available,
XA_INTEGER, 8,
PropModeReplace, 2, modes, FALSE);
if (rc != Success)
return;
XISetDevicePropertyDeletable(dev, prop_sendevents_available, FALSE);
memset(modes, 0, sizeof(modes));
sendevents = driver_data->options.sendevents;
switch(sendevents) {
case LIBINPUT_CONFIG_SEND_EVENTS_DISABLED:
modes[0] = TRUE;
break;
case LIBINPUT_CONFIG_SEND_EVENTS_DISABLED_ON_EXTERNAL_MOUSE:
modes[1] = TRUE;
break;
}
prop_sendevents_enabled = MakeAtom(LIBINPUT_PROP_SENDEVENTS_ENABLED,
strlen(LIBINPUT_PROP_SENDEVENTS_ENABLED),
TRUE);
rc = XIChangeDeviceProperty(dev, prop_sendevents_enabled,
XA_INTEGER, 8,
PropModeReplace, 2, modes, FALSE);
if (rc != Success)
return;
XISetDevicePropertyDeletable(dev, prop_sendevents_enabled, FALSE);
memset(modes, 0, sizeof(modes));
sendevents = driver_data->options.sendevents;
switch(sendevents) {
case LIBINPUT_CONFIG_SEND_EVENTS_DISABLED:
modes[0] = TRUE;
break;
case LIBINPUT_CONFIG_SEND_EVENTS_DISABLED_ON_EXTERNAL_MOUSE:
modes[1] = TRUE;
break;
}
if (libinput_device_config_left_handed_is_available(device)) {
BOOL left_handed = driver_data->options.left_handed;
prop_sendevents_enabled = MakeAtom(LIBINPUT_PROP_SENDEVENTS_ENABLED,
strlen(LIBINPUT_PROP_SENDEVENTS_ENABLED),
TRUE);
rc = XIChangeDeviceProperty(dev, prop_sendevents_enabled,
XA_INTEGER, 8,
PropModeReplace, 2, modes, FALSE);
if (rc != Success)
return;
XISetDevicePropertyDeletable(dev, prop_sendevents_enabled, FALSE);
}
prop_left_handed = MakeAtom(LIBINPUT_PROP_LEFT_HANDED,
strlen(LIBINPUT_PROP_LEFT_HANDED),
TRUE);
rc = XIChangeDeviceProperty(dev, prop_left_handed,
XA_INTEGER, 8,
PropModeReplace, 1, &left_handed, FALSE);
if (rc != Success)
return;
XISetDevicePropertyDeletable(dev, prop_left_handed, FALSE);
}
static void
LibinputInitLeftHandedProperty(DeviceIntPtr dev,
struct xf86libinput *driver_data,
struct libinput_device *device)
{
BOOL left_handed = driver_data->options.left_handed;
int rc;
if (!libinput_device_config_left_handed_is_available(device))
return;
prop_left_handed = MakeAtom(LIBINPUT_PROP_LEFT_HANDED,
strlen(LIBINPUT_PROP_LEFT_HANDED),
TRUE);
rc = XIChangeDeviceProperty(dev, prop_left_handed,
XA_INTEGER, 8,
PropModeReplace, 1, &left_handed, FALSE);
if (rc != Success)
return;
XISetDevicePropertyDeletable(dev, prop_left_handed, FALSE);
}
static void
LibinputInitScrollMethodsProperty(DeviceIntPtr dev,
struct xf86libinput *driver_data,
struct libinput_device *device)
{
uint32_t scroll_methods;
enum libinput_config_scroll_method method;
BOOL methods[3] = {FALSE};
int rc;
scroll_methods = libinput_device_config_scroll_get_methods(device);
if (scroll_methods != LIBINPUT_CONFIG_SCROLL_NO_SCROLL) {
enum libinput_config_scroll_method method;
BOOL methods[3] = {FALSE};
if (scroll_methods == LIBINPUT_CONFIG_SCROLL_NO_SCROLL)
return;
if (scroll_methods & LIBINPUT_CONFIG_SCROLL_2FG)
methods[0] = TRUE;
if (scroll_methods & LIBINPUT_CONFIG_SCROLL_EDGE)
methods[1] = TRUE;
if (scroll_methods & LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN)
methods[2] = TRUE;
if (scroll_methods & LIBINPUT_CONFIG_SCROLL_2FG)
methods[0] = TRUE;
if (scroll_methods & LIBINPUT_CONFIG_SCROLL_EDGE)
methods[1] = TRUE;
if (scroll_methods & LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN)
methods[2] = TRUE;
prop_scroll_methods_available =
MakeAtom(LIBINPUT_PROP_SCROLL_METHODS_AVAILABLE,
strlen(LIBINPUT_PROP_SCROLL_METHODS_AVAILABLE),
TRUE);
rc = XIChangeDeviceProperty(dev,
prop_scroll_methods_available,
XA_INTEGER, 8,
PropModeReplace,
ARRAY_SIZE(methods),
&methods, FALSE);
if (rc != Success)
return;
XISetDevicePropertyDeletable(dev,
prop_scroll_methods_available,
FALSE);
prop_scroll_methods_available =
MakeAtom(LIBINPUT_PROP_SCROLL_METHODS_AVAILABLE,
strlen(LIBINPUT_PROP_SCROLL_METHODS_AVAILABLE),
TRUE);
rc = XIChangeDeviceProperty(dev,
prop_scroll_methods_available,
XA_INTEGER, 8,
PropModeReplace,
ARRAY_SIZE(methods),
&methods, FALSE);
if (rc != Success)
return;
XISetDevicePropertyDeletable(dev,
prop_scroll_methods_available,
FALSE);
memset(methods, 0, sizeof(methods));
memset(methods, 0, sizeof(methods));
method = libinput_device_config_scroll_get_method(device);
switch(method) {
case LIBINPUT_CONFIG_SCROLL_2FG:
methods[0] = TRUE;
break;
case LIBINPUT_CONFIG_SCROLL_EDGE:
methods[1] = TRUE;
break;
case LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN:
methods[2] = TRUE;
break;
default:
break;
}
prop_scroll_method_enabled =
MakeAtom(LIBINPUT_PROP_SCROLL_METHOD_ENABLED,
strlen(LIBINPUT_PROP_SCROLL_METHOD_ENABLED),
TRUE);
rc = XIChangeDeviceProperty(dev,
prop_scroll_method_enabled,
XA_INTEGER, 8,
PropModeReplace,
ARRAY_SIZE(methods),
&methods, FALSE);
if (rc != Success)
return;
XISetDevicePropertyDeletable(dev,
prop_scroll_method_enabled,
FALSE);
method = libinput_device_config_scroll_get_method(device);
switch(method) {
case LIBINPUT_CONFIG_SCROLL_2FG:
methods[0] = TRUE;
break;
case LIBINPUT_CONFIG_SCROLL_EDGE:
methods[1] = TRUE;
break;
case LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN:
methods[2] = TRUE;
break;
default:
break;
}
prop_scroll_method_enabled =
MakeAtom(LIBINPUT_PROP_SCROLL_METHOD_ENABLED,
strlen(LIBINPUT_PROP_SCROLL_METHOD_ENABLED),
TRUE);
rc = XIChangeDeviceProperty(dev,
prop_scroll_method_enabled,
XA_INTEGER, 8,
PropModeReplace,
ARRAY_SIZE(methods),
&methods, FALSE);
if (rc != Success)
return;
XISetDevicePropertyDeletable(dev,
prop_scroll_method_enabled,
FALSE);
/* Scroll button */
if (libinput_device_config_scroll_get_methods(device) &
LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN) {
CARD32 scroll_button = driver_data->options.scroll_button;
@@ -1784,6 +1978,95 @@ LibinputInitProperty(DeviceIntPtr dev)
return;
XISetDevicePropertyDeletable(dev, prop_scroll_button, FALSE);
}
}
static void
LibinputInitClickMethodsProperty(DeviceIntPtr dev,
struct xf86libinput *driver_data,
struct libinput_device *device)
{
uint32_t click_methods;
enum libinput_config_click_method method;
BOOL methods[2] = {FALSE};
int rc;
click_methods = libinput_device_config_click_get_methods(device);
if (click_methods == LIBINPUT_CONFIG_CLICK_METHOD_NONE)
return;
if (click_methods & LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS)
methods[0] = TRUE;
if (click_methods & LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER)
methods[1] = TRUE;
prop_click_methods_available =
MakeAtom(LIBINPUT_PROP_CLICK_METHODS_AVAILABLE,
strlen(LIBINPUT_PROP_CLICK_METHODS_AVAILABLE),
TRUE);
rc = XIChangeDeviceProperty(dev,
prop_click_methods_available,
XA_INTEGER, 8,
PropModeReplace,
ARRAY_SIZE(methods),
&methods, FALSE);
if (rc != Success)
return;
XISetDevicePropertyDeletable(dev,
prop_click_methods_available,
FALSE);
memset(methods, 0, sizeof(methods));
method = libinput_device_config_click_get_method(device);
switch(method) {
case LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS:
methods[0] = TRUE;
break;
case LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER:
methods[1] = TRUE;
break;
default:
break;
}
prop_click_method_enabled =
MakeAtom(LIBINPUT_PROP_CLICK_METHOD_ENABLED,
strlen(LIBINPUT_PROP_CLICK_METHOD_ENABLED),
TRUE);
rc = XIChangeDeviceProperty(dev,
prop_click_method_enabled,
XA_INTEGER, 8,
PropModeReplace,
ARRAY_SIZE(methods),
&methods, FALSE);
if (rc != Success)
return;
XISetDevicePropertyDeletable(dev,
prop_click_method_enabled,
FALSE);
}
static void
LibinputInitProperty(DeviceIntPtr dev)
{
InputInfoPtr pInfo = dev->public.devicePrivate;
struct xf86libinput *driver_data = pInfo->private;
struct libinput_device *device = driver_data->device;
const char *device_node;
CARD32 product[2];
int rc;
prop_float = XIGetKnownProperty("FLOAT");
LibinputInitTapProperty(dev, driver_data, device);
LibinputInitCalibrationProperty(dev, driver_data, device);
LibinputInitAccelProperty(dev, driver_data, device);
LibinputInitNaturalScrollProperty(dev, driver_data, device);
LibinputInitSendEventsProperty(dev, driver_data, device);
LibinputInitLeftHandedProperty(dev, driver_data, device);
LibinputInitScrollMethodsProperty(dev, driver_data, device);
LibinputInitClickMethodsProperty(dev, driver_data, device);
/* Device node property, read-only */
device_node = driver_data->path;