aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hid/hid-wiimote-core.c
diff options
context:
space:
mode:
authorDavid Herrmann <dh.herrmann@gmail.com>2013-05-05 17:12:58 -0400
committerJiri Kosina <jkosina@suse.cz>2013-06-03 05:07:03 -0400
commitf1d4bed45b553dda2be402e427d8d708c4dca85d (patch)
tree182ad53d5c28f5f1e3e8696f16e36c7ea61cef58 /drivers/hid/hid-wiimote-core.c
parent4148b6bf8a4a4d6e533329775370ccf49778c061 (diff)
HID: wiimote: add Balance Board support
This adds Nintendo Wii Balance Board support to the new HOTPLUG capable wiimote core. It is mostly copied from the old extension. This also adds Balance Board device detection. Whenever we find a device that supports the balance-board extension, we assume that it is a real balance board and disable unsupported hardward like accelerometer, IR, rumble and more. Signed-off-by: David Herrmann <dh.herrmann@gmail.com> 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.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/drivers/hid/hid-wiimote-core.c b/drivers/hid/hid-wiimote-core.c
index 836611e3e37e..90ea5a2565d4 100644
--- a/drivers/hid/hid-wiimote-core.c
+++ b/drivers/hid/hid-wiimote-core.c
@@ -202,6 +202,14 @@ static __u8 select_drm(struct wiimote_data *wdata)
202 ext = (wdata->state.flags & WIIPROTO_FLAG_EXT_USED) || 202 ext = (wdata->state.flags & WIIPROTO_FLAG_EXT_USED) ||
203 (wdata->state.flags & WIIPROTO_FLAG_MP_USED); 203 (wdata->state.flags & WIIPROTO_FLAG_MP_USED);
204 204
205 /* some 3rd-party balance-boards are hard-coded to KEE, *sigh* */
206 if (wdata->state.devtype == WIIMOTE_DEV_BALANCE_BOARD) {
207 if (ext)
208 return WIIPROTO_REQ_DRM_KEE;
209 else
210 return WIIPROTO_REQ_DRM_K;
211 }
212
205 if (ir == WIIPROTO_FLAG_IR_BASIC) { 213 if (ir == WIIPROTO_FLAG_IR_BASIC) {
206 if (wdata->state.flags & WIIPROTO_FLAG_ACCEL) { 214 if (wdata->state.flags & WIIPROTO_FLAG_ACCEL) {
207 if (ext) 215 if (ext)
@@ -436,6 +444,9 @@ static __u8 wiimote_cmd_read_ext(struct wiimote_data *wdata, __u8 *rmem)
436 rmem[3] == 0xff && rmem[4] == 0xff && rmem[5] == 0xff) 444 rmem[3] == 0xff && rmem[4] == 0xff && rmem[5] == 0xff)
437 return WIIMOTE_EXT_NONE; 445 return WIIMOTE_EXT_NONE;
438 446
447 if (rmem[4] == 0x04 && rmem[5] == 0x02)
448 return WIIMOTE_EXT_BALANCE_BOARD;
449
439 return WIIMOTE_EXT_UNKNOWN; 450 return WIIMOTE_EXT_UNKNOWN;
440} 451}
441 452
@@ -570,6 +581,11 @@ static const __u8 * const wiimote_devtype_mods[WIIMOTE_DEV_NUM] = {
570 WIIMOD_IR, 581 WIIMOD_IR,
571 WIIMOD_NULL, 582 WIIMOD_NULL,
572 }, 583 },
584 [WIIMOTE_DEV_BALANCE_BOARD] = (const __u8[]) {
585 WIIMOD_BATTERY,
586 WIIMOD_LED1,
587 WIIMOD_NULL,
588 },
573}; 589};
574 590
575static void wiimote_modules_load(struct wiimote_data *wdata, 591static void wiimote_modules_load(struct wiimote_data *wdata,
@@ -753,6 +769,7 @@ static const char *wiimote_devtype_names[WIIMOTE_DEV_NUM] = {
753 [WIIMOTE_DEV_GENERIC] = "Generic", 769 [WIIMOTE_DEV_GENERIC] = "Generic",
754 [WIIMOTE_DEV_GEN10] = "Nintendo Wii Remote (Gen 1)", 770 [WIIMOTE_DEV_GEN10] = "Nintendo Wii Remote (Gen 1)",
755 [WIIMOTE_DEV_GEN20] = "Nintendo Wii Remote Plus (Gen 2)", 771 [WIIMOTE_DEV_GEN20] = "Nintendo Wii Remote Plus (Gen 2)",
772 [WIIMOTE_DEV_BALANCE_BOARD] = "Nintendo Wii Balance Board",
756}; 773};
757 774
758/* Try to guess the device type based on all collected information. We 775/* Try to guess the device type based on all collected information. We
@@ -770,12 +787,20 @@ static void wiimote_init_set_type(struct wiimote_data *wdata,
770 product = wdata->hdev->product; 787 product = wdata->hdev->product;
771 name = wdata->hdev->name; 788 name = wdata->hdev->name;
772 789
790 if (exttype == WIIMOTE_EXT_BALANCE_BOARD) {
791 devtype = WIIMOTE_DEV_BALANCE_BOARD;
792 goto done;
793 }
794
773 if (!strcmp(name, "Nintendo RVL-CNT-01")) { 795 if (!strcmp(name, "Nintendo RVL-CNT-01")) {
774 devtype = WIIMOTE_DEV_GEN10; 796 devtype = WIIMOTE_DEV_GEN10;
775 goto done; 797 goto done;
776 } else if (!strcmp(name, "Nintendo RVL-CNT-01-TR")) { 798 } else if (!strcmp(name, "Nintendo RVL-CNT-01-TR")) {
777 devtype = WIIMOTE_DEV_GEN20; 799 devtype = WIIMOTE_DEV_GEN20;
778 goto done; 800 goto done;
801 } else if (!strcmp(name, "Nintendo RVL-WBC-01")) {
802 devtype = WIIMOTE_DEV_BALANCE_BOARD;
803 goto done;
779 } 804 }
780 805
781 if (vendor == USB_VENDOR_ID_NINTENDO) { 806 if (vendor == USB_VENDOR_ID_NINTENDO) {
@@ -1009,6 +1034,7 @@ out_release:
1009static const char *wiimote_exttype_names[WIIMOTE_EXT_NUM] = { 1034static const char *wiimote_exttype_names[WIIMOTE_EXT_NUM] = {
1010 [WIIMOTE_EXT_NONE] = "None", 1035 [WIIMOTE_EXT_NONE] = "None",
1011 [WIIMOTE_EXT_UNKNOWN] = "Unknown", 1036 [WIIMOTE_EXT_UNKNOWN] = "Unknown",
1037 [WIIMOTE_EXT_BALANCE_BOARD] = "Nintendo Wii Balance Board",
1012}; 1038};
1013 1039
1014/* 1040/*