Commit graph

80 commits

Author SHA1 Message Date
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
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
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
115e68476e Merge branch 'master' into tablet-support 2015-02-20 10:16:21 +10:00
Peter Hutterer
002ef1635d cosmetic: drop double empty lines
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-02-20 09:57:39 +10:00
Peter Hutterer
52997faf45 Merge branch 'master' into tablet-support
Conflicts:
	src/libinput.sym
2015-02-18 15:14:26 +10:00
Peter Hutterer
a138069d5c Rename noaccel to unaccel for consistency
No functional changes, this affects the declaration only.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-02-18 15:05:56 +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
Benjamin Tissoires
cbeacfed13 Use LIBINPUT_DEVICE_GROUP from udev as group identifier
Store it as identifier in the device group, any two devices that have a
the same non-NULL identifier share the group.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-02-18 10:08:35 +10:00
Peter Hutterer
2365f7d3d1 Merge branch 'master' into tablet-support
Added: udev-tag detection for the tablet.
libwacom assigns ID_INPUT_TABLET to all known devices but also
ID_INPUT_TOUCHPAD to all known devices with a touch interface. That's a bug
and should be fixed there but we can work around it by checking both and
making sure only one is set.

Conflicts:
	src/evdev.c
	test/misc.c
2015-02-10 15:23:38 +10:00
Peter Hutterer
e3a43902f9 Introduce device groups to group logical devices together
Devices like Wacom tablets have multiple event nodes (touch, pad and stylus).
This requires some logical grouping, e.g. setting an Intuos 5 tablet
left-handed effectively turns it upside down. That then applies to both the
stylus and the touch device.

Merging the devices into one struct libinput_device is not feasable, it
complicates the API for little benefit. A caller would still need access to
all subdevices to get udev handles, etc. Some configuration options apply to
the whole device (left-handed) but some (may) only apply to a single subdevice
(calibration, natural scrolling).

Addressing this would make the libinput API unwieldly and hard to use.

Instead, add a device group concept. Each device is a member of a device
group - a singleton for most devices. Wacom tablets will have a single group
across multiple devices, allowing the caller to associate the devices together
if needed.

The API is intentionally very simple and requires the caller to keep track of
groups and which/how many devices are in it. The caller has more powerful
libraries available to do that than we have.

This patch does not address the actual merging of devices into the same
device group, it simply creates a new group for each new device.

[rebased on top of 0.10]
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>
2015-02-06 11:08:43 +10:00
Peter Hutterer
35b3992792 Merge branch 'master' into tablet-support
Conflicts:
	test/litest.h
2015-01-20 15:24:34 +10:00
Peter Hutterer
c8ec33e72a Add a config interface for click methods
Two methods are provided:
* button area - used on most clickpads, a click with a touch within a given
  area generates left/middle/right clicks
* clickfinger - used on apple touchpads, a click with 1/2/3 fingers on the
  touchpad generates a left, right, middle click

Both methods already exist in the touchpad code, this is just the
configuration interface.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-01-16 09:56:49 +10:00
Peter Hutterer
395c449c8e Merge branch 'master' into tablet-support
Conflicts:
	src/libinput.h
2015-01-16 07:55:23 +10:00
Peter Hutterer
cb2f2ed613 Merge branch 'merged-scroll-events'
This is merged on top of the wheel normalization patches. Those introduced an
axis source and an extra "discrete" value to the various internal and external
APIs. This branch changed from a single value to passing dx/dy into all scroll
events.

The conflicts are to change everything to take x, y, x_discrete, y_discrete as
values (and the source axis mask of course).

Conflicts:
	src/evdev-mt-touchpad-edge-scroll.c
	src/evdev.c
	src/libinput-private.h
	src/libinput.c
2015-01-15 10:11:44 +10:00
Peter Hutterer
1daa1a11aa Add libinput_event_pointer_get_axis_value_discrete() to count wheel clicks
The recent normalization of wheel events means we get the angle in degrees but
we don't know how this corresponds to clicks. The M325 has a 20 degree click
angle, most other mice have 15 degrees. So an angle of 60 can be 3 or 4 click
events.

Most clients care more about the click count than the angle on a mouse wheel.
Provide that value when needed.

Adding a discrete value to the axis event leaves the possibility of defining
discrete units for finger/continuous scroll sources in the future. Right now,
these will always reuturn 0.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-01-15 09:22:14 +10:00
Peter Hutterer
1baf109b40 Change axis events to carry all directions
Sending separate axis events instead of one unified events is limiting,
especially when simultaneously scrolling in both directions and the caller
tries to implement kinetic scrolling.

Take a page from the tablet-support branch and instead implement the axis
event as a generic event that can contain multiple axes simultaneously.

Right now we only have two (scroll) axes and we could easily just check both
for non-zero values. If we want to allow further axes in the future, we need
a check whether an axis is set in an event, that's what
libinput_event_pointer_has_axis to scroll events() is for.

We also need the mask to notify of a scroll stop event, which could otherwise
be confused as a vertical-only or horizontal-only event.

This is an API and ABI break.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-01-13 13:54:21 +10:00
Peter Hutterer
20ac4b3abd Add pointer axis sources to the API
For a caller to implement/provide kinetic scrolling ("inertial scrolling",
"fling scrolling"), it needs to know how the scrolling motion was implemented,
and what to expect in the future. Add this information to the pointer axis
event.

The three scroll sources we have are:
* wheels: scrolling is in discreet steps, you don't know when it ends, the
  wheel will just stop sending events
* fingers: scrolling is continuous coordinate space, we know when it stops and
  we can tell the caller
* continuous: scrolling is in continuous coordinate space but we may or may not
  know when it stops. if scroll lock is used, the device may never technically
  get out of scroll mode even if it doesn't send events at any given moment
  Use case: trackpoint/trackball scroll emulation on button press

The stop event is now codified in the API documentation, so callers can use
that for kinetic scrolling. libinput does not implement kinetic scrolling
itself.

Not covered by this patch:
* The wheel event is currently defined as "typical mouse wheel step", this is
  different to Qt where the step value is 1/8 of a degree. Some better
  definition here may help.
* It is unclear how an absolute device would map into relative motion if the
  device itself is not controlling absolute motion.
* For diagonal scrolling, the vertical/horizontal terminator events would come
  in separately. The caller would have to deal with that somehow.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Original patch, before the rebase onto today's master:
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2014-12-24 10:47:00 +10:00
Peter Hutterer
9c9524d9e8 Drop LIBINPUT_TABLET_AXIS_CNT from the public API
Avoid mismatches in what the caller expects vs what libinput actually
 provides when building against newer/older versions of libinput.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2014-12-09 09:40:14 +10:00
Peter Hutterer
83f97991a0 0.7.0
-----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1
 
 iEYEABECAAYFAlSBMWUACgkQ4jt+cLRn8L/4JQCgt0u/hImDVk9GLPXpUfFZinRc
 pIgAn1bZ91n/o4nEhq6zOXSsKRoZvxHL
 =oj19
 -----END PGP SIGNATURE-----

Merge tag '0.7.0' into tablet-support

0.7.0

Conflicts:
	src/libinput-private.h
	test/device.c
	test/litest.h
2014-12-08 11:14:11 +10:00
Jonas Ådahl
93eca929ae Introduce unaccelerated motion event vectors
For certain applications (such as FPS games) it is necessary to use
unaccelerated motion events (the motion vector that is passed to the
acceleration filter) to get a more natural feeling. Supply this
information by passing both accelerated and unaccelerated motion
vectors to the existing motion event.

Note that the unaccelerated motion event is not equivalent to 'raw'
events as read from devices.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-12-05 11:54:02 +10:00
Peter Hutterer
d546c284c8 Add libinput_device_set_seat_logical_name() to change seats at runtime
The seat of a device is currently immutable, but a device may (in a
multi-pointer case) move between different logical seats. Moving it between
seats is akin to removing it and re-plugging it, so let's do exactly that.

The physical seat name stays immutable.

Pro:
- device handling after changing a seat remains identical as handling any
  other device.
Con:
- tracking a device across seat changes is difficult
- this is not an atomic operation, if re-adding the device fails it stays
  removed from the original seat and is now dead

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2014-11-25 16:34:22 +10:00
Peter Hutterer
92d178f167 Rename scroll_mode to scroll_method
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2014-11-24 10:58:23 +10:00
Peter Hutterer
bded6ac1d1 Drop unused libinput_device->terminated field
Unused since commit 56f7dde "Port udev-seat to be used in libinput"

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-11-20 15:38:46 +10:00
Hans de Goede
71f703c50c Add configuration option to select scroll mode
Add a configuration option to allow selecting between 2-finger / edge / none
scrolling (for touchpads).

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-11-11 12:05:09 +10:00
Hans de Goede
50107eca3f core: Move libinput_event definition to libinput-private.h
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-11-06 15:08:28 +10:00
Hans de Goede
ad2acca72d core: Add internal event notification mechanism
For features like e.g. disable-touchpad-while-typing, it is necessary for one
device to be able to listen into another device's events.

It is tempting to use the existing device_added / device_removed mechanism
to give e.g. the keyboard a link to the touchpad, and make the keyboard code
disable / re-enable the touchpad but this is wrong. This needs to be a setting
of the touchpad, and the policy for things like which events to count as
activity, and what sort of timeout to use to consider the device idle, belongs
in the touchpad code not in the keyboard code.

Add an event listeners mechanism so that the touchpad can listen for (e.g.)
keyboard events, and respond to these itself.

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-11-06 15:08:28 +10:00
Hans de Goede
1113a3f4f8 core: Make time argument to internal foo_notify_bar functions 64 bit
The libinput evdev code uses 64 bit timestamps internally, to avoid having to
deal with timestamp wraps. The internal foo_notify_bar functions time argument
however is only 32 bits, bump this to 64 bits to avoid truncating the timestamps
when calling these functions.

This is a preparation patch for adding internal event listeners, so that the
callbacks for these can get the full 64 bit timestamps.

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-11-06 15:08:28 +10:00
Peter Hutterer
cba92f9762 Add configuration option for left-handed behavior
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2014-09-23 15:45:46 +10:00
Peter Hutterer
c481b47f17 Add a configuration option for natural scrolling
Natural scrolling is simply inverted scrolling, but I decided to
use the Apple terminology simply because it's easier to google for.

Add the usual quartett of config options for has/set/get/get_default/, as a
boolean option rather than an enum for scroll mode to avoid name collusion
with the (currently in the works) edge scrolling.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2014-09-23 10:54:23 +10:00
Peter Hutterer
339f3dc979 Add a pointer acceleration API
Only exposes one knob - speed, normalized to a [-1, 1] range with 0 being the
neutral "this is what we think is normal" speed. -1 and 1 reflect the
slowest/fastest reasonable speed on this device.

Note: with this API we commit to having any pointer accelerating as a true
gliding scale. We cannot map the [-1,1] range into a discrete set of steps
as we do not communicate to the caller whether a specific value has changed
the acceleration. Without that, a caller may assume that acceleration has
changed even when it is not visible to the user.

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
a6f18c9cca Merge branch 'master' into tablet-support
sendevents config tests currently disabled for LITEST_TABLET until that gains
the matching bits in the dispatch.

Conflicts:
	src/evdev.c
	src/libinput.c
	test/litest.c
	test/litest.h
2014-09-22 15:42:13 +10:00
Peter Hutterer
fa363ed0e8 Drop two semicolons after a macro definition
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-09-22 15:20:51 +10:00
Peter Hutterer
3b51ea5cce Add a config interface for enabling/disabling event generation from a device
Rather than adding a config interface to disable a device merely allow a
caller to toggle the "send events" mode on the device. If off, the device
won't send events (though further events may be received depending on the
current state of the device).
Default is enabled, i.e. the device sends events.

A special mode is added to the obvious enable/disable: disable the device when
an external mouse is connected. Once set, the device will be enabled when no
mouse is present and stop sending events otherwise. This isn't hooked up to
anything yet though.

Built into the config API is the default option of "enabled". Any device
supports this, for the obvious reason. Disabling or conditionally disabling is
left to the implementation.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2014-09-18 11:31:14 +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
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
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
11e0558f91 tablet: Add libinput_tool_get/set_user_data()
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-06 11:55:09 +10:00
Peter Hutterer
d9cf649199 Use an enum to enable/disable tapping configuration
More expressive in the caller and less ambiguous about return values (is it 1?
is it non-zero? can it be negative?)

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2014-07-22 08:19:29 +10:00
Peter Hutterer
0891bc0d92 Merge branch 'master' into tablet-support 2014-07-21 09:31:37 +10:00
Peter Hutterer
401592870d Add an interface to enable/disable tapping
Provide an interface to enable/disable tapping, with a default mapping of
1/2/3 fingers mapping to L/R/M button events, respectively.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
2014-07-03 13:48:44 +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
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
bad56cac5b Merge branch 'ref-counting-context'
Conflicts:
	src/udev-seat.c
	test/log.c
2014-06-25 10:32:42 +10:00
Jonas Ådahl
faab25c25c Make context reference counted
Instead of only allowing one owner keeping a libinput context alive,
make context reference counted, replacing libinput_destroy() with
libinput_unref() while adding another function libinput_ref().

Even though there might not be any current use cases, it doesn't mean we
should hard code this usage model in the API. The old behaviour can be
emulated by never calling libinput_ref() while replacing
libinput_destroy() with libinput_unref().

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-06-25 10:27:03 +10:00