Commit graph

30 commits

Author SHA1 Message Date
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
Stephen Chandler Paul
8f572b6fd1 tablet: Report and normalize distance, pressure, and tilt axes
Report the values for the distance, pressure, and tilt axes. Pressure is
normalized to a range of 0 to 1, and tilt is normalized to a range of -1 to 1.

Based off the patch originally written by Carlos Garnacho

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
Stephen Chandler Paul
5561e4502d tablet: Handle button-events
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
Stephen Chandler Paul
5fa892a88e Emit LIBINPUT_EVENT_TABLET_PROXIMITY_OUT when tool leaves proximity
This event is just used to notify the caller when the tool's no longer in
proximity. When an event like this occurs, everything from evdev up until the
next EV_SYN event is discarded along with any events that occured since the last
EV_SYN event. This also silences any tool update events where the tool type is
changed to LIBINPUT_TOOL_NONE, so we don't end up filling the tool list with a
bunch of tools that aren't actually tools.

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:13 -04:00
Stephen Chandler Paul
e5212e2080 Emit LIBINPUT_TABLET_EVENT_TOOL_UPDATE events on tool changes
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:11 -04:00
Stephen Chandler Paul
9357166114 evdev: Add basic support for tablet devices
These devices set the LIBINPUT_DEVICE_CAP_TABLET flag, and emit a lot more axis
information then mice and touchpads. As such, tablet events are in a whole new
group of events that is separate from everything else.

In this commit, only X and Y axes are reported in libinput.

Based off the patch originally written by Carlos Garnacho

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:15:58 -04:00