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.
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)
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
}
}
+ 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);
}
PT_RANGE,
PT_DOUBLE,
PT_TUPLES,
+ PT_UINT_ARRAY,
+};
+
+struct quirk_array {
+ union {
+ uint32_t u[32];
+ } data;
+ size_t nelements;
};
/**
struct quirk_dimensions dim;
struct quirk_range range;
struct quirk_tuples tuples;
+ struct quirk_array array;
} value;
};
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();
}
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);
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;
+}
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 */
};
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);
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
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,
EV_LED, LED_NUML,
EV_LED, LED_CAPSL,
EV_LED, LED_SCROLLL,
+
+ /* gets disabled */
+ INPUT_PROP_MAX, INPUT_PROP_POINTING_STICK,
+
-1, -1,
};
"\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,
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);
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);
}
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 {
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);