mirror of
https://github.com/X11Libre/xf86-input-libinput.git
synced 2026-04-10 09:12:07 +00:00
Compare commits
22 Commits
xf86-input
...
xf86-input
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5a925eaa84 | ||
|
|
e7eafa199e | ||
|
|
d13ab268bd | ||
|
|
347c78387e | ||
|
|
b63f7994dc | ||
|
|
04f42d6e0f | ||
|
|
5d341d1d6c | ||
|
|
4985de5ef3 | ||
|
|
e26fc3c66c | ||
|
|
a759610292 | ||
|
|
21ff2ca7d1 | ||
|
|
c67f191d5b | ||
|
|
1978a2555b | ||
|
|
0909a1a765 | ||
|
|
20bb8d6b9f | ||
|
|
1e88664d95 | ||
|
|
d84e0035d1 | ||
|
|
6c75acfcdf | ||
|
|
eaf847be16 | ||
|
|
d319092d55 | ||
|
|
18cc042e68 | ||
|
|
0db82219bb |
14
README.md
14
README.md
@@ -2,7 +2,7 @@ xf86-input-libinput - a libinput-based X driver
|
||||
===============================================
|
||||
|
||||
The official repository for this driver is
|
||||
http://cgit.freedesktop.org/xorg/driver/xf86-input-libinput/
|
||||
https://gitlab.freedesktop.org/xorg/driver/xf86-input-libinput
|
||||
|
||||
This is an X driver based on libinput. It is a thin wrapper around libinput,
|
||||
so while it does provide all features that libinput supports it does little
|
||||
@@ -20,10 +20,10 @@ xorg-x11-server-devel package or similar) and libinput (check your
|
||||
distribution for libinput-devel or similar).
|
||||
|
||||
To get libinput from source, see:
|
||||
http://www.freedesktop.org/wiki/Software/libinput/
|
||||
https://www.freedesktop.org/wiki/Software/libinput/
|
||||
|
||||
To build the X server from source:
|
||||
http://www.x.org/wiki/Building_the_X_Window_System/
|
||||
https://www.x.org/wiki/Building_the_X_Window_System/
|
||||
|
||||
Building
|
||||
--------
|
||||
@@ -48,8 +48,8 @@ This will assign this driver to *all* devices. Use with caution.
|
||||
Bugs
|
||||
----
|
||||
|
||||
Bugs in libinput go to the "libinput" component of wayland:
|
||||
https://bugs.freedesktop.org/enter_bug.cgi?product=Wayland
|
||||
Bugs in libinput go to the Issues section of the libinput gitlab project:
|
||||
https://gitlab.freedesktop.org/libinput/libinput/issues
|
||||
|
||||
Bugs in this driver go to the "Input/libinput" component of xorg:
|
||||
https://bugs.freedesktop.org/enter_bug.cgi?product=xorg
|
||||
Bugs in this driver go to the Issues section of its gitlab project:
|
||||
https://gitlab.freedesktop.org/xorg/driver/xf86-input-libinput/issues
|
||||
|
||||
@@ -1,4 +1,21 @@
|
||||
# Match on all types of devices but joysticks
|
||||
#
|
||||
# If you want to configure your devices, do not copy this file.
|
||||
# Instead, use a config snippet that contains something like this:
|
||||
#
|
||||
# Section "InputClass"
|
||||
# Identifier "something or other"
|
||||
# MatchDriver "libinput"
|
||||
#
|
||||
# MatchIsTouchpad "on"
|
||||
# ... other Match directives ...
|
||||
# Option "someoption" "value"
|
||||
# EndSection
|
||||
#
|
||||
# This applies the option any libinput device also matched by the other
|
||||
# directives. See the xorg.conf(5) man page for more info on
|
||||
# matching devices.
|
||||
|
||||
Section "InputClass"
|
||||
Identifier "libinput pointer catchall"
|
||||
MatchIsPointer "on"
|
||||
|
||||
21
configure.ac
21
configure.ac
@@ -23,8 +23,8 @@
|
||||
# Initialize Autoconf
|
||||
AC_PREREQ([2.60])
|
||||
AC_INIT([xf86-input-libinput],
|
||||
[0.27.0],
|
||||
[https://bugs.freedesktop.org/enter_bug.cgi?product=xorg],
|
||||
[0.28.2],
|
||||
[https://gitlab.freedesktop.org/xorg/driver/xf86-input-libinput/issues],
|
||||
[xf86-input-libinput])
|
||||
AC_CONFIG_SRCDIR([Makefile.am])
|
||||
AC_CONFIG_HEADERS([config.h])
|
||||
@@ -47,6 +47,23 @@ XORG_DEFAULT_OPTIONS
|
||||
PKG_CHECK_MODULES(XORG, [xorg-server >= 1.10] xproto [inputproto >= 2.2])
|
||||
PKG_CHECK_MODULES(LIBINPUT, [libinput >= 1.4.901])
|
||||
|
||||
OLD_LIBS=$LIBS
|
||||
OLD_CFLAGS=$CFLAGS
|
||||
LIBS="$LIBS $LIBINPUT_LIBS"
|
||||
CFLAGS="$CFLAGS $LIBINPUT_CFLAGS"
|
||||
AC_MSG_CHECKING([if libinput_device_touch_get_touch_count is available])
|
||||
AC_LINK_IFELSE(
|
||||
[AC_LANG_PROGRAM([[#include <libinput.h>]],
|
||||
[[libinput_device_touch_get_touch_count(NULL)]])],
|
||||
[AC_MSG_RESULT([yes])
|
||||
AC_DEFINE(HAVE_LIBINPUT_TOUCH_COUNT, [1],
|
||||
[libinput_device_touch_get_touch_count() is available])
|
||||
[libinput_have_touch_count=yes]],
|
||||
[AC_MSG_RESULT([no])
|
||||
[libinput_have_touch_count=no]])
|
||||
LIBS=$OLD_LIBS
|
||||
CFLAGS=$OLD_CFLAGS
|
||||
|
||||
# Define a configure option for an alternate input module directory
|
||||
AC_ARG_WITH(xorg-module-dir,
|
||||
AC_HELP_STRING([--with-xorg-module-dir=DIR],
|
||||
|
||||
@@ -15,11 +15,11 @@ libinput \- libinput-based X.Org input driver
|
||||
|
||||
.SH NOTE
|
||||
This is the man page for the X input driver. If you are looking for the
|
||||
library documentation, go to
|
||||
library documentation, go to
|
||||
.BI http://wayland.freedesktop.org/libinput/doc/
|
||||
|
||||
.SH DESCRIPTION
|
||||
.B libinput
|
||||
.B libinput
|
||||
is an __xservername__ input driver based on libinput. It
|
||||
therefore supports all input devices that libinput can handle, including
|
||||
most mice, keyboards, tablets and touchscreens.
|
||||
@@ -37,7 +37,7 @@ Please refer to __xconfigfile__(__filemansuffix__) for general configuration
|
||||
details and for options that can be used with all input drivers. This
|
||||
section only covers configuration details specific to this driver.
|
||||
.PP
|
||||
The following driver
|
||||
The following driver
|
||||
.B Options
|
||||
are supported:
|
||||
.TP 7
|
||||
@@ -277,7 +277,7 @@ enabled on this device.
|
||||
.BI "libinput Tablet Tool Pressurecurve"
|
||||
4 32-bit float values [0.0 to 1.0]. See section
|
||||
.B TABLET TOOL PRESSURE CURVE
|
||||
.TP7
|
||||
.TP 7
|
||||
.BI "libinput Tablet Tool Area Ratio"
|
||||
2 32-bit values, corresponding to width and height. Special value 0, 0
|
||||
resets to the default ratio. See section
|
||||
|
||||
@@ -116,7 +116,7 @@ draglock_get_meta(const struct draglock *dl)
|
||||
}
|
||||
|
||||
size_t
|
||||
draglock_get_pairs(const struct draglock *dl, int *array, size_t sz)
|
||||
draglock_get_pairs(const struct draglock *dl, int *array, size_t nelem)
|
||||
{
|
||||
unsigned int i;
|
||||
size_t last = 0;
|
||||
@@ -131,8 +131,8 @@ draglock_get_pairs(const struct draglock *dl, int *array, size_t sz)
|
||||
}
|
||||
|
||||
/* size N array with a[0] == 0, the rest ordered by button number */
|
||||
memset(array, 0, sz * sizeof(array[0]));
|
||||
for (i = 0; i < sz && i < ARRAY_SIZE(dl->lock_pair); i++) {
|
||||
memset(array, 0, nelem * sizeof(array[0]));
|
||||
for (i = 0; i < nelem && i < ARRAY_SIZE(dl->lock_pair); i++) {
|
||||
array[i] = dl->lock_pair[i];
|
||||
if (array[i] != 0 && i > last)
|
||||
last = i;
|
||||
@@ -153,20 +153,20 @@ draglock_set_meta(struct draglock *dl, int meta_button)
|
||||
}
|
||||
|
||||
int
|
||||
draglock_set_pairs(struct draglock *dl, const int *array, size_t sz)
|
||||
draglock_set_pairs(struct draglock *dl, const int *array, size_t nelem)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
if (sz == 0 || array[0] != 0)
|
||||
if (nelem == 0 || array[0] != 0)
|
||||
return 1;
|
||||
|
||||
for (i = 0; i < sz; i++) {
|
||||
for (i = 0; i < nelem; i++) {
|
||||
if (array[i] < 0 || array[i] >= DRAGLOCK_MAX_BUTTONS)
|
||||
return 1;
|
||||
}
|
||||
|
||||
dl->mode = DRAGLOCK_DISABLED;
|
||||
for (i = 0; i < sz; i++) {
|
||||
for (i = 0; i < nelem; i++) {
|
||||
dl->lock_pair[i] = array[i];
|
||||
if (dl->lock_pair[i])
|
||||
dl->mode = DRAGLOCK_PAIRS;
|
||||
|
||||
@@ -107,13 +107,13 @@ draglock_get_meta(const struct draglock *dl);
|
||||
* @note Button numbers start at 1, array[0] is always 0.
|
||||
*
|
||||
* @param[in|out] array Caller-allocated array to hold the button mappings.
|
||||
* @param[in] sz Maximum number of elements in array
|
||||
* @param[in] nelem Maximum number of elements in array
|
||||
*
|
||||
* @return The number of valid elements in array or 0 if the current mode is
|
||||
* not DRAGLOCK_PAIRS
|
||||
*/
|
||||
size_t
|
||||
draglock_get_pairs(const struct draglock *dl, int *array, size_t sz);
|
||||
draglock_get_pairs(const struct draglock *dl, int *array, size_t nelem);
|
||||
|
||||
/**
|
||||
* Set the drag lock config to the DRAGLOCK_META mode, with the given
|
||||
@@ -140,7 +140,7 @@ draglock_set_meta(struct draglock *dl, int meta_button);
|
||||
* @return 0 on successor nonzero otherwise
|
||||
*/
|
||||
int
|
||||
draglock_set_pairs(struct draglock *dl, const int *array, size_t sz);
|
||||
draglock_set_pairs(struct draglock *dl, const int *array, size_t nelem);
|
||||
|
||||
/**
|
||||
* Process the given button event through the drag lock state machine.
|
||||
|
||||
@@ -128,11 +128,10 @@ struct xf86libinput {
|
||||
uint32_t capabilities;
|
||||
|
||||
struct {
|
||||
int vdist;
|
||||
int hdist;
|
||||
|
||||
double vdist_fraction;
|
||||
double hdist_fraction;
|
||||
struct scroll_axis {
|
||||
int dist;
|
||||
double fraction;
|
||||
} v, h;
|
||||
} scroll;
|
||||
|
||||
struct {
|
||||
@@ -398,7 +397,7 @@ xf86libinput_shared_disable(struct xf86libinput_device *shared_device)
|
||||
|
||||
libinput_device_set_user_data(device, NULL);
|
||||
libinput_path_remove_device(device);
|
||||
device = libinput_device_unref(device);
|
||||
libinput_device_unref(device);
|
||||
shared_device->device = NULL;
|
||||
}
|
||||
|
||||
@@ -936,8 +935,8 @@ xf86libinput_init_pointer(InputInfoPtr pInfo)
|
||||
XIGetKnownProperty(AXIS_LABEL_PROP_REL_Y),
|
||||
min, max, res * 1000, 0, res * 1000, Relative);
|
||||
|
||||
SetScrollValuator(dev, 2, SCROLL_TYPE_HORIZONTAL, driver_data->scroll.hdist, 0);
|
||||
SetScrollValuator(dev, 3, SCROLL_TYPE_VERTICAL, driver_data->scroll.vdist, 0);
|
||||
SetScrollValuator(dev, 2, SCROLL_TYPE_HORIZONTAL, driver_data->scroll.h.dist, 0);
|
||||
SetScrollValuator(dev, 3, SCROLL_TYPE_VERTICAL, driver_data->scroll.v.dist, 0);
|
||||
|
||||
return Success;
|
||||
}
|
||||
@@ -984,8 +983,8 @@ xf86libinput_init_pointer_absolute(InputInfoPtr pInfo)
|
||||
XIGetKnownProperty(AXIS_LABEL_PROP_ABS_Y),
|
||||
min, max, res * 1000, 0, res * 1000, Absolute);
|
||||
|
||||
SetScrollValuator(dev, 2, SCROLL_TYPE_HORIZONTAL, driver_data->scroll.hdist, 0);
|
||||
SetScrollValuator(dev, 3, SCROLL_TYPE_VERTICAL, driver_data->scroll.vdist, 0);
|
||||
SetScrollValuator(dev, 2, SCROLL_TYPE_HORIZONTAL, driver_data->scroll.h.dist, 0);
|
||||
SetScrollValuator(dev, 3, SCROLL_TYPE_VERTICAL, driver_data->scroll.v.dist, 0);
|
||||
|
||||
driver_data->has_abs = TRUE;
|
||||
|
||||
@@ -1058,11 +1057,13 @@ xf86libinput_init_touch(InputInfoPtr pInfo)
|
||||
{
|
||||
DeviceIntPtr dev = pInfo->dev;
|
||||
struct xf86libinput *driver_data = pInfo->private;
|
||||
struct libinput_device *device = driver_data->shared_device->device;
|
||||
int min, max, res;
|
||||
unsigned char btnmap[MAX_BUTTONS + 1];
|
||||
Atom btnlabels[MAX_BUTTONS];
|
||||
Atom axislabels[TOUCHPAD_NUM_AXES];
|
||||
int nbuttons = 7;
|
||||
int ntouches = TOUCH_MAX_SLOTS;
|
||||
|
||||
init_button_map(btnmap, ARRAY_SIZE(btnmap));
|
||||
init_button_labels(btnlabels, ARRAY_SIZE(btnlabels));
|
||||
@@ -1086,7 +1087,13 @@ xf86libinput_init_touch(InputInfoPtr pInfo)
|
||||
xf86InitValuatorAxisStruct(dev, 1,
|
||||
XIGetKnownProperty(AXIS_LABEL_PROP_ABS_MT_POSITION_Y),
|
||||
min, max, res * 1000, 0, res * 1000, Absolute);
|
||||
InitTouchClassDeviceStruct(dev, TOUCH_MAX_SLOTS, XIDirectTouch, 2);
|
||||
|
||||
#if HAVE_LIBINPUT_TOUCH_COUNT
|
||||
ntouches = libinput_device_touch_get_touch_count(device);
|
||||
if (ntouches == 0) /* unknown - mtdev */
|
||||
ntouches = TOUCH_MAX_SLOTS;
|
||||
#endif
|
||||
InitTouchClassDeviceStruct(dev, ntouches, XIDirectTouch, 2);
|
||||
|
||||
}
|
||||
|
||||
@@ -1557,40 +1564,58 @@ xf86libinput_handle_key(InputInfoPtr pInfo, struct libinput_event_keyboard *even
|
||||
* e.g. a 2 degree click angle requires 8 clicks before a legacy event is
|
||||
* sent, but each of those clicks will send XI2.1 smooth scroll data for
|
||||
* compatible clients.
|
||||
*
|
||||
* Starting with kernel v5.0 we should get REL_WHEEL_HI_RES from those
|
||||
* devices for the fine-grained scrolling and REL_WHEEL for the normal one,
|
||||
* so the use-case above shouldn't matter anymore.
|
||||
*/
|
||||
static inline double
|
||||
get_scroll_fraction(struct xf86libinput *driver_data,
|
||||
struct libinput_event_pointer *event,
|
||||
enum libinput_pointer_axis axis)
|
||||
get_wheel_scroll_value(struct xf86libinput *driver_data,
|
||||
struct libinput_event_pointer *event,
|
||||
enum libinput_pointer_axis axis)
|
||||
{
|
||||
double *fraction;
|
||||
struct scroll_axis *s;
|
||||
double f;
|
||||
double angle;
|
||||
int discrete;
|
||||
|
||||
switch (axis) {
|
||||
case LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL:
|
||||
fraction = &driver_data->scroll.hdist_fraction;
|
||||
s = &driver_data->scroll.h;
|
||||
break;
|
||||
case LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL:
|
||||
fraction = &driver_data->scroll.vdist_fraction;
|
||||
s = &driver_data->scroll.v;
|
||||
break;
|
||||
default:
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
if (*fraction != 0.0)
|
||||
return *fraction;
|
||||
|
||||
/* Calculate the angle per single scroll event */
|
||||
angle = libinput_event_pointer_get_axis_value(event, axis);
|
||||
discrete = libinput_event_pointer_get_axis_value_discrete(event, axis);
|
||||
|
||||
/* We only need to guess the fraction on the first set of
|
||||
* scroll events until a discrete value arrives. Once known, we
|
||||
* re-use the fraction until the device goes away.
|
||||
*/
|
||||
if (s->fraction != 0.0)
|
||||
goto out;
|
||||
|
||||
/* if we get a discrete of 0, assume REL_WHEEL_HI_RES exists and
|
||||
* normal scroll events are sent correctly, so skip all the
|
||||
* guesswork.
|
||||
*/
|
||||
if (discrete == 0) {
|
||||
s->fraction = 1.0;
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* Calculate the angle per single scroll event */
|
||||
angle /= discrete;
|
||||
|
||||
/* We only do magic for click angles smaller than 10 degrees */
|
||||
if (angle >= 10) {
|
||||
*fraction = 1.0;
|
||||
return 1.0;
|
||||
s->fraction = 1.0;
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* Figure out something that gets close to 15 degrees (the general
|
||||
@@ -1601,9 +1626,10 @@ get_scroll_fraction(struct xf86libinput *driver_data,
|
||||
*/
|
||||
f = round(15.0/angle);
|
||||
|
||||
*fraction = f;
|
||||
s->fraction = f;
|
||||
|
||||
return f;
|
||||
out:
|
||||
return s->dist/s->fraction * discrete;
|
||||
}
|
||||
|
||||
static inline bool
|
||||
@@ -1620,11 +1646,7 @@ calculate_axis_value(struct xf86libinput *driver_data,
|
||||
|
||||
source = libinput_event_pointer_get_axis_source(event);
|
||||
if (source == LIBINPUT_POINTER_AXIS_SOURCE_WHEEL) {
|
||||
double scroll_fraction;
|
||||
|
||||
value = libinput_event_pointer_get_axis_value_discrete(event, axis);
|
||||
scroll_fraction = get_scroll_fraction(driver_data, event, axis);
|
||||
value *= driver_data->scroll.vdist/scroll_fraction;
|
||||
value = get_wheel_scroll_value(driver_data, event, axis);
|
||||
} else {
|
||||
value = libinput_event_pointer_get_axis_value(event, axis);
|
||||
}
|
||||
@@ -1697,7 +1719,7 @@ xf86libinput_handle_touch(InputInfoPtr pInfo,
|
||||
if ((driver_data->capabilities & CAP_TOUCH) == 0)
|
||||
return;
|
||||
|
||||
slot = libinput_event_touch_get_slot(event);
|
||||
slot = libinput_event_touch_get_seat_slot(event);
|
||||
|
||||
switch (event_type) {
|
||||
case LIBINPUT_EVENT_TOUCH_DOWN:
|
||||
@@ -2084,7 +2106,7 @@ static inline DeviceIntPtr
|
||||
xf86libinput_find_device_for_tool(InputInfoPtr pInfo,
|
||||
struct libinput_tablet_tool *tool)
|
||||
{
|
||||
struct xf86libinput *dev = pInfo->private;
|
||||
struct xf86libinput *dev;
|
||||
struct xf86libinput *driver_data = pInfo->private;
|
||||
struct xf86libinput_device *shared_device = driver_data->shared_device;
|
||||
uint64_t serial = libinput_tablet_tool_get_serial(tool);
|
||||
@@ -2684,9 +2706,9 @@ xf86libinput_parse_calibration_option(InputInfoPtr pInfo,
|
||||
libinput_device_config_calibration_get_matrix(device, matrix);
|
||||
memcpy(matrix_out, matrix, sizeof(matrix));
|
||||
|
||||
str = xf86CheckStrOption(pInfo->options,
|
||||
"CalibrationMatrix",
|
||||
NULL);
|
||||
str = xf86SetStrOption(pInfo->options,
|
||||
"CalibrationMatrix",
|
||||
NULL);
|
||||
if (!str)
|
||||
return;
|
||||
|
||||
@@ -2914,7 +2936,7 @@ xf86libinput_parse_draglock_option(InputInfoPtr pInfo,
|
||||
{
|
||||
char *str;
|
||||
|
||||
str = xf86CheckStrOption(pInfo->options, "DragLockButtons",NULL);
|
||||
str = xf86SetStrOption(pInfo->options, "DragLockButtons", NULL);
|
||||
if (draglock_init_from_string(&driver_data->draglock, str) != 0)
|
||||
xf86IDrvMsg(pInfo, X_ERROR,
|
||||
"Invalid DragLockButtons option: \"%s\"\n",
|
||||
@@ -3393,8 +3415,8 @@ xf86libinput_pre_init(InputDriverPtr drv,
|
||||
* affect touchpad scroll speed. For wheels it doesn't matter as
|
||||
* we're using the discrete value only.
|
||||
*/
|
||||
driver_data->scroll.vdist = 15;
|
||||
driver_data->scroll.hdist = 15;
|
||||
driver_data->scroll.v.dist = 15;
|
||||
driver_data->scroll.h.dist = 15;
|
||||
|
||||
if (!is_subdevice) {
|
||||
if (libinput_device_has_capability(device, LIBINPUT_DEVICE_CAP_POINTER))
|
||||
@@ -3616,13 +3638,13 @@ update_mode_prop_cb(ClientPtr client, pointer closure)
|
||||
groups[idx] = mode;
|
||||
|
||||
driver_data->allow_mode_group_updates = true;
|
||||
rc = XIChangeDeviceProperty(pInfo->dev,
|
||||
prop_mode_groups,
|
||||
XA_INTEGER, 8,
|
||||
PropModeReplace,
|
||||
val->size,
|
||||
groups,
|
||||
TRUE);
|
||||
XIChangeDeviceProperty(pInfo->dev,
|
||||
prop_mode_groups,
|
||||
XA_INTEGER, 8,
|
||||
PropModeReplace,
|
||||
val->size,
|
||||
groups,
|
||||
TRUE);
|
||||
driver_data->allow_mode_group_updates = false;
|
||||
|
||||
out:
|
||||
@@ -4930,9 +4952,6 @@ LibinputInitLeftHandedProperty(DeviceIntPtr dev,
|
||||
if (!subdevice_has_capabilities(dev, CAP_POINTER|CAP_TABLET))
|
||||
return;
|
||||
|
||||
if (prop_left_handed != 0)
|
||||
return;
|
||||
|
||||
if (!libinput_device_config_left_handed_is_available(device) ||
|
||||
driver_data->capabilities & CAP_TABLET)
|
||||
return;
|
||||
@@ -5321,7 +5340,7 @@ LibinputInitDragLockProperty(DeviceIntPtr dev,
|
||||
break;
|
||||
case DRAGLOCK_PAIRS:
|
||||
sz = draglock_get_pairs(&driver_data->draglock,
|
||||
dl_values, sizeof(dl_values));
|
||||
dl_values, ARRAY_SIZE(dl_values));
|
||||
break;
|
||||
default:
|
||||
xf86IDrvMsg(dev->public.devicePrivate,
|
||||
|
||||
Reference in New Issue
Block a user