Skip to content

Commit fce8c5f

Browse files
bentissJiri Kosina
authored andcommitted
HID: uclogic: actually invert the in-range bit for huion tablets only
This hack is only needed for Huion tablets. It does not seem to have any effect on the other tablets handled by this device right now, but it's better to check for the product id sooner than discovering that we have messed up one tablet later. Signed-off-by: Benjamin Tissoires <[email protected]> Reviewed-by: Nikolai Kondrashov <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent aa2121a commit fce8c5f

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

drivers/hid/hid-uclogic.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,7 @@ enum uclogic_ph_id {
564564

565565
/* Report descriptor template placeholder */
566566
#define UCLOGIC_PH(_ID) UCLOGIC_PH_HEAD, UCLOGIC_PH_ID_##_ID
567+
#define UCLOGIC_PEN_REPORT_ID 0x07
567568

568569
/* Fixed report descriptor template */
569570
static const __u8 uclogic_tablet_rdesc_template[] = {
@@ -625,6 +626,7 @@ enum uclogic_prm {
625626
struct uclogic_drvdata {
626627
__u8 *rdesc;
627628
unsigned int rsize;
629+
bool invert_pen_inrange;
628630
};
629631

630632
static __u8 *uclogic_report_fixup(struct hid_device *hdev, __u8 *rdesc,
@@ -905,6 +907,7 @@ static int uclogic_probe(struct hid_device *hdev,
905907
hid_err(hdev, "tablet enabling failed\n");
906908
return rc;
907909
}
910+
drvdata->invert_pen_inrange = true;
908911
}
909912
break;
910913
}
@@ -927,12 +930,12 @@ static int uclogic_probe(struct hid_device *hdev,
927930
static int uclogic_raw_event(struct hid_device *hdev, struct hid_report *report,
928931
u8 *data, int size)
929932
{
930-
struct usb_interface *intf = to_usb_interface(hdev->dev.parent);
933+
struct uclogic_drvdata *drvdata = hid_get_drvdata(hdev);
931934

932-
/* If this is a pen input report */
933-
if (intf->cur_altsetting->desc.bInterfaceNumber == 0 &&
934-
report->type == HID_INPUT_REPORT &&
935-
report->id == 0x07 && size >= 2)
935+
if ((drvdata->invert_pen_inrange) &&
936+
(report->type == HID_INPUT_REPORT) &&
937+
(report->id == UCLOGIC_PEN_REPORT_ID) &&
938+
(size >= 2))
936939
/* Invert the in-range bit */
937940
data[1] ^= 0x40;
938941

0 commit comments

Comments
 (0)