summaryrefslogtreecommitdiff
path: root/src/evdev-mt-touchpad-edge-scroll.c
AgeCommit message (Collapse)AuthorFilesLines
2016-01-20touchpad: constify a couple of helper functionsPeter Hutterer1-2/+3
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-08-20touchpad: use unaccelerated motion data for scrollingPeter Hutterer1-1/+2
For short and quick scroll gestures, those that should only trigger a few lines of scroll the pointer acceleration is wildly unpredictable. Since we average the motion of both fingers it's hard enough to intuitively predict what the motion will be like. On top of that is the small threshold before we start scrolling, so some of the initial motion gets swallowed before we accelerate, making the next motion even more unpredictable. The end result is that multiple seemingly identical finger motions cause wildly different scroll motion. Drop pointer acceleration for two-finger and edge scrolling. This makes short scroll motions much more predictable and doesn't seem to have much effect on long scroll motions. Plus, in natural scroll mode it really feels like the content is stuck to your fingers now. Go wash your hands. https://bugzilla.redhat.com/show_bug.cgi?id=1249365 Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-08-12touchpad: enable natural scrolling for edge scrollingPeter Hutterer1-10/+10
Instead of going straight to pointer_notify_axis, go through evdev_notify_axis() which flips the scroll direction around for us. https://bugs.freedesktop.org/show_bug.cgi?id=91597 Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-07-28Change to micro seconds for measuring time internallyJonas Ådahl1-1/+1
In order to provide higher precision event time stamps, change the internal time measuring from milliseconds to microseconds. Microseconds are chosen because it is the most fine grained time stamp we can get from evdev. The API is extended with high precision getters whenever the given information is available. Signed-off-by: Jonas Ådahl <jadahl@gmail.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-07-23touchpad: only edge-scroll while the finger is in the edge areaPeter Hutterer1-0/+5
When the touch leaves the area for edge scrolling after starting to scroll, discard any movement. This signals to the user that they've left the area and forces them to lift the finger to switch back to motion. If the finger moves back into the area, scrolling continues. https://bugs.freedesktop.org/show_bug.cgi?id=91323 Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-07-23touchpad: make the edge-scroll edge 7mm widePeter Hutterer1-22/+3
Rather than magic percentages of the touchpad axis ranges, make it a fixed size of 7mm. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-07-22Move CASE_RETURN_STRING to libinput-util.hPeter Hutterer1-2/+0
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-07-13touchpad: drop obsolete commentPeter Hutterer1-2/+1
Comment is obsolete now that we have edge scrolling on clickpads, see abff4a1c24830931f1cbd5e54d5b1a4621eab863 Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-07-09touchpad: allow edge scrolling on clickpadsPeter Hutterer1-3/+18
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-06-26evdev: store the device dimensionsPeter Hutterer1-2/+2
We use width/height often enough that storing it once is better than calculating it on each event. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-06-24touchpad: reduce edge scroll motion threshold to 3mmPeter Hutterer1-1/+1
Reduce the dead zone/initial jump https://bugs.freedesktop.org/show_bug.cgi?id=90990 Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-06-24touchpad: only send most recent edge delta when triggering thresholdPeter Hutterer1-1/+4
When edge scrolling is triggered by exceeding the motion threshold (5mm) we sent the whole delta as the first scroll event, causing a big jump. Instead, send only the current delta. This effectively introduces a 5mm dead zone when edge scrolling, still better than the jump. https://bugs.freedesktop.org/show_bug.cgi?id=90990 Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-06-22touchpad: disable right-edge palm detection for edge scrollingPeter Hutterer1-1/+1
Most scroll motions would be labelled a palm. https://bugs.freedesktop.org/show_bug.cgi?id=90980 Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-06-16COPYING: Update boilerplate from MIT X11 to MIT Expat licensePeter Hutterer1-16/+17
To quote Bryce Harrington from [1]: "MIT has released software under several slightly different licenses, including the old 'X11 License' or 'MIT License'. Some code under this license was in fact included in X.org's Xserver in the past. However, X.org now prefers the MIT Expat License as the standard (which, confusingly, is also referred to as the 'MIT License'). See http://cgit.freedesktop.org/xorg/xserver/tree/COPYING When Wayland started, it was Kristian Høgsberg's intent to license it compatibly with X.org. "I wanted Wayland to be usable (license-wise) whereever X was usable." But, the text of the older X11 License was taken for Wayland, rather than X11's current standard. This patch corrects this by swapping in the intended text." libinput is a fork of weston and thus inherited the original license intent and the license boilerplate itself. See this thread on wayland-devel here for a discussion: http://lists.freedesktop.org/archives/wayland-devel/2015-May/022301.html [1] http://lists.freedesktop.org/archives/wayland-devel/2015-June/022552.html Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Acked-by: Benjamin Tissoires <benjamin.tissoires@gmail.com> Acked-by: Jonas Ådahl <jadahl@gmail.com>
2015-06-01Add missing config.h includesJon A. Cruz1-0/+2
Signed-off-by: Jon A. Cruz <jonc@osg.samsung.com> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-05-28Update Red Hat's copyrightPeter Hutterer1-1/+1
Updated to 2015 where appropriate, added where missing. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-05-27touchpad: touches after the last key press can be releasedPeter Hutterer1-0/+3
The current code labels a touch as palm if it started within the typing timeouts. To move the pointer even after the timeout expires, a user has to lift the finger which is quite annoying and different to the old synaptics driver behaviour (which had a simple on/off toggle on whether to let events through or not). Be smarter about this: if a touch starts _after_ the last key press event, release it for pointer motion once the timeout expires. Touches started before the last key press remain labelled as palms. This makes it possible to rest the palm on the touchpad while typing without getting interference but also provides a more responsive UI when moving from typing to using the touchpad normally. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Tested-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-05-27touchpad: reset the touch state when edge scrolling is stoppedPeter Hutterer1-0/+4
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Tested-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-05-27touchpad: add helper function to get from tp to the libinput contextPeter Hutterer1-6/+6
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Tested-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-04-09touchpad: add state debugging to the edge scroll state machinePeter Hutterer1-1/+38
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-03-25Change tp_filter_motion to normalized_coordsHans de Goede1-2/+1
Change tp_filter_motion to use normalized_coords, rather then having it take separate x and y values. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-03-25Add a delta_coords type and use it were applicableHans de Goede1-7/+3
tp_normalize_coords is one of the last functions taking separate x, y values rather a coordinate pair, this commit cleans this up. 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>
2015-03-25Fix scroll-threshold check for edge-scrolling to use normalized coordinatesHans de Goede1-7/+3
The DEFAULT_SCROLL_THRESHOLD value is a TP_MM_TO_DPI_NORMALIZED value and as such should be compared to a normalized value. But since commit 8101e43774 ("touchpad: switch delta handling to typesafe coordinates"), the initial_dx / initial_dy values initial_delta points to are no longer in normalized coordinates, as the result of tp_normalize_delta is now stored into the normalized value. This commit changes the check to use the delta pointer which does point to the normalized x/y values. While at it also use the zero variable to set normalized to zero rather then manually setting x and y to 0. 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>
2015-03-17touchpad: add missing break in default: switch casePeter Hutterer1-0/+1
Unneeded, but better for symmetry. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-03-17Add another data type for discrete coordinatesPeter Hutterer1-3/+5
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-03-17Use typesafe coordinates for scrolling eventsPeter Hutterer1-3/+5
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-03-17touchpad: switch delta handling to typesafe coordinatesPeter Hutterer1-13/+13
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-03-17touchpad: switch touch point, hysteresis, initial coords to typesafe coordsPeter Hutterer1-6/+5
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-03-17cosmetic: rename touch to t for consistencyPeter Hutterer1-3/+3
Everywhere else in the touchpad code we use "t" for the struct tp_touch. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-03-10touchpad: Remove unnecessary edge scroll threshold variableHans de Goede1-6/+1
Now that we've separate handling of the EDGE_NEW vs EDGE states in tp_edge_scroll_post_events() we can drop the threshold variable, in EDGE_NEW we always want to check against DEFAULT_SCROLL_THRESHOLD and in the EDGE state we only want to make sure that the delta != 0.0 which is already checked later on in tp_edge_scroll_post_events(). 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>
2015-03-10touchpad: accumulate the initial scroll edge deltaPeter Hutterer1-3/+34
The previous setting of 10 wasn't 10 mm, it was used against the deltas normalized to a 1000DPI mouse, i.e. closer to 4mm. It was also also per-event, so a slow movement or a high-frequency touchpad can struggle to meet the threshold. Change the trigger to be ~5 mm from the initial touch down, accumulated until we either meet the threshold or the timeout expires. The first scroll event includes the delta since the touch down rather than the most recent delta. This removes the delay otherwise seen in scrolling and makes the scroll motion match the finger motion. This accumulated delta only applies when exceeding the motion threshold, when the timeout triggers the switch to scrolling the first delta posted is the current delta. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-02-23touchpad: Gesture support preparationHans de Goede1-1/+0
Handle everything which is not handled by the tap, (soft)button or edge-scroll code/statemachines in a unified way. Everything is treated as a X-finger gesture now, and the action to take on finger movement is decided by the gesture.finger_count setting. Pointer control now simply is seen as a 1 finger gesture, and 2fg scrolling as a 2fg gesture. This removed the need for special-casing things like switching back to pointer mode when lifting a finger in 2fg scrolling mode, and also lays the groundwork for adding 3+ fg gesture support. Note that 1 test-case needs to be updated to wait for the finger mode switching when switching mode while a gesture has already been started. This is actually an improvement as this stops sending spurious pointer motion events at the end of 2fg scrolling when not lifting both fingers at exactly the same time. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-02-23touchpad: Change how we deal with scroll methodsHans de Goede1-0/+3
With the upcoming gesture support 2fg scrolling will be handled as part of the main gesture state machine, whereas edge scrolling has its own state machine, our current way of dispatching scroll "actions" does not play well with this. Change the scroll method handling to treat edge and 2fg scrolling as 2 separate state machines. The double scroll calls this introduces will mostly be removed when the gesture handling code lands. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-01-16touchpad: add a TOUCH_HOVERING statePeter Hutterer1-0/+1
Some touchpads provide touch information while the finger hovers over the touchpad, i.e. before BTN_TOUCH. Add a touch state for those touchpads so we can ignore the touches until they actually start. The approach is now: instead of BEGIN we mark a new touch as HOVERING. Use the BTN_TOOL_FINGER, BTN_TOOL_DOUBLETAP information during tp_process_state() to mark any touches that are hovering as down or ended. i.e. provided BTN_TOUCH is down: if BTN_TOOL_FINGER is down, one hovering touch gets marked as down, if DOUBLETAP is down, two touches are marked as down, etc. When ending touches, switch them back into HOVERING if the BTN_TOOL_FINGER is still set, otherwise end them properly. https://bugs.freedesktop.org/show_bug.cgi?id=87197 Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-01-15Merge branch 'merged-scroll-events'Peter Hutterer1-9/+10
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-15Add libinput_event_pointer_get_axis_value_discrete() to count wheel clicksPeter Hutterer1-3/+6
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-13Change axis events to carry all directionsPeter Hutterer1-6/+7
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>
2014-12-24Add pointer axis sources to the APIPeter Hutterer1-3/+9
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-23touchpad: rename scroll.state to scroll.edge_statePeter Hutterer1-3/+3
In preparation for a twofinger_state field, to avoid confusion. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-12-12touchpad: print event type on state machine errorPeter Hutterer1-4/+8
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-12-12touchpad: fix typos in error messagePeter Hutterer1-4/+4
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-12-09touchpad: Use remove callback to unlink event listener and stop timersHans de Goede1-1/+1
We use 2 mechanisms to unregister the trackpoint event listener depending on device removal order. 1) We have a device_removed callback, if the trackpoint gets removed before the touchpad, this gets called, sees the device being removed is the trackpoint and unregisters the listener 2) If the touchpad gets removed first, then in tp_destroy we unregister the listener 2) May be delayed beyond the destruction of the trackpoint itself if the libinput user has a reference to the libinput_device for the touchpad. When this happens the trackpoint still has an eventlistener at destroy time and an assert triggers. To fix this we must do 2) at the same time as we do 1), so at remove time. While working on this I noticed that the touchpad code was also cancelling timers at destroy time rather then remove time, which means that they may expire between remove and destroy time, and cause events to be emitted from a removed device, so this commit moves the cancelling of the timers to the remove callback as well. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-12-05Introduce unaccelerated motion event vectorsJonas Ådahl1-1/+1
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-11-25touchpad: Add edge-scrolling supportHans de Goede1-0/+374
Add edge-scrolling support for non multi-touch touchpads as well as for users who prefer edge-scrolling (as long as they don't have a clickpad). Note the percentage to use of the width / height as scroll-edge differs from one manufacturer to the next, the various per model percentages were taken from xf86-input-synaptics. BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=85635 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>