From 771a028d2ff9098c9c1548764748e8517c530116 Mon Sep 17 00:00:00 2001 From: bru Date: Sun, 16 Oct 2022 20:17:08 +0000 Subject: [PATCH] Improve the clickpad/touchpad detection in hidmt. If the HID descriptors don't provide a HUD_BUTTON_TYPE property, hidmt should treat all devices as clickpads if they report a "clickpad button", or don't report to have both a left and right external button. --- sys/dev/hid/hidmt.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/sys/dev/hid/hidmt.c b/sys/dev/hid/hidmt.c index 5ca26899e50..62b500a4f44 100644 --- a/sys/dev/hid/hidmt.c +++ b/sys/dev/hid/hidmt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hidmt.c,v 1.12 2020/07/09 21:01:08 jcs Exp $ */ +/* $OpenBSD: hidmt.c,v 1.13 2022/10/16 20:17:08 bru Exp $ */ /* * HID multitouch driver for devices conforming to Windows Precision Touchpad * standard @@ -154,13 +154,14 @@ hidmt_setup(struct device *self, struct hidmt *mt, void *desc, int dlen) mt->sc_rep_cap, hid_feature, &cap, NULL)) { d = hid_get_udata(rep, capsize, &cap); mt->sc_clickpad = (d == 0); - } else { - /* if there's not a 2nd button, this is probably a clickpad */ - if (!hid_locate(desc, dlen, HID_USAGE2(HUP_BUTTON, 2), - mt->sc_rep_input, hid_input, &cap, NULL)) - mt->sc_clickpad = 1; + } else if (hid_locate(desc, dlen, HID_USAGE2(HUP_BUTTON, 1), + mt->sc_rep_input, hid_input, &cap, NULL) || + !hid_locate(desc, dlen, HID_USAGE2(HUP_BUTTON, 2), + mt->sc_rep_input, hid_input, &cap, NULL) || + !hid_locate(desc, dlen, HID_USAGE2(HUP_BUTTON, 3), + mt->sc_rep_input, hid_input, &cap, NULL)) { + mt->sc_clickpad = 1; } - /* * Walk HID descriptor and store usages we care about to know what to * pluck out of input reports. -- 2.20.1