summaryrefslogtreecommitdiff
path: root/src/libinput-util.c
AgeCommit message (Collapse)AuthorFilesLines
2018-06-11Merge branch 'wip/config-files'Peter Hutterer1-0/+14
2018-06-11util: put limits on how many strings we joinPeter Hutterer1-0/+2
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-06-11util: add null string test handling to strv_joinPeter Hutterer1-0/+4
Make it return NULL for a string array in the form of [ NULL ], like the docs say. This also adds an extra safety check for the joiner to be of a reasonable length to avoid overflows. Found in https://gitlab.freedesktop.org/libinput/libinput/issues/26#note_6320 Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-06-08util: add a list_append()Peter Hutterer1-0/+14
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-05-30touchpad: replace the hardcoded thumb threshold with a udev propPeter Hutterer1-0/+25
LIBINPUT_ATTR_THUMB_PRESSURE_THRESHOLD now determines whether we do thumb pressure detection or not. Much better than having a hardcoded default that may or may not be correct on any given device. This patch is likely to break thumb detection on some touchpads, the only property so far is to restore the default of 100 for all Lenovo Thinkpad touchpads. More rules are needed, we'll just wait until someone shouts. https://bugs.freedesktop.org/show_bug.cgi?id=106458 Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-05-16util: avoid potential integer overflowPeter Hutterer1-0/+2
If we need more than 1000 pairs, we have a problem... Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-05-03util: remove dead assignment in strv_joinPeter Hutterer1-1/+0
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-05-03util: add a strv_join() helper functionPeter Hutterer1-0/+43
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-04-30util: allow for palm pressure > 255Peter Hutterer1-3/+1
https://bugs.freedesktop.org/show_bug.cgi?id=105753 Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-10-18util: add an extra assert for list_insert()Peter Hutterer1-0/+2
If we're adding an element that's not null or not a freshly initialized list, chances are we haven't removed it from a previous list. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
2017-08-14touchpad: Allow larger palm sizes.Ronald Tschalär1-1/+1
On MBP13,3 the touch areas are quite large, and a thumb size easily gets to 1000+. Hence need to be able to set palm sizes > 1024 (using 1200 currently). Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-07-14Merge branch 'wip/touchpad-apple-touch-major-v2'Peter Hutterer1-1/+26
2017-07-12Abort if zalloc ever failsPeter Hutterer1-2/+0
There's no guarantee that libinput does the right thing if memory allocation fails and it's such a niche case on the systems we're targeting that it just doesn't matter. Simply abort if zalloc ever fails. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-07-11touchpad: add touch-size-based palm detectionPeter Hutterer1-0/+25
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-07-11util: rename the pressure range parser to a more generic range_parserPeter Hutterer1-1/+1
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-07-03touchpad: add pressure-base palm detectionPeter Hutterer1-0/+27
If a touch goes past the fixed pressure threshold it is labelled as a palm and stays a palm. Default value is one that works well here on a T440 and is virtually impossible to trigger by a normal finger or thumb. A udev property is exposed so we can handle this in the udev hwdb and the new tool introduce a few commits ago can help finding the palm detection threshold. Unlike the other palm detection features, once a palm goes past the threshold it remains a palm until the touch is released. This means palm overrides any other palm detection features. For code simplicity, we don't combine the states but merely check for pressure before and after the other palm detection functions. If the pressure triggers, it will trigger before anything else. And if something else is already active (e.g. edge where the pressure doesn't work well) it will trigger as soon as the palm is released. The palm threshold should thus be chosen with some room to spare between the highest finger pressure. https://bugs.freedesktop.org/show_bug.cgi?id=94236 Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-05-04util: add asserts with useful error messages to catch uninitialized listsPeter Hutterer1-0/+9
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-04-26touchpad: move the pressure range to a hwdb entryPeter Hutterer1-0/+36
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-02-13touchpad: add a hwdb quirk for (external) touchpad/keyboard combosPeter Hutterer1-0/+24
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-09evdev: split calibration property parsing into a helperPeter Hutterer1-0/+38
So we can test it externally. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-01-30switch: for surface 3 tablets, write the lid open to the devicePeter Hutterer1-0/+2
These tablets only ever give us a close event, the open event is broken. So when we detect keyboard events, fix the kernel device's state by writing the event to the fd. We still sync the lid state manually, in case this fails and we don't get the SW_LID through the normal event sequence. If it works fine, the real open event will just be ignored. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-01-26switch: only sync the initial state if we know the state is reliablePeter Hutterer1-0/+17
This changes the default behavior to "disable the touchpad on the first lid close event", thus filtering any laptops where the switch state is buggy and always in "on" state. Devices where we know the lid switch state is reliable can be marked as such. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-01-20util: make all property parsing helpers ignore NULL stringsPeter Hutterer1-0/+12
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2016-11-29util: tighten requirements on the click angle/count propertiesPeter Hutterer1-24/+4
Require both of them to be an integer, don't allow for a list or preceding whitespaces. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2016-11-29util: add a helper function to split a string into substringsPeter Hutterer1-0/+82
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2016-11-29util: add safe_atod for locale-independent conversionPeter Hutterer1-13/+2
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2016-11-04evdev: implement support for the MOUSE_WHEEL_CLICK_COUNT propertyPeter Hutterer1-0/+32
Not all mice have a click angle with integer degrees. The new MOUSE_WHEEL_CLICK_COUNT property specifies how many clicks per full rotation, the angle can be calculated from that. See https://github.com/systemd/systemd/pull/4440 for more information CLICK_COUNT overrides CLICK_ANGLE, so we check for the former first and then fall back to the angle if need be. No changes to the user-facing API. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2016-07-20Switch a bunch of internal functions from int to boolPeter Hutterer1-1/+1
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>
2015-07-28Change to micro seconds for measuring time internallyJonas Ådahl1-6/+6
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-14util: add a helper function to parse a "WIDTHxHEIGHT" propertyPeter Hutterer1-0/+30
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-05-28Update Red Hat's copyrightPeter Hutterer1-0/+1
Updated to 2015 where appropriate, added where missing. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-04-22evdev: Add support for POINTINGSTICK_CONST_ACCEL udev propertyHans de Goede1-0/+31
There is quite a wide spread in the delta events generated by trackpoints, some generate deltas of 1-2 under normal use, while others generate deltas from 1-20. It is desirable to normalize trackpoint deltas just like we are normalizing mouse deltas to 1000 dpi, so as to give different model laptops aprox. the same trackpoint cursor speed ootb. Recent versions of udev + hwdb set a POINTINGSTICK_CONST_ACCEL udev property which can be used to adjust trackpoints which are too slow / too fast ootb, this commit implements support for that property. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-03-20Revert "touchpad: parse the TOUCHPAD_RESOLUTION property"Peter Hutterer1-30/+0
This reverts commit 0e64837f30c310da878f28961a6db7c4bcd4f282. Rather than a customized touchpad property, let udev handle this and set the absinfo struct during the normal setup procedures. No need for libinput to have a custom workaround here. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-03-17touchpad: parse the TOUCHPAD_RESOLUTION propertyPeter Hutterer1-0/+30
Not all touchpad kernel drivers supply the x/y resolution. Let the udev hwdb fix this up where possible and read the value from it. This is intentionally only used on touchpads, touchscreen devices without resolution should be considered buggy and fixed in the kernel. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-01-13Parse the MOUSE_WHEEL_CLICK_ANGLE udev property if presentPeter Hutterer1-0/+30
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
2015-01-13Add a comment to clarify what the prop parameter isPeter Hutterer1-0/+3
prop isn't the full property line, just the value. And document the return value too while we're at it. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-12-02evdev: Query mouse DPI from udevDerek Foreman1-0/+55
Instead of using a hard coded mouse DPI value, we query it from udev. If it's not present or the property is obviously broken we fall back to default. Signed-off-by: Derek Foreman <derekf@osg.samsung.com> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2014-11-07util: introduce ratelimit helpersDavid Herrmann1-0/+48
This adds "struct ratelimit" and "ratelimit_test()". It's a very simple rate-limit helper modeled after Linux' lib/ratelimit.c by Dave Young. This comes in handy to limit log-messages in possible busy loops etc.. Signed-off-by: David Herrmann <dh.herrmann@gmail.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-02-19Add a customizable log handlerPeter Hutterer1-20/+0
The previous log handler wasn't actually hooked up to anything. Add a public API for the log handler with priority filtering, defaulting to priority 'error' and stderr as output stream. And to keep the diff down and convenience up, provide a few simple wrappers for logging. The generic is log_msg(), but let's use log_info, log_error, etc. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
2013-11-23util: Add logging utilitiesJonas Ådahl1-0/+25
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2013-11-17Introduce libinput object managing all input dataJonas Ådahl1-0/+62
Instead of having the user manage added and removed fd's as well as the fd used for creating evdev devices, introduce a libinput object that itself has an epoll fd. The user no longer manages multiple fd's per libinput instance, but instead handles one fd, dispatches libinput when data is available, then reading events using libinput_get_event(). libinput_event's are now per libinstance, but divided into categories. So far the only category is device events. Device events are categorized by the presence of a non-NULL device pointer in the event. The current API usage should look like: struct libinput libinput = ...; struct libinput_event *event; if (libinput_dispatch(libinput) != 0) return -1; while ((event = libinput_get_event(libinput))) { if (event->device) process_device_event(event); free(event); } Signed-off-by: Jonas Ådahl <jadahl@gmail.com>