Skip to content

Commit 9c2913b

Browse files
flying-elephantBenjamin Tissoires
authored andcommitted
HID: wacom: more appropriate tool type categorization
Recent eraser and pen tools are able to be distinguished by looking at its least significant nibble. This modification applies it to wacom_intuos_get_tool_type function and reduces its code lines. Signed-off-by: Tatsunosuke Tobita <[email protected]> Signed-off-by: Tatsunosuke Tobita <[email protected]> Reviewed-by: Ping Cheng <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Benjamin Tissoires <[email protected]>
1 parent f0d17d6 commit 9c2913b

File tree

1 file changed

+10
-56
lines changed

1 file changed

+10
-56
lines changed

drivers/hid/wacom_wac.c

Lines changed: 10 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -692,88 +692,42 @@ static bool wacom_is_art_pen(int tool_id)
692692

693693
static int wacom_intuos_get_tool_type(int tool_id)
694694
{
695-
int tool_type = BTN_TOOL_PEN;
696-
697-
if (wacom_is_art_pen(tool_id))
698-
return tool_type;
699-
700695
switch (tool_id) {
701696
case 0x812: /* Inking pen */
702697
case 0x801: /* Intuos3 Inking pen */
703698
case 0x12802: /* Intuos4/5 Inking Pen */
704699
case 0x012:
705-
tool_type = BTN_TOOL_PENCIL;
706-
break;
707-
708-
case 0x822: /* Pen */
709-
case 0x842:
710-
case 0x852:
711-
case 0x823: /* Intuos3 Grip Pen */
712-
case 0x813: /* Intuos3 Classic Pen */
713-
case 0x802: /* Intuos4/5 13HD/24HD General Pen */
714-
case 0x8e2: /* IntuosHT2 pen */
715-
case 0x022:
716-
case 0x200: /* Pro Pen 3 */
717-
case 0x10842: /* MobileStudio Pro Pro Pen slim */
718-
case 0x14802: /* Intuos4/5 13HD/24HD Classic Pen */
719-
case 0x16802: /* Cintiq 13HD Pro Pen */
720-
case 0x18802: /* DTH2242 Pen */
721-
case 0x10802: /* Intuos4/5 13HD/24HD General Pen */
722-
case 0x8842: /* Intuos Pro and Cintiq Pro 3D Pen */
723-
tool_type = BTN_TOOL_PEN;
724-
break;
700+
return BTN_TOOL_PENCIL;
725701

726702
case 0x832: /* Stroke pen */
727703
case 0x032:
728-
tool_type = BTN_TOOL_BRUSH;
729-
break;
704+
return BTN_TOOL_BRUSH;
730705

731706
case 0x007: /* Mouse 4D and 2D */
732707
case 0x09c:
733708
case 0x094:
734709
case 0x017: /* Intuos3 2D Mouse */
735710
case 0x806: /* Intuos4 Mouse */
736-
tool_type = BTN_TOOL_MOUSE;
737-
break;
711+
return BTN_TOOL_MOUSE;
738712

739713
case 0x096: /* Lens cursor */
740714
case 0x097: /* Intuos3 Lens cursor */
741715
case 0x006: /* Intuos4 Lens cursor */
742-
tool_type = BTN_TOOL_LENS;
743-
break;
744-
745-
case 0x82a: /* Eraser */
746-
case 0x84a:
747-
case 0x85a:
748-
case 0x91a:
749-
case 0xd1a:
750-
case 0x0fa:
751-
case 0x82b: /* Intuos3 Grip Pen Eraser */
752-
case 0x81b: /* Intuos3 Classic Pen Eraser */
753-
case 0x91b: /* Intuos3 Airbrush Eraser */
754-
case 0x80c: /* Intuos4/5 13HD/24HD Marker Pen Eraser */
755-
case 0x80a: /* Intuos4/5 13HD/24HD General Pen Eraser */
756-
case 0x90a: /* Intuos4/5 13HD/24HD Airbrush Eraser */
757-
case 0x1480a: /* Intuos4/5 13HD/24HD Classic Pen Eraser */
758-
case 0x1090a: /* Intuos4/5 13HD/24HD Airbrush Eraser */
759-
case 0x1080c: /* Intuos4/5 13HD/24HD Art Pen Eraser */
760-
case 0x1084a: /* MobileStudio Pro Pro Pen slim Eraser */
761-
case 0x1680a: /* Cintiq 13HD Pro Pen Eraser */
762-
case 0x1880a: /* DTH2242 Eraser */
763-
case 0x1080a: /* Intuos4/5 13HD/24HD General Pen Eraser */
764-
tool_type = BTN_TOOL_RUBBER;
765-
break;
716+
return BTN_TOOL_LENS;
766717

767718
case 0xd12:
768719
case 0x912:
769720
case 0x112:
770721
case 0x913: /* Intuos3 Airbrush */
771722
case 0x902: /* Intuos4/5 13HD/24HD Airbrush */
772723
case 0x10902: /* Intuos4/5 13HD/24HD Airbrush */
773-
tool_type = BTN_TOOL_AIRBRUSH;
774-
break;
724+
return BTN_TOOL_AIRBRUSH;
725+
726+
default:
727+
if (tool_id & 0x0008)
728+
return BTN_TOOL_RUBBER;
729+
return BTN_TOOL_PEN;
775730
}
776-
return tool_type;
777731
}
778732

779733
static void wacom_exit_report(struct wacom_wac *wacom)

0 commit comments

Comments
 (0)