mirror of
https://github.com/X11Libre/xf86-input-libinput.git
synced 2026-03-24 17:44:05 +00:00
Compare commits
11 Commits
xf86-input
...
xf86-input
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5a925eaa84 | ||
|
|
e7eafa199e | ||
|
|
d13ab268bd | ||
|
|
347c78387e | ||
|
|
b63f7994dc | ||
|
|
04f42d6e0f | ||
|
|
5d341d1d6c | ||
|
|
4985de5ef3 | ||
|
|
e26fc3c66c | ||
|
|
a759610292 | ||
|
|
21ff2ca7d1 |
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"
|
||||
|
||||
@@ -23,8 +23,8 @@
|
||||
# Initialize Autoconf
|
||||
AC_PREREQ([2.60])
|
||||
AC_INIT([xf86-input-libinput],
|
||||
[0.28.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])
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -1565,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
|
||||
@@ -1609,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
|
||||
@@ -1628,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);
|
||||
}
|
||||
@@ -1705,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:
|
||||
@@ -2092,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);
|
||||
@@ -3401,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))
|
||||
@@ -3624,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:
|
||||
|
||||
Reference in New Issue
Block a user