aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hid/hid-wiimote-core.c
diff options
context:
space:
mode:
authorDavid Herrmann <dh.herrmann@gmail.com>2013-06-15 09:32:45 -0400
committerJiri Kosina <jkosina@suse.cz>2013-06-27 05:57:49 -0400
commitb8e0fe31a7c8623741f91bc27f925220341fdf81 (patch)
tree9dd36399fd722510dfe06c46ca5c9a74850f979d /drivers/hid/hid-wiimote-core.c
parent701ba533f6587aaf402a9bb732548503263d2b23 (diff)
HID: wiimote: support Nintendo Wii U Pro Controller
The Wii U Pro Controller is a new Nintendo remote device that looks very similar to the XBox controller. It has nearly the same features and uses the same protocol as the Wii Remote. We add a new wiimote extension device so the Pro Controller is properly detected and supported. The device reports MP support, which is odd and I couldn't get it working, yet. Hence, we disable MP registers for now. Further investigation is needed to see what extra capabilities are provided. There are some other unknown bits in the extension reports that I couldn't figure out what they do. You can use hidraw to access these if you're interested. We might want to hook up the "charging" and "USB" bits to the battery device so user-space can query whether it is currently charged via USB. Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid/hid-wiimote-core.c')
-rw-r--r--drivers/hid/hid-wiimote-core.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/drivers/hid/hid-wiimote-core.c b/drivers/hid/hid-wiimote-core.c
index e0ac84b2f74b..0c06054cab8f 100644
--- a/drivers/hid/hid-wiimote-core.c
+++ b/drivers/hid/hid-wiimote-core.c
@@ -452,6 +452,8 @@ static __u8 wiimote_cmd_read_ext(struct wiimote_data *wdata, __u8 *rmem)
452 return WIIMOTE_EXT_CLASSIC_CONTROLLER; 452 return WIIMOTE_EXT_CLASSIC_CONTROLLER;
453 if (rmem[4] == 0x04 && rmem[5] == 0x02) 453 if (rmem[4] == 0x04 && rmem[5] == 0x02)
454 return WIIMOTE_EXT_BALANCE_BOARD; 454 return WIIMOTE_EXT_BALANCE_BOARD;
455 if (rmem[4] == 0x01 && rmem[5] == 0x20)
456 return WIIMOTE_EXT_PRO_CONTROLLER;
455 457
456 return WIIMOTE_EXT_UNKNOWN; 458 return WIIMOTE_EXT_UNKNOWN;
457} 459}
@@ -601,6 +603,15 @@ static const __u8 * const wiimote_devtype_mods[WIIMOTE_DEV_NUM] = {
601 WIIMOD_NO_MP, 603 WIIMOD_NO_MP,
602 WIIMOD_NULL, 604 WIIMOD_NULL,
603 }, 605 },
606 [WIIMOTE_DEV_PRO_CONTROLLER] = (const __u8[]) {
607 WIIMOD_BATTERY,
608 WIIMOD_LED1,
609 WIIMOD_LED2,
610 WIIMOD_LED3,
611 WIIMOD_LED4,
612 WIIMOD_NO_MP,
613 WIIMOD_NULL,
614 },
604}; 615};
605 616
606static void wiimote_modules_load(struct wiimote_data *wdata, 617static void wiimote_modules_load(struct wiimote_data *wdata,
@@ -785,6 +796,7 @@ static const char *wiimote_devtype_names[WIIMOTE_DEV_NUM] = {
785 [WIIMOTE_DEV_GEN10] = "Nintendo Wii Remote (Gen 1)", 796 [WIIMOTE_DEV_GEN10] = "Nintendo Wii Remote (Gen 1)",
786 [WIIMOTE_DEV_GEN20] = "Nintendo Wii Remote Plus (Gen 2)", 797 [WIIMOTE_DEV_GEN20] = "Nintendo Wii Remote Plus (Gen 2)",
787 [WIIMOTE_DEV_BALANCE_BOARD] = "Nintendo Wii Balance Board", 798 [WIIMOTE_DEV_BALANCE_BOARD] = "Nintendo Wii Balance Board",
799 [WIIMOTE_DEV_PRO_CONTROLLER] = "Nintendo Wii U Pro Controller",
788}; 800};
789 801
790/* Try to guess the device type based on all collected information. We 802/* Try to guess the device type based on all collected information. We
@@ -805,6 +817,9 @@ static void wiimote_init_set_type(struct wiimote_data *wdata,
805 if (exttype == WIIMOTE_EXT_BALANCE_BOARD) { 817 if (exttype == WIIMOTE_EXT_BALANCE_BOARD) {
806 devtype = WIIMOTE_DEV_BALANCE_BOARD; 818 devtype = WIIMOTE_DEV_BALANCE_BOARD;
807 goto done; 819 goto done;
820 } else if (exttype == WIIMOTE_EXT_PRO_CONTROLLER) {
821 devtype = WIIMOTE_DEV_PRO_CONTROLLER;
822 goto done;
808 } 823 }
809 824
810 if (!strcmp(name, "Nintendo RVL-CNT-01")) { 825 if (!strcmp(name, "Nintendo RVL-CNT-01")) {
@@ -816,6 +831,9 @@ static void wiimote_init_set_type(struct wiimote_data *wdata,
816 } else if (!strcmp(name, "Nintendo RVL-WBC-01")) { 831 } else if (!strcmp(name, "Nintendo RVL-WBC-01")) {
817 devtype = WIIMOTE_DEV_BALANCE_BOARD; 832 devtype = WIIMOTE_DEV_BALANCE_BOARD;
818 goto done; 833 goto done;
834 } else if (!strcmp(name, "Nintendo RVL-CNT-01-UC")) {
835 devtype = WIIMOTE_DEV_PRO_CONTROLLER;
836 goto done;
819 } 837 }
820 838
821 if (vendor == USB_VENDOR_ID_NINTENDO) { 839 if (vendor == USB_VENDOR_ID_NINTENDO) {
@@ -1058,6 +1076,7 @@ static const char *wiimote_exttype_names[WIIMOTE_EXT_NUM] = {
1058 [WIIMOTE_EXT_NUNCHUK] = "Nintendo Wii Nunchuk", 1076 [WIIMOTE_EXT_NUNCHUK] = "Nintendo Wii Nunchuk",
1059 [WIIMOTE_EXT_CLASSIC_CONTROLLER] = "Nintendo Wii Classic Controller", 1077 [WIIMOTE_EXT_CLASSIC_CONTROLLER] = "Nintendo Wii Classic Controller",
1060 [WIIMOTE_EXT_BALANCE_BOARD] = "Nintendo Wii Balance Board", 1078 [WIIMOTE_EXT_BALANCE_BOARD] = "Nintendo Wii Balance Board",
1079 [WIIMOTE_EXT_PRO_CONTROLLER] = "Nintendo Wii U Pro Controller",
1061}; 1080};
1062 1081
1063/* 1082/*
@@ -1642,6 +1661,8 @@ static ssize_t wiimote_ext_show(struct device *dev,
1642 return sprintf(buf, "classic\n"); 1661 return sprintf(buf, "classic\n");
1643 case WIIMOTE_EXT_BALANCE_BOARD: 1662 case WIIMOTE_EXT_BALANCE_BOARD:
1644 return sprintf(buf, "balanceboard\n"); 1663 return sprintf(buf, "balanceboard\n");
1664 case WIIMOTE_EXT_PRO_CONTROLLER:
1665 return sprintf(buf, "procontroller\n");
1645 case WIIMOTE_EXT_UNKNOWN: 1666 case WIIMOTE_EXT_UNKNOWN:
1646 /* fallthrough */ 1667 /* fallthrough */
1647 default: 1668 default:
@@ -1688,6 +1709,8 @@ static ssize_t wiimote_dev_show(struct device *dev,
1688 return sprintf(buf, "gen20\n"); 1709 return sprintf(buf, "gen20\n");
1689 case WIIMOTE_DEV_BALANCE_BOARD: 1710 case WIIMOTE_DEV_BALANCE_BOARD:
1690 return sprintf(buf, "balanceboard\n"); 1711 return sprintf(buf, "balanceboard\n");
1712 case WIIMOTE_DEV_PRO_CONTROLLER:
1713 return sprintf(buf, "procontroller\n");
1691 case WIIMOTE_DEV_PENDING: 1714 case WIIMOTE_DEV_PENDING:
1692 return sprintf(buf, "pending\n"); 1715 return sprintf(buf, "pending\n");
1693 case WIIMOTE_DEV_UNKNOWN: 1716 case WIIMOTE_DEV_UNKNOWN: