Commit graph

118 commits

Author SHA1 Message Date
Peter Hutterer
c6a082dfd9 tablet: move left-handed initialization into tablet_init
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2016-02-10 13:57:10 +10:00
Peter Hutterer
4bf8365a02 tablet: fix artpen rotation on left-handed tablets
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2016-02-10 12:05:16 +10:00
Peter Hutterer
6bd2a4a5f1 test: add test for left-handed mouse rotation on tablets
Should be offset by 180 degrees

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2016-02-10 12:05:16 +10:00
Peter Hutterer
d8eced2afe tablet: move clearing the tilt bits up to where we reset the axes
No functional change.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2016-02-10 12:05:16 +10:00
Peter Hutterer
ebe02cb19e tablet: delay initial proximity in event until we have a serial
If the tablet is already in proximity on startup, we used to immediately sent
a proximity event. We can't fetch MSC_SERIAL from the kernel, so that tool
always had a serial of 0, followed by events with the real serial. Since
clients are supposed to use the serial for the tracking of tools, this is
suboptimal.

When the tablet is added, merely set the internal proximity flags. This way we
wait until the first real event from the device (which includes the serial
number) and convert that into a proximity event.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2016-02-10 12:02:08 +10:00
Peter Hutterer
c9abcb2e1c tablet: change tilt axes to use degrees
The Wacom tilt range is 64 degrees so we map everything into that until we
know otherwise.

This commit also switches the tilt axes around to align the angles with the
x/y orientation, i.e. tilting the top of the stylus towards the positive x
axis now generates a positive x tilt.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jason Gerecke <jason.gerecke@wacom.com>
2016-02-09 12:19:12 +10:00
Peter Hutterer
6920a42fd4 tablet: fix potential null-pointer dereference
Found by coverity

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2016-01-22 18:08:44 +10:00
Peter Hutterer
7164d6eff5 tablet: hook up relative motion events
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Acked-by: Jason Gerecke <jason.gerecke@wacom.com>
2016-01-22 16:16:55 +10:00
Peter Hutterer
f5200c5325 tablet: drop delta array, provided by the tablet_axis struct now
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Acked-by: Jason Gerecke <jason.gerecke@wacom.com>
2016-01-15 10:07:18 +10:00
Peter Hutterer
d524313d2b tablet: use a struct rather than a double array for axis values
Makes the code less generic, but more expressive. No visible functional
changes.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Acked-by: Jason Gerecke <jason.gerecke@wacom.com>
2016-01-15 10:07:18 +10:00
Peter Hutterer
3c5483ac16 tablet: don't set a pressure offset of 0
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Acked-by: Jason Gerecke <jason.gerecke@wacom.com>
2016-01-11 15:17:46 +10:00
Peter Hutterer
1a99977ca0 tablet: a tip event can replace an axis event
When we're only dealing with BTN_TOUCH we can make the tip event independent
of the axis event. Now that we handle pressure thresholds to trigger tip state
this does not work, we'd have to send an axis event with the new pressure and
then a tip event. Since the pressure triggers the tip event this seems
disconnected.

Make the tip event officially capable of carrying axes. A caller can then
decide how to forward this to the next layer.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Acked-by: Jason Gerecke <jason.gerecke@wacom.com>
2016-01-11 15:17:46 +10:00
Peter Hutterer
96fbf84862 tablet: add pressure threshold handling
On tablets with ABS_PRESSURE use a pressure value to determine tip state, not
BTN_TOUCH. This enables us (down the road) to have device-specific pressure
thresholds. For now we use a 5% default for all devices.

The threshold is a range, if we go past the upper range we initiate the tip
down, if we go below the lower range we release the tip again.

This affects two current tests:
* Once we have pressure offsets and pressure thresholds, we're biased towards
pressure. So we can only check that distance is zero when there is a pressure
value, not the other way round.
* When the pressure threshold is exceeded on proximity in with a nonzero
distance, we can only warn and handle the pressure as normal. Since this is a
niche case anyway anything fancier is likely unnecessary.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Acked-by: Jason Gerecke <jason.gerecke@wacom.com>
2016-01-11 15:17:46 +10:00
Peter Hutterer
d51c8f9420 tablet: always set the pressure offset
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Acked-by: Jason Gerecke <jason.gerecke@wacom.com>
2016-01-11 15:17:46 +10:00
Peter Hutterer
a28c198e2a tablet: whitespace fix
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2016-01-11 15:15:20 +10:00
Peter Hutterer
0b124a1a5d tablet: insert "STATE" into proximity/tip states
Makes it even longer, but at least it's consistent with button and key state.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jason Gerecke <jason.gerecke@wacom.com>
2016-01-06 11:02:40 +10:00
Peter Hutterer
0319ee1d33 tablet: split sanitize_tablet_axes up into two helpers
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-12-23 09:59:35 +10:00
Peter Hutterer
2f481ba4a2 tablet: handle custom proximity handling
For the puck/lens cursor tool we need to artificially reduce proximity
detection. These tools are usually used in a relative mode (i.e. like a mouse)
and thus require lifting and resetting the tool multiple times to move across
the screen. The tablets' distance detection goes too far, requiring the user
to lift the device several cm on every move. This is uncomfortable.

Introduce an artificial distance threshold for the devices with the default
value taken from the X.Org wacom driver. If a tool is in proximity but outside
of this range, fake proximity events accordingly.

If a button was pressed while we were out of range we discard that event and
send it later when we enter proximity again.

This is the simple implementation that only takes one proximity out value (the
one from the wacom driver) and applies it to all. Those devices that support a
button/lens tool and have a different default threshold are well out of date.

Reviewed-by: Hans de Goede <hdegoede@redhat.com>

[rebased, tests updated for new axis percentage behavior (8d76734f)]

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-12-23 09:15:36 +10:00
Peter Hutterer
c124209cad tablet: drop unused argument from tablet_mark_all_axes_changed
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-12-23 09:15:36 +10:00
Peter Hutterer
cd36b44b9b tablet: invert tilt axes when left-handed is enabled
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-12-23 08:08:06 +10:00
Peter Hutterer
7309fd0ed3 tablet: simplify marking axes as changed
The only time we need this is on proximity in, so move it to where we handle
that to have better locality. And rather than looping through and checking
each bit, just memcpy the axis capabilities, because by definition they
represent the set of axes that can possibly change.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-12-23 07:33:39 +10:00
Peter Hutterer
c39a91200e tablet: don't mark all axes changed on init
This will be set when the tool comes into proximity later.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-12-23 07:33:39 +10:00
Peter Hutterer
53ac112d6c tablet: split out axis handling into helper functions
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-12-23 07:33:39 +10:00
Peter Hutterer
fa71278c19 tablet: store the wheel delta in the normal axes
Now that we don't provide an API anymore to access the absolute value of the
wheel and the axes are handled separately, we can safely store the wheel delta
in the normal axis array.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-12-23 07:33:39 +10:00
Peter Hutterer
67220c643f tablet: simplify check for testing if an axis update is needed
We know when one of the bits is set we need to send an event

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-12-23 07:33:39 +10:00
Peter Hutterer
c8a99cdf10 tablet: simplify check for testing if an axis update is needed
We know when one of the bits is set we need to send an event

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-12-23 07:33:39 +10:00
Peter Hutterer
ea07cbcd89 tablet: unroll the tablet axis processing loop
Process the axes explicitly, rather than having a loop that needs special
casing for most axes anyway. And since we do the axes one-by-one, we can use
the evdev axis code directly rather than the axis_to_evcode helper.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-12-23 07:33:39 +10:00
Peter Hutterer
9fd0fb0df8 tablet: dump deltas, replace it with a single wheel_delta variable
The wheel is the only one axis that has actual deltas, all others have
straightforward deltas that we don't need to care about, the caller can
calculate those where needed.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-12-23 07:33:39 +10:00
Peter Hutterer
d5e18a8e64 tablet: dump deltas_discrete, replace with a single wheel_discrete variable
Only the wheel has a discrete value, no need to keep arrays for a single
value.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-12-23 07:33:39 +10:00
Peter Hutterer
458734e6eb doc: minor comment clarification
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-12-16 09:03:05 +10:00
Peter Hutterer
db852ef0db tablet: support tool-specific pressure offsets
If a tool wears out, it may have a pre-loaded pressure offset. In that case,
even when the tool is not physically in contact with the tablet surface it
will send pressure events.

Use automatic pressure offset detection, similar to what the X.Org wacom
driver does. On proximity-in, check the pressure and if the distance is above
50% of the range and the pressure is nonzero but below 20% of the range, use
that value as pressure offset.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Ping Cheng <pingc@wacom.com>
2015-12-15 08:21:39 +10:00
Peter Hutterer
6861039c29 tablet: drop unused condition
Since bd0f43eeb6 this condition isn't triggered
anymore.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-12-15 08:01:07 +10:00
Peter Hutterer
bd0f43eeb6 tablet: enable the calibration matrix for internal tablets
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-12-09 09:01:03 +10:00
Peter Hutterer
70e9fd7874 tablet: force the pressure/distance to 0 depending on contact state
If we have pressure but not BTN_TOUCH, force the pressure to 0. Otherwise,
force distance to 0.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-12-03 10:24:59 +10:00
Peter Hutterer
319fb38ded tablet: drop pressure when either pressure or distance changed
Keep pressure and distance mutually exclusive regardless which one of the two
updates.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-12-03 10:24:59 +10:00
Peter Hutterer
8be0813e17 tablet: drop the tool type 'finger' from the tablet interface
If it's a finger, it's a touchscreen or a touchpad, not a tablet.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-12-02 11:06:27 +10:00
Peter Hutterer
5952aa6b50 tablet: break up a condition to improve readability
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-12-02 11:05:38 +10:00
Peter Hutterer
be520bf6e0 tablet: add two missing curly braces
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-12-02 11:05:38 +10:00
Peter Hutterer
abb98d5738 tablet: rename the libinput_tool calls to libinput_tablet_tool
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-11-18 12:13:54 +10:00
Peter Hutterer
759ef04465 tablet: rename TOOL_TIP to TABLET_TOOL_TIP
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-11-18 12:13:54 +10:00
Peter Hutterer
7123c37f1c tablet: rename tool_tip_state to tablet_tool_tip_state
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-11-18 12:13:53 +10:00
Peter Hutterer
cc2b45dd50 tablet: rename TOOL_PROXIMITY_ to TABLET_TOOL_PROXIMITY
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-11-18 12:13:53 +10:00
Peter Hutterer
c7cb77b36f tablet: rename TOOL_TYPE to TABLET_TOOL_TYPE
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-11-18 12:13:53 +10:00
Peter Hutterer
b85d57fdf8 tablet: rename libinput_tool_type to libinput_tablet_tool_type
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-11-18 12:13:53 +10:00
Peter Hutterer
827abfbb56 tablet: rename the tablet axes to "LIBINPUT_TABLET_TOOL_AXIS_..."
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-11-18 12:13:53 +10:00
Peter Hutterer
cd2cd2f112 tablet: rename libinput_tablet_axis to libinput_tablet_tool_axis
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-11-18 12:13:53 +10:00
Peter Hutterer
98df9eb63f tablet: rename libinput_tool to libinput_tablet_tool
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-11-18 12:13:53 +10:00
Peter Hutterer
7835e74604 tablet: allow fetching the tip state from any tablet event
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-11-16 09:23:59 +10:00
Peter Hutterer
6f5d9902c8 tablet: hook up tip events
Behavior for axis events in the same event frame as the BTN_TOUCH is to
always send axis events before any tip state.
Behavior for button events in the same event frame as the BTN_TOUCH is to
order button events to happen when the tip is in proximity, i.e. after the tip
event on tip down and before the tip event on tip up.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-11-16 08:43:58 +10:00
Peter Hutterer
003e9b14d7 tablet: rename STYLUS_IN_CONTACT to TOOL_IN_CONTACT
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-11-12 06:52:51 +10:00