Compare commits

...

105 Commits

Author SHA1 Message Date
Peter Hutterer
44f4b2ed70 xf86-input-libinput 0.15.0
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-10-27 17:08:59 +10:00
Peter Hutterer
0163482e22 Add property support for the accel profiles
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-10-26 10:00:57 +10:00
Peter Hutterer
80c356f58f conf: install the libinput xorg.conf.d snippet
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-09-18 00:29:20 +10:00
Peter Hutterer
1645a79c34 conf: don't hook onto tablets and joysticks
If we install the config file by default, we shouldn't use libinput for
devices we know we can't handle.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-09-18 00:29:17 +10:00
Peter Hutterer
b7f8db12a3 conf: rename 99-libinput.conf to 90-libinput.conf
This way it still sorts after the usual subjects, but it's easier to stack
extra config in afterwards.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-09-18 00:27:43 +10:00
Peter Hutterer
6abd341279 Fix invalid pointer passed to the properties
Takes a void*, not a void**

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-09-03 17:42:20 +10:00
Peter Hutterer
19b42f242d Move the read-only properties into the same condition
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-09-03 17:33:40 +10:00
Peter Hutterer
f48b64c8cd xf86-input-libinput 0.14.0
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-31 13:27:09 +10:00
Yomi0
b55239ef25 Fix typo in libinput.man
Correct typo. Draging to dragging.
2015-08-30 23:14:25 -04:00
Peter Hutterer
9563334dda Use xf86OpenSerial instead of a direct open() call
This will transparently handle server-side fds for us.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Martin Pieuchot <mpi@openbsd.org>
2015-08-17 09:18:01 +10:00
Peter Hutterer
353c52f2be Revamp server fd opening
The server already stores the server-fd in the options, so we only need to run
through the list of current devices, find a match and extract that fd from the
options. Less magic in our driver and it gives us a pInfo handle in
open_restricted which we'll can use for xf86OpenSerial().

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Martin Pieuchot <mpi@openbsd.org>
2015-08-17 09:16:42 +10:00
Peter Hutterer
f139f14249 Add an option to disable horizontal scrolling
libinput always has horizontal scrolling enabled and punts the decision when
to scroll horizontally to the toolkit/widget. This is the better approach, but
while we have a stack that's not ready for that, and in the X case likely
never will be fully ready provide an option to disable horizontal scrolling.

This option doesn't really disable horizontal scrolling, it merely discards
any horizontal scroll delta. libinput will still think it's scrolling.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-08-13 07:53:19 +10:00
Peter Hutterer
e3a888c3ab Add drag lock support
First, why is this here and not in libinput: drag lock should be implemented
in the compositor (not in libinput) so it can provide feedback when it
activates and grouped in with other accessibility features. That will work for
Wayland but in X the compositor cannot filter button events - only the server
and the drivers can.

This patch adds mostly the same functionality that evdev provides with two
options on how it works:
* a single button number configures the given button to lock the next button
  pressed in a logically down state until a press+ release of that same button
  again
* a set of button number pairs configures each button with the to-be-locked
  logical button, i.e. a pair of "1 3" will hold 3 logically down after a
  button 1 press

The property and the xorg.conf options take the same configuration as the
evdev driver (though the property has a different prefix, libinput instead of
Evdev).

The behavior difference to evdev is in how releases are handled, evdev sends
the release on the second button press event, this implementation sends the
release on the second release event.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-08-13 07:52:48 +10:00
Martin Pieuchot
cd61ddb040 Remove unneeded header, epoll(7) interface is not directly used.
Signed-off-by: Martin Pieuchot <mpi@openbsd.org>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-12 10:16:11 +10:00
Martin Pieuchot
a199880057 Rename a local variable to not shadow the BSD strmode(3) function.
Signed-off-by: Martin Pieuchot <mpi@openbsd.org>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-12 10:16:01 +10:00
Peter Hutterer
cc57eecd72 gitignore: add patterns for automake test suite and misc other bits
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-11 15:06:43 +10:00
Peter Hutterer
fe58cff48b Rename main source file to x86libinput.c
To avoid conflict and confusion with libinput's sources. This was originally
triggered by needing a header file for the driver which cannot be named
libinput.h. That need went away after other refacturing, but we might as well
rename it now, sooner or later we'll need a xf86libinput.h file.

Can't do much about the libinput-properties header though, not worth breaking
other projects and it's namespaced into /usr/include/xorg anyway.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-11 15:05:29 +10:00
Peter Hutterer
4b2bed6912 xf86-input-libinput 0.13.0
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-04 17:08:22 +10:00
Stephen Chandler Paul
223be9f62b Add a property for Disable While Typing
Signed-off-by: Stephen Chandler Paul <cpaul@redhat.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-04 14:14:48 +10:00
Peter Hutterer
d3ee745a24 man: minor man page improvements
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-07-21 11:21:47 +10:00
Peter Hutterer
b550b70a00 Fix compiler warnings about touchpad gestures
We don't do anything with them though.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-07-21 11:16:06 +10:00
Peter Hutterer
254b1f27a0 xf86-input-libinput 0.12.0
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-07-14 16:18:38 +10:00
Peter Hutterer
bfedf7dbac Add a property for tap drag lock
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-07-09 11:08:23 +10:00
Peter Hutterer
9c5cf97143 Support buttons > BTN_BACK on mice
https://bugzilla.redhat.com/show_bug.cgi?id=1230945

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-06-15 10:20:18 +10:00
Peter Hutterer
449b496a3a xf86-input-libinput 0.11.0
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-06-05 13:40:31 +10:00
Peter Hutterer
d4e0b5420f Fix missing scroll methods default/scroll button property
Even if no scroll method is enabled by default, we still want those
properties.

Introduced in 8d4e03570c.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-06-01 11:46:33 +10:00
Peter Hutterer
19c91044e4 Use the new unaccelerated valuator ValuatorMask features
SDL Games like openarena rely on relative input that's handled by the DGA code
in the server. That code casts the driver's input data to int and sends it to
the client. libinput does pointer acceleration for us, so sending any deltas
of less than 1 (likely for slow movements) ends up being 0.

Use the new ValuatorMask accelerated/unaccelerated values to pass the
unaccelerated values along, the server can then decide what to do with it.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-05-22 07:42:15 +10:00
Peter Hutterer
3d6afca975 Only init abs axes if we don't have acceleration
A lot of devices (mainly MS input devices) have abs axes on top of the
relative axes. Those axes are usually mute but with the current code we set up
absolute axes for those devices. Relative events are then scaled by the server
which makes the device appear slow.

As an immediate fix always prefer relative axes and only set up absolute axes
if the device has a calibration matrix but no pointer acceleration.
This may mess up other devices where the relative axes are dead, we'll deal
with this when it comes.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-05-22 07:42:15 +10:00
Peter Hutterer
158e3264ce xf86-input-libinput 0.10.0
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-05-21 09:52:40 +10:00
Peter Hutterer
006c802630 Group scroll distances into a struct
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-05-20 14:22:17 +10:00
Peter Hutterer
d6ce065cea Add option "ButtonMapping" (#90206)
With a long entry in the man page to detail what this option does.
Specifically, it's the xorg.conf equivalent to XSetPointerMapping(3), it
doesn't do any physical button remappings, merely the logical ones. If the
physical button isn't mapped to the right logical button by default, that's
either a libiput bug or an xkcd 1172 issue.

X.Org Bug 90206 <http://bugs.freedesktop.org/show_bug.cgi?id=90206>

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-04-30 11:34:15 +10:00
Peter Hutterer
b9a2150576 man: add two linebreaks to make things easier to visually parse
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-04-29 09:19:09 +10:00
Peter Hutterer
9356471f3f Move the option parsing into helper functions
No functional changes, though I did move a free() up a bit in the process (see
sendevents parsing).

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-04-29 08:51:12 +10:00
Peter Hutterer
d5fa03c343 Add a property for middle button emulation
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-04-23 17:48:44 +10:00
Peter Hutterer
446401bea9 xf86-input-libinput 0.9.0
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-04-23 12:23:01 +10:00
Peter Hutterer
8d4e03570c Add "libinput something Default" properties
A client or xorg.conf setting may change the property but once changed it
cannot be reset by a client to the original state without knowledge about the
device.

Export the various libinput_...get_default() functions as properties.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-03-18 09:15:40 +10:00
Peter Hutterer
0c5620a29c Add a helper function for making properties
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-03-18 09:15:40 +10:00
Peter Hutterer
fb50cef700 man: update the property list in the man page
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-03-18 09:15:40 +10:00
Peter Hutterer
64a0f870e0 Fix a couple of -Wformat warnings
unsigned int vs int

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-03-18 09:15:40 +10:00
Peter Hutterer
e362e4dc4c cosmetic: drop duplicate empty lines
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-03-16 10:38:07 +10:00
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
Peter Hutterer
64e1b14598 xf86-input-libinput 0.6.0
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-01-27 10:08:32 +10:00
Peter Hutterer
e729451bb1 Swap button labels for back/forward to align with linux/input.h
We just forward the kernel buttons, so this should be in the same order.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-01-27 07:51:34 +10:00
Olivier Fourdan
7d73602c4b Move properties to a separate header
And install the header as part of the SDK, so that applications interfacing
with the libinput driver do not have to copy paste all the properties' names.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-01-21 11:57:58 +10:00
Peter Hutterer
00b96de351 Revert "libinput-drv: Move properties to a separate header"
Missing the pkg-config file, updated patch coming up.

This reverts commit 8ceed9c73d.
2015-01-21 11:56:35 +10:00
Olivier Fourdan
8ceed9c73d libinput-drv: Move properties to a separate header
And install the header as part of the SDK, so that applications interfacing
with the libinput driver do not have to copy paste all the properties' names.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-01-21 07:15:48 +10:00
Olivier Fourdan
e4cd6cef91 libinput-drv: Add autogen.sh
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-01-21 07:13:46 +10:00
Peter Hutterer
7bc662d0b4 Remove unused define
Obsolete since 2348a6812a

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-01-19 14:36:59 +10:00
Peter Hutterer
a55cb9121a Move the property #defines up
Since they serve as documentation, make them easier to find.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-01-19 14:36:19 +10:00
Peter Hutterer
efb5cacb25 xf86-input-libinput 0.5.0
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-01-16 14:39:29 +10:00
Peter Hutterer
2348a6812a 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>
2015-01-15 13:12:36 +10:00
Peter Hutterer
0c4eaf5480 Support server-side fds
libinput's device handling and server-side fd handling are a bit of a
mismatch, so this is hackier than one would hope for.

The server sets pInfo->fd and the options "fd" and "device".
The server requires pInfo->fd to be the one triggering select(2) to call the
correct pInfo->read_input. We can't pass an fd to use into libinput, all we
have is the open_restricted callback. That callback gives us the context, but
not the pInfo with the fd we want.

The solution:
1) In PreInit, store the patch + fd combination in a driver-wide list. Search
that list for an fd in open_restricted, return the pre-openend fd.

2) Overwrite all devices' pInfo->fd with the libinput epollfd. In this driver
we don't care about which device read_input is called on, we get the correct
pInfo to post events from through the struct libinput_device of the libinput
events.

3) When a device is closed, swap the real fd back in so systemd-logind closes the
right fd.

This saves us worrying about keeping the right refcount on who currently has
the fd set to the libinput fd. We just set it for all devices, let the server
figure out which device to call (the first in inputInfo.devices) and we only
need to remember to swap it back during DEVICE_OFF.

If the server calls close on a pInfo->fd without telling the driver, that's a
bug anyway.

This patch also drops the pInfo->fd = -1 calls, they've been unnecessary since
at least 1.11, possibly earlier.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2014-12-08 08:36:16 +10:00
Peter Hutterer
bc7bcca342 xf86-input-libinput 0.4.0
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-12-05 15:18:40 +10:00
Peter Hutterer
e5079cd98e Require libinput 0.7.0
We've required this already anyway, now we have the libinput version to match
though

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-12-05 15:12:31 +10:00
Peter Hutterer
200be95ac9 Support absolute pointer devices
Detecting them is a bit of guesswork: if a device is a pointer device and has
a calibration matrix option, then the device must be an abs device.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-12-05 15:12:31 +10:00
Peter Hutterer
8b5dbd4c01 Split up a really long line
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-12-01 15:20:41 +10:00
Peter Hutterer
fb5c5b6f85 Move the option parsing into a separate function
No functional changes, makes preinit a bit more digestible.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-12-01 11:52:28 +10:00
Peter Hutterer
182363d674 Change a sigsafe error to xf86IDrvMsg
We don't use the signal handler in this driver, so no need for sigsafe
logging.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-12-01 11:48:56 +10:00
Peter Hutterer
f0b14c6ccc Change the touch IDs to uints
Better overflow behavior, not that we're likely to trigger it.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-12-01 11:47:15 +10:00
Peter Hutterer
e92c9f0bad man: fix wrong option name
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-12-01 11:45:40 +10:00
Peter Hutterer
dda952fafe Leave the XKB defaults up to the server
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-12-01 11:44:11 +10:00
Peter Hutterer
17302c3352 Allow disabling scroll methods
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-12-01 11:31:30 +10:00
Peter Hutterer
7e3926f2b7 Split sendevent modes property into "available" and "current"
Clients need to know which methods are available, not just which one
is currently set. Export bitmask config options as two properties,
one read-only named "... Available" and one set-able one named "... Enabled"

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-12-01 11:31:30 +10:00
Peter Hutterer
9ad23dd1cb Split scroll methods property into "available" and "current"
Clients need to know which methods are available, not just which one is
currently set. Export bitmask config options as two properties, one read-only
named "... Available" and one set-able one named "... Enabled"

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-11-28 09:14:24 +10:00
Peter Hutterer
7b2dbdc224 xf86-input-libinput 0.3.0
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-11-24 17:43:23 +10:00
Peter Hutterer
eddc8cb1b2 Don't process events from devices that got removed already
If the driver doesn't have a pInfo reference anymore for a libinput device,
don't bother processing events, the device was already removed. This was
triggered by the libevdev test suite which adds/removes devices very quickly.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-11-24 11:50:48 +10:00
Peter Hutterer
95597d8070 Drop double empty lines
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-11-24 11:50:48 +10:00
Peter Hutterer
a323e221a7 Use the button conversion helper for normal button events too
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-11-24 11:01:25 +10:00
Peter Hutterer
6385974e4d Add support for changing the button-scrolling button
This currently exposes the libinput button name, which isn't ideal. Needs to
be switched to X button numbers.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-11-24 11:01:25 +10:00
Peter Hutterer
439a244ae7 Add support for switching scroll methods
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-11-24 11:00:44 +10:00
Peter Hutterer
4a049ad6f8 Add support for left-handed button orientation
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-11-24 10:50:24 +10:00
Peter Hutterer
ef948537e1 xf86-input-libinput 0.2.0
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-11-19 14:54:02 +10:00
Peter Hutterer
576da9db26 Hook up the libinput log handler
Let the server filter based on the verbosity levels in the server, so map
ERROR to -1 (always), INFO to 3 (default verbosity) and DEBUG to 10.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-11-19 14:40:58 +10:00
Peter Hutterer
2eb01498bd Add an explanatory comment for the disabled ptraccel
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-11-19 14:40:58 +10:00
Peter Hutterer
a4fb161c3e Allow re-enabling of the sendevents configuration
When re-enabling the device, the mode is 0.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-11-19 14:40:58 +10:00
Peter Hutterer
15291e53b7 Update the README
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-11-19 14:40:58 +10:00
Peter Hutterer
d9c212d266 Init the right number of buttons for pointer devices
This only makes room for the highest button number present on the device, it
doesn't cater for devices with 'holes'. i.e. if a device has only BTN_BACK, it
will initialize buttons for all below too.

Which is also evdev's current behavior.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-11-19 14:40:58 +10:00
Peter Hutterer
d48f437aa9 Replace hardcoded button number with one we can calculate
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-11-19 14:39:50 +10:00
Peter Hutterer
84f301f7e3 Fix loop condition
Use the passed-in value, not the global constant.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-11-19 14:39:50 +10:00
Peter Hutterer
6f06b1dd1d Set the XI type for the device
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-11-18 13:37:39 +10:00
Peter Hutterer
fdbf7eaf4b man: add missing Makefile.am 2014-10-05 22:48:30 +10:00
Peter Hutterer
2b6c485117 Store the data in the local options, then apply all at once
Less code this way, though if we somehow sneak in a bad option we get the
error for it every time we update any property.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-09-26 14:42:31 +10:00
Peter Hutterer
246200cbdc Apply all config options on DEVICE_ON
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-09-26 14:36:10 +10:00
Peter Hutterer
fb41458a93 Expose all config options as xorg.conf options
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-09-26 14:36:10 +10:00
Peter Hutterer
d9d2e9a501 Add a man page
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-09-26 14:25:20 +10:00
Peter Hutterer
0a58edd3f6 Add a couple of general properties that all drivers should support
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-09-26 14:25:20 +10:00
Peter Hutterer
8d6019c786 Expose properties for the various configuration settings.
The property support isn't ideal, the server relies on the driver to check
first if a setting is possible, applying the setting itself cannot fail.
Thus we can't just check the libinput config status code, which matters mostly
in the sendevents property where we simply check that only a single bit is set
and that the supported modes are equal or more to the requested mode.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-09-26 14:23:28 +10:00
Peter Hutterer
532fe35522 Require libinput 0.6
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-09-24 15:59:00 +10:00
Peter Hutterer
65a40e2cfc Add a rudimentary README
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-08-07 10:04:42 +10:00
Peter Hutterer
7522884a9e Drop some mention of evdev
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-08-07 09:48:46 +10:00
Peter Hutterer
ef5f0295e7 Ship an example config snippet
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-08-07 09:48:32 +10:00
Peter Hutterer
adb4963109 Replace AC_PROG_LIBTOOL with LT_INIT
Former is deprecated in favor of the latter.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-07-24 16:55:44 +10:00
19 changed files with 4531 additions and 683 deletions

8
.gitignore vendored
View File

@@ -76,3 +76,11 @@ core
# Edit the following section as needed
# For example, !report.pc overrides *.pc. See 'man gitignore'
#
*.log
*.trs
*.swp
*.announce
*.sig
test-driver
tags
.vimdir

View File

@@ -19,12 +19,16 @@
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# Provide an sdk location that is writable by the evdev module
DISTCHECK_CONFIGURE_FLAGS = --with-sdkdir='$${includedir}/xorg'
SUBDIRS = src
SUBDIRS = src include man test
MAINTAINERCLEANFILES = ChangeLog INSTALL
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = xorg-libinput.pc
dist_xorgconf_DATA = conf/90-libinput.conf
.PHONY: ChangeLog INSTALL
INSTALL:
@@ -34,3 +38,5 @@ ChangeLog:
$(CHANGELOG_CMD)
dist-hook: ChangeLog INSTALL
EXTRA_DIST = README.md

55
README.md Normal file
View File

@@ -0,0 +1,55 @@
xf86-input-libinput - a libinput-based X driver
===============================================
The official repository for this driver is
http://cgit.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
beyond.
***WARNING: misconfiguration of an X input driver may leave you without
usable input devices in your X session. Use with caution.***
Prerequisites
-------------
To build, you'll need the X.Org X server SDK (check your distribution for a
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/
To build the X server from source:
http://www.x.org/wiki/Building_the_X_Window_System/
Building
--------
To build this driver:
autoreconf -vif
./configure --prefix=$HOME/build
make && make install
Note that this assumes the same prefix as used in "Building the X Window
System" above, adjust as required. If you want a system install, use a
prefix of */usr*.
Install the default configuration file:
cp conf/99-libinput.conf /etc/X11/xorg.conf.d/
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 this driver go to the "Input/libinput" component of xorg:
https://bugs.freedesktop.org/enter_bug.cgi?product=xorg

14
autogen.sh Executable file
View File

@@ -0,0 +1,14 @@
#! /bin/sh
srcdir=`dirname $0`
test -z "$srcdir" && srcdir=.
ORIGDIR=`pwd`
cd $srcdir
autoreconf -v --install || exit 1
cd $ORIGDIR || exit $?
if test -z "$NOCONFIGURE"; then
exec $srcdir/configure "$@"
fi

28
conf/90-libinput.conf Normal file
View File

@@ -0,0 +1,28 @@
# Match on all types of devices but tablet devices and joysticks
Section "InputClass"
Identifier "libinput pointer catchall"
MatchIsPointer "on"
MatchDevicePath "/dev/input/event*"
Driver "libinput"
EndSection
Section "InputClass"
Identifier "libinput keyboard catchall"
MatchIsKeyboard "on"
MatchDevicePath "/dev/input/event*"
Driver "libinput"
EndSection
Section "InputClass"
Identifier "libinput touchpad catchall"
MatchIsTouchpad "on"
MatchDevicePath "/dev/input/event*"
Driver "libinput"
EndSection
Section "InputClass"
Identifier "libinput touchscreen catchall"
MatchIsTouchscreen "on"
MatchDevicePath "/dev/input/event*"
Driver "libinput"
EndSection

View File

@@ -23,7 +23,7 @@
# Initialize Autoconf
AC_PREREQ([2.60])
AC_INIT([xf86-input-libinput],
[0.1.2],
[0.15.0],
[https://bugs.freedesktop.org/enter_bug.cgi?product=xorg],
[xf86-input-libinput])
AC_CONFIG_SRCDIR([Makefile.am])
@@ -35,7 +35,7 @@ AM_INIT_AUTOMAKE([foreign dist-bzip2])
# Initialize libtool
AC_DISABLE_STATIC
AC_PROG_LIBTOOL
LT_INIT
# Initialize X.Org macros 1.8 or later for MAN_SUBSTS set by XORG_MANPAGE_SECTIONS
m4_ifndef([XORG_MACROS_VERSION],
@@ -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.4.0])
PKG_CHECK_MODULES(LIBINPUT, [libinput >= 1.0.901])
# Define a configure option for an alternate input module directory
AC_ARG_WITH(xorg-module-dir,
@@ -56,6 +56,13 @@ AC_ARG_WITH(xorg-module-dir,
inputdir=${moduledir}/input
AC_SUBST(inputdir)
AC_ARG_WITH(xorg-conf-dir,
AC_HELP_STRING([--with-xorg-conf-dir=DIR],
[Default xorg.conf.d directory [[default=$prefix/share/X11/xorg.conf.d/]]]),
[xorgconfdir="$withval"],
[xorgconfdir="$prefix/share/X11/xorg.conf.d"])
AC_SUBST(xorgconfdir)
# X Server SDK location is required to install header files
sdkdir=`$PKG_CONFIG --variable=sdkdir xorg-server`
@@ -68,5 +75,9 @@ DRIVER_NAME=libinput
AC_SUBST([DRIVER_NAME])
AC_CONFIG_FILES([Makefile
src/Makefile])
include/Makefile
src/Makefile
man/Makefile
test/Makefile
xorg-libinput.pc])
AC_OUTPUT

1
include/Makefile.am Normal file
View File

@@ -0,0 +1 @@
sdk_HEADERS = libinput-properties.h

View File

@@ -0,0 +1,139 @@
/*
* Copyright © 2015 Red Hat, Inc.
*
* Permission to use, copy, modify, distribute, and sell this software
* and its documentation for any purpose is hereby granted without
* fee, provided that the above copyright notice appear in all copies
* and that both that copyright notice and this permission notice
* appear in supporting documentation, and that the name of Red Hat
* not be used in advertising or publicity pertaining to distribution
* of the software without specific, written prior permission. Red
* Hat makes no representations about the suitability of this software
* for any purpose. It is provided "as is" without express or implied
* warranty.
*
* THE AUTHORS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
* NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#ifndef _LIBINPUT_PROPERTIES_H_
#define _LIBINPUT_PROPERTIES_H_
/* Tapping enabled/disabled: BOOL, 1 value */
#define LIBINPUT_PROP_TAP "libinput Tapping Enabled"
/* Tapping default enabled/disabled: BOOL, 1 value, read-only */
#define LIBINPUT_PROP_TAP_DEFAULT "libinput Tapping Enabled Default"
/* Tap drag lock enabled/disabled: BOOL, 1 value */
#define LIBINPUT_PROP_TAP_DRAG_LOCK "libinput Tapping Drag Lock Enabled"
/* Tap drag lock default enabled/disabled: BOOL, 1 value */
#define LIBINPUT_PROP_TAP_DRAG_LOCK_DEFAULT "libinput Tapping Drag Lock Enabled Default"
/* Calibration matrix: FLOAT, 9 values of a 3x3 matrix, in rows */
#define LIBINPUT_PROP_CALIBRATION "libinput Calibration Matrix"
/* Calibration matrix: FLOAT, 9 values of a 3x3 matrix, in rows, read-only*/
#define LIBINPUT_PROP_CALIBRATION_DEFAULT "libinput Calibration Matrix Default"
/* Pointer accel speed: FLOAT, 1 value, 32 bit */
#define LIBINPUT_PROP_ACCEL "libinput Accel Speed"
/* Pointer accel speed: FLOAT, 1 value, 32 bit, read-only*/
#define LIBINPUT_PROP_ACCEL_DEFAULT "libinput Accel Speed Default"
/* Pointer accel profile: BOOL, 2 values in oder adaptive, flat,
* only one is enabled at a time at max, read-only */
#define LIBINPUT_PROP_ACCEL_PROFILES_AVAILABLE "libinput Accel Profiles Available"
/* Pointer accel profile: BOOL, 2 values in order adaptive, flat,
only one is enabled at a time at max, read-only */
#define LIBINPUT_PROP_ACCEL_PROFILE_ENABLED_DEFAULT "libinput Accel Profile Enabled Default"
/* Pointer accel profile: BOOL, 2 values in order adaptive, flat,
only one is enabled at a time at max */
#define LIBINPUT_PROP_ACCEL_PROFILE_ENABLED "libinput Accel Profile Enabled"
/* Natural scrolling: BOOL, 1 value */
#define LIBINPUT_PROP_NATURAL_SCROLL "libinput Natural Scrolling Enabled"
/* Natural scrolling: BOOL, 1 value, read-only */
#define LIBINPUT_PROP_NATURAL_SCROLL_DEFAULT "libinput Natural Scrolling Enabled Default"
/* Send-events mode: BOOL read-only, 2 values in order disabled,
disabled-on-external-mouse */
#define LIBINPUT_PROP_SENDEVENTS_AVAILABLE "libinput Send Events Modes Available"
/* Send-events mode: BOOL, 2 values in order disabled,
disabled-on-external-mouse */
#define LIBINPUT_PROP_SENDEVENTS_ENABLED "libinput Send Events Mode Enabled"
/* Send-events mode: BOOL, 2 values in order disabled,
disabled-on-external-mouse, read-only */
#define LIBINPUT_PROP_SENDEVENTS_ENABLED_DEFAULT "libinput Send Events Mode Enabled Default"
/* Left-handed enabled/disabled: BOOL, 1 value */
#define LIBINPUT_PROP_LEFT_HANDED "libinput Left Handed Enabled"
/* Left-handed enabled/disabled: BOOL, 1 value, read-only */
#define LIBINPUT_PROP_LEFT_HANDED_DEFAULT "libinput Left Handed Enabled Default"
/* Scroll method: BOOL read-only, 3 values in order 2fg, edge, button.
shows available scroll methods */
#define LIBINPUT_PROP_SCROLL_METHODS_AVAILABLE "libinput Scroll Methods Available"
/* Scroll method: BOOL, 3 values in order 2fg, edge, button
only one is enabled at a time at max */
#define LIBINPUT_PROP_SCROLL_METHOD_ENABLED "libinput Scroll Method Enabled"
/* Scroll method: BOOL, 3 values in order 2fg, edge, button
only one is enabled at a time at max, read-only */
#define LIBINPUT_PROP_SCROLL_METHOD_ENABLED_DEFAULT "libinput Scroll Method Enabled Default"
/* Scroll button for button scrolling: 32-bit int, 1 value */
#define LIBINPUT_PROP_SCROLL_BUTTON "libinput Button Scrolling Button"
/* Scroll button for button scrolling: 32-bit int, 1 value, read-only */
#define LIBINPUT_PROP_SCROLL_BUTTON_DEFAULT "libinput Button Scrolling Button Default"
/* 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"
/* Click method: BOOL, 2 values in order buttonareas, clickfinger
only one enabled at a time at max, read-only */
#define LIBINPUT_PROP_CLICK_METHOD_ENABLED_DEFAULT "libinput Click Method Enabled Default"
/* Middle button emulation: BOOL, 1 value */
#define LIBINPUT_PROP_MIDDLE_EMULATION_ENABLED "libinput Middle Emulation Enabled"
/* Middle button emulation: BOOL, 1 value, read-only */
#define LIBINPUT_PROP_MIDDLE_EMULATION_ENABLED_DEFAULT "libinput Middle Emulation Enabled Default"
/* Disable while typing: BOOL, 1 value */
#define LIBINPUT_PROP_DISABLE_WHILE_TYPING "libinput Disable While Typing Enabled"
/* Disable while typing: BOOL, 1 value, read-only */
#define LIBINPUT_PROP_DISABLE_WHILE_TYPING_DEFAULT "libinput Disable While Typing Enabled Default"
/* Drag lock buttons, either:
CARD8, one value, the meta lock button, or
CARD8, n * 2 values, the drag lock pairs with n being the button and n+1
the target button number */
#define LIBINPUT_PROP_DRAG_LOCK_BUTTONS "libinput Drag Lock Buttons"
/* Horizontal scroll events enabled: BOOL, 1 value (0 or 1).
* If disabled, horizontal scroll events are discarded */
#define LIBINPUT_PROP_HORIZ_SCROLL_ENABLED "libinput Horizonal Scroll Enabled"
#endif /* _LIBINPUT_PROPERTIES_H_ */

37
man/Makefile.am Normal file
View File

@@ -0,0 +1,37 @@
# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice (including the next
# paragraph) shall be included in all copies or substantial portions of the
# Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
#
drivermandir = $(DRIVER_MAN_DIR)
driverman_PRE = $(DRIVER_NAME).man
driverman_DATA = $(driverman_PRE:man=$(DRIVER_MAN_SUFFIX))
EXTRA_DIST = $(DRIVER_NAME).man
CLEANFILES = $(driverman_DATA)
SUFFIXES = .$(DRIVER_MAN_SUFFIX) .man
# String replacements in MAN_SUBSTS now come from xorg-macros.m4 via configure
.man.$(DRIVER_MAN_SUFFIX):
$(AM_V_GEN)$(SED) $(MAN_SUBSTS) < $< > $@

295
man/libinput.man Normal file
View File

@@ -0,0 +1,295 @@
.\" shorthand for double quote that works everywhere.
.ds q \N'34'
.TH LIBINPUT __drivermansuffix__ __vendorversion__
.SH NAME
libinput \- libinput-based X.Org input driver
.SH SYNOPSIS
.nf
.B "Section \*qInputDevice\*q"
.BI " Identifier \*q" devname \*q
.B " Driver \*qlibinput\*q"
.BI " Option \*qDevice\*q \*q" devpath \*q
\ \ ...
.B EndSection
.fi
.SH NOTE
This is the man page for the X input driver. If you are looking for the
library documentation, go to
.BI http://wayland.freedesktop.org/libinput/doc/
.SH DESCRIPTION
.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.
.PP
It is recommended that
.B libinput
devices are configured through the
.B InputClass
directive (refer to __xconfigfile__(__filemansuffix__)) instead of manual
per-device configuration. Devices configured in the
__xconfigfile__(__filemansuffix__) are not hot-plug capable.
.SH CONFIGURATION DETAILS
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
.B Options
are supported:
.TP 7
.BI "Option \*qDevice\*q \*q" string \*q
Specifies the device through which the device can be accessed. This will
generally be of the form \*q/dev/input/eventX\*q, where X is some integer.
When using
.B InputClass
directives, this option is set by the server.
The mapping from device node to hardware is system-dependent. Property:
"Device Node" (read-only).
.TP 7
.BI "Option \*qAccelProfile\*q \*q" string \*q
Sets the pointer acceleration profile to the given profile. Permitted values
are
.BI adaptive,
.BI flat.
Not all devices support this option or all profiles. If a profile is
unsupported, the default profile for this is used. For a description on the
profiles and their behavior, see the libinput documentation.
.TP 7
.BI "Option \*qAccelSpeed\*q \*q" float \*q
Sets the pointer acceleration speed within the range [-1, 1]
.TP 7
.BI "Option \*qButtonMapping\*q \*q" string \*q
Sets the logical button mapping for this device, see
XSetPointerMapping(__libmansuffix__). The string must be a
space-separated list of button mappings in the order of the
logical buttons on the device, starting with button 1.
The default mapping is "1 2 3 ... 32". A mapping of 0
deactivates the button. Multiple buttons can have the same mapping.
Invalid mapping strings are discarded and the default mapping
is used for all buttons. Buttons not specified in the user's mapping use the
default mapping. See section
.B BUTTON MAPPING
for more details.
.TP 7
.BI "Option \*qCalibrationMatrix\*q \*q" string \*q
A string of 9 space-separated floating point numbers, in the order
\*qa b c d e f g h i\*q.
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
.BI "Option \*qMiddleEmulation\*q \*q" bool \*q
Enables middle button emulation. When enabled, pressing the left and right
buttons simultaneously produces a middle mouse button click.
.TP 7
.BI "Option \*qNaturalScrolling\*q \*q" bool \*q
Enables or disables natural scrolling behavior.
.TP 7
.BI "Option \*qScrollButton\*q \*q" int \*q
Designates a button as scroll button. If the
.BI ScrollMethod
is
.BI button
and the button is logically held down, x/y axis movement is converted into
scroll events.
.TP 7
.BI "Option \*qScrollMethod\*q \*q" string \*q
Enables a scroll method. Permitted values are
.BI none,
.BI twofinger,
.BI edge,
.BI button.
Not all devices support all options, if an option is unsupported, the
default scroll option for this device is used.
.TP 7
.BI "Option \*qHorizontalScrolling\*q" bool \*q
Disables horizontal scrolling. When disabled, this driver will discard any
horizontal scroll events from libinput. Note that this does not disable
horizontal scrolling, it merely discards the horizontal axis from any scroll
events.
.TP 7
.BI "Option \*qSendEventsMode\*q \*q" (disabled|enabled|disabled-on-external-mouse) \*q
Sets the send events mode to disabled, enabled, or "disable when an external
mouse is connected".
.TP 7
.BI "Option \*qTapping\*q \*q" bool \*q
Enables or disables tap-to-click behavior.
.TP 7
.BI "Option \*qTappingDragLock\*q \*q" bool \*q
Enables or disables drag lock during tapping behavior. When enabled, a
finger up during tap-and-drag will not immediately release the button. If
the finger is set down again within the timeout, the dragging process
continues.
.TP 7
.BI "Option \*qDisableWhileTyping\*q \*q" bool \*q
Indicates if the touchpad should be disabled while typing on the keyboard
(this does not apply to modifier keys such as Ctrl or Alt).
.TP 7
.BI "Option \*qDragLockButtons\*q \*q" "L1 B1 L2 B2 ..." \*q
Sets "drag lock buttons" that simulate a button logically down even when it has
been physically released. To logically release a locked button, a second click
of the same button is required.
.IP
If the option is a single button number, that button acts as the
"meta" locking button for the next button number. See section
.B BUTTON DRAG LOCK
for details.
.IP
If the option is a list of button number pairs, the first number of each
number pair is the lock button, the second number the logical button number
to be locked. See section
.B BUTTON DRAG LOCK
for details.
.IP
For both meta and button pair configuration, the button numbers are
device button numbers, i.e. the
.B ButtonMapping
applies after drag lock.
.PP
For all options, the options are only parsed if the device supports that
configuration option. For all options, the default value is the one used by
libinput. On configuration failure, the default value is applied.
.SH SUPPORTED PROPERTIES
.B libinput
exports runtime-configurable options as properties. If a property listed
below is not available, the matching configuration option is not available
on the device. This however does not imply that the feature is not available
on the device. The following properties are provided by the
.B libinput
driver.
.TP 7
.BI "libinput Tapping Enabled"
1 boolean value (8 bit, 0 or 1). 1 enables tapping
.TP 7
.BI "libinput Tapping Drag Lock Enabled"
1 boolean value (8 bit, 0 or 1). 1 enables drag lock during tapping
.TP 7
.BI "libinput Calibration Matrix"
9 32-bit float values, representing a 3x3 calibration matrix, order is row
1, row 2, row 3
.TP 7
.BI "libinput Accel Speed"
1 32-bit float value, defines the pointer speed. Value range -1, 1
.TP 7
.BI "libinput Natural Scrolling Enabled"
1 boolean value (8 bit, 0 or 1). 1 enables natural scrolling
.TP 7
.BI "libinput Send Events Modes Available"
2 boolean values (8 bit, 0 or 1), in order "disabled" and
"disabled-on-external-mouse". Indicates which send-event modes are available
on this device.
.TP 7
.BI "libinput Send Events Mode Enabled"
2 boolean values (8 bit, 0 or 1), in order "disabled" and
"disabled-on-external-mouse". Indicates which send-event modes is currently
enabled on this device.
.TP 7
.BI "libinput Left Handed Enabled"
1 boolean value (8 bit, 0 or 1). Indicates if left-handed mode is enabled or
disabled.
.TP 7
.BI "libinput Scroll Methods Available"
3 boolean values (8 bit, 0 or 1), in order "two-finger", "edge", "button".
Indicates which scroll methods are available on this device.
.TP 7
.BI "libinput Scroll Method Enabled"
3 boolean values (8 bit, 0 or 1), in order "two-finger", "edge", "button".
Indicates which scroll method is currently enabled on this device.
.TP 7
.BI "libinput Button Scrolling Button"
1 32-bit value. Sets the button number to use for button scrolling. This
setting is independent of the scroll method, to enable button scrolling the
method must be set to button-scrolling and a valid button must be set.
.TP 7
.BI "libinput Click Methods Available"
2 boolean values (8 bit, 0 or 1), in order "buttonareas", "clickfinger".
Indicates which click methods are available on this device.
.TP 7
.BI "libinput Click Methods Enabled"
2 boolean values (8 bit, 0 or 1), in order "buttonareas", "clickfinger".
Indicates which click methods are enabled on this device.
.TP 7
.BI "libinput Middle Emulation Enabled"
1 boolean value (8 bit, 0 or 1). Indicates if middle emulation is enabled or
disabled.
.TP 7
.BI "libinput Disable While Typing Enabled"
1 boolean value (8 bit, 0 or 1). Indicates if disable while typing is
enabled or disabled.
.PP
The above properties have a
.BI "libinput <property name> Default"
equivalent that indicates the default value for this setting on this device.
.TP 7
.BI "libinput Drag Lock Buttons"
Either one 8-bit value specifying the meta drag lock button, or a list of
button pairs. See section
.B BUTTON DRAG LOCK
for details.
.TP 7
.BI "libinput Horizontal Scrolling Enabled"
1 boolean value (8 bit, 0 or 1). Indicates whether horizontal scrolling
events are enabled or not.
.SH BUTTON MAPPING
X clients receive events with logical button numbers, where 1, 2, 3
are usually interpreted as left, middle, right and logical buttons 4, 5, 6,
7 are usually interpreted as scroll up, down, left, right. The fourth and
fifth physical buttons on a device will thus send logical buttons 8 and 9.
The
.B ButtonMapping
option adjusts the logical button mapping, it does not affect how a physical
button is mapped to a logical button.
.PP
Traditionally, a device was set to left-handed button mode by applying a
button mapping of
.B "\*q3 2 1 ...\*q"
On systems using the
.B libinput
__xservername__ input driver it is recommended to use the
.B LeftHanded
option instead.
.PP
The
.B libinput
__xservername__ input driver does not use the button mapping after setup.
Use XSetPointerMapping(__libmansuffix__) to modify the button mapping at
runtime.
.SH BUTTON DRAG LOCK
Button drag lock holds a button logically down even when the button itself
has been physically released since. Button drag lock comes in two modes.
.PP
If in "meta" mode, a meta button click activates drag lock for the next
button press of any other button. A button click in the future will keep
that button held logically down until a subsequent click of that same
button. The meta button events themselves are discarded. A separate meta
button click is required each time a drag lock should be activated for a
button in the future.
.PP
If in "pairs" mode, each button can be assigned a target locking button.
On button click, the target lock button is held logically down until the
next click of the same button. The button events themselves are discarded
and only the target button events are sent.
.TP
This feature is provided by this driver, not by libinput.
.SH AUTHORS
Peter Hutterer
.SH "SEE ALSO"
__xservername__(__appmansuffix__), __xconfigfile__(__filemansuffix__), Xserver(__appmansuffix__), X(__miscmansuffix__)

View File

@@ -30,8 +30,10 @@ AM_CPPFLAGS =-I$(top_srcdir)/include $(LIBINPUT_CFLAGS)
@DRIVER_NAME@_drv_la_LTLIBRARIES = @DRIVER_NAME@_drv.la
@DRIVER_NAME@_drv_la_LDFLAGS = -module -avoid-version
@DRIVER_NAME@_drv_la_LIBADD = $(LIBINPUT_LIBS)
@DRIVER_NAME@_drv_la_LIBADD = $(LIBINPUT_LIBS) libdraglock.la
@DRIVER_NAME@_drv_ladir = @inputdir@
@DRIVER_NAME@_drv_la_SOURCES = @DRIVER_NAME@.c
@DRIVER_NAME@_drv_la_SOURCES = xf86libinput.c
noinst_LTLIBRARIES = libdraglock.la
libdraglock_la_SOURCES = draglock.c draglock.h

282
src/draglock.c Normal file
View File

@@ -0,0 +1,282 @@
/*
* Copyright © 2015 Red Hat, Inc.
*
* Permission to use, copy, modify, distribute, and sell this software
* and its documentation for any purpose is hereby granted without
* fee, provided that the above copyright notice appear in all copies
* and that both that copyright notice and this permission notice
* appear in supporting documentation, and that the name of Red Hat
* not be used in advertising or publicity pertaining to distribution
* of the software without specific, written prior permission. Red
* Hat makes no representations about the suitability of this software
* for any purpose. It is provided "as is" without express or implied
* warranty.
*
* THE AUTHORS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
* NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "draglock.h"
#include <string.h>
#include <stdlib.h>
#define ARRAY_SIZE(a) (sizeof(a)/sizeof((a)[0]))
static int
draglock_parse_config(struct draglock *dl, const char *config)
{
int button = 0, target = 0;
const char *str = NULL;
char *end_str = NULL;
int pairs[DRAGLOCK_MAX_BUTTONS] = {0};
if (!config)
return 0;
/* empty string disables drag lock */
if (*config == '\0') {
dl->mode = DRAGLOCK_DISABLED;
return 0;
}
/* check for a single-number string first, config is "<int>" */
button = strtol(config, &end_str, 10);
if (*end_str == '\0') {
if (button < 0 || button >= DRAGLOCK_MAX_BUTTONS)
return 1;
/* we allow for button 0 so stacked xorg.conf.d snippets can
* disable the config again */
if (button == 0) {
dl->mode = DRAGLOCK_DISABLED;
return 0;
}
return draglock_set_meta(dl, button);
}
dl->mode = DRAGLOCK_DISABLED;
/* check for a set of button pairs, config is
* "<int> <int> <int> <int>..." */
str = config;
while (*str != '\0') {
button = strtol(str, &end_str, 10);
if (*end_str == '\0')
return 1;
str = end_str;
target = strtol(str, &end_str, 10);
if (end_str == str)
return 1;
if (button <= 0 || button >= DRAGLOCK_MAX_BUTTONS || target >= DRAGLOCK_MAX_BUTTONS)
return 1;
pairs[button] = target;
str = end_str;
}
return draglock_set_pairs(dl, pairs, ARRAY_SIZE(pairs));
}
int
draglock_init_from_string(struct draglock *dl, const char *config)
{
dl->mode = DRAGLOCK_DISABLED;
dl->meta_button = 0;
dl->meta_state = false;
memset(dl->lock_pair, 0, sizeof(dl->lock_pair));
memset(dl->lock_state, 0, sizeof(dl->lock_state));
return draglock_parse_config(dl, config);
}
enum draglock_mode
draglock_get_mode(const struct draglock *dl)
{
return dl->mode;
}
int
draglock_get_meta(const struct draglock *dl)
{
if (dl->mode == DRAGLOCK_META)
return dl->meta_button;
return 0;
}
size_t
draglock_get_pairs(const struct draglock *dl, int *array, size_t sz)
{
unsigned int i;
size_t last = 0;
if (dl->mode != DRAGLOCK_PAIRS)
return 0;
/* size 1 array with the meta button */
if (dl->meta_button) {
*array = dl->meta_button;
return 1;
}
/* 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++) {
array[i] = dl->lock_pair[i];
if (array[i] != 0 && i > last)
last = i;
}
return last;
}
int
draglock_set_meta(struct draglock *dl, int meta_button)
{
if (meta_button < 0 || meta_button >= DRAGLOCK_MAX_BUTTONS)
return 1;
dl->meta_button = meta_button;
dl->mode = meta_button ? DRAGLOCK_META : DRAGLOCK_DISABLED;
return 0;
}
int
draglock_set_pairs(struct draglock *dl, const int *array, size_t sz)
{
unsigned int i;
if (sz == 0 || array[0] != 0)
return 1;
for (i = 0; i < sz; i++) {
if (array[i] < 0 || array[i] >= DRAGLOCK_MAX_BUTTONS)
return 1;
}
dl->mode = DRAGLOCK_DISABLED;
for (i = 0; i < sz; i++) {
dl->lock_pair[i] = array[i];
if (dl->lock_pair[i])
dl->mode = DRAGLOCK_PAIRS;
}
return 0;
}
static int
draglock_filter_meta(struct draglock *dl, int *button, int *press)
{
int b = *button,
is_press = *press;
if (b == dl->meta_button) {
if (is_press)
dl->meta_state = true;
*button = 0;
return 0;
}
switch (dl->lock_state[b]) {
case DRAGLOCK_BUTTON_STATE_NONE:
if (dl->meta_state && is_press) {
dl->lock_state[b] = DRAGLOCK_BUTTON_STATE_DOWN_1;
dl->meta_state = false;
}
break;
case DRAGLOCK_BUTTON_STATE_DOWN_1:
if (!is_press) {
dl->lock_state[b] = DRAGLOCK_BUTTON_STATE_UP_1;
b = 0;
}
break;
case DRAGLOCK_BUTTON_STATE_UP_1:
if (is_press) {
dl->lock_state[b] = DRAGLOCK_BUTTON_STATE_DOWN_2;
b = 0;
}
break;
case DRAGLOCK_BUTTON_STATE_DOWN_2:
if (!is_press) {
dl->lock_state[b] = DRAGLOCK_BUTTON_STATE_NONE;
}
break;
}
*button = b;
return 0;
}
static int
draglock_filter_pair(struct draglock *dl, int *button, int *press)
{
int b = *button,
is_press = *press;
if (dl->lock_pair[b] == 0)
return 0;
switch (dl->lock_state[b]) {
case DRAGLOCK_BUTTON_STATE_NONE:
if (is_press) {
dl->lock_state[b] = DRAGLOCK_BUTTON_STATE_DOWN_1;
b = dl->lock_pair[b];
}
break;
case DRAGLOCK_BUTTON_STATE_DOWN_1:
if (!is_press) {
dl->lock_state[b] = DRAGLOCK_BUTTON_STATE_UP_1;
b = 0;
}
break;
case DRAGLOCK_BUTTON_STATE_UP_1:
if (is_press) {
dl->lock_state[b] = DRAGLOCK_BUTTON_STATE_DOWN_2;
b = 0;
}
break;
case DRAGLOCK_BUTTON_STATE_DOWN_2:
if (!is_press) {
dl->lock_state[b] = DRAGLOCK_BUTTON_STATE_NONE;
b = dl->lock_pair[b];
}
break;
}
*button = b;
return 0;
}
int
draglock_filter_button(struct draglock *dl, int *button, int *is_press)
{
if (*button == 0)
return 0;
switch(dl->mode) {
case DRAGLOCK_DISABLED:
return 0;
case DRAGLOCK_META:
return draglock_filter_meta(dl, button, is_press);
case DRAGLOCK_PAIRS:
return draglock_filter_pair(dl, button, is_press);
default:
abort();
break;
}
return 0;
}

159
src/draglock.h Normal file
View File

@@ -0,0 +1,159 @@
/*
* Copyright © 2015 Red Hat, Inc.
*
* Permission to use, copy, modify, distribute, and sell this software
* and its documentation for any purpose is hereby granted without
* fee, provided that the above copyright notice appear in all copies
* and that both that copyright notice and this permission notice
* appear in supporting documentation, and that the name of Red Hat
* not be used in advertising or publicity pertaining to distribution
* of the software without specific, written prior permission. Red
* Hat makes no representations about the suitability of this software
* for any purpose. It is provided "as is" without express or implied
* warranty.
*
* THE AUTHORS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
* NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifndef DRAGLOCK_H
#define DRAGLOCK_H 1
#include <stdbool.h>
#include <stdlib.h>
/* 32 buttons are enough for everybody™
* Note that this is the limit of physical buttons as well as the highest
* allowed target button.
*/
#define DRAGLOCK_MAX_BUTTONS 32
enum draglock_mode
{
DRAGLOCK_DISABLED,
DRAGLOCK_META,
DRAGLOCK_PAIRS
};
enum draglock_button_state
{
DRAGLOCK_BUTTON_STATE_NONE,
DRAGLOCK_BUTTON_STATE_DOWN_1,
DRAGLOCK_BUTTON_STATE_UP_1,
DRAGLOCK_BUTTON_STATE_DOWN_2,
};
struct draglock
{
enum draglock_mode mode;
int meta_button; /* meta key to lock any button */
bool meta_state; /* meta_button state */
unsigned int lock_pair[DRAGLOCK_MAX_BUTTONS + 1];/* specify a meta/lock pair */
enum draglock_button_state lock_state[DRAGLOCK_MAX_BUTTONS + 1]; /* state of any locked buttons */
};
/**
* Initialize the draglock struct based on the config string. The string is
* either a single number to configure DRAGLOCK_META mode or a list of
* number pairs, with pair[0] as button and pair[1] as target lock number to
* configure DRAGLOCK_PAIRS mode.
*
* If config is NULL, the empty string, "0" or an even-numbered list of 0,
* the drag lock mode is DRAGLOCK_DISABLED.
*
* @return 0 on success or nonzero on error
*/
int
draglock_init_from_string(struct draglock *dl, const char *config);
/**
* Get the current drag lock mode.
*
* If the mode is DRAGLOCK_META, a meta button click will cause the next
* subsequent button click to be held logically down until the release of
* the second button click of that same button. Events from the meta button
* are always discarded.
*
* If the mode is DRAGLOCK_PAIRS, any button may be configured with a
* 'target' button number. A click of that button causes the target button
* to be held logically down until the release of the second button click.
*/
enum draglock_mode
draglock_get_mode(const struct draglock *dl);
/**
* @return the meta button number or 0 if the current mode is not
* DRAGLOCK_META.
*/
int
draglock_get_meta(const struct draglock *dl);
/**
* Get the drag lock button mapping pairs. The array is filled with the
* button number as index and the mapped target button number as value, i.e.
* array[3] == 8 means button 3 will draglock button 8.
*
* A value of 0 indicates draglock is disabled for that button.
*
* @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
*
* @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);
/**
* Set the drag lock config to the DRAGLOCK_META mode, with the given
* button as meta button.
*
* If the button is 0 the mode becomes DRAGLOCK_DISABLED.
*
* @return 0 on success, nonzero otherwise
*/
int
draglock_set_meta(struct draglock *dl, int meta_button);
/**
* Set the drag lock config to the DRAGLOCK_PAIRS mode. The array
* must be filled with the button number as index and the mapped target
* button number as value, i.e.
* array[3] == 8 means button 3 will draglock button 8.
*
* A value of 0 indicates draglock is disabled for that button. If all
* buttons are 0, the mode becomes DRAGLOCK_DISABLED.
*
* @note Button numbers start at 1, array[0] is always 0.
*
* @return 0 on successor nonzero otherwise
*/
int
draglock_set_pairs(struct draglock *dl, const int *array, size_t sz);
/**
* Process the given button event through the drag lock state machine.
* If the event is to be discarded by the caller, button is set to 0.
* Otherwise, button is set to the button event to process and is_press is
* set to the button state to process.
*
* @param[in|out] button The button number to process
* @param[in|out] is_press nonzero for press, zero for release
*
* @return 0 on success or 1 on error
*/
int
draglock_filter_button(struct draglock *dl, int *button, int *is_press);
#endif /* DRAGLOCK_H */

View File

@@ -1,675 +0,0 @@
/*
* Copyright © 2013 Red Hat, Inc.
*
* Permission to use, copy, modify, distribute, and sell this software
* and its documentation for any purpose is hereby granted without
* fee, provided that the above copyright notice appear in all copies
* and that both that copyright notice and this permission notice
* appear in supporting documentation, and that the name of Red Hat
* not be used in advertising or publicity pertaining to distribution
* of the software without specific, written prior permission. Red
* Hat makes no representations about the suitability of this software
* for any purpose. It is provided "as is" without express or implied
* warranty.
*
* THE AUTHORS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
* NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <sys/epoll.h>
#include <errno.h>
#include <fcntl.h>
#include <time.h>
#include <unistd.h>
#include <xorg-server.h>
#include <exevents.h>
#include <xkbsrv.h>
#include <xf86Xinput.h>
#include <xserver-properties.h>
#include <libinput.h>
#include <linux/input.h>
#define TOUCHPAD_MAX_BUTTONS 7 /* three buttons, 4 scroll buttons */
#define TOUCHPAD_NUM_AXES 4 /* x, y, hscroll, vscroll */
#define TOUCH_MAX_SLOTS 15
#define XORG_KEYCODE_OFFSET 8
/*
libinput does not provide axis information for absolute devices, instead
it scales into the screen dimensions provided. So we set up the axes with
a fixed range, let libinput scale into that range and then the server
do the scaling it usually does.
*/
#define TOUCH_AXIS_MAX 0xffff
/*
libinput scales wheel events by DEFAULT_AXIS_STEP_DISTANCE, which is
currently 10.
*/
#define DEFAULT_LIBINPUT_AXIS_STEP_DISTANCE 10
struct xf86libinput_driver {
struct libinput *libinput;
int device_enabled_count;
};
static struct xf86libinput_driver driver_context;
struct xf86libinput {
char *path;
struct libinput_device *device;
int scroll_vdist;
int scroll_hdist;
int scroll_vdist_remainder;
int scroll_hdist_remainder;
struct {
double x;
double y;
double x_remainder;
double y_remainder;
} scale;
ValuatorMask *valuators;
};
static int
xf86libinput_on(DeviceIntPtr dev)
{
InputInfoPtr pInfo = dev->public.devicePrivate;
struct xf86libinput *driver_data = pInfo->private;
struct libinput *libinput = driver_context.libinput;
struct libinput_device *device = driver_data->device;
device = libinput_path_add_device(libinput, driver_data->path);
if (!device)
return !Success;
libinput_device_ref(device);
libinput_device_set_user_data(device, pInfo);
driver_data->device = device;
pInfo->fd = libinput_get_fd(libinput);
if (driver_context.device_enabled_count == 0) {
/* Can't use xf86AddEnabledDevice on an epollfd */
AddEnabledDevice(pInfo->fd);
}
driver_context.device_enabled_count++;
dev->public.on = TRUE;
return Success;
}
static int
xf86libinput_off(DeviceIntPtr dev)
{
InputInfoPtr pInfo = dev->public.devicePrivate;
struct xf86libinput *driver_data = pInfo->private;
if (--driver_context.device_enabled_count == 0) {
RemoveEnabledDevice(pInfo->fd);
}
pInfo->fd = -1;
dev->public.on = FALSE;
libinput_device_set_user_data(driver_data->device, NULL);
libinput_path_remove_device(driver_data->device);
libinput_device_unref(driver_data->device);
driver_data->device = NULL;
return Success;
}
static void
xf86libinput_ptr_ctl(DeviceIntPtr dev, PtrCtrl *ctl)
{
}
static void
init_button_map(unsigned char *btnmap, size_t size)
{
int i;
memset(btnmap, 0, size);
for (i = 0; i <= TOUCHPAD_MAX_BUTTONS; i++)
btnmap[i] = i;
}
static void
init_button_labels(Atom *labels, size_t size)
{
memset(labels, 0, size * sizeof(Atom));
labels[0] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_LEFT);
labels[1] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_MIDDLE);
labels[2] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_RIGHT);
labels[3] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_UP);
labels[4] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_DOWN);
labels[5] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_HWHEEL_LEFT);
labels[6] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_HWHEEL_RIGHT);
}
static void
init_axis_labels(Atom *labels, size_t size)
{
memset(labels, 0, size * sizeof(Atom));
labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_X);
labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_Y);
labels[2] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_HSCROLL);
labels[3] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_VSCROLL);
}
static int
xf86libinput_init_pointer(InputInfoPtr pInfo)
{
DeviceIntPtr dev= pInfo->dev;
struct xf86libinput *driver_data = pInfo->private;
int min, max, res;
unsigned char btnmap[TOUCHPAD_MAX_BUTTONS + 1];
Atom btnlabels[TOUCHPAD_MAX_BUTTONS];
Atom axislabels[TOUCHPAD_NUM_AXES];
init_button_map(btnmap, ARRAY_SIZE(btnmap));
init_button_labels(btnlabels, ARRAY_SIZE(btnlabels));
init_axis_labels(axislabels, ARRAY_SIZE(axislabels));
InitPointerDeviceStruct((DevicePtr)dev, btnmap,
TOUCHPAD_MAX_BUTTONS,
btnlabels,
xf86libinput_ptr_ctl,
GetMotionHistorySize(),
TOUCHPAD_NUM_AXES,
axislabels);
min = -1;
max = -1;
res = 0;
xf86InitValuatorAxisStruct(dev, 0,
XIGetKnownProperty(AXIS_LABEL_PROP_REL_X),
min, max, res * 1000, 0, res * 1000, Relative);
xf86InitValuatorAxisStruct(dev, 1,
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);
return Success;
}
static void
xf86libinput_kbd_ctrl(DeviceIntPtr device, KeybdCtrl *ctrl)
{
#define CAPSFLAG 1
#define NUMFLAG 2
#define SCROLLFLAG 4
static struct { int xbit, code; } bits[] = {
{ CAPSFLAG, LIBINPUT_LED_CAPS_LOCK },
{ NUMFLAG, LIBINPUT_LED_NUM_LOCK },
{ SCROLLFLAG, LIBINPUT_LED_SCROLL_LOCK },
{ 0, 0 },
};
int i = 0;
enum libinput_led leds = 0;
InputInfoPtr pInfo = device->public.devicePrivate;
struct xf86libinput *driver_data = pInfo->private;
struct libinput_device *ldevice = driver_data->device;
while (bits[i].xbit) {
if (ctrl->leds & bits[i].xbit)
leds |= bits[i].code;
i++;
}
libinput_device_led_update(ldevice, leds);
}
static void
xf86libinput_init_keyboard(InputInfoPtr pInfo)
{
DeviceIntPtr dev= pInfo->dev;
XkbRMLVOSet rmlvo = {0};
rmlvo.rules = xf86SetStrOption(pInfo->options, "xkb_rules", "evdev");
rmlvo.model = xf86SetStrOption(pInfo->options, "xkb_model", "pc104");
rmlvo.layout = xf86SetStrOption(pInfo->options, "xkb_layout", "us");
rmlvo.variant = xf86SetStrOption(pInfo->options, "xkb_variant", NULL);
rmlvo.options = xf86SetStrOption(pInfo->options, "xkb_options", NULL);
InitKeyboardDeviceStruct(dev, &rmlvo, NULL,
xf86libinput_kbd_ctrl);
XkbFreeRMLVOSet(&rmlvo, FALSE);
}
static void
xf86libinput_init_touch(InputInfoPtr pInfo)
{
DeviceIntPtr dev = pInfo->dev;
int min, max, res;
unsigned char btnmap[TOUCHPAD_MAX_BUTTONS + 1];
Atom btnlabels[TOUCHPAD_MAX_BUTTONS];
Atom axislabels[TOUCHPAD_NUM_AXES];
init_button_map(btnmap, ARRAY_SIZE(btnmap));
init_button_labels(btnlabels, ARRAY_SIZE(btnlabels));
init_axis_labels(axislabels, ARRAY_SIZE(axislabels));
InitPointerDeviceStruct((DevicePtr)dev, btnmap,
TOUCHPAD_MAX_BUTTONS,
btnlabels,
xf86libinput_ptr_ctl,
GetMotionHistorySize(),
TOUCHPAD_NUM_AXES,
axislabels);
min = 0;
max = TOUCH_AXIS_MAX;
res = 0;
xf86InitValuatorAxisStruct(dev, 0,
XIGetKnownProperty(AXIS_LABEL_PROP_ABS_X),
min, max, res * 1000, 0, res * 1000, Absolute);
xf86InitValuatorAxisStruct(dev, 1,
XIGetKnownProperty(AXIS_LABEL_PROP_ABS_Y),
min, max, res * 1000, 0, res * 1000, Absolute);
InitTouchClassDeviceStruct(dev, TOUCH_MAX_SLOTS, XIDirectTouch, 2);
}
static int
xf86libinput_init(DeviceIntPtr dev)
{
InputInfoPtr pInfo = dev->public.devicePrivate;
struct xf86libinput *driver_data = pInfo->private;
struct libinput_device *device = driver_data->device;
dev->public.on = FALSE;
if (libinput_device_has_capability(device, LIBINPUT_DEVICE_CAP_KEYBOARD))
xf86libinput_init_keyboard(pInfo);
if (libinput_device_has_capability(device, LIBINPUT_DEVICE_CAP_POINTER))
xf86libinput_init_pointer(pInfo);
if (libinput_device_has_capability(device, LIBINPUT_DEVICE_CAP_TOUCH))
xf86libinput_init_touch(pInfo);
/* unref the device now, because we'll get a new ref during
DEVICE_ON */
libinput_device_unref(device);
return 0;
}
static void
xf86libinput_destroy(DeviceIntPtr dev)
{
}
static int
xf86libinput_device_control(DeviceIntPtr dev, int mode)
{
int rc = BadValue;
switch(mode) {
case DEVICE_INIT:
rc = xf86libinput_init(dev);
break;
case DEVICE_ON:
rc = xf86libinput_on(dev);
break;
case DEVICE_OFF:
rc = xf86libinput_off(dev);
break;
case DEVICE_CLOSE:
xf86libinput_destroy(dev);
break;
}
return rc;
}
static void
xf86libinput_handle_motion(InputInfoPtr pInfo, struct libinput_event_pointer *event)
{
DeviceIntPtr dev = pInfo->dev;
struct xf86libinput *driver_data = pInfo->private;
ValuatorMask *mask = driver_data->valuators;
double x, y;
x = libinput_event_pointer_get_dx(event);
y = libinput_event_pointer_get_dy(event);
valuator_mask_zero(mask);
valuator_mask_set_double(mask, 0, x);
valuator_mask_set_double(mask, 1, y);
xf86PostMotionEventM(dev, Relative, mask);
}
static void
xf86libinput_handle_button(InputInfoPtr pInfo, struct libinput_event_pointer *event)
{
DeviceIntPtr dev = pInfo->dev;
int button;
int is_press;
switch(libinput_event_pointer_get_button(event)) {
case BTN_LEFT: button = 1; break;
case BTN_MIDDLE: button = 2; break;
case BTN_RIGHT: button = 3; break;
default: /* no touchpad actually has those buttons */
return;
}
is_press = (libinput_event_pointer_get_button_state(event) == LIBINPUT_BUTTON_STATE_PRESSED);
xf86PostButtonEvent(dev, Relative, button, is_press, 0, 0);
}
static void
xf86libinput_handle_key(InputInfoPtr pInfo, struct libinput_event_keyboard *event)
{
DeviceIntPtr dev = pInfo->dev;
int is_press;
int key = libinput_event_keyboard_get_key(event);
key += XORG_KEYCODE_OFFSET;
is_press = (libinput_event_keyboard_get_key_state(event) == LIBINPUT_KEY_STATE_PRESSED);
xf86PostKeyboardEvent(dev, key, is_press);
}
static void
xf86libinput_handle_axis(InputInfoPtr pInfo, struct libinput_event_pointer *event)
{
DeviceIntPtr dev = pInfo->dev;
struct xf86libinput *driver_data = pInfo->private;
ValuatorMask *mask = driver_data->valuators;
int axis;
double value;
if (libinput_event_pointer_get_axis(event) ==
LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL)
axis = 3;
else
axis = 2;
value = libinput_event_pointer_get_axis_value(event) / DEFAULT_LIBINPUT_AXIS_STEP_DISTANCE;
valuator_mask_zero(mask);
valuator_mask_set_double(mask, axis, value);
xf86PostMotionEventM(dev, Relative, mask);
}
static void
xf86libinput_handle_touch(InputInfoPtr pInfo,
struct libinput_event_touch *event,
enum libinput_event_type event_type)
{
DeviceIntPtr dev = pInfo->dev;
struct xf86libinput *driver_data = pInfo->private;
int type;
int slot;
ValuatorMask *m = driver_data->valuators;
double val;
/* libinput doesn't give us hw touch ids which X expects, so
emulate them here */
static int next_touchid;
static int touchids[TOUCH_MAX_SLOTS] = {0};
slot = libinput_event_touch_get_slot(event);
switch (event_type) {
case LIBINPUT_EVENT_TOUCH_DOWN:
type = XI_TouchBegin;
touchids[slot] = next_touchid++;
break;
case LIBINPUT_EVENT_TOUCH_UP:
type = XI_TouchEnd;
break;
case LIBINPUT_EVENT_TOUCH_MOTION:
type = XI_TouchUpdate;
break;
default:
return;
};
valuator_mask_zero(m);
if (event_type != LIBINPUT_EVENT_TOUCH_UP) {
val = libinput_event_touch_get_x_transformed(event, TOUCH_AXIS_MAX);
valuator_mask_set_double(m, 0, val);
val = libinput_event_touch_get_y_transformed(event, TOUCH_AXIS_MAX);
valuator_mask_set_double(m, 1, val);
}
xf86PostTouchEvent(dev, touchids[slot], type, 0, m);
}
static void
xf86libinput_handle_event(struct libinput_event *event)
{
struct libinput_device *device;
InputInfoPtr pInfo;
device = libinput_event_get_device(event);
pInfo = libinput_device_get_user_data(device);
if (pInfo && !pInfo->dev->public.on)
return;
switch (libinput_event_get_type(event)) {
case LIBINPUT_EVENT_NONE:
case LIBINPUT_EVENT_DEVICE_ADDED:
case LIBINPUT_EVENT_DEVICE_REMOVED:
break;
case LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE:
/* FIXME */
break;
case LIBINPUT_EVENT_POINTER_MOTION:
xf86libinput_handle_motion(pInfo,
libinput_event_get_pointer_event(event));
break;
case LIBINPUT_EVENT_POINTER_BUTTON:
xf86libinput_handle_button(pInfo,
libinput_event_get_pointer_event(event));
break;
case LIBINPUT_EVENT_KEYBOARD_KEY:
xf86libinput_handle_key(pInfo,
libinput_event_get_keyboard_event(event));
break;
case LIBINPUT_EVENT_POINTER_AXIS:
xf86libinput_handle_axis(pInfo,
libinput_event_get_pointer_event(event));
break;
case LIBINPUT_EVENT_TOUCH_FRAME:
break;
case LIBINPUT_EVENT_TOUCH_UP:
case LIBINPUT_EVENT_TOUCH_DOWN:
case LIBINPUT_EVENT_TOUCH_MOTION:
case LIBINPUT_EVENT_TOUCH_CANCEL:
xf86libinput_handle_touch(pInfo,
libinput_event_get_touch_event(event),
libinput_event_get_type(event));
break;
}
}
static void
xf86libinput_read_input(InputInfoPtr pInfo)
{
struct libinput *libinput = driver_context.libinput;
int rc;
struct libinput_event *event;
rc = libinput_dispatch(libinput);
if (rc == -EAGAIN)
return;
if (rc < 0) {
ErrorFSigSafe("Error reading events: %d\n", -rc);
return;
}
while ((event = libinput_get_event(libinput))) {
xf86libinput_handle_event(event);
libinput_event_destroy(event);
}
}
static int
open_restricted(const char *path, int flags, void *data)
{
int fd = open(path, flags);
return fd < 0 ? -errno : fd;
}
static void
close_restricted(int fd, void *data)
{
close(fd);
}
const struct libinput_interface interface = {
.open_restricted = open_restricted,
.close_restricted = close_restricted,
};
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;
pInfo->fd = -1;
pInfo->type_name = XI_TOUCHPAD;
pInfo->device_control = xf86libinput_device_control;
pInfo->read_input = xf86libinput_read_input;
pInfo->control_proc = NULL;
pInfo->switch_mode = NULL;
driver_data = calloc(1, sizeof(*driver_data));
if (!driver_data)
goto fail;
driver_data->valuators = valuator_mask_new(2);
if (!driver_data->valuators)
goto fail;
driver_data->scroll_vdist = 1;
driver_data->scroll_hdist = 1;
path = xf86SetStrOption(pInfo->options, "Device", NULL);
if (!path)
goto fail;
if (!driver_context.libinput)
driver_context.libinput = libinput_path_create_context(&interface, &driver_context);
else
libinput_ref(driver_context.libinput);
libinput = driver_context.libinput;
if (libinput == NULL) {
xf86IDrvMsg(pInfo, X_ERROR, "Creating a device for %s failed\n", path);
goto fail;
}
device = libinput_path_add_device(libinput, path);
if (!device) {
xf86IDrvMsg(pInfo, X_ERROR, "Failed to create a device for %s\n", path);
goto fail;
}
/* We ref the device but remove it afterwards. The hope is that
between now and DEVICE_INIT/DEVICE_ON, the device doesn't change.
*/
libinput_device_ref(device);
libinput_path_remove_device(device);
pInfo->fd = -1;
pInfo->private = driver_data;
driver_data->path = path;
driver_data->device = device;
pInfo->options = xf86ReplaceIntOption(pInfo->options, "AccelerationProfile", -1);
pInfo->options = xf86ReplaceStrOption(pInfo->options, "AccelerationScheme", "none");
return Success;
fail:
if (driver_data->valuators)
valuator_mask_free(&driver_data->valuators);
free(path);
free(driver_data);
return BadValue;
}
static void
xf86libinput_uninit(InputDriverPtr drv,
InputInfoPtr pInfo,
int flags)
{
struct xf86libinput *driver_data = pInfo->private;
if (driver_data) {
driver_context.libinput = libinput_unref(driver_context.libinput);
valuator_mask_free(&driver_data->valuators);
free(driver_data->path);
free(driver_data);
pInfo->private = NULL;
}
xf86DeleteInput(pInfo, flags);
}
InputDriverRec xf86libinput_driver = {
.driverVersion = 1,
.driverName = "libinput",
.PreInit = xf86libinput_pre_init,
.UnInit = xf86libinput_uninit,
};
static XF86ModuleVersionInfo xf86libinput_version_info = {
"libinput",
MODULEVENDORSTRING,
MODINFOSTRING1,
MODINFOSTRING2,
XORG_VERSION_CURRENT,
PACKAGE_VERSION_MAJOR, PACKAGE_VERSION_MINOR, PACKAGE_VERSION_PATCHLEVEL,
ABI_CLASS_XINPUT,
ABI_XINPUT_VERSION,
MOD_CLASS_XINPUT,
{0, 0, 0, 0}
};
static pointer
xf86libinput_setup_proc(pointer module, pointer options, int *errmaj, int *errmin)
{
xf86AddInputDriver(&xf86libinput_driver, module, 0);
return module;
}
_X_EXPORT XF86ModuleData libinputModuleData = {
.vers = &xf86libinput_version_info,
.setup = &xf86libinput_setup_proc,
.teardown = NULL
};

2926
src/xf86libinput.c Normal file

File diff suppressed because it is too large Load Diff

1
test/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
test-draglock

13
test/Makefile.am Normal file
View File

@@ -0,0 +1,13 @@
AM_CPPFLAGS = $(XORG_CFLAGS) \
$(CWARNFLAGS) \
-I$(top_srcdir)/include \
-I$(top_srcdir)/src
tests = test-draglock
noinst_PROGRAMS = $(tests)
test_draglock_SOURCES = test-draglock.c
test_draglock_LDADD = ../src/libdraglock.la
TESTS = $(tests)

540
test/test-draglock.c Normal file
View File

@@ -0,0 +1,540 @@
/*
* Copyright © 2013-2015 Red Hat, Inc.
*
* Permission to use, copy, modify, distribute, and sell this software
* and its documentation for any purpose is hereby granted without
* fee, provided that the above copyright notice appear in all copies
* and that both that copyright notice and this permission notice
* appear in supporting documentation, and that the name of Red Hat
* not be used in advertising or publicity pertaining to distribution
* of the software without specific, written prior permission. Red
* Hat makes no representations about the suitability of this software
* for any purpose. It is provided "as is" without express or implied
* warranty.
*
* THE AUTHORS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
* NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include "draglock.h"
#include <assert.h>
#include <string.h>
static void
test_config_empty(void)
{
struct draglock dl;
int rc;
rc = draglock_init_from_string(&dl, NULL);
assert(dl.mode == DRAGLOCK_DISABLED);
assert(rc == 0);
}
static void
test_config_invalid(void)
{
struct draglock dl;
int rc;
/* no trailing space */
rc = draglock_init_from_string(&dl, "1 ");
assert(rc != 0);
assert(dl.mode == DRAGLOCK_DISABLED);
rc = draglock_init_from_string(&dl, "256");
assert(rc != 0);
assert(dl.mode == DRAGLOCK_DISABLED);
rc = draglock_init_from_string(&dl, "-1");
assert(rc != 0);
assert(dl.mode == DRAGLOCK_DISABLED);
rc = draglock_init_from_string(&dl, "1 2 3");
assert(rc != 0);
assert(dl.mode == DRAGLOCK_DISABLED);
rc = draglock_init_from_string(&dl, "0 2");
assert(rc != 0);
assert(dl.mode == DRAGLOCK_DISABLED);
rc = draglock_init_from_string(&dl, "0 0");
assert(rc != 0);
assert(dl.mode == DRAGLOCK_DISABLED);
}
static void
test_config_disable(void)
{
struct draglock dl;
int rc;
rc = draglock_init_from_string(&dl, "");
assert(rc == 0);
assert(dl.mode == DRAGLOCK_DISABLED);
rc = draglock_init_from_string(&dl, "0");
assert(rc == 0);
assert(dl.mode == DRAGLOCK_DISABLED);
}
static void
test_config_meta_button(void)
{
struct draglock dl;
int rc;
rc = draglock_init_from_string(&dl, "1");
assert(rc == 0);
assert(dl.mode == DRAGLOCK_META);
assert(dl.meta_button == 1);
rc = draglock_init_from_string(&dl, "2");
assert(rc == 0);
assert(dl.mode == DRAGLOCK_META);
assert(dl.meta_button == 2);
rc = draglock_init_from_string(&dl, "10");
assert(rc == 0);
assert(dl.mode == DRAGLOCK_META);
assert(dl.meta_button == 10);
}
static void
test_config_button_pairs(void)
{
struct draglock dl;
int rc;
rc = draglock_init_from_string(&dl, "1 1");
assert(rc == 0);
assert(dl.mode == DRAGLOCK_PAIRS);
rc = draglock_init_from_string(&dl, "1 2 3 4 5 6 7 8");
assert(rc == 0);
assert(dl.mode == DRAGLOCK_PAIRS);
rc = draglock_init_from_string(&dl, "1 2 3 4 5 0 7 8");
assert(rc == 0);
assert(dl.mode == DRAGLOCK_PAIRS);
/* all disabled */
rc = draglock_init_from_string(&dl, "1 0 3 0 5 0 7 0");
assert(rc == 0);
assert(dl.mode == DRAGLOCK_DISABLED);
}
static void
test_config_get(void)
{
struct draglock dl;
int rc;
const int sz = 32;
int map[sz];
draglock_init_from_string(&dl, "");
rc = draglock_get_meta(&dl);
assert(rc == 0);
rc = draglock_get_pairs(&dl, map, sz);
assert(rc == 0);
draglock_init_from_string(&dl, "8");
rc = draglock_get_meta(&dl);
assert(rc == 8);
rc = draglock_get_pairs(&dl, map, sz);
assert(rc == 0);
draglock_init_from_string(&dl, "1 2 3 4 5 6");
rc = draglock_get_meta(&dl);
assert(rc == 0);
rc = draglock_get_pairs(&dl, map, sz);
assert(rc == 5);
assert(map[0] == 0);
assert(map[1] == 2);
assert(map[2] == 0);
assert(map[3] == 4);
assert(map[4] == 0);
assert(map[5] == 6);
}
static void
test_set_meta(void)
{
struct draglock dl;
int rc;
draglock_init_from_string(&dl, "");
rc = draglock_set_meta(&dl, 0);
assert(rc == 0);
assert(dl.mode == DRAGLOCK_DISABLED);
rc = draglock_set_meta(&dl, 1);
assert(rc == 0);
assert(dl.mode == DRAGLOCK_META);
rc = draglock_set_meta(&dl, -1);
assert(rc == 1);
rc = draglock_set_meta(&dl, 32);
assert(rc == 1);
}
static void
test_set_pairs(void)
{
struct draglock dl;
int rc;
const int sz = 32;
int map[sz];
draglock_init_from_string(&dl, "");
memset(map, 0, sizeof(map));
rc = draglock_set_pairs(&dl, map, sz);
assert(rc == 0);
assert(dl.mode == DRAGLOCK_DISABLED);
rc = draglock_set_pairs(&dl, map, 1);
assert(rc == 0);
assert(dl.mode == DRAGLOCK_DISABLED);
map[0] = 1;
rc = draglock_set_pairs(&dl, map, 1);
assert(rc == 1);
map[0] = 0;
map[1] = 2;
rc = draglock_set_pairs(&dl, map, sz);
assert(rc == 0);
assert(dl.mode == DRAGLOCK_PAIRS);
map[0] = 0;
map[1] = 0;
map[10] = 8;
rc = draglock_set_pairs(&dl, map, sz);
assert(rc == 0);
assert(dl.mode == DRAGLOCK_PAIRS);
}
static void
test_filter_meta_passthrough(void)
{
struct draglock dl;
int rc;
int button, press;
int i;
rc = draglock_init_from_string(&dl, "10");
for (i = 0; i < 10; i++) {
button = i;
press = 1;
rc = draglock_filter_button(&dl, &button, &press);
assert(rc == 0);
assert(button == i);
assert(press == 1);
press = 1;
rc = draglock_filter_button(&dl, &button, &press);
assert(rc == 0);
assert(button == i);
assert(press == 1);
}
}
static void
test_filter_meta_click_meta_only(void)
{
struct draglock dl;
int rc;
int button, press;
rc = draglock_init_from_string(&dl, "10");
button = 10;
press = 1;
rc = draglock_filter_button(&dl, &button, &press);
assert(rc == 0);
assert(button == 0);
button = 10;
press = 0;
rc = draglock_filter_button(&dl, &button, &press);
assert(rc == 0);
assert(button == 0);
}
static void
test_filter_meta(void)
{
struct draglock dl;
int rc;
int button, press;
int i;
rc = draglock_init_from_string(&dl, "10");
for (i = 1; i < 10; i++) {
/* meta down */
button = 10;
press = 1;
rc = draglock_filter_button(&dl, &button, &press);
assert(rc == 0);
assert(button == 0);
/* meta up */
button = 10;
press = 0;
rc = draglock_filter_button(&dl, &button, &press);
assert(rc == 0);
assert(button == 0);
/* button down -> passthrough */
button = i;
press = 1;
rc = draglock_filter_button(&dl, &button, &press);
assert(rc == 0);
assert(button == i);
/* button up -> eaten */
button = i;
press = 0;
rc = draglock_filter_button(&dl, &button, &press);
assert(rc == 0);
assert(button == 0);
/* button down -> eaten */
button = i;
press = 1;
rc = draglock_filter_button(&dl, &button, &press);
assert(rc == 0);
assert(button == 0);
/* button up -> passthrough */
button = i;
press = 0;
rc = draglock_filter_button(&dl, &button, &press);
assert(rc == 0);
assert(button == i);
assert(press == 0);
}
}
static void
test_filter_meta_extra_click(void)
{
struct draglock dl;
int rc;
int button, press;
int i;
rc = draglock_init_from_string(&dl, "10");
for (i = 1; i < 10; i++) {
/* meta down */
button = 10;
press = 1;
rc = draglock_filter_button(&dl, &button, &press);
assert(rc == 0);
assert(button == 0);
/* meta up */
button = 10;
press = 0;
rc = draglock_filter_button(&dl, &button, &press);
assert(rc == 0);
assert(button == 0);
/* button down -> passthrough */
button = i;
press = 1;
rc = draglock_filter_button(&dl, &button, &press);
assert(rc == 0);
assert(button == i);
/* button up -> eaten */
button = i;
press = 0;
rc = draglock_filter_button(&dl, &button, &press);
assert(rc == 0);
assert(button == 0);
/* meta down */
button = 10;
press = 1;
rc = draglock_filter_button(&dl, &button, &press);
assert(rc == 0);
assert(button == 0);
/* meta up */
button = 10;
press = 0;
rc = draglock_filter_button(&dl, &button, &press);
assert(rc == 0);
assert(button == 0);
/* button down -> eaten */
button = i;
press = 1;
rc = draglock_filter_button(&dl, &button, &press);
assert(rc == 0);
assert(button == 0);
/* button up -> passthrough */
button = i;
press = 0;
rc = draglock_filter_button(&dl, &button, &press);
assert(rc == 0);
assert(button == i);
assert(press == 0);
}
}
static void
test_filter_meta_interleaved(void)
{
struct draglock dl;
int rc;
int button, press;
int i;
rc = draglock_init_from_string(&dl, "10");
for (i = 1; i < 10; i++) {
/* meta down */
button = 10;
press = 1;
rc = draglock_filter_button(&dl, &button, &press);
assert(rc == 0);
assert(button == 0);
/* meta up */
button = 10;
press = 0;
rc = draglock_filter_button(&dl, &button, &press);
assert(rc == 0);
assert(button == 0);
/* button down -> passthrough */
button = i;
press = 1;
rc = draglock_filter_button(&dl, &button, &press);
assert(rc == 0);
assert(button == i);
/* button up -> eaten */
button = i;
press = 0;
rc = draglock_filter_button(&dl, &button, &press);
assert(rc == 0);
assert(button == 0);
}
for (i = 0; i < 10; i++) {
/* button down -> eaten */
button = i;
press = 1;
rc = draglock_filter_button(&dl, &button, &press);
assert(rc == 0);
assert(button == 0);
/* button up -> passthrough */
button = i;
press = 0;
rc = draglock_filter_button(&dl, &button, &press);
assert(rc == 0);
assert(button == i);
assert(press == 0);
}
}
static void
test_filter_pairs(void)
{
struct draglock dl;
int rc;
int button, press;
int i;
rc = draglock_init_from_string(&dl, "1 11 2 0 3 13 4 0 5 15 6 0 7 17 8 0 9 19");
for (i = 1; i < 10; i++) {
button = i;
press = 1;
rc = draglock_filter_button(&dl, &button, &press);
assert(rc == 0);
if (i % 2)
assert(button == i + 10);
else
assert(button == i);
assert(press == 1);
button = i;
press = 0;
rc = draglock_filter_button(&dl, &button, &press);
assert(rc == 0);
if (i % 2) {
assert(button == 0);
} else {
assert(button == i);
assert(press == 0);
}
}
for (i = 1; i < 10; i++) {
button = i;
press = 1;
rc = draglock_filter_button(&dl, &button, &press);
assert(rc == 0);
if (i % 2) {
assert(button == 0);
} else {
assert(button == i);
assert(press == 1);
}
button = i;
press = 0;
rc = draglock_filter_button(&dl, &button, &press);
assert(rc == 0);
if (i % 2)
assert(button == i + 10);
else
assert(button == i);
assert(press == 0);
}
}
int
main(int argc, char **argv)
{
test_config_empty();
test_config_invalid();
test_config_disable();
test_config_meta_button();
test_config_button_pairs();
test_config_get();
test_set_meta();
test_set_pairs();
test_filter_meta_passthrough();
test_filter_meta_click_meta_only();
test_filter_meta();
test_filter_meta_extra_click();
test_filter_meta_interleaved();
test_filter_pairs();
return 0;
}

6
xorg-libinput.pc.in Normal file
View File

@@ -0,0 +1,6 @@
sdkdir=@sdkdir@
Name: xorg-libinput
Description: X.Org libinput input driver.
Version: @PACKAGE_VERSION@
Cflags: -I${sdkdir}