From 925172d03069d7d8666f1a70d8ce4c2b1be2ac8e Mon Sep 17 00:00:00 2001 From: "Peter F. Patel-Schneider" Date: Thu, 27 Oct 2022 11:06:46 -0400 Subject: [PATCH] hidapi: be more permissive when recognizing HID++ report descriptors --- lib/hidapi/udev.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/hidapi/udev.py b/lib/hidapi/udev.py index c20b1562..ed6b235e 100644 --- a/lib/hidapi/udev.py +++ b/lib/hidapi/udev.py @@ -107,19 +107,17 @@ def _match(action, device, filterfn): try: # if report descriptor does not indicate HID++ capabilities then this device is not of interest to Solaar from hid_parser import ReportDescriptor as _ReportDescriptor - from hid_parser import Usage as _Usage + # from hid_parser import Usage as _Usage hidpp_short = hidpp_long = False devfile = '/sys' + hid_device.get('DEVPATH') + '/report_descriptor' with fileopen(devfile, 'rb') as fd: with _warnings.catch_warnings(): _warnings.simplefilter('ignore') rd = _ReportDescriptor(fd.read()) - hidpp_short = 0x10 in rd.input_report_ids and 6 * 8 == int( - rd.get_input_report_size(0x10) - ) and _Usage(0xFF00, 0x0001) in rd.get_input_items(0x10)[0].usages - hidpp_long = 0x11 in rd.input_report_ids and 19 * 8 == int( - rd.get_input_report_size(0x11) - ) and _Usage(0xFF00, 0x0002) in rd.get_input_items(0x11)[0].usages + hidpp_short = 0x10 in rd.input_report_ids and 6 * 8 == int(rd.get_input_report_size(0x10)) + # and _Usage(0xFF00, 0x0001) in rd.get_input_items(0x10)[0].usages # be more permissive + hidpp_long = 0x11 in rd.input_report_ids and 19 * 8 == int(rd.get_input_report_size(0x11)) + # and _Usage(0xFF00, 0x0002) in rd.get_input_items(0x11)[0].usages # be more permissive if not hidpp_short and not hidpp_long: return except Exception as e: # if can't process report descriptor fall back to old scheme