Commit graph

248 commits

Author SHA1 Message Date
Derek Foreman
84d59fe8e6 evdev: Log evdev event queue overflows
Log a message when the kernel event queue overflows and events are dropped.
After 10 messages logging stops to avoid flooding the logs if the condition
is persistent.

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-10-31 13:42:32 +10:00
Derek Foreman
80356864e1 cosmetic: convert evdev_need_touch_frame from int to bool
We use stdbool elsewhere, so use it here too for consistency.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-10-06 17:21:49 +10:00
Peter Hutterer
3240b4287b evdev: hook up left-handed configuration option
Two separate flags needed, want_left_handed and left_handed to avoid switching
to left_handed while a button is still down. Since each backend has a
different way of determining whether buttons are down, let them set a function
to do exactly that. Then call that function whenever a button release event is
posted to switch the device to right/left-handed if applicable.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2014-09-23 16:00:06 +10:00
Peter Hutterer
1dfb248ab9 touchpad: hook up pointer acceleration configuration
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2014-09-23 10:46:35 +10:00
Peter Hutterer
cd6b5770b2 evdev: hook into pointer acceleration config interface
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2014-09-23 10:46:35 +10:00
Peter Hutterer
4913fd7a48 Replace pointer acceleration with a much simpler linear one
We ran a userstudy, evaluating three different accel methods. Detailed results are
available at:
http://www.who-t.net/publications/hutterer2014_libinput_ptraccel_study.pdf

We found that there was little difference between the method we had in
libinput 0.6 and this three-line function. Users didn't really notice a
difference, but measured data suggests that it has slight advantages in some
use-cases.

The method proposed here is the one labeled "linear" in the paper, its profile
looks roughly like this:

        _____________
       /
  ____/
 /
/

where the x axis is the speed, y is the acceleration factor.
The first plateau is at the acceleration factor 1 (i.e. unaccelerated
movement), the second plateau is at the max acceleration factor. The threshold
in the code defines where and how long the plateau is.

Differences to the previous accel function:
- both inclines are linear rather than curved
- the second incline is less steep than the current method

From a maintainer's point-of-view, this function is significantly easier to
understand and manipulate than the previous one.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2014-09-23 10:46:22 +10:00
Peter Hutterer
a8ffc096be touchpad: Keep track of associated trackpoint device
The top soft buttons are intended for use with a trackpoint, and to e.g.
make middle button scrolling work correctly, we must post the events for
these "buttons" through the trackpoint device.

This commit is a preparation patch for this, it adds a link to the
trackpoint to the touchpad, but does not yet do anything with it.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-09-18 13:29:42 +10:00
Hans de Goede
3bf9b02d81 evdev: Add an internal device suspend / resume notification system
We have the ability for a device to form a link to another device through the
device_added / device_removed callbacks. A device having such a link to
another device may also want to know when that other device is disabled /
enabled (suspended / resumed). So add a notification mechanism for this too.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-09-18 13:29:42 +10:00
Hans de Goede
7e932ed33f evdev: Add middle button scrolling for trackpoints
Most trackpoint users want to be able to scroll using the trackpoint with
the middle button pressed, add support for this.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-09-18 13:29:42 +10:00
Hans de Goede
0f112646ce evdev: Move generic scroll code from evdev-mt-touchpad.c to evdev.c
So that it can be used for middle button trackpoint scrolling too.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-09-18 13:29:42 +10:00
Peter Hutterer
cc44e747c7 evdev: add internal tagging system
For conditional touchpad disabling we need two pieces of knowledge: is the
device an internal touchpad and is another device an external mouse-like
device. For that use-case it's enough to tag any device that's on USB and
Bluetooth with pointer capabilities as external mouse. A more complex can be
done when needed.

The tag function is part of the dispatch interface (to save on udev code) and
called before the caller is notified about the new device, i.e. the device is
fully configured by the time it needs to be tagged, and other devices can rely
on the tags being assigned by the time they get notified about the new device.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2014-09-18 13:29:42 +10:00
Peter Hutterer
1c8a5ca659 evdev: add a internal device notification mechanism
When a device is added or removed, notify all internal devices about the
device change. This allows all devices to configure themselves depending on
other devices in the system. Prime use-case here is an internal touchpad that
wants to know if an external mouse is connected.

On device added, notification goes both ways: existing devices are notified
about the new device, and the new device is notified about existing devices.
On device removed, notification only goes one way.

In both cases, the internal notification is complete before the event is sent
to the caller.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2014-09-18 13:29:42 +10:00
Peter Hutterer
bd7f7e8a08 evdev: drop the button count when releasing keys on remove
We previously called this function only before device removal, so failing to
update the button state didn't matter. To make this function generic for the
device suspend/resume, we need to keep track of the button/key count properly.

If we have a key down multiple times on suspend though, log a bug.
The dispatch should release the keys before we even get here (functionality
added in a subsequent patch).

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2014-09-18 11:31:23 +10:00
Peter Hutterer
8be1abf58a evdev: don't resume a removed device
A device may disappear and a new device may re-appear with the same device
node while the original device is suspended. Prevent a device resume to open
the wrong device.

In a path context, a changing syspath is the only indicator we get of the
device changing.
In a udev context, if the device was removed and libinput_dispatch() was
called, we can short-cut the syspath comparison by setting it to NULL.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2014-09-18 11:31:23 +10:00
Peter Hutterer
3e93d913be evdev: hook up a generic enable/disable interface for devices
The evdev fallback dispatch supports enabling and disabling devices. That's
fairly easy to support since we don't (yet) have extra event generation within
the fallback backend. Thus, we can simply close the fd and re-open it again
later.

Touchpads are currently excluded here, they generate extra events on tapping,
scrolling, and software buttons and need a more complex implementation.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2014-09-18 11:31:23 +10:00
Peter Hutterer
7bef1ecf4e evdev: add helper function evdev_need_mtdev
Prep work for upcoming patches

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2014-09-18 11:31:20 +10:00
Peter Hutterer
1e37d3bc44 evdev: prevent double-suspending a device
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2014-09-18 11:30:15 +10:00
Peter Hutterer
702e8db2cf evdev: factor out closing a device into evdev_suspend()
No functional changes, just prep work for an upcoming patch

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2014-09-18 11:30:15 +10:00
Peter Hutterer
9f2b05d5ac evdev: prefix the hw key/button bitmask with 'hw'
This bitmask reflects the hw state, prefix it accordingly.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2014-09-18 11:30:15 +10:00
Peter Hutterer
e9239d81a9 Add a helper function for clock_gettime
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2014-09-18 11:30:15 +10:00
Peter Hutterer
d5136c6cb9 evdev: load the LIBINPUT_CALIBRATION_MATRIX as default matrix
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2014-09-01 11:23:54 +10:00
Peter Hutterer
ea00ff9114 Change calibration into a configuration option
New configuration API:
	libinput_device_config_calibration_has_matrix()
	libinput_device_config_calibration_set_matrix()
	libinput_device_config_calibration_get_matrix()
	libinput_device_config_calibration_get_default_matrix()

Deprecates libinput_device_calibrate().

For coordinate transformation, we're using a precalculated matrix. Thus, to
support ..._get_matrix() we need to store the original user-specified matrix
separately, in an unmangled state.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2014-09-01 11:23:54 +10:00
Peter Hutterer
13972efd82 evdev: switch to a normalized transformation matrix
The big change here is the requirement to have the translation component in a
device-normalized coordinate space. Without that, we cannot reliably rotate as
the coordinate space is effectively unknown and may differ between the axes.
This affects any rotation matrix or translation matrix, pure scale matrices
were working just fine since they're unit-less.

Requiring the matrix in device-normalized space makes it possible for libinput
to rotate or otherwise handle the matrix independent of the screen resolution.
The rotation matrix is documented in a bit more detail to make it easier for
users to figure it out.

This changes the definition of the WL_CALIBRATION property (which is currently
broken).

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2014-09-01 11:23:54 +10:00
Peter Hutterer
24c03646a9 evdev: apply calibration to multitouch values as well
We apply calibration to single-touch and absolute devices, but we might as
well do so for multitouch events.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2014-08-27 12:33:11 +10:00
Peter Hutterer
6f5f83e7c3 evdev: constify evdev_device_calibrate
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2014-08-27 12:33:11 +10:00
Peter Hutterer
c6478bbeeb evdev: plug memory leak on libevdev_new_from_fd failure
Found by coverity.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-08-26 11:04:42 +10:00
Jonas Ådahl
8f846a41fa evdev: Release still pressed keys/buttons when removing device
When removing a device, its not guaranteed that all button or key
presses have been released, resulting in an invalid seat wide button
count.

Note that kernel devices normally will send release events when being
unplugged, but this won't happen when removing a device from the path
backend.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-08-18 22:41:16 +02:00
Jonas Ådahl
3a3d70a3a8 evdev: Keep track of button/key press count per device
Keep track of the number of times a given button or key is pressed on a
device. For regular mouse devices or keyboard devices, such a count will
never exceed 1, but counting button presses could help when button
presses with the same code can originate from different sources. One could
for example implement overlapping tap-drags with button presses by
having them deal with their own life-time independently, sorting out
when the user should receive button presses or not depending on the
pressed count.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-08-18 22:35:19 +02:00
Jonas Ådahl
c8017595fc evdev: Ignore key/button release events if key was never pressed
The kernel may send a 'release' event without ever having sent a key
'pressed' event in case the key was pressed before libinput was
initiated. Ignore these events so that we always guarantee a release
event always comes after a pressed event for any given key or button.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2014-08-18 22:35:19 +02:00
Jonas Ådahl
100ba70e87 evdev: Use helper for separating buttons from keys
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-08-18 22:35:19 +02:00
Jonas Ådahl
c17282ffc4 evdev: Let dispatch instances set their own capabilities
It's up to a evdev device backend to configure seat capabilities it
supports. Even though it may be possible for a touchpad to have extra
keys, there is currently no support for sending keyboard events from the
touchpad driver, and if that would be implemented, it'd be a detail of
the touchpad driver, not the generic evdev device part.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-08-18 22:35:19 +02:00
Peter Hutterer
22e86f9322 evdev: don't return a width/height if we faked the resolution
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2014-08-04 20:20:59 +10:00
Peter Hutterer
03a1ef7540 filter: rename motion_filter_destroy to filter_destroy
For better consistency with filter_dispatch(). And move the things around to keep
the consumable API together.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2014-07-09 12:39:41 +10:00
Peter Hutterer
6b6f24ee1c Add functions to get the device name, PID and VID
Those three are the ones that matter for logging or device identification in
callers, so let's provide them.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
2014-07-02 08:52:33 +10:00
Peter Hutterer
97a6bf10f9 Change the logging system to be per-context
Rather than a single global logging function, make the logging dependent on
the individual context. This way we won't stomp on each other's feet in the
(admittedly unusual) case of having multiple libinput contexts.

The userdata argument to the log handler was dropped. The caller has a ref to
the libinput context now, any userdata can be attached to that context
instead.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2014-06-23 15:39:08 +10:00
Peter Hutterer
967911791f Rename KEYBOARD_KEY_STATE to KEY_STATE
e912d620d0 changed from POINTER_BUTTON_STATE to
simply BUTTON_STATE, replicate that for key events too.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-06-23 15:23:35 +10:00
Peter Hutterer
55bf505807 Name-space the scroll event types
To provide a generic naming system of type_direction. That will become more
important once we add new axes as part of the ongoing work to support graphics
tablets.

[edit: and switch to the new defines]

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2014-06-23 14:31:56 +10:00
Peter Hutterer
41f9176c0a Add a function to get the size of a device
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2014-06-19 13:38:15 +10:00
Peter Hutterer
3a812385d1 evdev: force a resolution of 1 where no resolution is set
Avoids nasty surprises later when we divide by 0. This matters particularly
when testing a device through uinput, which can't set the resolution.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2014-06-19 12:07:17 +10:00
Peter Hutterer
df212db2a3 evdev: keep the absinfo struct around instead of min/max
We'll need that later for conversion to mm.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2014-06-19 12:00:58 +10:00
Jonas Ådahl
864232bcb2 evdev: Migrate rest of 32 bit time variables to uint64_t
Makes tests pass again with long uptime.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2014-06-09 22:26:22 +02:00
Stephen Chandler Paul
e912d620d0 s/libinput_pointer_button_state/libinput_button_state/
Button states are applicable to more then just the pointer, so having a
non-generic name name for a generic enumerator value like
libinput_pointer_button_state doesn't make sense. Changing it to something
generic like libinput_button_state allows it to be reused by other devices that
may potentially be added to libinput in the future.

Signed-off-by: Stephen Chandler Paul <thatslyude@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-06-09 20:48:05 +02:00
Jonas Ådahl
f3084e2c0d Use floating point numbers instead of fixed point numbers
Fixed point numbers can easily overflow, and double to fixed point
conversion is lossy. Use floating point (double) where fixed point
numbers where previously used and remove the li_fixed_t type.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-06-09 20:46:53 +02:00
Peter Hutterer
4982b46010 Add our own version of linux/input.h
Avoids having to #define any values we're trying to use.

Header file is from Linux 3.15-rc8.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
2014-06-04 09:40:39 +10:00
Peter Korsgaard
fa8439e644 evdev: Provide fallback definition for KEY_MICMUTE
KEY_MICMUTE was added relatively recently (3.1 with 33009557bd: Add
KEY_MICMUTE and enable it on Lenovo X220), so provide a fallback definition
similar to how we do it for KEY_LIGHTS_TOGGLE to fix compilation with older
toolchains.

Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
2014-06-02 23:23:26 +02:00
Peter Korsgaard
0d02b13ec2 evdev: Use correct fallback value for KEY_LIGHTS_TOGGLE
The kernel defines KEY_LIGHTS_TOGGLE as 0x21e, not 0x160 (which is KEY_OK).

Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
2014-06-02 23:23:13 +02:00
Peter Hutterer
055b1c8bc9 Replace log_bug with per-component bug macros
When we knowingly hit a bug, we should know what the bug is caused by. Log
that in a standardized fashion.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2014-05-30 11:55:23 +10:00
Peter Hutterer
90b8de4ddd evdev: INPUT_PROP_DIRECT devices can't be touchpads
Devices that are direct input devices are marked by the kernel with the
INPUT_PROP_DIRECT property. Touchpads are always indirect input devices, so
let's do the easiest check first before we try device-specific capabilities.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-05-30 07:11:59 +10:00
Jonas Ådahl
505e92b1a5 Add basic mouse pointer acceleration
This patch reimplements the simple smooth pointer acceleration profile
from X.org xserver. The algorithm is identical to the classic profile
with a non-zero pointer acceleration threshold.

When support for changable parameters is in place, to get a pointer
acceleration the same as the default classic profile of X.org a
polynomial acceleration profile should be used for when the threshold
parameter is zero.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2014-05-29 13:06:32 +02:00
Hans de Goede
89165da6d6 Change internal timestamps to uint64_t to properly deal with wrapping
We store timestamps in ms since system boot (CLOCK_MONOTONIC). This will wrap
after circa 50 days.

I've considered making our code wrapping safe, but that won't work. We also
use our internal timestamps to program timer-fds for timeouts. And we store
ms in a single integer but the kernel uses 2 integers, one for seconds and
one for usec/nanosec. So at 32 bits our ms containing integer will wrap
in 50 days, while the kernels seconds storing integer lasts a lot longer.
So when we wrap our ms timestamps, we will be programming the timer-fds
with a seconds value in the past.

So change all our internal timestamps to uint64_t to avoid the wrapping
when programming the timer-fds. Note that we move from 64-bit timestamps to
32-bit timestamps when calling the foo_notify_bar functions from
libinput-private.h. Having 64 bit timestamps has no use past this point,
since the wayland input protocol uses 32 bit timestamps (and clients will
have to deal with wrapping).

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-05-22 14:51:41 +02:00