Re: [systemd-devel] [PATCH] udev: input_id: fix detection of various touchscreens

2015-05-28 Thread Lennart Poettering
On Thu, 28.05.15 11:59, Andreas Pokorny (andreas.poko...@canonical.com) wrote:

> There are touch screens that do not provide 'BTN_TOUCH' and hence no
> 'EV_KEY'. Previously those would not get any properties assigned and
> libinput would not treat those as input devices. Additionally there
> is an 'IS_DIRECT' property exposed by most touch screens, that would
> otherwise be detected as touch pads.

I didn't check what the patch actually precisely does, and I am not
sure if it's something to merge (that's probably something Peter
Hutterer has to decide).

However: please check CODING_STYLE when prepping patches. For new
code, please use bools rather than ints to encode booleans. It appears
that "has_coordinates" and the other variables should really be
bools.

Also, please write "test_bit(...)" rather than "test_bit (...)".

>  src/udev/udev-builtin-input_id.c | 134 
> +--
>  1 file changed, 74 insertions(+), 60 deletions(-)
> 
> diff --git a/src/udev/udev-builtin-input_id.c 
> b/src/udev/udev-builtin-input_id.c
> index b14190e..8b08742 100644
> --- a/src/udev/udev-builtin-input_id.c
> +++ b/src/udev/udev-builtin-input_id.c
> @@ -135,77 +135,91 @@ static bool test_pointers(struct udev_device *dev,
>bool test) {
>  int is_mouse = 0;
>  int is_touchpad = 0;
> -bool ret = false;
> -
> -if (test_bit(INPUT_PROP_ACCELEROMETER, bitmask_props)) {
> -udev_builtin_add_property(dev, test, 
> "ID_INPUT_ACCELEROMETER", "1");
> -return true;
> -}
> -
> -if (!test_bit(EV_KEY, bitmask_ev)) {
> -if (test_bit(EV_ABS, bitmask_ev) &&
> -test_bit(ABS_X, bitmask_abs) &&
> -test_bit(ABS_Y, bitmask_abs) &&
> -test_bit(ABS_Z, bitmask_abs)) {
> -udev_builtin_add_property(dev, test, 
> "ID_INPUT_ACCELEROMETER", "1");
> -ret = true;
> -}
> -return ret;
> -}
> -
> -if (test_bit(EV_ABS, bitmask_ev) &&
> -test_bit(ABS_X, bitmask_abs) && test_bit(ABS_Y, bitmask_abs)) {
> -if (test_bit(BTN_STYLUS, bitmask_key) || 
> test_bit(BTN_TOOL_PEN, bitmask_key)) {
> -udev_builtin_add_property(dev, test, 
> "ID_INPUT_TABLET", "1");
> -ret = true;
> -} else if (test_bit(BTN_TOOL_FINGER, bitmask_key) && 
> !test_bit(BTN_TOOL_PEN, bitmask_key)) {
> +int is_direct = 0;
> +int has_coordinates = 0;
> +int has_mt_coordinates = 0;
> +int has_joystick_axes_or_buttons = 0;
> +int has_touch = 0;
> +int stylus_or_pen = 0;
> +int finger_but_no_pen = 0;
> +int has_mouse = 0;
> +int is_touchscreen = 0;
> +int is_tablet = 0;
> +int is_joystick = 0;
> +int is_accelerometer = 0;
> +int is_pointing_stick= 0;
> +int has_3d_coordinates = 0;
> +int has_keys = 0;
> +
> +has_keys = test_bit (EV_KEY, bitmask_ev);
> +has_touch = test_bit (BTN_TOUCH, bitmask_key);
> +has_mouse = test_bit (BTN_MOUSE, bitmask_key);
> +has_coordinates = test_bit (ABS_X, bitmask_abs) && test_bit (ABS_Y, 
> bitmask_abs);
> +has_3d_coordinates = has_coordinates && test_bit (ABS_Z, 
> bitmask_abs);
> +has_mt_coordinates = test_bit (ABS_MT_POSITION_X, bitmask_abs) &&
> +test_bit (ABS_MT_POSITION_Y, bitmask_abs);
> +is_direct = test_bit (INPUT_PROP_DIRECT, bitmask_props);
> +is_accelerometer = test_bit (INPUT_PROP_ACCELEROMETER, 
> bitmask_props);
> +is_pointing_stick = test_bit(INPUT_PROP_POINTING_STICK, 
> bitmask_props);
> +stylus_or_pen = test_bit (BTN_STYLUS, bitmask_key) ||
> +test_bit (BTN_STYLUS2, bitmask_key) ||
> +test_bit (BTN_TOOL_PEN, bitmask_key);
> +finger_but_no_pen = test_bit (BTN_TOOL_FINGER, bitmask_key) &&
> +!test_bit (BTN_TOOL_PEN, bitmask_key);
> +/* joysticks don't necessarily have to have buttons; e. g.
> + * rudders/pedals are joystick-like, but buttonless; they have
> + * other fancy axes */
> +has_joystick_axes_or_buttons = test_bit (BTN_TRIGGER, bitmask_key) ||
> +test_bit (BTN_A, bitmask_key) ||
> +test_bit (BTN_1, bitmask_key) ||
> +test_bit (ABS_RX, bitmask_abs) ||
> +test_bit (ABS_RY, bitmask_abs) ||
> +test_bit (ABS_RZ, bitmask_abs) ||
> +test_bit (ABS_THROTTLE, bitmask_abs) ||
> +test_bit (ABS_RUDDER, bitmask_abs) ||
> +test_bit (ABS_WHEEL, bitmask_abs) ||
> +test_bit (ABS_GAS, bitmask_abs) ||
> +test_bit (ABS_BRAKE, bitmask_abs);
> +
> +if (has_coordinates) {
> +if (stylus_or_pen)
> +   

Re: [systemd-devel] [PATCH] udev: input_id: fix detection of various touchscreens

2015-05-28 Thread systemd github import bot
Patchset imported to github.
Pull request:


--
Generated by https://github.com/haraldh/mail2git
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH] udev: input_id: fix detection of various touchscreens

2015-05-28 Thread Andreas Pokorny
There are touch screens that do not provide 'BTN_TOUCH' and hence no
'EV_KEY'. Previously those would not get any properties assigned and
libinput would not treat those as input devices. Additionally there
is an 'IS_DIRECT' property exposed by most touch screens, that would
otherwise be detected as touch pads.
---
 src/udev/udev-builtin-input_id.c | 134 +--
 1 file changed, 74 insertions(+), 60 deletions(-)

diff --git a/src/udev/udev-builtin-input_id.c b/src/udev/udev-builtin-input_id.c
index b14190e..8b08742 100644
--- a/src/udev/udev-builtin-input_id.c
+++ b/src/udev/udev-builtin-input_id.c
@@ -135,77 +135,91 @@ static bool test_pointers(struct udev_device *dev,
   bool test) {
 int is_mouse = 0;
 int is_touchpad = 0;
-bool ret = false;
-
-if (test_bit(INPUT_PROP_ACCELEROMETER, bitmask_props)) {
-udev_builtin_add_property(dev, test, "ID_INPUT_ACCELEROMETER", 
"1");
-return true;
-}
-
-if (!test_bit(EV_KEY, bitmask_ev)) {
-if (test_bit(EV_ABS, bitmask_ev) &&
-test_bit(ABS_X, bitmask_abs) &&
-test_bit(ABS_Y, bitmask_abs) &&
-test_bit(ABS_Z, bitmask_abs)) {
-udev_builtin_add_property(dev, test, 
"ID_INPUT_ACCELEROMETER", "1");
-ret = true;
-}
-return ret;
-}
-
-if (test_bit(EV_ABS, bitmask_ev) &&
-test_bit(ABS_X, bitmask_abs) && test_bit(ABS_Y, bitmask_abs)) {
-if (test_bit(BTN_STYLUS, bitmask_key) || 
test_bit(BTN_TOOL_PEN, bitmask_key)) {
-udev_builtin_add_property(dev, test, 
"ID_INPUT_TABLET", "1");
-ret = true;
-} else if (test_bit(BTN_TOOL_FINGER, bitmask_key) && 
!test_bit(BTN_TOOL_PEN, bitmask_key)) {
+int is_direct = 0;
+int has_coordinates = 0;
+int has_mt_coordinates = 0;
+int has_joystick_axes_or_buttons = 0;
+int has_touch = 0;
+int stylus_or_pen = 0;
+int finger_but_no_pen = 0;
+int has_mouse = 0;
+int is_touchscreen = 0;
+int is_tablet = 0;
+int is_joystick = 0;
+int is_accelerometer = 0;
+int is_pointing_stick= 0;
+int has_3d_coordinates = 0;
+int has_keys = 0;
+
+has_keys = test_bit (EV_KEY, bitmask_ev);
+has_touch = test_bit (BTN_TOUCH, bitmask_key);
+has_mouse = test_bit (BTN_MOUSE, bitmask_key);
+has_coordinates = test_bit (ABS_X, bitmask_abs) && test_bit (ABS_Y, 
bitmask_abs);
+has_3d_coordinates = has_coordinates && test_bit (ABS_Z, bitmask_abs);
+has_mt_coordinates = test_bit (ABS_MT_POSITION_X, bitmask_abs) &&
+test_bit (ABS_MT_POSITION_Y, bitmask_abs);
+is_direct = test_bit (INPUT_PROP_DIRECT, bitmask_props);
+is_accelerometer = test_bit (INPUT_PROP_ACCELEROMETER, bitmask_props);
+is_pointing_stick = test_bit(INPUT_PROP_POINTING_STICK, bitmask_props);
+stylus_or_pen = test_bit (BTN_STYLUS, bitmask_key) ||
+test_bit (BTN_STYLUS2, bitmask_key) ||
+test_bit (BTN_TOOL_PEN, bitmask_key);
+finger_but_no_pen = test_bit (BTN_TOOL_FINGER, bitmask_key) &&
+!test_bit (BTN_TOOL_PEN, bitmask_key);
+/* joysticks don't necessarily have to have buttons; e. g.
+ * rudders/pedals are joystick-like, but buttonless; they have
+ * other fancy axes */
+has_joystick_axes_or_buttons = test_bit (BTN_TRIGGER, bitmask_key) ||
+test_bit (BTN_A, bitmask_key) ||
+test_bit (BTN_1, bitmask_key) ||
+test_bit (ABS_RX, bitmask_abs) ||
+test_bit (ABS_RY, bitmask_abs) ||
+test_bit (ABS_RZ, bitmask_abs) ||
+test_bit (ABS_THROTTLE, bitmask_abs) ||
+test_bit (ABS_RUDDER, bitmask_abs) ||
+test_bit (ABS_WHEEL, bitmask_abs) ||
+test_bit (ABS_GAS, bitmask_abs) ||
+test_bit (ABS_BRAKE, bitmask_abs);
+
+if (has_coordinates) {
+if (stylus_or_pen)
+is_tablet = 1;
+else if (!is_direct && finger_but_no_pen)
 is_touchpad = 1;
-} else if (test_bit(BTN_MOUSE, bitmask_key)) {
+else if (has_mouse)
 /* This path is taken by VMware's USB mouse, which has
  * absolute axes, but no touch/pressure button. */
 is_mouse = 1;
-} else if (test_bit(BTN_TOUCH, bitmask_key)) {
-udev_builtin_add_property(dev, test, 
"ID_INPUT_TOUCHSCREEN", "1");
-ret = true;
-/* joysticks don't necessarily have to have buttons; e. g.
-