import libinput-1.16.3-2.el8

This commit is contained in:
CentOS Sources 2021-10-05 05:34:16 -04:00 committed by Stepan Oksanichenko
parent 9a47b13306
commit c07416393f
7 changed files with 1134 additions and 2 deletions

View File

@ -0,0 +1,36 @@
From f8a01c184ab00b048fd5413214a3d8620fe0b060 Mon Sep 17 00:00:00 2001
From: Peter Hutterer <peter.hutterer@who-t.net>
Date: Fri, 23 Oct 2020 12:53:35 +1000
Subject: [PATCH libinput 1/5] evdev: quirks_get_tuples can deal with a NULL
quirks
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
(cherry picked from commit fa0c3ee38838be11a9e50cc51e4a5d42cc394b44)
---
src/evdev.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/src/evdev.c b/src/evdev.c
index 40f0726b..e6a00199 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -2083,7 +2083,7 @@ evdev_pre_configure_model_quirks(struct evdev_device *device)
libevdev_disable_event_code(device->evdev, EV_MSC, MSC_TIMESTAMP);
}
- if (q && quirks_get_tuples(q, QUIRK_ATTR_EVENT_CODE_DISABLE, &t)) {
+ if (quirks_get_tuples(q, QUIRK_ATTR_EVENT_CODE_DISABLE, &t)) {
int type, code;
for (size_t i = 0; i < t->ntuples; i++) {
@@ -2107,7 +2107,6 @@ evdev_pre_configure_model_quirks(struct evdev_device *device)
}
quirks_unref(q);
-
}
static void
--
2.31.1

View File

@ -0,0 +1,33 @@
From 7a69cf4c04c86d1699d82486ca84d1892ad65e07 Mon Sep 17 00:00:00 2001
From: Peter Hutterer <peter.hutterer@who-t.net>
Date: Fri, 23 Oct 2020 12:54:54 +1000
Subject: [PATCH libinput 2/5] evdev: localize two variables during quirks
handling
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
(cherry picked from commit 30502dee1e925c270429669c4acd293645c3cba3)
---
src/evdev.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/src/evdev.c b/src/evdev.c
index e6a00199..2f6c7447 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -2084,11 +2084,9 @@ evdev_pre_configure_model_quirks(struct evdev_device *device)
}
if (quirks_get_tuples(q, QUIRK_ATTR_EVENT_CODE_DISABLE, &t)) {
- int type, code;
-
for (size_t i = 0; i < t->ntuples; i++) {
- type = t->tuples[i].first;
- code = t->tuples[i].second;
+ int type = t->tuples[i].first;
+ int code = t->tuples[i].second;
if (code == EVENT_CODE_UNDEFINED)
libevdev_disable_event_type(device->evdev,
--
2.31.1

View File

@ -0,0 +1,488 @@
From ec0c4a65e00302c193a36c56a7f2f021c43bf183 Mon Sep 17 00:00:00 2001
From: Peter Hutterer <peter.hutterer@who-t.net>
Date: Fri, 23 Oct 2020 09:14:33 +1000
Subject: [PATCH libinput 3/5] quirks: add AttrEventCodeEnable as counterpoint
to the disable one
Currently unused, but let's get this in because we may need this very soon for
broken tablets.
Enabling EV_ABS axes requires an absinfo struct - we default to a simple 0-1
axis range for those as the most generic option. Anything more custom will
need more custom treatment when we need it.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
(cherry picked from commit e3c4ff38984dfb4b51c245032c4aff5169d15257)
---
doc/user/device-quirks.rst | 4 +
meson.build | 1 +
src/evdev.c | 26 ++++
src/quirks.c | 10 +-
src/quirks.h | 1 +
src/util-strings.h | 12 ++
test/litest-device-keyboard-quirked.c | 216 ++++++++++++++++++++++++++
test/litest.h | 1 +
test/test-device.c | 76 +++++++++
9 files changed, 345 insertions(+), 2 deletions(-)
create mode 100644 test/litest-device-keyboard-quirked.c
diff --git a/doc/user/device-quirks.rst b/doc/user/device-quirks.rst
index 0a055a35..21c43e1c 100644
--- a/doc/user/device-quirks.rst
+++ b/doc/user/device-quirks.rst
@@ -177,6 +177,10 @@ AttrEventCodeDisable=EV_ABS;BTN_STYLUS;EV_KEY:0x123;
Disables the evdev event type/code tuples on the device. Entries may be
a named event type, or a named event code, or a named event type with a
hexadecimal event code, separated by a single colon.
+AttrEventCodeEnable=EV_ABS;BTN_STYLUS;EV_KEY:0x123;
+ Enables the evdev event type/code tuples on the device. Entries may be
+ a named event type, or a named event code, or a named event type with a
+ hexadecimal event code, separated by a single colon.
AttrPointingStickIntegration=internal|external
Indicates the integration of the pointing stick. This is a string enum.
Only needed for external pointing sticks. These are rare.
diff --git a/meson.build b/meson.build
index c9b53a3b..0481fa10 100644
--- a/meson.build
+++ b/meson.build
@@ -780,6 +780,7 @@ if get_option('tests')
'test/litest-device-ignored-mouse.c',
'test/litest-device-keyboard.c',
'test/litest-device-keyboard-all-codes.c',
+ 'test/litest-device-keyboard-quirked.c',
'test/litest-device-keyboard-razer-blackwidow.c',
'test/litest-device-keyboard-razer-blade-stealth.c',
'test/litest-device-keyboard-razer-blade-stealth-videoswitch.c',
diff --git a/src/evdev.c b/src/evdev.c
index 2f6c7447..4bcd3066 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -2083,6 +2083,32 @@ evdev_pre_configure_model_quirks(struct evdev_device *device)
libevdev_disable_event_code(device->evdev, EV_MSC, MSC_TIMESTAMP);
}
+ if (quirks_get_tuples(q, QUIRK_ATTR_EVENT_CODE_ENABLE, &t)) {
+ for (size_t i = 0; i < t->ntuples; i++) {
+ const struct input_absinfo absinfo = {
+ .minimum = 0,
+ .maximum = 1,
+ };
+
+ int type = t->tuples[i].first;
+ int code = t->tuples[i].second;
+
+ if (code == EVENT_CODE_UNDEFINED)
+ libevdev_enable_event_type(device->evdev, type);
+ else
+ libevdev_enable_event_code(device->evdev,
+ type,
+ code,
+ type == EV_ABS ? &absinfo : NULL);
+ evdev_log_debug(device,
+ "quirks: enabling %s %s (%#x %#x)\n",
+ libevdev_event_type_get_name(type),
+ libevdev_event_code_get_name(type, code),
+ type,
+ code);
+ }
+ }
+
if (quirks_get_tuples(q, QUIRK_ATTR_EVENT_CODE_DISABLE, &t)) {
for (size_t i = 0; i < t->ntuples; i++) {
int type = t->tuples[i].first;
diff --git a/src/quirks.c b/src/quirks.c
index 45d1f554..69f41fde 100644
--- a/src/quirks.c
+++ b/src/quirks.c
@@ -273,6 +273,7 @@ quirk_get_name(enum quirk q)
case QUIRK_ATTR_THUMB_SIZE_THRESHOLD: return "AttrThumbSizeThreshold";
case QUIRK_ATTR_MSC_TIMESTAMP: return "AttrMscTimestamp";
case QUIRK_ATTR_EVENT_CODE_DISABLE: return "AttrEventCodeDisable";
+ case QUIRK_ATTR_EVENT_CODE_ENABLE: return "AttrEventCodeEnable";
default:
abort();
}
@@ -737,10 +738,15 @@ parse_attr(struct quirks_context *ctx,
p->type = PT_STRING;
p->value.s = safe_strdup(value);
rc = true;
- } else if (streq(key, quirk_get_name(QUIRK_ATTR_EVENT_CODE_DISABLE))) {
+ } else if (streq(key, quirk_get_name(QUIRK_ATTR_EVENT_CODE_DISABLE)) ||
+ streq(key, quirk_get_name(QUIRK_ATTR_EVENT_CODE_ENABLE))) {
struct input_event events[32];
size_t nevents = ARRAY_LENGTH(events);
- p->id = QUIRK_ATTR_EVENT_CODE_DISABLE;
+ if (streq(key, quirk_get_name(QUIRK_ATTR_EVENT_CODE_DISABLE)))
+ p->id = QUIRK_ATTR_EVENT_CODE_DISABLE;
+ else
+ p->id = QUIRK_ATTR_EVENT_CODE_ENABLE;
+
if (!parse_evcode_property(value, events, &nevents) ||
nevents == 0)
goto out;
diff --git a/src/quirks.h b/src/quirks.h
index ee85fe3b..0b2fe9f3 100644
--- a/src/quirks.h
+++ b/src/quirks.h
@@ -109,6 +109,7 @@ enum quirk {
QUIRK_ATTR_THUMB_SIZE_THRESHOLD,
QUIRK_ATTR_MSC_TIMESTAMP,
QUIRK_ATTR_EVENT_CODE_DISABLE,
+ QUIRK_ATTR_EVENT_CODE_ENABLE,
_QUIRK_LAST_ATTR_QUIRK_, /* Guard: do not modify */
};
diff --git a/src/util-strings.h b/src/util-strings.h
index 2c31ff80..80e88aeb 100644
--- a/src/util-strings.h
+++ b/src/util-strings.h
@@ -111,6 +111,18 @@ xasprintf(char **strp, const char *fmt, ...)
return rc;
}
+__attribute__ ((format (printf, 2, 0)))
+static inline int
+xvasprintf(char **strp, const char *fmt, va_list args)
+{
+ int rc = 0;
+ rc = vasprintf(strp, fmt, args);
+ if ((rc == -1) && strp)
+ *strp = NULL;
+
+ return rc;
+}
+
static inline bool
safe_atoi_base(const char *str, int *val, int base)
{
diff --git a/test/litest-device-keyboard-quirked.c b/test/litest-device-keyboard-quirked.c
new file mode 100644
index 00000000..748794b2
--- /dev/null
+++ b/test/litest-device-keyboard-quirked.c
@@ -0,0 +1,216 @@
+/*
+ * Copyright © 2013 Red Hat, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#include "config.h"
+
+#include "litest.h"
+#include "litest-int.h"
+
+static struct input_id input_id = {
+ .bustype = 0x11,
+ .vendor = 0x1,
+ .product = 0x1,
+};
+
+static int events[] = {
+ EV_REL, REL_X,
+ EV_REL, REL_Y,
+
+ EV_KEY, KEY_ESC,
+ EV_KEY, KEY_1,
+ EV_KEY,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
+ EV_KEY, KEY_VOLUMEDOWN,
+ EV_KEY, KEY_VOLUMEUP,
+ EV_KEY, KEY_POWER,
+ EV_KEY, KEY_KPEQUAL,
+ EV_KEY, KEY_KPPLUSMINUS,
+ EV_KEY, KEY_PAUSE,
+ /* EV_KEY, KEY_SCALE, */
+ EV_KEY, KEY_KPCOMMA,
+ EV_KEY, KEY_HANGEUL,
+ EV_KEY, KEY_HANJA,
+ EV_KEY, KEY_YEN,
+ EV_KEY, KEY_LEFTMETA,
+ EV_KEY, KEY_RIGHTMETA,
+ EV_KEY, KEY_COMPOSE,
+ EV_KEY, KEY_STOP,
+
+ EV_KEY, KEY_MENU,
+ EV_KEY, KEY_CALC,
+ EV_KEY, KEY_SETUP,
+ EV_KEY, KEY_SLEEP,
+ EV_KEY, KEY_WAKEUP,
+ EV_KEY, KEY_SCREENLOCK,
+ EV_KEY, KEY_DIRECTION,
+ EV_KEY, KEY_CYCLEWINDOWS,
+ EV_KEY, KEY_MAIL,
+ EV_KEY, KEY_BOOKMARKS,
+ EV_KEY, KEY_COMPUTER,
+ EV_KEY, KEY_BACK,
+ EV_KEY, KEY_FORWARD,
+ EV_KEY, KEY_NEXTSONG,
+ EV_KEY, KEY_PLAYPAUSE,
+ EV_KEY, KEY_PREVIOUSSONG,
+ EV_KEY, KEY_STOPCD,
+ EV_KEY, KEY_HOMEPAGE,
+ EV_KEY, KEY_REFRESH,
+ EV_KEY, KEY_F14,
+ EV_KEY, KEY_F15,
+ EV_KEY, KEY_SEARCH,
+ EV_KEY, KEY_MEDIA,
+ EV_KEY, KEY_FN,
+ EV_LED, LED_NUML,
+ EV_LED, LED_CAPSL,
+ EV_LED, LED_SCROLLL,
+ -1, -1,
+};
+
+static const char quirk_file[] =
+"[litest Quirked Keyboard enable rel]\n"
+"MatchName=litest Quirked Keyboard\n"
+"AttrEventCodeEnable=BTN_RIGHT;EV_KEY:0x110\n" /* BTN_LEFT */
+"\n"
+"[litest Quirked keyboard disable F1-F3]\n"
+"MatchName=litest Quirked Keyboard\n"
+"AttrEventCodeDisable=KEY_F1;EV_KEY:0x3c;KEY_F3\n";
+
+TEST_DEVICE("keyboard-quirked",
+ .type = LITEST_KEYBOARD_QUIRKED,
+ .features = LITEST_KEYS | LITEST_IGNORED, /* Only use this keyboard in specific tests */
+ .interface = NULL,
+
+ .name = "Quirked Keyboard",
+ .id = &input_id,
+ .events = events,
+ .absinfo = NULL,
+ .quirk_file = quirk_file,
+)
diff --git a/test/litest.h b/test/litest.h
index 1f4e609d..25dc9eed 100644
--- a/test/litest.h
+++ b/test/litest.h
@@ -306,6 +306,7 @@ enum litest_device_type {
LITEST_TABLET_MODE_UNRELIABLE,
LITEST_KEYBOARD_LOGITECH_MEDIA_KEYBOARD_ELITE,
LITEST_SONY_VAIO_KEYS,
+ LITEST_KEYBOARD_QUIRKED,
};
#define LITEST_DEVICELESS -2
diff --git a/test/test-device.c b/test/test-device.c
index 3a4a6b57..a50372d4 100644
--- a/test/test-device.c
+++ b/test/test-device.c
@@ -1419,6 +1419,81 @@ START_TEST(device_quirks_logitech_marble_mouse)
}
END_TEST
+char *debug_messages[64] = { NULL };
+
+static void
+debug_log_handler(struct libinput *libinput,
+ enum libinput_log_priority priority,
+ const char *format,
+ va_list args)
+{
+ char *message;
+ int n;
+
+ if (priority != LIBINPUT_LOG_PRIORITY_DEBUG)
+ return;
+
+ n = xvasprintf(&message, format, args);
+ litest_assert_int_gt(n, 0);
+
+ for (size_t idx = 0; idx < ARRAY_LENGTH(debug_messages); idx++) {
+ if (debug_messages[idx] == NULL) {
+ debug_messages[idx] = message;
+ return;
+ }
+ }
+
+ litest_abort_msg("Out of space for debug messages");
+}
+
+START_TEST(device_quirks)
+{
+ struct libinput *li;
+ struct litest_device *dev;
+ struct libinput_device *device;
+ char **message;
+ bool disable_key_f1 = false,
+ enable_btn_left = false;
+
+ li = litest_create_context();
+ libinput_log_set_priority(li, LIBINPUT_LOG_PRIORITY_DEBUG);
+ libinput_log_set_handler(li, debug_log_handler);
+ dev = litest_add_device(li, LITEST_KEYBOARD_QUIRKED);
+ device = dev->libinput_device;
+
+ ck_assert(libinput_device_pointer_has_button(device,
+ BTN_LEFT));
+ ck_assert(libinput_device_pointer_has_button(dev->libinput_device,
+ BTN_RIGHT));
+ ck_assert(!libinput_device_keyboard_has_key(dev->libinput_device,
+ KEY_F1));
+ ck_assert(!libinput_device_keyboard_has_key(dev->libinput_device,
+ KEY_F2));
+ ck_assert(!libinput_device_keyboard_has_key(dev->libinput_device,
+ KEY_F3));
+
+ /* Scrape the debug messages for confirmation that our quirks are
+ * triggered, the above checks cannot work non-key codes */
+ message = debug_messages;
+ while (*message) {
+ if (strstr(*message, "disabling EV_KEY KEY_F1"))
+ disable_key_f1 = true;
+ if (strstr(*message, "enabling EV_KEY BTN_LEFT"))
+ enable_btn_left = true;
+
+ message++;
+ }
+
+ ck_assert(disable_key_f1);
+ ck_assert(enable_btn_left);
+
+ litest_disable_log_handler(li);
+
+ litest_delete_device(dev);
+ litest_destroy_context(li);
+}
+END_TEST
+
START_TEST(device_capability_at_least_one)
{
struct litest_device *dev = litest_current_device();
@@ -1670,6 +1745,7 @@ TEST_COLLECTION(device)
litest_add_for_device("device:quirks", device_quirks_cyborg_rat_mode_button, LITEST_CYBORG_RAT);
litest_add_for_device("device:quirks", device_quirks_apple_magicmouse, LITEST_MAGICMOUSE);
litest_add_for_device("device:quirks", device_quirks_logitech_marble_mouse, LITEST_LOGITECH_TRACKBALL);
+ litest_add_no_device("device:quirks", device_quirks);
litest_add("device:capability", device_capability_at_least_one, LITEST_ANY, LITEST_ANY);
litest_add("device:capability", device_capability_check_invalid, LITEST_ANY, LITEST_ANY);
--
2.31.1

View File

@ -0,0 +1,447 @@
From ea835c0f9a3cf8b599ea63f1057ee8cdb997db95 Mon Sep 17 00:00:00 2001
From: Peter Hutterer <peter.hutterer@who-t.net>
Date: Fri, 23 Oct 2020 10:38:14 +1000
Subject: [PATCH libinput 4/5] quirks: add AttrInputPropEnable and Disable
The latter requires libevdev 1.10 but since that'll take a while to filter
into our various CI systems, let's make it conditional.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
(cherry picked from commit e882bd02167a9e2ca1c26c104026a8b29bf23ffa)
---
doc/user/device-quirks.rst | 6 +++
meson.build | 3 ++
src/evdev.c | 35 ++++++++++++++++
src/quirks.c | 51 ++++++++++++++++++++++++
src/quirks.h | 16 ++++++++
src/util-prop-parsers.c | 57 +++++++++++++++++++++++++++
src/util-prop-parsers.h | 1 +
test/litest-device-keyboard-quirked.c | 17 +++++++-
test/test-device.c | 16 +++++++-
test/test-utils.c | 47 ++++++++++++++++++++++
10 files changed, 247 insertions(+), 2 deletions(-)
diff --git a/doc/user/device-quirks.rst b/doc/user/device-quirks.rst
index 21c43e1c..faaea47f 100644
--- a/doc/user/device-quirks.rst
+++ b/doc/user/device-quirks.rst
@@ -181,6 +181,12 @@ AttrEventCodeEnable=EV_ABS;BTN_STYLUS;EV_KEY:0x123;
Enables the evdev event type/code tuples on the device. Entries may be
a named event type, or a named event code, or a named event type with a
hexadecimal event code, separated by a single colon.
+AttrInputPropDisable=INPUT_PROP_BUTTONPAD;INPUT_PROP_POINTER;
+ Disables the evdev input property on the device. Entries may be
+ a named input property or the hexadecimal value of that property.
+AttrInputPropEnable=INPUT_PROP_BUTTONPAD;INPUT_PROP_POINTER;
+ Enables the evdev input property on the device. Entries may be
+ a named input property or the hexadecimal value of that property.
AttrPointingStickIntegration=internal|external
Indicates the integration of the pointing stick. This is a string enum.
Only needed for external pointing sticks. These are rare.
diff --git a/meson.build b/meson.build
index 0481fa10..040e3f1f 100644
--- a/meson.build
+++ b/meson.build
@@ -125,6 +125,9 @@ pkgconfig = import('pkgconfig')
dep_udev = dependency('libudev')
dep_mtdev = dependency('mtdev', version : '>= 1.1.0')
dep_libevdev = dependency('libevdev')
+config_h.set10('HAVE_LIBEVDEV_DISABLE_PROPERTY',
+ dep_libevdev.version().version_compare('>= 1.9.902'))
+
dep_lm = cc.find_library('m', required : false)
dep_rt = cc.find_library('rt', required : false)
diff --git a/src/evdev.c b/src/evdev.c
index 4bcd3066..44d01711 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -2050,6 +2050,8 @@ evdev_pre_configure_model_quirks(struct evdev_device *device)
struct quirks_context *quirks;
struct quirks *q;
const struct quirk_tuples *t;
+ const uint32_t *props = NULL;
+ size_t nprops = 0;
char *prop;
/* Touchpad is a clickpad but INPUT_PROP_BUTTONPAD is not set, see
@@ -2130,6 +2132,39 @@ evdev_pre_configure_model_quirks(struct evdev_device *device)
}
}
+ if (quirks_get_uint32_array(q,
+ QUIRK_ATTR_INPUT_PROP_ENABLE,
+ &props,
+ &nprops)) {
+ for (size_t idx = 0; idx < nprops; idx++) {
+ unsigned int p = props[idx];
+ libevdev_enable_property(device->evdev, p);
+ evdev_log_debug(device,
+ "quirks: enabling %s (%#x)\n",
+ libevdev_property_get_name(p),
+ p);
+ }
+ }
+
+ if (quirks_get_uint32_array(q,
+ QUIRK_ATTR_INPUT_PROP_DISABLE,
+ &props,
+ &nprops)) {
+#if HAVE_LIBEVDEV_DISABLE_PROPERTY
+ for (size_t idx = 0; idx < nprops; idx++) {
+ unsigned int p = props[idx];
+ libevdev_disable_property(device->evdev, p);
+ evdev_log_debug(device,
+ "quirks: disabling %s (%#x)\n",
+ libevdev_property_get_name(p),
+ p);
+ }
+#else
+ evdev_log_error(device,
+ "quirks: a quirk for this device requires newer libevdev than installed\n");
+#endif
+ }
+
quirks_unref(q);
}
diff --git a/src/quirks.c b/src/quirks.c
index 69f41fde..4a49154f 100644
--- a/src/quirks.c
+++ b/src/quirks.c
@@ -57,6 +57,14 @@ enum property_type {
PT_RANGE,
PT_DOUBLE,
PT_TUPLES,
+ PT_UINT_ARRAY,
+};
+
+struct quirk_array {
+ union {
+ uint32_t u[32];
+ } data;
+ size_t nelements;
};
/**
@@ -79,6 +87,7 @@ struct property {
struct quirk_dimensions dim;
struct quirk_range range;
struct quirk_tuples tuples;
+ struct quirk_array array;
} value;
};
@@ -274,6 +283,8 @@ quirk_get_name(enum quirk q)
case QUIRK_ATTR_MSC_TIMESTAMP: return "AttrMscTimestamp";
case QUIRK_ATTR_EVENT_CODE_DISABLE: return "AttrEventCodeDisable";
case QUIRK_ATTR_EVENT_CODE_ENABLE: return "AttrEventCodeEnable";
+ case QUIRK_ATTR_INPUT_PROP_DISABLE: return "AttrInputPropDisable";
+ case QUIRK_ATTR_INPUT_PROP_ENABLE: return "AttrInputPropEnable";
default:
abort();
}
@@ -758,6 +769,24 @@ parse_attr(struct quirks_context *ctx,
p->value.tuples.ntuples = nevents;
p->type = PT_TUPLES;
+ rc = true;
+ } else if (streq(key, quirk_get_name(QUIRK_ATTR_INPUT_PROP_DISABLE)) ||
+ streq(key, quirk_get_name(QUIRK_ATTR_INPUT_PROP_ENABLE))) {
+ unsigned int props[INPUT_PROP_CNT];
+ size_t nprops = ARRAY_LENGTH(props);
+ if (streq(key, quirk_get_name(QUIRK_ATTR_INPUT_PROP_DISABLE)))
+ p->id = QUIRK_ATTR_INPUT_PROP_DISABLE;
+ else
+ p->id = QUIRK_ATTR_INPUT_PROP_ENABLE;
+
+ if (!parse_input_prop_property(value, props, &nprops) ||
+ nprops == 0)
+ goto out;
+
+ memcpy(p->value.array.data.u, props, nprops * sizeof(unsigned int));
+ p->value.array.nelements = nprops;
+ p->type = PT_UINT_ARRAY;
+
rc = true;
} else {
qlog_error(ctx, "Unknown key %s in %s\n", key, s->name);
@@ -1589,3 +1618,25 @@ quirks_get_tuples(struct quirks *q,
return true;
}
+
+bool
+quirks_get_uint32_array(struct quirks *q,
+ enum quirk which,
+ const uint32_t **array,
+ size_t *nelements)
+{
+ struct property *p;
+
+ if (!q)
+ return false;
+
+ p = quirk_find_prop(q, which);
+ if (!p)
+ return false;
+
+ assert(p->type == PT_UINT_ARRAY);
+ *array = p->value.array.data.u;
+ *nelements = p->value.array.nelements;
+
+ return true;
+}
diff --git a/src/quirks.h b/src/quirks.h
index 0b2fe9f3..4f2c6a8c 100644
--- a/src/quirks.h
+++ b/src/quirks.h
@@ -110,6 +110,8 @@ enum quirk {
QUIRK_ATTR_MSC_TIMESTAMP,
QUIRK_ATTR_EVENT_CODE_DISABLE,
QUIRK_ATTR_EVENT_CODE_ENABLE,
+ QUIRK_ATTR_INPUT_PROP_DISABLE,
+ QUIRK_ATTR_INPUT_PROP_ENABLE,
_QUIRK_LAST_ATTR_QUIRK_, /* Guard: do not modify */
};
@@ -313,3 +315,17 @@ bool
quirks_get_tuples(struct quirks *q,
enum quirk which,
const struct quirk_tuples **tuples);
+
+/**
+ * Get the uint32 array of the given quirk.
+ * This function will assert if the quirk type does not match the
+ * requested type. If the quirk is not set for this device, tuples is
+ * unchanged.
+ *
+ * @return true if the quirk value is valid, false otherwise.
+ */
+bool
+quirks_get_uint32_array(struct quirks *q,
+ enum quirk which,
+ const uint32_t **array,
+ size_t *nelements);
diff --git a/src/util-prop-parsers.c b/src/util-prop-parsers.c
index 9e076328..5a5cf8e0 100644
--- a/src/util-prop-parsers.c
+++ b/src/util-prop-parsers.c
@@ -402,6 +402,63 @@ out:
return rc;
}
+/**
+ * Parses a string of the format "INPUT_PROP_BUTTONPAD;INPUT_PROP_POINTER;0x123;"
+ * where each element must be a named input prop OR a hexcode in the form
+ * 0x1234
+ *
+ * props must point to an existing array of size nprops.
+ * nprops specifies the size of the array in props and returns the number
+ * of elements, elements exceeding nprops are simply ignored, just make sure
+ * props is large enough for your use-case.
+ *
+ * On success, props contains nprops elements.
+ */
+bool
+parse_input_prop_property(const char *prop, unsigned int *props_out, size_t *nprops)
+{
+ char **strv = NULL;
+ bool rc = false;
+ size_t count = 0;
+ size_t idx;
+ unsigned int props[INPUT_PROP_CNT]; /* doubling up on quirks is a bug */
+
+ strv = strv_from_string(prop, ";");
+ if (!strv)
+ goto out;
+
+ for (idx = 0; strv[idx]; idx++)
+ count++;
+
+ if (count == 0 || count > ARRAY_LENGTH(props))
+ goto out;
+
+ count = min(*nprops, count);
+ for (idx = 0; strv[idx]; idx++) {
+ char *s = strv[idx];
+ unsigned int prop;
+
+ if (safe_atou_base(s, &prop, 16)) {
+ if (prop > INPUT_PROP_MAX)
+ goto out;
+ } else {
+ int val = libevdev_property_from_name(s);
+ if (val == -1)
+ goto out;
+ prop = (unsigned int)val;
+ }
+ props[idx] = prop;
+ }
+
+ memcpy(props_out, props, count * sizeof *props);
+ *nprops = count;
+ rc = true;
+
+out:
+ strv_free(strv);
+ return rc;
+}
+
/**
* Parse the property value for the EVDEV_ABS_00 properties. Spec is
* EVDEV_ABS_00=min:max:res:fuzz:flat
diff --git a/src/util-prop-parsers.h b/src/util-prop-parsers.h
index 7ed136a9..5f0d8673 100644
--- a/src/util-prop-parsers.h
+++ b/src/util-prop-parsers.h
@@ -38,6 +38,7 @@ bool parse_calibration_property(const char *prop, float calibration[6]);
bool parse_range_property(const char *prop, int *hi, int *lo);
#define EVENT_CODE_UNDEFINED 0xffff
bool parse_evcode_property(const char *prop, struct input_event *events, size_t *nevents);
+bool parse_input_prop_property(const char *prop, unsigned int *props_out, size_t *nprops);
enum tpkbcombo_layout {
TPKBCOMBO_LAYOUT_UNKNOWN,
diff --git a/test/litest-device-keyboard-quirked.c b/test/litest-device-keyboard-quirked.c
index 748794b2..53161fa4 100644
--- a/test/litest-device-keyboard-quirked.c
+++ b/test/litest-device-keyboard-quirked.c
@@ -191,6 +191,10 @@ static int events[] = {
EV_LED, LED_NUML,
EV_LED, LED_CAPSL,
EV_LED, LED_SCROLLL,
+
+ /* gets disabled */
+ INPUT_PROP_MAX, INPUT_PROP_POINTING_STICK,
+
-1, -1,
};
@@ -201,7 +205,18 @@ static const char quirk_file[] =
"\n"
"[litest Quirked keyboard disable F1-F3]\n"
"MatchName=litest Quirked Keyboard\n"
-"AttrEventCodeDisable=KEY_F1;EV_KEY:0x3c;KEY_F3\n";
+"AttrEventCodeDisable=KEY_F1;EV_KEY:0x3c;KEY_F3\n"
+#if HAVE_LIBEVDEV_DISABLE_PROPERTY
+"\n"
+"[litest Quirked keyboard enable buttonpad]\n"
+"MatchName=litest Quirked Keyboard\n"
+"AttrInputPropEnable=INPUT_PROP_BUTTONPAD\n"
+"\n"
+"[litest Quirked keyboard disable pointingstick]\n"
+"MatchName=litest Quirked Keyboard\n"
+"AttrInputPropDisable=INPUT_PROP_POINTING_STICK\n"
+#endif
+;
TEST_DEVICE("keyboard-quirked",
.type = LITEST_KEYBOARD_QUIRKED,
diff --git a/test/test-device.c b/test/test-device.c
index a50372d4..6c38ed44 100644
--- a/test/test-device.c
+++ b/test/test-device.c
@@ -1454,6 +1454,10 @@ START_TEST(device_quirks)
char **message;
bool disable_key_f1 = false,
enable_btn_left = false;
+#if HAVE_LIBEVDEV_DISABLE_PROPERTY
+ bool disable_pointingstick = false,
+ enable_buttonpad = false;
+#endif
li = litest_create_context();
libinput_log_set_priority(li, LIBINPUT_LOG_PRIORITY_DEBUG);
@@ -1480,12 +1484,22 @@ START_TEST(device_quirks)
disable_key_f1 = true;
if (strstr(*message, "enabling EV_KEY BTN_LEFT"))
enable_btn_left = true;
-
+#if HAVE_LIBEVDEV_DISABLE_PROPERTY
+ if (strstr(*message, "enabling INPUT_PROP_BUTTONPAD"))
+ enable_buttonpad = true;
+ if (strstr(*message, "disabling INPUT_PROP_POINTING_STICK"))
+ disable_pointingstick = true;
+#endif
+ free(*message);
message++;
}
ck_assert(disable_key_f1);
ck_assert(enable_btn_left);
+#if HAVE_LIBEVDEV_DISABLE_PROPERTY
+ ck_assert(enable_buttonpad);
+ ck_assert(disable_pointingstick);
+#endif
litest_disable_log_handler(li);
diff --git a/test/test-utils.c b/test/test-utils.c
index 5faec0e4..5955f56e 100644
--- a/test/test-utils.c
+++ b/test/test-utils.c
@@ -546,6 +546,52 @@ START_TEST(evcode_prop_parser)
}
END_TEST
+START_TEST(input_prop_parser)
+{
+ struct parser_test_val {
+ const char *prop;
+ bool success;
+ size_t nvals;
+ uint32_t values[20];
+ } tests[] = {
+ { "INPUT_PROP_BUTTONPAD", true, 1, {INPUT_PROP_BUTTONPAD}},
+ { "INPUT_PROP_BUTTONPAD;INPUT_PROP_POINTER", true, 2,
+ { INPUT_PROP_BUTTONPAD,
+ INPUT_PROP_POINTER }},
+ { "INPUT_PROP_BUTTONPAD;0x00;0x03", true, 3,
+ { INPUT_PROP_BUTTONPAD,
+ INPUT_PROP_POINTER,
+ INPUT_PROP_SEMI_MT }},
+ { .prop = "", .success = false },
+ { .prop = "0xff", .success = false },
+ { .prop = "INPUT_PROP", .success = false },
+ { .prop = "INPUT_PROP_FOO", .success = false },
+ { .prop = "INPUT_PROP_FOO;INPUT_PROP_FOO", .success = false },
+ { .prop = "INPUT_PROP_POINTER;INPUT_PROP_FOO", .success = false },
+ { .prop = "none", .success = false },
+ { .prop = NULL },
+ };
+ struct parser_test_val *t;
+
+ for (int i = 0; tests[i].prop; i++) {
+ bool success;
+ uint32_t props[32];
+ size_t nprops = ARRAY_LENGTH(props);
+
+ t = &tests[i];
+ success = parse_input_prop_property(t->prop, props, &nprops);
+ ck_assert(success == t->success);
+ if (!success)
+ continue;
+
+ ck_assert_int_eq(nprops, t->nvals);
+ for (size_t j = 0; j < t->nvals; j++) {
+ ck_assert_int_eq(t->values[j], props[j]);
+ }
+ }
+}
+END_TEST
+
START_TEST(evdev_abs_parser)
{
struct test {
@@ -1244,6 +1290,7 @@ litest_utils_suite(void)
tcase_add_test(tc, calibration_prop_parser);
tcase_add_test(tc, range_prop_parser);
tcase_add_test(tc, evcode_prop_parser);
+ tcase_add_test(tc, input_prop_parser);
tcase_add_test(tc, evdev_abs_parser);
tcase_add_test(tc, safe_atoi_test);
tcase_add_test(tc, safe_atoi_base_16_test);
--
2.31.1

View File

@ -0,0 +1,85 @@
From ab7b8fb32294d0923af4132e85c00d7b6c51e1d3 Mon Sep 17 00:00:00 2001
From: Peter Hutterer <peter.hutterer@who-t.net>
Date: Tue, 10 Nov 2020 13:32:26 +1000
Subject: [PATCH libinput 5/5] tools: print the AttrEventCodeEnable and
AttrInputPropEnable/Disable quirks
Introduced in e3c4ff3 and e882bd02
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
(cherry picked from commit 2c50ffab249f21f6dece2fdd0f45a6f2427f44bb)
---
tools/shared.c | 37 +++++++++++++++++++++++++++++++++----
1 file changed, 33 insertions(+), 4 deletions(-)
diff --git a/tools/shared.c b/tools/shared.c
index af791274..55c48ea1 100644
--- a/tools/shared.c
+++ b/tools/shared.c
@@ -576,15 +576,15 @@ tools_exec_command(const char *prefix, int real_argc, char **real_argv)
}
static void
-sprintf_event_codes(char *buf, size_t sz, struct quirks *quirks)
+sprintf_event_codes(char *buf, size_t sz, struct quirks *quirks, enum quirk q)
{
const struct quirk_tuples *t;
size_t off = 0;
int printed;
const char *name;
- quirks_get_tuples(quirks, QUIRK_ATTR_EVENT_CODE_DISABLE, &t);
- name = quirk_get_name(QUIRK_ATTR_EVENT_CODE_DISABLE);
+ quirks_get_tuples(quirks, q, &t);
+ name = quirk_get_name(q);
printed = snprintf(buf, sz, "%s=", name);
assert(printed != -1);
off += printed;
@@ -600,6 +600,29 @@ sprintf_event_codes(char *buf, size_t sz, struct quirks *quirks)
}
}
+static void
+sprintf_input_props(char *buf, size_t sz, struct quirks *quirks, enum quirk q)
+{
+ const uint32_t *properties;
+ size_t nprops = 0;
+ size_t off = 0;
+ int printed;
+ const char *name;
+
+ quirks_get_uint32_array(quirks, q, &properties, &nprops);
+ name = quirk_get_name(q);
+ printed = snprintf(buf, sz, "%s=", name);
+ assert(printed != -1);
+ off += printed;
+
+ for (size_t i = 0; off < sz && i < nprops; i++) {
+ const char *name = libevdev_property_get_name(properties[i]);
+ printed = snprintf(buf + off, sz - off, "%s;", name);
+ assert(printed != -1);
+ off += printed;
+ }
+}
+
void
tools_list_device_quirks(struct quirks_context *ctx,
struct udev_device *device,
@@ -680,7 +703,13 @@ tools_list_device_quirks(struct quirks_context *ctx,
callback(userdata, buf);
break;
case QUIRK_ATTR_EVENT_CODE_DISABLE:
- sprintf_event_codes(buf, sizeof(buf), quirks);
+ case QUIRK_ATTR_EVENT_CODE_ENABLE:
+ sprintf_event_codes(buf, sizeof(buf), quirks, q);
+ callback(userdata, buf);
+ break;
+ case QUIRK_ATTR_INPUT_PROP_DISABLE:
+ case QUIRK_ATTR_INPUT_PROP_ENABLE:
+ sprintf_input_props(buf, sizeof(buf), quirks, q);
callback(userdata, buf);
break;
default:
--
2.31.1

View File

@ -0,0 +1,32 @@
From 89e2e00b307d7aea63b43ff83cbf520aee27fad5 Mon Sep 17 00:00:00 2001
From: Scott Jann <sjann@knight-rider.org>
Date: Mon, 3 Aug 2020 00:03:59 -0500
Subject: [PATCH libinput] quirks: add quirk for Dell Precision 7550/7750
touchpad
Signed-off-by: Scott Jann <sjann@knight-rider.org>
(cherry picked from commit 69959c8a3b0612fb2bea015713f630a896188529)
---
quirks/50-system-dell.quirks | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/quirks/50-system-dell.quirks b/quirks/50-system-dell.quirks
index 232c309a..aaddbffe 100644
--- a/quirks/50-system-dell.quirks
+++ b/quirks/50-system-dell.quirks
@@ -65,6 +65,12 @@ MatchName=*DualPoint Stick
MatchDMIModalias=dmi:*svnDellInc.:pnLatitudeE7470*
AttrTrackpointMultiplier=0.125
+[Precision 7x50 Touchpad]
+MatchBus=i2c
+MatchUdevType=touchpad
+MatchDMIModalias=dmi:*svnDellInc.:pnPrecision7?50*
+AttrInputPropDisable=INPUT_PROP_BUTTONPAD
+
# The touch device has the same vid/pid as the totem, the MatchName
# directive is required here
[Canvas Totem]
--
2.31.1

View File

@ -5,7 +5,7 @@
Name: libinput Name: libinput
Version: 1.16.3 Version: 1.16.3
Release: 1%{?gitdate:.%{gitdate}git%{gitversion}}%{?dist} Release: 2%{?gitdate:.%{gitdate}git%{gitversion}}%{?dist}
Summary: Input device library Summary: Input device library
License: MIT License: MIT
@ -24,12 +24,20 @@ Patch002: 0002-Revert-tools-switch-measure-touchpad-pressure-to-pyt.patch
Patch003: 0003-Revert-tools-switch-measure-touch-size-to-python-lib.patch Patch003: 0003-Revert-tools-switch-measure-touch-size-to-python-lib.patch
Patch004: 0004-Revert-tools-switch-measure-fuzz-to-use-python-libev.patch Patch004: 0004-Revert-tools-switch-measure-fuzz-to-use-python-libev.patch
# AttrInputPropDisable support (#1951885)
Patch005: 0001-evdev-quirks_get_tuples-can-deal-with-a-NULL-quirks.patch
Patch006: 0002-evdev-localize-two-variables-during-quirks-handling.patch
Patch007: 0003-quirks-add-AttrEventCodeEnable-as-counterpoint-to-th.patch
Patch008: 0004-quirks-add-AttrInputPropEnable-and-Disable.patch
Patch009: 0005-tools-print-the-AttrEventCodeEnable-and-AttrInputPro.patch
Patch010: 0006-quirks-add-quirk-for-Dell-Precision-7550-7750-touchp.patch
BuildRequires: git-core BuildRequires: git-core
BuildRequires: gcc gcc-c++ BuildRequires: gcc gcc-c++
BuildRequires: meson BuildRequires: meson
BuildRequires: pkgconfig(libudev) BuildRequires: pkgconfig(libudev)
BuildRequires: pkgconfig(mtdev) >= 1.1.0 BuildRequires: pkgconfig(mtdev) >= 1.1.0
BuildRequires: pkgconfig(libevdev) >= 0.4 BuildRequires: pkgconfig(libevdev) >= 1.10
BuildRequires: pkgconfig(libwacom) >= 0.20 BuildRequires: pkgconfig(libwacom) >= 0.20
BuildRequires: python3-devel BuildRequires: python3-devel
BuildRequires: check-devel BuildRequires: check-devel
@ -151,6 +159,9 @@ rm $RPM_BUILD_ROOT/%{_mandir}/man1/libinput-measure-touchpad-size.1*
%{_mandir}/man1/libinput-test-suite.1* %{_mandir}/man1/libinput-test-suite.1*
%changelog %changelog
* Tue May 25 2021 Peter Hutterer <peter.hutterer@redhat.com> 1.16.3-2
- Add support for AddrInputPropDisable (#1951885)
* Tue Nov 03 2020 Peter Hutterer <peter.hutterer@redhat.com> 1.16.3-1 * Tue Nov 03 2020 Peter Hutterer <peter.hutterer@redhat.com> 1.16.3-1
- libinput 1.16.3 (#1886648) - libinput 1.16.3 (#1886648)