summaryrefslogtreecommitdiff
path: root/drivers/hid/hid-wiimote-core.c
diff options
context:
space:
mode:
authorDavid Herrmann <dh.herrmann@gmail.com>2013-05-05 23:12:58 +0200
committerJiri Kosina <jkosina@suse.cz>2013-06-03 11:07:03 +0200
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)
ext = (wdata->state.flags & WIIPROTO_FLAG_EXT_USED) ||
(wdata->state.flags & WIIPROTO_FLAG_MP_USED);
+ /* some 3rd-party balance-boards are hard-coded to KEE, *sigh* */
+ if (wdata->state.devtype == WIIMOTE_DEV_BALANCE_BOARD) {
+ if (ext)
+ return WIIPROTO_REQ_DRM_KEE;
+ else
+ return WIIPROTO_REQ_DRM_K;
+ }
+
if (ir == WIIPROTO_FLAG_IR_BASIC) {
if (wdata->state.flags & WIIPROTO_FLAG_ACCEL) {
if (ext)
@@ -436,6 +444,9 @@ static __u8 wiimote_cmd_read_ext(struct wiimote_data *wdata, __u8 *rmem)
rmem[3] == 0xff && rmem[4] == 0xff && rmem[5] == 0xff)
return WIIMOTE_EXT_NONE;
+ if (rmem[4] == 0x04 && rmem[5] == 0x02)
+ return WIIMOTE_EXT_BALANCE_BOARD;
+
return WIIMOTE_EXT_UNKNOWN;
}
@@ -570,6 +581,11 @@ static const __u8 * const wiimote_devtype_mods[WIIMOTE_DEV_NUM] = {
WIIMOD_IR,
WIIMOD_NULL,
},
+ [WIIMOTE_DEV_BALANCE_BOARD] = (const __u8[]) {
+ WIIMOD_BATTERY,
+ WIIMOD_LED1,
+ WIIMOD_NULL,
+ },
};
static void wiimote_modules_load(struct wiimote_data *wdata,
@@ -753,6 +769,7 @@ static const char *wiimote_devtype_names[WIIMOTE_DEV_NUM] = {
[WIIMOTE_DEV_GENERIC] = "Generic",
[WIIMOTE_DEV_GEN10] = "Nintendo Wii Remote (Gen 1)",
[WIIMOTE_DEV_GEN20] = "Nintendo Wii Remote Plus (Gen 2)",
+ [WIIMOTE_DEV_BALANCE_BOARD] = "Nintendo Wii Balance Board",
};
/* 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,
product = wdata->hdev->product;
name = wdata->hdev->name;
+ if (exttype == WIIMOTE_EXT_BALANCE_BOARD) {
+ devtype = WIIMOTE_DEV_BALANCE_BOARD;
+ goto done;
+ }
+
if (!strcmp(name, "Nintendo RVL-CNT-01")) {
devtype = WIIMOTE_DEV_GEN10;
goto done;
} else if (!strcmp(name, "Nintendo RVL-CNT-01-TR")) {
devtype = WIIMOTE_DEV_GEN20;
goto done;
+ } else if (!strcmp(name, "Nintendo RVL-WBC-01")) {
+ devtype = WIIMOTE_DEV_BALANCE_BOARD;
+ goto done;
}
if (vendor == USB_VENDOR_ID_NINTENDO) {
@@ -1009,6 +1034,7 @@ out_release:
static const char *wiimote_exttype_names[WIIMOTE_EXT_NUM] = {
[WIIMOTE_EXT_NONE] = "None",
[WIIMOTE_EXT_UNKNOWN] = "Unknown",
+ [WIIMOTE_EXT_BALANCE_BOARD] = "Nintendo Wii Balance Board",
};
/*