Skip to content

Commit 2b9a520

Browse files
Pinglinuxjigpu
authored andcommitted
backport: HID: wacom: Only report rotation for art pen
The generic routine, wacom_wac_pen_event, turns rotation value 90 degree anti-clockwise before posting the events. This non-zero event trggers a non-zero ABS_Z event for non art pen tools. However, HID_DG_TWIST is only supported by art pen. [[email protected]: fix build: add missing brace] Cc: [email protected] Signed-off-by: Ping Cheng <[email protected]> Reviewed-by: Jason Gerecke <[email protected]> -- Hi Jiri, This is kind of a version 2 of the last one I posted two days ago. I updated the logic so it has less changed lines: 29 vs 158! Hopefully, the logic is easier to follow now. Please ignore the last one. Thank you! Signed-off-by: Jiri Kosina <[email protected]> [[email protected]: Imported into input-wacom (7ccced33a0)] Signed-off-by: Jason Gerecke <[email protected]> [[email protected]: Backported from input-wacom (9c59843)] Signed-off-by: Jason Gerecke <[email protected]>
1 parent 680b0fb commit 2b9a520

File tree

2 files changed

+39
-16
lines changed

2 files changed

+39
-16
lines changed

3.17/wacom_wac.c

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -654,9 +654,26 @@ static int wacom_intuos_id_mangle(int tool_id)
654654
return (tool_id & ~0xFFF) << 4 | (tool_id & 0xFFF);
655655
}
656656

657+
static bool wacom_is_art_pen(int tool_id)
658+
{
659+
bool is_art_pen = false;
660+
661+
switch (tool_id) {
662+
case 0x885: /* Intuos3 Marker Pen */
663+
case 0x804: /* Intuos4/5 13HD/24HD Marker Pen */
664+
case 0x10804: /* Intuos4/5 13HD/24HD Art Pen */
665+
is_art_pen = true;
666+
break;
667+
}
668+
return is_art_pen;
669+
}
670+
657671
static int wacom_intuos_get_tool_type(int tool_id)
658672
{
659-
int tool_type;
673+
int tool_type = BTN_TOOL_PEN;
674+
675+
if (wacom_is_art_pen(tool_id))
676+
return tool_type;
660677

661678
switch (tool_id) {
662679
case 0x812: /* Inking pen */
@@ -671,12 +688,9 @@ static int wacom_intuos_get_tool_type(int tool_id)
671688
case 0x852:
672689
case 0x823: /* Intuos3 Grip Pen */
673690
case 0x813: /* Intuos3 Classic Pen */
674-
case 0x885: /* Intuos3 Marker Pen */
675691
case 0x802: /* Intuos4/5 13HD/24HD General Pen */
676-
case 0x804: /* Intuos4/5 13HD/24HD Marker Pen */
677692
case 0x8e2: /* IntuosHT2 pen */
678693
case 0x022:
679-
case 0x10804: /* Intuos4/5 13HD/24HD Art Pen */
680694
case 0x10842: /* MobileStudio Pro Pro Pen slim */
681695
case 0x14802: /* Intuos4/5 13HD/24HD Classic Pen */
682696
case 0x16802: /* Cintiq 13HD Pro Pen */
@@ -734,10 +748,6 @@ static int wacom_intuos_get_tool_type(int tool_id)
734748
case 0x10902: /* Intuos4/5 13HD/24HD Airbrush */
735749
tool_type = BTN_TOOL_AIRBRUSH;
736750
break;
737-
738-
default: /* Unknown tool */
739-
tool_type = BTN_TOOL_PEN;
740-
break;
741751
}
742752
return tool_type;
743753
}
@@ -2352,6 +2362,9 @@ static void wacom_wac_pen_event(struct hid_device *hdev, struct hid_field *field
23522362
}
23532363
return;
23542364
case HID_DG_TWIST:
2365+
/* don't modify the value if the pen doesn't support the feature */
2366+
if (!wacom_is_art_pen(wacom_wac->id[0])) return;
2367+
23552368
/*
23562369
* Userspace expects pen twist to have its zero point when
23572370
* the buttons/finger is on the tablet's left. HID values

3.7/wacom_wac.c

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -644,9 +644,26 @@ static int wacom_intuos_id_mangle(int tool_id)
644644
return (tool_id & ~0xFFF) << 4 | (tool_id & 0xFFF);
645645
}
646646

647+
static bool wacom_is_art_pen(int tool_id)
648+
{
649+
bool is_art_pen = false;
650+
651+
switch (tool_id) {
652+
case 0x885: /* Intuos3 Marker Pen */
653+
case 0x804: /* Intuos4/5 13HD/24HD Marker Pen */
654+
case 0x10804: /* Intuos4/5 13HD/24HD Art Pen */
655+
is_art_pen = true;
656+
break;
657+
}
658+
return is_art_pen;
659+
}
660+
647661
static int wacom_intuos_get_tool_type(int tool_id)
648662
{
649-
int tool_type;
663+
int tool_type = BTN_TOOL_PEN;
664+
665+
if (wacom_is_art_pen(tool_id))
666+
return tool_type;
650667

651668
switch (tool_id) {
652669
case 0x812: /* Inking pen */
@@ -661,12 +678,9 @@ static int wacom_intuos_get_tool_type(int tool_id)
661678
case 0x852:
662679
case 0x823: /* Intuos3 Grip Pen */
663680
case 0x813: /* Intuos3 Classic Pen */
664-
case 0x885: /* Intuos3 Marker Pen */
665681
case 0x802: /* Intuos4/5 13HD/24HD General Pen */
666-
case 0x804: /* Intuos4/5 13HD/24HD Marker Pen */
667682
case 0x8e2: /* IntuosHT2 pen */
668683
case 0x022:
669-
case 0x10804: /* Intuos4/5 13HD/24HD Art Pen */
670684
case 0x10842: /* MobileStudio Pro Pro Pen slim */
671685
case 0x14802: /* Intuos4/5 13HD/24HD Classic Pen */
672686
case 0x16802: /* Cintiq 13HD Pro Pen */
@@ -724,10 +738,6 @@ static int wacom_intuos_get_tool_type(int tool_id)
724738
case 0x10902: /* Intuos4/5 13HD/24HD Airbrush */
725739
tool_type = BTN_TOOL_AIRBRUSH;
726740
break;
727-
728-
default: /* Unknown tool */
729-
tool_type = BTN_TOOL_PEN;
730-
break;
731741
}
732742
return tool_type;
733743
}

0 commit comments

Comments
 (0)