Commit graph

66 commits

Author SHA1 Message Date
Yu Watanabe f13467ec23 license: GPL-2.0+ -> GPL-2.0-or-later 2020-11-09 13:25:50 +09:00
Peter Hutterer 9aa5c97158 udev: if a tablet has BTN_0, label it as ID_INPUT_TABLET_PAD
Graphics tablet devices comprise multiple event nodes, usually a Pen, Finger
and Pad node (that's how the kernel postfixes them). Pen and Pad are labeled
as ID_INPUT_TABLET but the pad doesn't actually send stylus events - it
doesn't usually have BTN_TOOL_PEN, merely BTN_STYLUS.

For the last several years, libwacom has set ID_INPUT_TABLET_PAD for all pad
devices known to it based on vid/pid and a "* Pad" name match. That does not
cover devices not in libwacom. libinput relies on ID_INPUT_TABLET_PAD to
initialize the pad backend.

We can't drop ID_INPUT_TABLET without breaking userspace, but we can add
ID_INPUT_TABLET_PAD ourselves - where a device has BTN_0 in addition to
BTN_STYLUS, let's add it as a pad.

There are some devices (notably: bamboos) that use BTN_LEFT instead of BTN_0
but they are relatively rare and there's a risk of mislabeling those devices,
so let's just stick with BTN_0 only.
2020-09-17 10:14:25 +02:00
Zbigniew Jędrzejewski-Szmek 38cd55b007 Remove unneded {}s
$ perl -i -0pe 's|\s+{\n([^\n]*;)\n\s+}\n|\n\1\n|gms' **/*.c

Inspired by ea7cbf5bdd.
2020-04-13 09:31:49 +02:00
Peter Hutterer 3d7ac1c655 udev-builtin-input_id: any i2c mouse is a pointing stick
Where we have a device that looks like a mouse and is connected over i2c, tag
it as pointing stick. There is no such thing as a i2c mouse.

Even touchpads that aren't recognized by the kernel will not show up as i2c
mouse - either the touchpad follows the Win8.1 specs in which case the kernel
switches it to multitouch mode and it shows up like a touchpad. The built-in
trackpoint, if any, is then the i2c mouse device.

Where the touchpad doesn't follow the spec, the kernel will not handle it and
the touchpad remains on the PS/2 legacy bus - not i2c. Hence we can assume
that any i2c mouse device is really a pointing stick.
2020-02-27 19:53:46 +09:00
Yu Watanabe 8cb28504a5 tree-wide: drop input.h when missing_input.h is included 2019-11-04 00:30:32 +09:00
Yu Watanabe 1405cb653a tree-wide: drop stdio.h when stdio-util.h is included 2019-11-04 00:30:32 +09:00
Yu Watanabe 455fa9610c tree-wide: drop string.h when string-util.h or friends are included 2019-11-04 00:30:32 +09:00
Yu Watanabe f5947a5e92 tree-wide: drop missing.h 2019-10-31 17:57:03 +09:00
Yu Watanabe 25de7aa7b9 udev: modernize udev-rules.c
This does the following:
- rename enum udev_builtin_cmd -> UdevBuiltinCmd
- rename struct udev_builtin -> UdevBuiltin
- move type definitions to udev-rules.h
- move prototypes of functions defined in udev-rules.c to udev-rules.h
- drop to use strbuf
- propagate critical errors in applying rules,
- drop limitation for number of tokens per line.
2019-06-02 14:15:26 +09:00
Topi Miettinen a1e92eee3e Remove 'inline' attributes from static functions in .c files (#11426)
Let the compiler perform inlining (see #11397).
2019-01-15 08:12:28 +01:00
Yu Watanabe d9de38caa4 udev-builtin-input_id: update log messages 2018-10-24 04:33:21 +09:00
Yu Watanabe d354690e7d udev-builtin: propagate negative errno 2018-10-23 18:29:25 +09:00
Yu Watanabe 3fc2e9a247 udev: replace udev_device by sd_device from prototype of udev builtin commands 2018-10-23 18:28:38 +09:00
Yu Watanabe ff79992751 udev: replace udev_device by sd_device in udev-builtin-input_id.c 2018-10-23 17:51:34 +09:00
Yu Watanabe 0c9c063477 udev: make udev_builtin_add_property() take sd_device instead of udev_device 2018-10-23 17:51:34 +09:00
Yu Watanabe 07a26e42da udev-builtin: move definitions related to builtin commands to udev-builtin.h 2018-10-11 04:21:14 +09:00
Yu Watanabe f330408d62 tree-wide: drop empty lines in comments 2018-07-23 08:44:24 +02:00
Zbigniew Jędrzejewski-Szmek 25612ecba4 tree-wide: drop copyright lines for more authors
Acks in https://github.com/systemd/systemd/issues/9320.
2018-06-22 16:39:45 +02:00
Zbigniew Jędrzejewski-Szmek d9b02e1697 tree-wide: drop copyright headers from frequent contributors
Fixes #9320.

for p in Shapovalov Chevalier Rozhkov Sievers Mack Herrmann Schmidt Rudenberg Sahani Landden Andersen Watanabe; do
  git grep -e 'Copyright.*'$p -l|xargs perl -i -0pe 's|/([*][*])?[*]\s+([*#]\s+)?Copyright[^\n]*'$p'[^\n]*\s*[*]([*][*])?/\n*|\n|gms; s|\s+([*#]\s+)?Copyright[^\n]*'$p'[^\n]*\n*|\n|gms'
done
2018-06-20 11:58:53 +02:00
Zbigniew Jędrzejewski-Szmek 50d1760d26 Drop more license boilerplate
$ git grep -e 'This program is free software' -l |grep -v LICENSE | \
  xargs perl -i -0pe 's/ \* This program.*?for more details.\s*\*\n( \* You should have.*licenses.>.\n)?//gms'

For some reason they were missed previously. All those files seem to
have proper SDPX tags.
2018-06-14 13:05:41 +02:00
Lennart Poettering 810adae9e9 tree-wide: use proper unicode © instead of (C) where we can
Let's use a proper unicode copyright symbol where we can, it's prettier.

This important patch is very important.
2018-06-14 10:20:20 +02:00
Zbigniew Jędrzejewski-Szmek d94a24ca2e Add macro for checking if some flags are set
This way we don't need to repeat the argument twice.
I didn't replace all instances. I think it's better to leave out:
- asserts
- comparisons like x & y == x, which are mathematically equivalent, but
  here we aren't checking if flags are set, but if the argument fits in the
  flags.
2018-06-04 11:50:44 +02:00
Peter Hutterer 0cd6767cf0 udev: don't label high-button mice as joysticks (#8493)
If a device exposes more than 16 mouse buttons, we run into the BTN_JOYSTICK
range, also labelling it as joystick. And since 774ff9b this results in only
ID_INPUT_JOYSTICK but no ID_INPUT_MOUSE.

Fixes #8460
2018-03-23 15:15:41 +01:00
Peter Hutterer 774ff9ba69 udev: don't assign INPUT_ID_MOUSE to a touchpad/joystick/touchscreen (#8259)
If a touchpad has MT axes only but not ABS_X/ABS_Y (DualShock 4 controller),
then we hit both the conditions is_touchpad and the later check for
!has_abs_axes here, assigning is_mouse and ID_INPUT_MOUSE later.

This is a bug, we historically only assigned either of of the pointing device
tags ID_INPUT_MOUSE/TOUCHPAD/JOYSTICK/TOUCHSCREEN, never multiple of them.

Note that we cannot just check for has_abs_axes and has_mt_coordinates because
the apple touch mouse has both. We really need to check if the device has
already been assigned something else.

https://bugs.freedesktop.org/show_bug.cgi?id=105050
2018-02-23 09:36:45 +01:00
Lennart Poettering ad5d4b1703 cocci: use strempty() at more places
This shortens the code by a few lines.
2018-01-10 17:11:19 +01:00
Zbigniew Jędrzejewski-Szmek e7145211c7 Add SPDX license identifiers to source files under the GPL 2017-11-19 19:08:15 +01:00
Peter Hutterer ea7a562a69 udev: move the KEY_* defines to missing.h (#6278) 2017-07-04 09:41:46 +02:00
Peter Hutterer 0e4959973f udev: define BTN_DPAD_RIGHT if not present (#6267)
Regression introduced in commit b876bc0 when building on systemds with a pre
3.11 headers (RHEL7 and derivatives).

All the DPAD defines were introduced in the same kernel commit
d09bbfd2a8408a9954, we don't need a separate ifdef check for right.

Fixes #6240
2017-07-03 10:03:22 +02:00
hramrach b876bc09b1 Include dpad buttons in joystick detection (#6240)
Since f472d466ec ("Remove BTN_DPAD_* keys from ID_INPUT_KEY test
    (#5701)") dpad buttons are excluded from keyboard keys for keyboard
detection.

Include them in joystick buttons for joystick detection.
2017-06-30 10:23:58 +10:00
Michal Suchanek 22811ad065 input_id: fix button detection
Due to remapping some devices might not have the first button.

Check whole button range.
2017-06-27 13:28:11 +02:00
Michal Suchanek 0c21944e24 input_id: fix detection of devices with mouse buttons
Assign ID_INPUT_MOUSE property to devices with mouse buttons and no axis.

Libinput tries to use libwacom on devices with tablet-pad capability
which are detected by ID_INPUT_TABLET_PAD=1 property so assign pointer
class by setting ID_INPUT_MOUSE=1 to devices with mouse buttons and let
libwacom override the class for Wacom pads.
2017-06-27 13:28:11 +02:00
Peter Hutterer 2e856c63d4 udev: always consider devices with joystick axes/buttons as joystick
Even when they don't have an x/y axis.

https://github.com/systemd/systemd/issues/6137

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-06-22 09:19:53 +10:00
Peter Hutterer c874fed348 udev: consider a device with BTN_TRIGGER_HAPPY as joystick
These buttons were added specifically for joysticks with lots of buttons, no
other device should be using them. See kernel commit
cf2f765f18960 "HID: handle joysticks with large number of buttons"

We only test for BTN_TRIGGER_HAPPY (an alias for BTN_TRIGGER_HAPPY1) here, a
device that sets buttons 2 and above but doesn't set 1 is considered buggy.

https://github.com/systemd/systemd/issues/6137

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-06-22 09:19:25 +10:00
Nathaniel R. Lewis f472d466ec Remove BTN_DPAD_* keys from ID_INPUT_KEY test (#5701)
At present, devices implementing the BTN_DPAD_UP/DOWN/LEFT/RIGHT
codes will be incorrectly classified as key devices.  This causes
devices respecting the Linux gamepad spec (such as the DS3 as of
kernel 4.12) to be classified as keyboards by X11.

This is caused by the test_key function checking all codes on
[KEY_OK, BTN_TRIGGER_HAPPY).  Unfortunately the BTN_DPAD_* codes
are placed between KEY_LIGHTS_TOGGLE and KEY_ALS_TOGGLE.  This
patch splits the upper key block check into the block before and
after the BTN_DPAD_* codes.  An array is used to avoid dedicated,
per block loops in the event that more event codes are added in
the future.
2017-04-06 21:13:14 +02:00
Peter Hutterer 64083a6078 udev: add ID_INPUT_SWITCH for devices with switch capability (#5057) 2017-01-10 08:36:46 +01:00
Andreas Pokorny d3a37494e6 Fix tablet detection, by replicating decision tree of non-multi-touch axes (#3724)
Signed-off-by: Andreas Pokorny <andreas.pokorny@canonical.com>
2016-07-14 22:42:10 +02:00
Vito Caputo 9ed794a32d tree-wide: minor formatting inconsistency cleanups 2016-02-23 14:20:34 -08:00
Daniel Mack b26fa1a2fb tree-wide: remove Emacs lines from all files
This should be handled fine now by .dir-locals.el, so need to carry that
stuff in every file.
2016-02-10 13:41:57 +01:00
Daniel Mack d054f0a4d4 tree-wide: use xsprintf() where applicable
Also add a coccinelle receipt to help with such transitions.
2016-01-12 15:36:32 +01:00
Andreas Pokorny 1a3439ef68 udev: Fix touch screen detection
Use BTN_TOUCH or INPUT_PROP_DIRECT to detect touch screens.

Signed-off-by: Andreas Pokorny <andreas.pokorny@canonical.com>
2016-01-01 13:35:36 +01:00
Zbigniew Jędrzejewski-Szmek 3f65d73149 udev: add emacs header line
Otherwise emacs wants to use 2-space indentation and other
attrocities.
2015-12-07 00:45:08 -05:00
Lennart Poettering 3ffd4af220 util-lib: split out fd-related operations into fd-util.[ch]
There are more than enough to deserve their own .c file, hence move them
over.
2015-10-25 13:19:18 +01:00
Lennart Poettering 07630cea1f util-lib: split our string related calls from util.[ch] into its own file string-util.[ch]
There are more than enough calls doing string manipulations to deserve
its own files, hence do something about it.

This patch also sorts the #include blocks of all files that needed to be
updated, according to the sorting suggestions from CODING_STYLE. Since
pretty much every file needs our string manipulation functions this
effectively means that most files have sorted #include blocks now.

Also touches a few unrelated include files.
2015-10-24 23:05:02 +02:00
Andreas Pokorny 495968cf4e udev: input_id - use ABS_MT_SLOT{-1} to exclude non touch screen devices
Peek at the ABS_MT_SLOT-1 axis. Expect that touch screens only
have axes inside the MT range.
2015-06-03 08:31:02 +10:00
Andreas Pokorny fa5a113d11 udev: input_id - use direct property and mt axis for touch screen detection
A lot of touch screens use INPUT_PROP_DIRECT to indicate that touch input
maps directly to the underlying screen, while the BTN_TOUCH bit might not be
set.
2015-06-03 08:31:02 +10:00
Andreas Pokorny 15264e5aee udev: input_id - refactor device detection
This change switches to bools and separates bit flag evaluation from
decision making and application of udev properties, while hopefully
keeping the same semantics. Apart from using BTN_LEFT instead of BTN_MOUSE
for mouse detection.
2015-06-03 08:31:02 +10:00
Tom Gundersen 3b64e4d4f4 udev: add some asserts
Mostly for documentation purposes.
2015-06-02 18:12:47 +02:00
Hans de Goede 37186823f3 input_id: Identify scroll-wheel device on Trust TB7300 tablet as keyboard
The Trust TB7300 (relabelled Waltop?) tablet has a scrollwheel which shows
up as a /dev/input/event# node all by itself. Currently input_id does not
set any ID_INPUT_FOO attr on this causing it it to not be recognized by
Xorg / libinput.

This commit fixes this by marking it with ID_INPUT_KEY.

Reported-by: Sjoerd Timmer <themba@randomdata.nl>
2015-04-14 09:51:41 +10:00
Hans de Goede 941a2aca3d udev: input_id: Make test_pointer / test_keys return if they've found anything
Make test_pointer / test_keys return a boolean indicating whether or not
they've set any properties on the device.
2015-04-14 09:51:07 +10:00
Peter Hutterer b914418a15 udev: input_id: whitespace fixes
Remove whitespaces before opening parentheses, mostly before test_bit.
2015-04-14 09:40:19 +10:00