HID: uclogic: Switch to matching subreport bytes
authorNikolai Kondrashov <spbnick@gmail.com>
Sat, 19 Feb 2022 10:01:51 +0000 (11:01 +0100)
committerJiri Kosina <jkosina@suse.cz>
Tue, 1 Mar 2022 14:28:14 +0000 (15:28 +0100)
Switch from matching UC-Logic subreport with a mask to a full value to
support detecting Huion HS610 touch dial reports. Those would match the
button mask otherwise.

Signed-off-by: Nikolai Kondrashov <spbnick@gmail.com>
Signed-off-by: José Expósito <jose.exposito89@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
drivers/hid/hid-uclogic-core.c
drivers/hid/hid-uclogic-params.c
drivers/hid/hid-uclogic-params.h

index 7092f86517a55fc57c7286bc2379853dcb437319..a02edeb30a35d7519955d1e9a5a1d28ec9bd08a2 100644 (file)
@@ -365,9 +365,12 @@ static int uclogic_raw_event(struct hid_device *hdev,
                                ARRAY_SIZE(params->pen.subreport_list);
                        /* Try to match a subreport */
                        for (subreport = params->pen.subreport_list;
-                            subreport < subreport_list_end &&
-                               (data[1] & subreport->mask) != subreport->mask;
-                            subreport++);
+                            subreport < subreport_list_end; subreport++) {
+                               if (subreport->value != 0 &&
+                                   subreport->value == data[1]) {
+                                       break;
+                               }
+                       }
                        /* If a subreport matched */
                        if (subreport < subreport_list_end) {
                                /* Change to subreport ID, and restart */
index 138dd8b0a3603be618cf055935fcab5113a50b12..a4a53ab1e72c7e3bccd66fb20352766c1d741223 100644 (file)
@@ -763,7 +763,7 @@ static int uclogic_params_huion_init(struct uclogic_params *params,
                                goto cleanup;
                        }
                        /* Link frame button subreports from pen reports */
-                       p.pen.subreport_list[0].mask = 0x20;
+                       p.pen.subreport_list[0].value = 0xe0;
                        p.pen.subreport_list[0].id =
                                UCLOGIC_RDESC_BUTTONPAD_V2_ID;
                        goto output;
@@ -791,7 +791,7 @@ static int uclogic_params_huion_init(struct uclogic_params *params,
                        (found ? "" : " not"));
                if (found) {
                        /* Link frame button subreports from pen reports */
-                       p.pen.subreport_list[0].mask = 0x20;
+                       p.pen.subreport_list[0].value = 0xe0;
                        p.pen.subreport_list[0].id =
                                UCLOGIC_RDESC_BUTTONPAD_V1_ID;
                }
index 82db8ab36fecbc5c7d9dc990606bbb2c6dbd4134..c18569591b7579dbfb964b31e040d3d49eac19e8 100644 (file)
@@ -39,14 +39,15 @@ extern const char *uclogic_params_pen_inrange_to_str(
  */
 struct uclogic_params_pen_subreport {
        /*
-        * The subreport's bitmask matching the second byte of the pen report.
-        * If zero, the subreport is considered invalid, and won't match.
+        * The value of the second byte of the pen report indicating this
+        * subreport. If zero, the subreport should be considered invalid and
+        * not matched.
         */
-       __u8 mask;
+       __u8 value;
 
        /*
-        * The ID to be assigned to the report, if the "mask" matches.
-        * Only valid if "mask" is not zero.
+        * The ID to be assigned to the report, if the second byte of the pen
+        * report is equal to "value". Only valid if "value" is not zero.
         */
        __u8 id;
 };
@@ -200,7 +201,7 @@ extern int uclogic_params_init(struct uclogic_params *params,
                (_params)->pen.desc_ptr,                                    \
                (_params)->pen.desc_size,                                   \
                (_params)->pen.id,                                          \
-               (_params)->pen.subreport_list[0].mask,                      \
+               (_params)->pen.subreport_list[0].value,                     \
                (_params)->pen.subreport_list[0].id,                        \
                uclogic_params_pen_inrange_to_str((_params)->pen.inrange),  \
                ((_params)->pen.fragmented_hires ? "true" : "false"),       \