Commit 3699dd7e authored by Ping Cheng's avatar Ping Cheng Committed by Dmitry Torokhov

Input: wacom - clean up device type code

Use switch instead of if statement to verify device types
Signed-off-by: default avatarPing Cheng <pinglinux@gmail.com>
Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
parent 2be975c6
...@@ -386,23 +386,36 @@ static int wacom_parse_hid(struct usb_interface *intf, ...@@ -386,23 +386,36 @@ static int wacom_parse_hid(struct usb_interface *intf,
if (usage == WCM_DESKTOP) { if (usage == WCM_DESKTOP) {
if (finger) { if (finger) {
features->device_type = BTN_TOOL_FINGER; features->device_type = BTN_TOOL_FINGER;
if (features->type == TABLETPC2FG) {
/* need to reset back */ switch (features->type) {
case TABLETPC2FG:
features->pktlen = WACOM_PKGLEN_TPC2FG; features->pktlen = WACOM_PKGLEN_TPC2FG;
} break;
if (features->type == MTSCREEN || features->type == WACOM_24HDT) case MTSCREEN:
case WACOM_24HDT:
features->pktlen = WACOM_PKGLEN_MTOUCH; features->pktlen = WACOM_PKGLEN_MTOUCH;
break;
if (features->type == BAMBOO_PT) { case BAMBOO_PT:
/* need to reset back */
features->pktlen = WACOM_PKGLEN_BBTOUCH; features->pktlen = WACOM_PKGLEN_BBTOUCH;
break;
default:
features->pktlen = WACOM_PKGLEN_GRAPHIRE;
break;
}
switch (features->type) {
case BAMBOO_PT:
features->x_phy = features->x_phy =
get_unaligned_le16(&report[i + 5]); get_unaligned_le16(&report[i + 5]);
features->x_max = features->x_max =
get_unaligned_le16(&report[i + 8]); get_unaligned_le16(&report[i + 8]);
i += 15; i += 15;
} else if (features->type == WACOM_24HDT) { break;
case WACOM_24HDT:
features->x_max = features->x_max =
get_unaligned_le16(&report[i + 3]); get_unaligned_le16(&report[i + 3]);
features->x_phy = features->x_phy =
...@@ -410,7 +423,9 @@ static int wacom_parse_hid(struct usb_interface *intf, ...@@ -410,7 +423,9 @@ static int wacom_parse_hid(struct usb_interface *intf,
features->unit = report[i - 1]; features->unit = report[i - 1];
features->unitExpo = report[i - 3]; features->unitExpo = report[i - 3];
i += 12; i += 12;
} else { break;
default:
features->x_max = features->x_max =
get_unaligned_le16(&report[i + 3]); get_unaligned_le16(&report[i + 3]);
features->x_phy = features->x_phy =
...@@ -418,10 +433,11 @@ static int wacom_parse_hid(struct usb_interface *intf, ...@@ -418,10 +433,11 @@ static int wacom_parse_hid(struct usb_interface *intf,
features->unit = report[i + 9]; features->unit = report[i + 9];
features->unitExpo = report[i + 11]; features->unitExpo = report[i + 11];
i += 12; i += 12;
break;
} }
} else if (pen) { } else if (pen) {
/* penabled only accepts exact bytes of data */ /* penabled only accepts exact bytes of data */
if (features->type == TABLETPC2FG) if (features->type >= TABLETPC)
features->pktlen = WACOM_PKGLEN_GRAPHIRE; features->pktlen = WACOM_PKGLEN_GRAPHIRE;
features->device_type = BTN_TOOL_PEN; features->device_type = BTN_TOOL_PEN;
features->x_max = features->x_max =
...@@ -434,32 +450,39 @@ static int wacom_parse_hid(struct usb_interface *intf, ...@@ -434,32 +450,39 @@ static int wacom_parse_hid(struct usb_interface *intf,
case HID_USAGE_Y: case HID_USAGE_Y:
if (usage == WCM_DESKTOP) { if (usage == WCM_DESKTOP) {
if (finger) { if (finger) {
int type = features->type; switch (features->type) {
case TABLETPC2FG:
if (type == TABLETPC2FG || type == MTSCREEN) { case MTSCREEN:
features->y_max = features->y_max =
get_unaligned_le16(&report[i + 3]); get_unaligned_le16(&report[i + 3]);
features->y_phy = features->y_phy =
get_unaligned_le16(&report[i + 6]); get_unaligned_le16(&report[i + 6]);
i += 7; i += 7;
} else if (type == WACOM_24HDT) { break;
case WACOM_24HDT:
features->y_max = features->y_max =
get_unaligned_le16(&report[i + 3]); get_unaligned_le16(&report[i + 3]);
features->y_phy = features->y_phy =
get_unaligned_le16(&report[i - 2]); get_unaligned_le16(&report[i - 2]);
i += 7; i += 7;
} else if (type == BAMBOO_PT) { break;
case BAMBOO_PT:
features->y_phy = features->y_phy =
get_unaligned_le16(&report[i + 3]); get_unaligned_le16(&report[i + 3]);
features->y_max = features->y_max =
get_unaligned_le16(&report[i + 6]); get_unaligned_le16(&report[i + 6]);
i += 12; i += 12;
} else { break;
default:
features->y_max = features->y_max =
features->x_max; features->x_max;
features->y_phy = features->y_phy =
get_unaligned_le16(&report[i + 3]); get_unaligned_le16(&report[i + 3]);
i += 4; i += 4;
break;
} }
} else if (pen) { } else if (pen) {
features->y_max = features->y_max =
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment