summaryrefslogtreecommitdiff
path: root/src/evdev-tablet.h
AgeCommit message (Collapse)AuthorFilesLines
2016-09-07tablet: add touch arbitrationPeter Hutterer1-0/+3
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-08-11evdev: split evdev_dispatch and fallback_dispatch into separate entitiesPeter Hutterer1-0/+2
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2016-06-10tablet: add helper function to access the libinput contextPeter Hutterer1-0/+6
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2016-04-13tablet: add a fuzz-filter to avoid spamming callers with subpixel updatesPeter Hutterer1-0/+2
This is especially a problem for the cursor tool which can be legitimately left on the tablet. It wobbles by a couple of device units, resulting in continuous axis updates to the caller. Pre-filter any of these events by the axis' fuzz value so we don't even process them. For ABS_DISTANCE which doesn't have a fuzz we hard-code a minimum fuzz of 2. This should eventually land in the kernel though. https://bugs.freedesktop.org/show_bug.cgi?id=94892 Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Jason Gerecke <jason.gerecke@wacom.com>
2016-03-01tablet: sanitize button mask passingPeter Hutterer1-1/+1
We have a struct, use it. Better than passing arrays and array lengths around. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2016-01-15tablet: drop delta array, provided by the tablet_axis struct nowPeter Hutterer1-1/+0
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Acked-by: Jason Gerecke <jason.gerecke@wacom.com>
2016-01-15tablet: use a struct rather than a double array for axis valuesPeter Hutterer1-1/+1
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>
2015-12-23tablet: handle custom proximity handlingPeter Hutterer1-0/+3
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-15tablet: support tool-specific pressure offsetsPeter Hutterer1-0/+21
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-02tablet: drop the tool type 'finger' from the tablet interfacePeter Hutterer1-1/+0
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-02Whitespace fixPeter Hutterer1-1/+1
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-11-18tablet: rename TOOL_TYPE to TABLET_TOOL_TYPEPeter Hutterer1-9/+9
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-11-18tablet: rename libinput_tool_type to libinput_tablet_tool_typePeter Hutterer1-2/+2
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-11-18tablet: rename the tablet axes to "LIBINPUT_TABLET_TOOL_AXIS_..."Peter Hutterer1-24/+24
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-11-18tablet: rename libinput_tablet_axis to libinput_tablet_tool_axisPeter Hutterer1-5/+5
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-11-16tablet: hook up tip eventsPeter Hutterer1-2/+4
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-12tablet: rename STYLUS_IN_CONTACT to TOOL_IN_CONTACTPeter Hutterer1-1/+1
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-11-09tablet: rename all tool types to LIBINPUT_TOOL_TYPE_*Peter Hutterer1-9/+9
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Jason Gerecke <jason.gerecke@wacom.com>
2015-03-05tablet: sync tools already in proximity at startupPeter Hutterer1-0/+21
If a tool is in proximity when we init, send a proximity event immediately. This is only partially reliable due to the current kernel behavior: * if the tool comes into proximity when there is no evdev client, the device won't send any events and must be lifted out-of-proximity first. Patch is in the works, see https://patchwork.kernel.org/patch/5924611/ * before 3.19, if the tool was in proximity (with an evdev client attached), but goes out of proximity and back in with no client connected, we get an immediate proximity out event from the kernel once we connect to the device and no further events after that. See kernel commit b905811a49bcd6e6726ce5bbb591f57aaddfd3be Otherwise, things work as expected. The above should be fixed in the kernel anyway. Note that this changes the order of events during a udev seat init, before we had all DEVICE_ADDED events in a row, now the proximity event may be interspersed. Reported-by: Jason Gerecke <killertofu@gmail.com> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Acked-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-03-02tablet: support the rel wheel on the mouse devicePeter Hutterer1-0/+18
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-02tablet: support artpen rotationPeter Hutterer1-0/+6
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Stephen Chandler Paul <thatslyude@gmail.com>
2015-03-02tablet: support airbrush wheel as sliderPeter Hutterer1-0/+6
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-02tablet: expand the button mask to allow for BTN_LEFT, RIGHT, MIDDLEPeter Hutterer1-1/+1
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-02tablet: add libinput_tool_get_tool_id()Peter Hutterer1-0/+1
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-02tablet: drop LIBINPUT_TOOL_NONE from the public APIPeter Hutterer1-0/+1
This is only used internally. 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-02-20cosmetic: drop double empty linesPeter Hutterer1-1/+0
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-02-18tablet: drop LIBINPUT_TABLET_AXIS_NONE from the APIPeter Hutterer1-3/+5
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>
2014-08-08tablet: Add libinput_tool_has_axis() and testsStephen Chandler Paul1-0/+1
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-08tablet: Use separate tool objects for tools without serialsStephen Chandler Paul1-0/+3
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-07-11tablet: Don't swap X and Y in evcode_to_axis()Stephen Chandler Paul1-2/+2
Signed-off-by: Stephen Chandler Paul <thatslyude@gmail.com> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-07-10tablet: Rename TILT_VERTICAL and TILT_HORIZONTAL to TILT_X and TILT_YStephen Chandler Paul1-4/+4
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-06-27tablet: Include tool with all eventsStephen Chandler Paul1-7/+6
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-27tablet: Replace tool-update with proximity-inStephen Chandler Paul1-1/+2
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-27tablet: Stop redundant proximity-out events from being reportedStephen Chandler Paul1-1/+2
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-24tablet: ignore pad buttonsPeter Hutterer1-1/+0
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-19evdev: Continue updating axes internally when tool leaves proximityStephen Chandler Paul1-5/+4
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-17Sanitize distance and pressure axes before reporting their valuesStephen Chandler Paul1-1/+2
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-17tablet: Report and normalize distance, pressure, and tilt axesStephen Chandler Paul1-1/+26
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-17tablet: Handle button-eventsStephen Chandler Paul1-1/+11
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-17Emit LIBINPUT_EVENT_TABLET_PROXIMITY_OUT when tool leaves proximityStephen Chandler Paul1-1/+2
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-17Emit LIBINPUT_TABLET_EVENT_TOOL_UPDATE events on tool changesStephen Chandler Paul1-1/+5
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-17evdev: Add basic support for tablet devicesStephen Chandler Paul1-0/+82
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>