Commit graph

55 commits

Author SHA1 Message Date
Peter Hutterer
71c2cd26cc tablet: support the rel wheel on the mouse device
Providing a relative axis in the axis_get_value() is inconsistent with the
other axes, this will be fixed in a follow-up commit.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
Reviewed-by: Stephen Chandler Paul <thatslyude@gmail.com>
2015-03-02 13:20:44 +10:00
Peter Hutterer
3407226804 tablet: support artpen rotation
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Stephen Chandler Paul <thatslyude@gmail.com>
2015-03-02 13:20:44 +10:00
Peter Hutterer
0d87dd8121 tablet: support airbrush wheel as slider
The little wheel isn't a full wheel, it has a ~90 degree rotation angle with a
range of 1024 values. To avoid confusion with "wheel" elsewhere in the API
name it slider.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Stephen Chandler Paul <thatslyude@gmail.com>
2015-03-02 13:20:44 +10:00
Peter Hutterer
8edae426e3 tablet: support z-rotation for the mouse/lens tool
Needs to be calculated from the x/y tilt values, the mouse has a fixed offset
of 175 degrees counterclockwise.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
Reviewed-by: Stephen Chandler Paul <thatslyude@gmail.com>
2015-03-02 13:20:44 +10:00
Peter Hutterer
cbce0d03b0 tablet: rely on libwacom to give us the right tablet axes
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Stephen Chandler Paul <thatslyude@gmail.com>
2015-03-02 13:20:44 +10:00
Peter Hutterer
7d62532479 tablet: handle mouse-buttons from a tool
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
Reviewed-by: Stephen Chandler Paul <thatslyude@gmail.com>
2015-03-02 13:20:44 +10:00
Peter Hutterer
9be6b3e864 tablet: add support for libinput_tool_has_button
libwacom can tell us how many buttons we have per stylus, so we map those into
BTN_STYLUS and BTN_STYLUS2.
BTN_TOUCH is set on all styli.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Stephen Chandler Paul <thatslyude@gmail.com>
2015-03-02 13:20:44 +10:00
Peter Hutterer
733fef5a67 tablet: expand the button mask to allow for BTN_LEFT, RIGHT, MIDDLE
Expand the mask to fit KEY_CNT buttons, the mouse has LMR buttons and a few
more, trying to squash the range is more error-prone than having the full key
range instead.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Stephen Chandler Paul <thatslyude@gmail.com>
2015-03-02 13:20:44 +10:00
Peter Hutterer
5cac5248fc tablet: factor out setting axis bits on a tool
No functional changes.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
Reviewed-by: Stephen Chandler Paul <thatslyude@gmail.com>
2015-03-02 13:20:44 +10:00
Peter Hutterer
8f56a7ea93 tablet: factor out checking a device for axes
This gets more complicated for axes that aren't a 1:1 relationship with event
codes.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
Reviewed-by: Stephen Chandler Paul <thatslyude@gmail.com>
2015-03-02 13:20:44 +10:00
Peter Hutterer
d43f92b464 tablet: explicitly ignore ABS_THROTTLE, ABS_RX, ABS_RY, and ABS_RZ
ABS_THROTTLE:
	Tablets still advertise this axis but the mouse itself isn't available
	anymore. The Pad sends the second wheel as ABS_THROTTLE but that's a
	task for the buttonset interface.  Explanation of what the throttle
	did on page
	http://101.wacom.com/productsupport/manual/Intuos2UsersManual.pdf

ABS_RX/ABS_RY:
	These only happen on the Intuos3 device and only on the Pad device
	(kernel >= 3.17)

ABS_RZ:
	The 4D mouse for the Intuos2, obsolete.

No functional changes, this is to clarify why we're only handling a subset of
codes.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
Reviewed-by: Stephen Chandler Paul <thatslyude@gmail.com>
2015-03-02 13:20:44 +10:00
Peter Hutterer
9c62daf1d8 tablet: use libwacom to identify tablets for left-handedness
A tablet hotplug event is rare and not a time-critical event, so we load the
database on tablet init and throw it away again.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Stephen Chandler Paul <thatslyude@gmail.com>
2015-03-02 13:20:44 +10:00
Peter Hutterer
9088138c80 tablet: add libinput_tool_get_tool_id()
The tool ID on wacom tablets is what really defines the tool, so one can
differ between say an Intuos Grip Pen, Art Pen or Classic Pen. They're all
BTN_TOOL_PEN in the kernel driver.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
Reviewed-by: Stephen Chandler Paul <thatslyude@gmail.com>
2015-03-02 13:19:01 +10:00
Peter Hutterer
5146bd00fd tablet: de-couple tool enum values from linux/input.h
There's no real reason to keep them in sync but it has drawbacks when we start
introducing tools that the kernel doesn't have (and can't easily add due to
range constraints).

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
Reviewed-by: Stephen Chandler Paul <thatslyude@gmail.com>
2015-03-02 13:19:01 +10:00
Peter Hutterer
d0805e41d2 tablet: fix two coding style issues
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
Reviewed-by: Stephen Chandler Paul <thatslyude@gmail.com>
2015-03-02 13:19:00 +10:00
Stephen Chandler Paul
f3ac8d03fe tablet: mark all axes as unchanged before the proximity out event
When the tablet goes out of proximity we provide the last-known axis status
(which was sent in a previous axis event anyway), make sure the changed_axis
bitfield is unset for all axes though.

Signed-off-by: Stephen Chandler Paul <thatslyude@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-02-19 13:49:33 +10:00
Peter Hutterer
1c3de35abb tablet: drop LIBINPUT_TABLET_AXIS_NONE from the API
This constant isn't used in the public API, let's drop it. To make it easier
to use it internally and avoid accidental boolean comparisions with axes, bump
all real axes up to start at 1.

Internally that means we drop the AXIS_CNT since it'd be misleading and
instead use MAX or MAX + 1 everywhere.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-02-18 13:59:14 +10:00
Stephen Chandler Paul
b5d6be3cd6 tablet: Include starting values of axes in proximity events
Having a motion event that's sent right after the original proximity event just
to give the values of each axis is somewhat redundant. Since we already include
the values of each axis with each type of event, we may as well use the
proximity event to give the client the starting values for each axis on the
tablet.

Signed-off-by: Stephen Chandler Paul <thatslyude@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-02-18 13:59:14 +10:00
Stephen Chandler Paul
c7948e3bb5 tablet: Merge PROXIMITY_IN and PROXIMITY_OUT into a single event
There isn't much purpose in having proximity in and out as different events,
combining them into one single event is more consistent with the rest of the
API, and means less code for clients to have to work with.

Signed-off-by: Stephen Chandler Paul <thatslyude@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-02-18 13:27:29 +10:00
Stephen Chandler Paul
06f424afb7 tablet: Make note of filtering out events while the tool is out of proximity
This is in reference to an issue I discovered during the GSoC where I found that
there is a grey area with the tablet tool and the tablet itself, where the
tablet will pick up the presence of a tool, but won't get any useful information
from it. When this happens, tablets have a habit of sending distance events with
incorrect values in them. As such, it's a good idea not to forward any axis
events from evdev until we know that the tool is within usable proximity.

Signed-off-by: Stephen Chandler Paul <thatslyude@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-02-18 13:27:29 +10:00
Stephen Chandler Paul
1751688cc8 tablet: Add a left handed mode and tests
On the majority of Wacom tablets, the buttons are on the left side, opposite of
the side where the palm is meant to rest. Because of this, it's impossible to
use the tablet with your left hand (comfortably, anyway) unless you flip it
over, in which case the coordinates need to be inverted for it to match up with
the screen properly. This is where left handed mode comes in. When enabled, it
reverses all the coordinates so that the tablet may be rotated, and the palm
rest on the tablet moved over to the left side.

Signed-off-by: Stephen Chandler Paul <thatslyude@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-02-18 13:27:29 +10:00
Stephen Chandler Paul
a98d4831b6 tablet: Set the tool as out of proximity by default when we initialize a tablet
We should be able to set the tablet to left-handed mode immediately when it's
connected to the system. Since left-handed mode won't activate until the tool is
out of proximity however, we have to make sure that upon initially connecting
the tablet, we set the tool to be out of proximity (it may as well be anyway,
since we haven't processed any proximity in events from evdev just yet)

Signed-off-by: Stephen Chandler Paul <thatslyude@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-02-18 08:35:20 +10:00
Stephen Chandler Paul
145663d0a2 tablet: Remove leftover-comment
Signed-off-by: Stephen Chandler Paul <thatslyude@gmail.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-02-16 13:52:54 +10:00
Peter Hutterer
24b1f2e995 Merge branch 'master' into tablet-support
Manual changes:
* add tablet APIs to libinput.sym
* add the tablet-specific events to litest_event_type_str
* add NULL for device_remove in the tablet interface

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-12-18 09:47:45 +10:00
Jason Gerecke
a5d80f02f6 Remove spurious addition from range normalization calculation
The presence of a "+1" in the range calculation prevents the
normalization functions from returning a value of "1.0" when
absinfo->value has reached its maximum.

Signed-off-by: Jason Gerecke <killertofu@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-12-08 12:57:26 +10:00
Peter Hutterer
1809baa59e tablet: initialize all unused dispatch callbacks to NULL
evdev-tablet.c:545:1: warning: missing initializer for field 'device_added' of
'struct evdev_dispatch_interface' [-Wmissing-field-initializers]

and similar

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-12-08 12:38:11 +10:00
Jason Gerecke
297cbe4808 Fix normalization functions
We need to *subtract*, not *add* the minimum to determine the
range-effective value. For example: if (min, current, max) is
(100, 100, 1000) then the normalized value would be 0.0, not 0.2.

Signed-off-by: Jason Gerecke <killertofu@gmail.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-10-09 14:32:59 +10:00
Stephen Chandler Paul
a0c9f1224e tablet: Add libinput_tool_has_axis() and tests
Because the axes that tool reports can change depending on the tool in use, we
want to be able to provide functionality to determine which axes each tool can
support.

Signed-off-by: Stephen Chandler Paul <thatslyude@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-08-08 13:12:53 +10:00
Stephen Chandler Paul
142cc66880 tablet: Use separate tool objects for tools without serials
With tablets that don't support serial numbers, we can't guarantee that the tool
objects are unique. Because of this, this can give clients the false impression
that a tool without a serial number is being shared between tablets when it very
well might not be. So we keep tools without serial numbers in a list that's
local to the tablet they belong to, and keep tools with serials in a list that's
global within the libinput context.

Signed-off-by: Stephen Chandler Paul <thatslyude@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-08-08 10:22:45 +10:00
Stephen Chandler Paul
78b474ee37 tablet: fix get_x_transformed() and get_y_transformed()
Because the values for each axis were stored in struct tablet_dispatch in
millimeters, coordinates were not being translated properly to screen
coordinates. This stores the values internally as raw coordinates, and only
translates them to millimeters if the client asks for it.

Signed-off-by: Stephen Chandler Paul <thatslyude@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-07-22 11:01:56 +10:00
Stephen Chandler Paul
43356a2979 tablet: Rename TILT_VERTICAL and TILT_HORIZONTAL to TILT_X and TILT_Y
Since the orientation of the tablet can potentially change, this naming scheme
makes a lot more sense then VERTICAL and HORIZONTAL does since they don't
reflect the actual physical movement.

Signed-off-by: Stephen Chandler Paul <thatslyude@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-07-10 14:24:13 +10:00
Stephen Chandler Paul
521bd2f112 tablet: Include axes with all events
Signed-off-by: Stephen Chandler Paul <thatslyude@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-06-27 12:08:39 +10:00
Stephen Chandler Paul
bcbf9f95fd tablet: Include tool with all events
Signed-off-by: Stephen Chandler Paul <thatslyude@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-06-27 12:08:33 +10:00
Stephen Chandler Paul
8b1b988fd8 tablet: Replace tool-update with proximity-in
A proximity-in event is something we want, especially since the current drafted
wayland spec has a proximity-in event. Adding this also makes our events more
consistent. And since we can just report the current tool in use with
proximity-in events, we can get rid of the tool-update event.

Signed-off-by: Stephen Chandler Paul <thatslyude@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-06-27 12:08:31 +10:00
Stephen Chandler Paul
e18f713289 tablet: Remove tablet_notify_tool() and add tablet_get_tool()
Signed-off-by: Stephen Chandler Paul <thatslyude@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-06-27 12:07:48 +10:00
Stephen Chandler Paul
62a0995d19 tablet: Stop redundant proximity-out events from being reported
Because bad distance events still trigger calls to tablet_flush(),
tablet_flush() will see that the tablet is out of proximity and assume it's an
appropriate time to send a proximity-out event, even when we've already sent
one. This results in multiple proximity-out events being sent in a row instead
of just one.
In addition, the bad distance events test has been modified to pick up on this.
We shouldn't be receiving /any/ events when we get false distance events from
evdev anyway.

Signed-off-by: Stephen Chandler Paul <thatslyude@gmail.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-06-27 11:57:40 +10:00
Peter Hutterer
8302b0b7e3 Merge branch 'master' into tablet-support
Conflicts:
	src/libinput-util.h
	test/misc.c
2014-06-25 14:43:45 +10:00
Peter Hutterer
52cc0ef25a tablet: ignore pad buttons
We've got big plans for handling pad buttons, and the interface will likely
be different for those. Meanwhile, discard any pad button events so no-one can
get too used to them.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2014-06-24 10:47:04 +10:00
Peter Hutterer
6fd00f74d4 tablet: normalize the distance to 0..1
The actual data provided by current tablets is not anywhere close to accurate.
While it'd be nice to have this in mm, this is unlikely to happen anytime
soon. Use the same 0..1 normalized range as pressure has.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2014-06-24 10:47:04 +10:00
Peter Hutterer
797b4b4e5a tablet: provide x/y by default in mm off the top/left corner
Given that tablets may not have the same x/y resolution, raw or normalized
values are mostly meaningless and likely to be handled the wrong way.
Providing x/y in mm is the only constant, meaningful value.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2014-06-23 14:12:24 +10:00
Stephen Chandler Paul
04915ced72 evdev: Update all axes when the tool comes back into proximity
Signed-off-by: Stephen Chandler Paul <thatslyude@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-06-19 15:50:16 +10:00
Stephen Chandler Paul
2fed26aa11 evdev: Add tablet_mark_all_axes_changed()
Occasionally all the axes that are valid for a device need to be marked as
updated for the caller's sake.

Signed-off-by: Stephen Chandler Paul <thatslyude@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-06-19 15:50:12 +10:00
Stephen Chandler Paul
39b43c7058 evdev: Continue updating axes internally when tool leaves proximity
Axis changes are now still processed by libinput regardless of whether or not
the tool is in proximity, however we refrain from reporting them unless the tool
is in proximity. This stops bad distance events from being reported without
needing a huge mess of conditional statements in sanitize_axes(). The tool is
now counted as back in proximity when a tool update is received instead of when
an axis update is received.

Signed-off-by: Stephen Chandler Paul <thatslyude@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-06-19 15:45:35 +10:00
Stephen Chandler Paul
563268fa9f tablet: Clear pressure axis when tool loses contact with the tablet
Signed-off-by: Stephen Chandler Paul <thatslyude@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-06-18 15:55:21 +10:00
Stephen Chandler Paul
584ef1dbf5 tablet: remove parentheses around tablet_(un)set_status
Having parantheses around tablet_has_status() is completely appropriate, but not
for setting/unsetting a status. There's no legitimate reason we'd ever be
checking the return value of tablet_(un)set_status() since it already stores
it's result in a variable. As such, having it expand with parantheses around it
means that if it's accidentally used in a conditional instead of
tablet_has_status() our compiler won't throw any sort of warning. And the subtle
differences between tablet_has_status() and tablet_set_status() are very easy to
miss when trying to debug this. Removing the parantheses causes gcc to warn if
the function is used as a conditional unintentionally.

Signed-off-by: Stephen Chandler Paul <thatslyude@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-06-18 15:55:14 +10:00
Peter Hutterer
0f70e2b309 tablet: print invalid evdev types/codes as string for debugging purposes
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-06-18 15:43:31 +10:00
Peter Hutterer
f64a85c981 tablet: use "int32_t", not "signed"
stdint is a lot nicer, and safer once we're in the habit.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Stephen Chandler Paul <thatslyude@gmail.com>
2014-06-18 15:43:28 +10:00
Peter Hutterer
ee8fb790b0 tablet: rename flags to mask
This is a simple button mask, use that naming.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Stephen Chandler Paul <thatslyude@gmail.com>
2014-06-18 15:41:56 +10:00
Peter Hutterer
f86c89c5c8 tablet: check the button range before we use it
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Stephen Chandler Paul <thatslyude@gmail.com>
2014-06-18 15:41:52 +10:00
Stephen Chandler Paul
4e4ff21e31 Sanitize distance and pressure axes before reporting their values
This commit changes two things with the way distance and pressure axes are
reported:
1. Distance and pressure are made mutually exclusive. When there is a distance
   event and a pressure event and the tool is in contact with the tablet, only
   the pressure change will be reported. When the tool is not in contact and
   both a distance and pressure change are received, only the distance update
   will be received.
2. Bad distance events are not reported to the caller. There is a certain
   distance a tool can be from the tablet where the tablet recongnizes that a
   tool appeared, but the tool doesn't send any useful information to the
   tablet. When this happens, the distance will update to it's minimum or
   maximum value, and no other axis updates will be sent. Since this can give
   a caller the impression that the tool is within a useful proximity of the
   tablet, we filter out any distance events with a value of maximum or minimum
   when the tool is not within useful proximity of the tablet.

Signed-off-by: Stephen Chandler Paul <thatslyude@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2014-06-17 17:17:14 -04:00