summaryrefslogtreecommitdiff
path: root/src/evdev-mt-touchpad.c
AgeCommit message (Collapse)AuthorFilesLines
2017-02-24evdev: standardize log messsagesPeter Hutterer1-54/+48
Prefix device log messages with the device's sysname so it's more obvious where the messages are coming from. This makes it much easier to grep for a specific device's messages but also adds some identifier to messages that were previously without any identifier (e.g. all the state machine debugging) All info and error messages also automatically prefix the device name, so those messages are standardised too, e.g an info message now: event4 - SynPS/2 Synaptics TouchPad: is tagged by udev as: Touchpad a debug message now: event4 - using pressure-based touch detection And since this required changing a lot of the strings in messages anyway, polish a few minor things too. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Acked-by: Hans de Goede <hdegoede@redhat.com>
2017-02-13touchpad: drop 'is blacklisted' check for dwt pairingPeter Hutterer1-22/+2
dwt is needed on internal touchpads only and those external ones that are a combo device. This also now gives us the same check for palm detect and dwt. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2017-02-13touchpad: add a hwdb quirk for (external) touchpad/keyboard combosPeter Hutterer1-2/+17
Specify the layout of the combo so we know when to initialize palm detection. This allows us to drop palm detection on external touchpads otherwise, replacing the wacom-specific check with something more generic.. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2017-02-09touchpad: mark the Apple onebutton touchpad as clickfinger-defaultPeter Hutterer1-1/+5
We don't initialize click methods on devices with physical buttons. This model is a special case, it's not a clickpad but it only has one button (because one button is all you ever need and whatnot). https://bugs.freedesktop.org/show_bug.cgi?id=99283 Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-02-03Merge branch 'touchpad-pressure-based-v2'Peter Hutterer1-22/+109
2017-02-01Merge branch 'wip/switch-interface'Peter Hutterer1-20/+67
2017-01-31touchpad: remove unnecessary return statementPeter Hutterer1-2/+0
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-01-31evdev: add a wrapper to get the evdev device from a libinput devicePeter Hutterer1-12/+12
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-01-31evdev: improve type-safety on dispatch switchesPeter Hutterer1-8/+6
Set the dispatch type on creation, then check that whenever we try to get the dispatch struct. This avoids a potential mismatch between the backends. Plus, use of container_of means we're not dependent on the exact layout anymore. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-01-30touchpad: use pressure values for touch is-down decisionPeter Hutterer1-22/+107
Don't rely on BTN_TOUCH for "finger down", the value for that is hardcoded in the kernel and not always suitable. Some devices need a different value to avoid reacting to accidental touches or hovering fingers. Implement a basic Schmitt trigger, same as we have in the synaptics driver. We also take the default values from there but these will likely see some updates. A special case is when we have more fingers down than slots. Since we can't detect the pressure on fake fingers (we only get a bit for 'is down') we assume that *all* fingers are down with sufficient pressure. It's too much of a niche case to have this work any other way. This patch drops the handling of ABS_DISTANCE because it's simply not needed anymore. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-01-26touchpad: ignore hovering touches when tappingPeter Hutterer1-0/+2
We need to remember whether a tap was down or just hovering, otherwise we mess up the state machine when we send tap release events for taps that never switched to TOUCH_BEGIN. This is quick fix, really we should have a new state here, but that's a lot harder to implement. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-01-26touchpad: check for a switch type before handling the eventPeter Hutterer1-12/+12
Don't call get_switch_event immediately, doing so for non-switch events is documented as a bug. Check the event type instead, if that one is correct then we can assume the rest works. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-01-26Pair touchpad and lid_switch for disableJames Ye1-0/+49
Add listener for lid switch events, disable touchpad on switch event. Signed-off-by: James Ye <jye836@gmail.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-01-25touchpad: use a helper function for the libinput contextPeter Hutterer1-1/+1
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-01-23Drop normalized_get_direction, use physical distances insteadPeter Hutterer1-1/+1
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2017-01-23touchpad: convert normalized_length to physical coordinatesPeter Hutterer1-4/+3
Now that the acceleration code doesn't use dpi-normalized coordinates anymore, we don't need to use them in the touchpad code. Switch to physical distances instead, it makes debugging a lot saner. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2017-01-23touchpad: mask out ABS_MT if we don't have or disable MTPeter Hutterer1-0/+13
Make sure the events we deal with are the ones we actually honor. This reduces the chance that we accidentally process events we weren't event supposed to get based on some earlier device decision. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2016-12-21Merge branch 'touchpad-pointer-accel-revamp'Peter Hutterer1-2/+18
2016-12-21filter: change the filter functions to take raw device coordinatesPeter Hutterer1-2/+14
We used to normalize all deltas to equivalents of a 1000dpi mouse before passing it into the acceleration functions. This has a bunch of drawbacks, not least that we already have to un-normalize back into device units for a few devices already (trackpoints, tablet, low-dpi mice). Switch the filter code over to use device units, relying on the dpi set earlier during filter creation to convert to normalized. To make things easy, the output of the filter code is still normalized data, i.e. data ready to be handed to the libinput caller. No effective functional changes. For touchpads, we still send normalized coordinates (for now, anyway). For the various filter methods, we either drop the places where we unnormalized before or we normalize where needed. Two possible changes: for trackpoints and low-dpi mice we had a max dpi factor of 1.0 before - now we don't anymore. This was only the case if a low-dpi mouse had more than 1000dpi (never true) or a trackpoint had a const accel lower than 1.0 (yeah, whatever). Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2016-12-21touchpad: init the device's dpi correctlyPeter Hutterer1-0/+4
This has no real effect just yet because we don't use a touchpad's dpi anywhere in the touchpad code. Only the acceleration code wants it but all touchpads use the same acceleration method, and that one doesn't care about the dpi. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2016-12-20touchpad: if an external touchpad and keyboard share a VID/PID assume dwtPeter Hutterer1-2/+11
This requires to expand the blacklisting to be a bit more specific so we don't initialize dwt config on devices that won't need it. https://bugs.freedesktop.org/show_bug.cgi?id=99140 Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2016-12-14touchpad: convert two functions to use the device->phys helpersPeter Hutterer1-11/+13
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2016-12-14touchpad: constify a few helper functionsPeter Hutterer1-1/+1
May help the compiler with further optimization Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2016-12-06touchpad: sync BTN_TOOL_FINGER state on initPeter Hutterer1-0/+8
The Elantech touchpad on my Asus Vivobook doesn't release BTN_TOOL_FINGER on up. If the touchpad was used before libinput initializes, the kernel filters the event because its state is already set. We never receive it and keep ignoring all events until the first switch to BTN_TOOL_DOUBLETAP and back. On touchpad init sync the BTN_TOOL_FINGER state and set it accordingly. This is the only event that can be legitimately down on init. We don't care about BTN_TOUCH because ignoring an ongoing touch on init is generally a good idea and we can ignore any multifinger gesture as well. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2016-12-01touchpad: add a quirk for the HP Pavilion dm4Peter Hutterer1-1/+11
This touchpad has cursor jumps for 2-finger scrolling that also affects the single-finger emulation. So disable any multitouch bits on this device and disallow the 2-finger scroll method. This still allows for 2-finger tapping/clicking. https://bugs.freedesktop.org/show_bug.cgi?id=91135 Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2016-11-30evdev: init axis range warnings for touch devices tooPeter Hutterer1-63/+13
Move the code from the touchpad code into the more generic evdev code Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2016-11-23touchpad: only use the last two coordinates for delta calculationPeter Hutterer1-15/+5
Taking the last 4 points means factoring in a coordinate that may be more than 40ms in the past - or even more when the finger moves slowly and we don't get events for a while. This makes the pointer more sluggish and slower to catch up with what the finger is actually doing. We already have the motion hysteresis as a separate item to prevent jumps (and thus adds some delay to the movement), the calculation over time doesn't provide enough benefit to justify the sluggish pointer. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2016-10-28touchpad: check for trackpoint/keyboard at the top of the helpersPeter Hutterer1-3/+7
No functional changes, just to filter out devices that don't match immediately. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2016-10-28touchpad: split the touchpad->keyboard/trackpoint pairing helpers outPeter Hutterer1-8/+16
No functional changes Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2016-10-25touchpad: switch from fabs() to abs()Peter Hutterer1-2/+2
silence clang warning: evdev-mt-touchpad.c:1017:7: warning: using floating point absolute value function 'fabs' when argument is of integer type [-Wabsolute-value] Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
2016-09-12touchpad: require at least 3 events before enabling trackpoint palm detectionPeter Hutterer1-1/+8
Some trackpoints, notably the one on the Lenovo T460s have a tendency to send the odd event even when they're not actually used. Trackpoint events trigger palm detection (see 0210f1fee193) and thus effectively disable the touchpad, causing the touchpad to appear nonresponsive. Fix this by requiring at least 3 events from a trackpoint before palm detection is enabled. For normal use it's hard enough to trigger a single event anyway so this should not affect the normal use-case. https://bugzilla.redhat.com/show_bug.cgi?id=1364850 Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2016-09-07tablet: add touch arbitrationPeter Hutterer1-0/+21
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-29touchpad: always reset the motion history on finger changesPeter Hutterer1-5/+5
We've already been doing this for semi-mt devices and for non-clickpads but let's do it for clickpads as well. On Synaptics touchpads (PS/2 and RMI4) we see slot jumps where two slots are active, slot X ends but slot Y continues with the other slot's positional data. This causes a cursor jump on finger lift after a two-finger scrolling motion. Simply resetting the motion history fixes it. The only multi-finger interaction where a user could expect perfect fluid motion is when using a second finger to touch cone of the software button areas. Let's see if we have complaints first before we implement something more complex. https://bugs.freedesktop.org/show_bug.cgi?id=91695 Signed-off-by:Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2016-08-19touchpad: on a non-clickpad, reset the motion history on nfingers changePeter Hutterer1-2/+5
The only reason to have more than one finger on a non-clickpad is to tap, scroll or gesture. In all cases resetting the motion history is a good idea to avoid jumps moving from 2 to 1 finger. https://bugs.freedesktop.org/show_bug.cgi?id=97194 Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2016-08-15touchpad: implement configurable button mapping for tappingPeter Hutterer1-0/+2
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2016-08-11evdev: switch three ints to booleansPeter Hutterer1-3/+3
And a minor rename to make it more obvious Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2016-08-05touchpad: ignore modifier key combos for dwtPeter Hutterer1-6/+29
Inspired by the syndaemon -K switch and Anton Lindqvist's patch. https://patchwork.freedesktop.org/patch/102417/ We already ignored modifiers for dwt. Now we also ignore modifier + key combinations, i.e. hitting Ctrl+s to save does not trigger dwt, the touchpad remains immediately usable. However, if dwt is already active and a modifier combination is pressed, dwt remains active, i.e. while typing, a shift + key does not disable dwt. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2016-08-01touchpad: use the udev ID_INPUT_TOUCHPAD_INTEGRATION property if availablePeter Hutterer1-0/+18
udev now labels touchpads as "internal" or "external" for us, use that value where available and only fall back onto our own labelling if it's missing or unknown. systemd commit: https://github.com/systemd/systemd/pull/3638 https://bugs.freedesktop.org/show_bug.cgi?id=96735 Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2016-08-01touchpad: change manual calculations of dimensions to helper functionsPeter Hutterer1-11/+22
Wherever we use an absolute size in mm on the touchpad, switch to the new helper functions. In a few cases we only need one coordinate so just leave the other one as 0 in those cases. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2016-07-20touchpad: change the sanity check function to a boolPeter Hutterer1-7/+7
And rename to make the return value more obvious Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Yong Bakos <ybakos@humanoriented.com> Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
2016-07-20touchpad: change palm detection trigger functions to boolsPeter Hutterer1-13/+15
And rename to make it more obvious what the return value means. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Yong Bakos <ybakos@humanoriented.com> Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
2016-07-20Switch a bunch of internal functions from int to boolPeter Hutterer1-13/+13
All these effectively returned bools anyway, switch the signature over to be less ambiguous. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Yong Bakos <ybakos@humanoriented.com> Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
2016-07-20Change a few functions that only ever returned 0 to voidsPeter Hutterer1-53/+24
These are internal functions, if we need them to return an error code we can change that at any time. Meanwhile, if we only ever return 0 anyway we might as well just make them voids to save on error paths. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Yong Bakos <ybakos@humanoriented.com> Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
2016-07-19touchpad: whitespace fixPeter Hutterer1-1/+1
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2016-07-13touchpad: drop unused argument diagonal from tp_init_accelPeter Hutterer1-4/+2
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2016-07-04touchpad: remove software middle button when emulation is enabledPeter Hutterer1-0/+2
Expose the middle button emulation on software buttons as proper config option. When enabled, remove the middle button software button area. https://bugs.freedesktop.org/show_bug.cgi?id=96663 Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2016-07-04touchpad: unify internal/external touchpad taggingPeter Hutterer1-13/+52
To unify this we need to move the tagging process forward so tp_init() can rely on it for config setup. This means moving it to the touchpad init code. Other than that no real functional changes, the rules stay the same: * serial/i2c/etc. are considered internal touchpads * Bluetooth is always external * USB is external for Logitech devices * USB is external for Wacom devices * USB is internal for Apple touchpads And if we can't figure it out, we assume it's external and log a message so we can put a quirk in place. https://bugs.freedesktop.org/show_bug.cgi?id=96735 Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2016-06-20touchpad: re-enable hysteresis by default for all devicesPeter Hutterer1-6/+0
The removal of the hysteresis even on precise touchpads has led to difficulties controlling the cursor in a few instances. Since 27078b2667d we only have the hysteresis on Apple touchpads and the Lenovo *40 series and later. Even on those do we see some positioning difficulties (bug 94379). So restore the hysteresis by default again for all touchpads. In the future a knob could be exposed for precision vs reactivity or something, but for now the drawback of imprecise positioning does not outweigh the benefits we get on those few devices. https://bugs.freedesktop.org/show_bug.cgi?id=94379 Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2016-06-20Revert "touchpad: reset the motion history on significant negative pressure ↵Peter Hutterer1-4/+0
changes" We will reinstate the hysteresis for all devices making the negative pressure check unncessary. This reverts commit ef48c07a9600733e068a2a437a145862ba07fdab. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2016-06-20Revert "touchpad: only use negative pressure change check on Lenovo *50 and ↵Peter Hutterer1-3/+1
*60 series" We will reinstate the hysteresis for all devices making the negative pressure check unncessary and thus this commit as well. This reverts commit 2f5231cc88fccf389a78270d827f6c9201b86794. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com>