Commit graph

176 commits

Author SHA1 Message Date
Deepa Dinamani
ee163ef63e Update struct input_event
The struct input_event is not y2038 safe.
Update the struct according to the kernel patch:
https://lkml.org/lkml/2018/1/6/324

Signed-off-by: Deepa Dinamani <deepa.kernel@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-05-03 10:03:28 +10:00
Peter Hutterer
419db83dad tablet: add missing space in an error message
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-03-23 10:17:52 +10:00
Peter Hutterer
56fd071412 evdev: pass the time down to toggle_touch
Currently unused, will be used in later patches

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-02-21 15:13:08 +10:00
Peter Hutterer
2191ed6cc0 tablet: fake a BTN_TOOL_PEN on the first event if needed
Some (?) Aiptek tablets have BTN_TOOL_PEN but aren't inclined to actually send
this on proximity in. This means we don't have a tool assigned and ignore the
events.

This patch piggy-backs on the already-existing proximity-out quirks. On the
first EV_SYN and if the tool is still NONE (i.e. no BTN_TOOL_* was received), we
pretend that we've earlier forced a proximity-out event for this tablet. This
causes the proximity-out quirk code to emulate a proximity in and we're off.
Hooray.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-02-13 16:04:08 +10:00
Peter Hutterer
ee2b58a66f tablet: disable BTN_TOOL_MOUSE/LENS for non-Wacom tablets
Mouse and lens cursor tools are rare and the rotation calculation is quirky to
say the least. I don't have access to a non-Wacom mouse tool, so
until this changes, just disable those tools and wait for someone to shout.

This is a much easier fix than trying to figure out the correct generic
rotation calculation that may not be correct anyway.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-02-13 16:04:08 +10:00
Peter Hutterer
26705762e2 tablet: skip tablet_flush() if our current tool type is none
If a tablet never sends a BTN_TOOL_foo, we never update the tool and we remain
on the 'none' tool.

Somewhat related to:
https://bugzilla.redhat.com/show_bug.cgi?id=1535755
https://bugs.freedesktop.org/show_bug.cgi?id=104911

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-02-13 16:04:08 +10:00
Peter Hutterer
44426b460c tablet: release the tablet state on device delete
When the device gets deleted in a non-neutral state, we need to release all
buttons, lift the tip up and send a proximity out event.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-02-13 16:04:08 +10:00
Peter Hutterer
c897b1e2f8 tablet: move the quirk disabling up within tablet_init
Let's make sure all libevdev manipluations are done before we start
initializing anything based on the event codes.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-02-13 16:04:08 +10:00
Peter Hutterer
cbb4ec1e3e tablet: don't set rotation on a tool if we don't have ABS_Z
Rotation on a tool can either ABS_Z or in the case of the mouse/lens tools a
combination of ABS_TILT_X/Y. The code assumes that if the rotation on a stylus
(not mouse/lense) changes, we need to fetch it from ABS_Z. This happens on the
very first event from the tablet, proximity in invalidates all axes so we can
send the current state to the caller.

On libwacom-recognized tablets we never set the rotation bit on the stylus, so
that's all fine. On tablets without libwacom support, the stylus may have a
rotation bit copied because we have it set thanks to mouse+tilt on the tablet.
When that first event is handled, we try to access ABS_Z. On tablets without
ABS_Z like Aipteks, we go boom.

Fix this by checking for ABS_Z during tablet init, if we don't have that axis
then never set the rotation bit on the tool. That's the only axis where we
need this, all other axes have a single cause only and thus the tablet bits
are accurate anyway.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-02-09 12:18:35 +10:00
Peter Hutterer
2872cb4dec tablet: remove obsolete BTN_TOUCH case
We filter BTN_TOUCH in the caller, so this cannot happen here.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-02-07 10:06:29 +10:00
Peter Hutterer
5ec1dcbfb4 tablet: drop unnecessary switch case statements
We fall through to the default statement anyway

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-02-07 10:06:29 +10:00
Peter Hutterer
43de03a08c tablet: break up a long line
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-12-18 14:41:14 +10:00
Peter Hutterer
61bdc05fb0 tablet: set the tip-up pressure threshold to 1%
Some pens keep sending small amounts of pressure even when the tip is up. This
isn't always a sign of the pens worn out, it also happens on the new Pro Pen
3D models.

The X driver uses a default threshould of ~1.3% to paper over this, let's do
the same with a 1% threshold. This threshold only applies to pens that don't
already have a pressure offset anyway.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-12-08 12:59:58 +10:00
Lyude Paul
4ebb131bc7 Correct Lyude's Copyright assignment
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-11-21 15:33:49 +10:00
Peter Hutterer
940658e1b7 tablet: print what capability is missing when rejecting a device
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-10-26 11:01:29 +10:00
Peter Hutterer
27eff1ac03 evdev: abstract the get_switch_state method
Shove it into the generic dispatch interface so we don't entangle evdev and
fallback.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-09-25 15:13:37 +10:00
Peter Hutterer
6c7dd36398 Use named initializers for the various dispatch interfaces
Better for self-documentation than comments and makes it more obvious if we
initialize something wrongly.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-09-25 15:13:37 +10:00
Peter Hutterer
77890ecc8f tablet: always enable the no-proximity-out quirk on HUION tablets
And instead disable it when we do get a proximity out.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2017-09-21 12:27:46 +10:00
Peter Hutterer
0ac868143a tablet: support tablet devices without BTN_TOOL_PEN
Some devices like the UC Logic WP5540U has BTN_STYLUS but not BTN_TOOL_PEN.
While a kernel bug, let's just handle these correctly anyway.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Yay-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2017-09-20 09:30:06 +10:00
Peter Hutterer
1962c6f2db tablet: add a quirk for the HUION PenTablet that doesn't send proximity out events
Could be fixed in the kernel, but these tablets are effectively abandoned and
fixing them is a one-by-one issue. Let's put the infrastructure in place to
have this fixed once for this type of device and move on.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Yay-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2017-09-20 09:30:06 +10:00
Peter Hutterer
d5d6d4cd53 Abort if zalloc ever fails
There's no guarantee that libinput does the right thing if memory allocation
fails and it's such a niche case on the systems we're targeting that it just
doesn't matter. Simply abort if zalloc ever fails.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-07-12 10:18:07 +10:00
Peter Hutterer
a49ebfe593 tablet: remove useless self-assignment
Introduced in 230af3f9fc

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-04-01 15:37:24 +10:00
Peter Hutterer
411a3a4766 tablet: add axis smoothing
Taking the tablet events as-is produces the occasional wobble in what should
be a straight line. Bug 99961 has a jpg attachment to illustrate that.
Emulate the wacom driver behavior and average x/y across the last 4 values to
smoothen out these dents.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Acked-by: Ping Cheng <pingc@wacom.com>
2017-03-23 10:18:09 +10:00
Peter Hutterer
ae11eaa265 tablet: reset delta and changed axes as soon as we send them
We don't have frame events for tablets so we must take care to send the
axis change notifications only once and leave the others as-is. Most of the
axes are absolute so it doesn't really matter, but we need to reset the delta
to make sure clients don't receive the same delta twice.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Acked-by: Ping Cheng <pingc@wacom.com>
2017-03-23 10:18:09 +10:00
Peter Hutterer
a19d18f9c6 tablet: add assert that deltas are always 0
The tablet axis struct has a delta field that's only useful for the events,
not for our internal axis handling. Make sure we never set it to anything
nonzero.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Acked-by: Ping Cheng <pingc@wacom.com>
2017-03-23 10:18:09 +10:00
Peter Hutterer
88876e66fa tablet: split point vs delta handling up
Handle the delta in the end once we've updated the device state for all axes.
This requires us to use the device history rather than the current state
delta, and it also requires us to update both x and y whenever an axis change
comes in.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Acked-by: Ping Cheng <pingc@wacom.com>
2017-03-23 10:18:09 +10:00
Peter Hutterer
230af3f9fc table: move custom rotation handling into a helper function
This is a bit hard to follow:
- tilt is handled first and if either tilt axis is set we fetch *both* tilt axes
  into tablet->axes.tilt
- rotation is handled second but it only triggers if either tilt axis is
  flagged. as we now guarantee to have both axes in tablet->axes.tilt, we
  can continue with the rotation conversion without needing some other state

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Acked-by: Ping Cheng <pingc@wacom.com>
2017-03-23 10:18:09 +10:00
Peter Hutterer
401bbf52d8 tablet: reshuffle device axis updates
This is prep work for axis smoothing. Modify the various helper functions to
just update the state in the tablet and then grab the state later for better
grouping.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Acked-by: Ping Cheng <pingc@wacom.com>
2017-03-23 10:18:09 +10:00
Peter Hutterer
1e113f6283 tablet: move the axis transforms to the end
No functional changes, part of the grouping of tablet axis manipulation vs.
processing of that manipulated state.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Acked-by: Ping Cheng <pingc@wacom.com>
2017-03-23 10:18:09 +10:00
Peter Hutterer
f8aa49b619 tablet: move delta processing down
No functional changes, this is just to group the calls that modify tablet axis
state together and move the bits that rely on this state (but don't modify it)
to the bottom.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Acked-by: Ping Cheng <pingc@wacom.com>
2017-03-23 10:18:09 +10:00
Peter Hutterer
0d757a94f9 tablet: add a motion history
Stores the processed axes values in a history 4 events deep. Currently unused
but will be used to smoothen out axis values to avoid transducer-caused axis
wobbles.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Acked-by: Ping Cheng <pingc@wacom.com>
2017-03-23 10:18:09 +10:00
Peter Hutterer
cadefc1265 tablet: reshuffle the event sending code
The current code modifies a bit of state inside the proximity_tip_down
function which makes for confusing reading. Clean this up by having a bunch of
helper functions for the various events.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Acked-by: Ping Cheng <pingc@wacom.com>
2017-03-23 10:18:09 +10:00
Peter Hutterer
c39a84da9e tablet: remove unnecessary out-of-proximity check
This cannot trigger because we'd never get here if out-of-proximity is set,
tablet_flush() will return early.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Acked-by: Ping Cheng <pingc@wacom.com>
2017-03-23 10:18:09 +10:00
Peter Hutterer
c8fde99ad9 tablet: drop unnecessary call to reset the changed axes
The only code path that leads here would see the changed_axes array zeroed out
in tablet_send_axis_proximity_tip_down_events(), zeroing again is unlikely to
make it more zero.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Acked-by: Ping Cheng <pingc@wacom.com>
2017-03-23 10:18:09 +10:00
Peter Hutterer
6181adbdcd evdev: standardize log messsages
Prefix device log messages with the device's sysname so it's more obvious
where the messages are coming from. This makes it much easier to grep for a
specific device's messages but also adds some identifier to messages that
were previously without any identifier (e.g. all the state machine debugging)

All info and error messages also automatically prefix the device name, so
those messages are standardised too, e.g

an info message now:
  event4  - SynPS/2 Synaptics TouchPad: is tagged by udev as: Touchpad
a debug message now:
  event4  - using pressure-based touch detection

And since this required changing a lot of the strings in messages anyway,
polish a few minor things too.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Acked-by: Hans de Goede <hdegoede@redhat.com>
2017-02-24 16:04:44 +10:00
Peter Hutterer
60de087e65 evdev: improve type-safety on dispatch switches
Set the dispatch type on creation, then check that whenever we try to get the
dispatch struct. This avoids a potential mismatch between the backends.

Plus, use of container_of means we're not dependent on the exact layout
anymore.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-01-31 07:36:12 +10:00
Peter Hutterer
06489d9b07 tablet: ignore MSC_SCAN
Sent by some HUION tablets

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2016-12-21 14:32:45 +10:00
Peter Hutterer
bdd4264d61 filter: change the filter functions to take raw device coordinates
We used to normalize all deltas to equivalents of a 1000dpi mouse before
passing it into the acceleration functions. This has a bunch of drawbacks, not
least that we already have to un-normalize back into device units for a few
devices already (trackpoints, tablet, low-dpi mice).

Switch the filter code over to use device units, relying on the dpi set
earlier during filter creation to convert to normalized. To make things easy,
the output of the filter code is still normalized data, i.e. data ready to be
handed to the libinput caller.

No effective functional changes. For touchpads, we still send normalized
coordinates (for now, anyway). For the various filter methods, we either drop
the places where we unnormalized before or we normalize where needed.

Two possible changes: for trackpoints and low-dpi mice we had a max dpi factor
of 1.0 before - now we don't anymore. This was only the case if a low-dpi
mouse had more than 1000dpi (never true) or a trackpoint had a const accel
lower than 1.0 (yeah, whatever).

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2016-12-21 10:55:57 +10:00
Peter Hutterer
dbeb2f7916 tablet: reject tablets without resolution
Fix the kernel driver or get a udev override in place. Tablets not having a
physical size is not ok.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2016-11-29 11:25:24 +10:00
Peter Hutterer
b519ea4ab5 tablet: add touch arbitration
So far we've relied on the wacom kernel module to do touch arbitration for us
but that won't be the case in upcoming kernels. Implement touch arbitration in
userspace by pairing the two devices and suspending the touch device whenever
a tool comes into proximity.

In the future more sophisticated arbitration can be done (e.g. only touches
which are close to the pen) but let's burn that bridge when we have to cross
it.

Note that touch arbitration is "device suspend light", i.e. we leave the
device enabled and the fd is active. Tablet interactions are comparatively
short-lived, so closing the fd and asking logind for a new one every time the
pen changes proximity is suboptimal. Instead, we just keep a boolean around
and discard all events while it is set.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jason Gerecke <jason.gerecke@wacom.com>
2016-09-07 11:17:03 +10:00
Peter Hutterer
d686e13338 tablet: if a serial comes in late, discard it
If a tool starts reporting with serial 0 and later updates to a real serial,
discard that serial and keep reporting as serial 0. We cannot really change
the tool after proximity in as we don't know when callers query for the serial
(well, we could know but any well-written caller will ask for the serial on
the proximity in event, so what's the point).

Thus if we do get a serial in and the matching tool, check if we have a tool
with the serial 0 already. If so, re-use that. This means we lose correct tool
tracking on such tablets but so far these seem to only be on devices where the
use of multiple tools is unlikely.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jason Gerecke <jason.gerecke@wacom.com>
2016-09-02 09:10:57 +10:00
Peter Hutterer
bb93f9fd93 tablet: fix minor coding style issue
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2016-08-26 14:12:44 +10:00
Peter Hutterer
b02acd346b Read the horizontal wheel click angle property if available
The Logitech MX master has different click angles for the two wheels.

https://github.com/systemd/systemd/issues/3947

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2016-08-22 11:29:35 +10:00
Peter Hutterer
aac42ca528 evdev: split evdev_dispatch and fallback_dispatch into separate entities
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2016-08-11 19:56:16 +10:00
Peter Hutterer
271dc496dc Switch a bunch of internal functions from int to bool
All these effectively returned bools anyway, switch the signature over to be
less ambiguous.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Yong Bakos <ybakos@humanoriented.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
2016-07-20 11:43:45 +10:00
Peter Hutterer
2f0d0b9f63 Change a few functions that only ever returned 0 to voids
These are internal functions, if we need them to return an error code we can
change that at any time. Meanwhile, if we only ever return 0 anyway we might
as well just make them voids to save on error paths.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Yong Bakos <ybakos@humanoriented.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
2016-07-20 11:43:40 +10:00
Peter Hutterer
53baf3d17f tablet: catch potential segfault if the filter fails to allocate
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2016-07-13 08:33:30 +10:00
Peter Hutterer
0926f570c4 tablet: make the cursor/lens tool behave like a 1000dpi mouse
The current code tried to emulate the relative motion to be equivalent to the
absolute motion, except in screen coordinates. This is way too slow for the
cursor tool that we want to behave like a mouse.

Tablets have high resolution (e.g. an Intuos 4 is a 5080dpi mouse) and that
motion is way too fast to be usable. Scale it down to match a 1000dpi device
instead. Since the cursor and lens tool are still high precision devices leave
them in a flat acceleration profile without actual acceleration.

For the stylus-like devices leave the current accel, pointer acceleration on a
stylus is hard to handle.

This also adds the missing bits for actually using the speed factor set
through the config interface.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jason Gerecke <jason.gerecke@wacom.com>
Reviewed-by: Carlos Garnacho <carlosg@gnome.org>
2016-06-28 11:28:49 +10:00
Peter Hutterer
3824e161ed tablet: add helper function to access the libinput context
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2016-06-10 06:57:41 +10:00
Peter Hutterer
45d23a6b0e evdev: add helper to get the libinput context from the evdev device
And change the various callers, especially those where we only had the
separate struct for indentation purposes.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2016-06-10 06:57:41 +10:00