aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hid
diff options
context:
space:
mode:
authorDavid Herrmann <dh.herrmann@googlemail.com>2011-09-06 07:50:27 -0400
committerJiri Kosina <jkosina@suse.cz>2011-09-07 07:25:15 -0400
commitd020be9246735ff1fc49b99bea0574a597592709 (patch)
tree504952c067b44481ae39129657686d280e512865 /drivers/hid
parentc003ec216561077b09a8ab38876a7d6ce375f739 (diff)
HID: wiimote: Add force-feedback support
The wiimote has a single rumble motor. This adds force feedback support for wiimote devices with FF_RUMBLE. The rumble motor is very simple and only supports an on/off switch so no complex ff-effects are supported. This also removes the event callback that was registered before but unused. The ff-device overwrites this callback, anyway. Signed-off-by: David Herrmann <dh.herrmann@googlemail.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid')
-rw-r--r--drivers/hid/hid-wiimote.c31
1 files changed, 28 insertions, 3 deletions
diff --git a/drivers/hid/hid-wiimote.c b/drivers/hid/hid-wiimote.c
index 680975436289..57faac527230 100644
--- a/drivers/hid/hid-wiimote.c
+++ b/drivers/hid/hid-wiimote.c
@@ -305,9 +305,28 @@ static void wiimote_leds_set(struct led_classdev *led_dev,
305 } 305 }
306} 306}
307 307
308static int wiimote_input_event(struct input_dev *dev, unsigned int type, 308static int wiimote_ff_play(struct input_dev *dev, void *data,
309 unsigned int code, int value) 309 struct ff_effect *eff)
310{ 310{
311 struct wiimote_data *wdata = input_get_drvdata(dev);
312 __u8 value;
313 unsigned long flags;
314
315 /*
316 * The wiimote supports only a single rumble motor so if any magnitude
317 * is set to non-zero then we start the rumble motor. If both are set to
318 * zero, we stop the rumble motor.
319 */
320
321 if (eff->u.rumble.strong_magnitude || eff->u.rumble.weak_magnitude)
322 value = 1;
323 else
324 value = 0;
325
326 spin_lock_irqsave(&wdata->state.lock, flags);
327 wiiproto_req_rumble(wdata, value);
328 spin_unlock_irqrestore(&wdata->state.lock, flags);
329
311 return 0; 330 return 0;
312} 331}
313 332
@@ -480,7 +499,6 @@ static struct wiimote_data *wiimote_create(struct hid_device *hdev)
480 hid_set_drvdata(hdev, wdata); 499 hid_set_drvdata(hdev, wdata);
481 500
482 input_set_drvdata(wdata->input, wdata); 501 input_set_drvdata(wdata->input, wdata);
483 wdata->input->event = wiimote_input_event;
484 wdata->input->open = wiimote_input_open; 502 wdata->input->open = wiimote_input_open;
485 wdata->input->close = wiimote_input_close; 503 wdata->input->close = wiimote_input_close;
486 wdata->input->dev.parent = &wdata->hdev->dev; 504 wdata->input->dev.parent = &wdata->hdev->dev;
@@ -494,6 +512,13 @@ static struct wiimote_data *wiimote_create(struct hid_device *hdev)
494 for (i = 0; i < WIIPROTO_KEY_COUNT; ++i) 512 for (i = 0; i < WIIPROTO_KEY_COUNT; ++i)
495 set_bit(wiiproto_keymap[i], wdata->input->keybit); 513 set_bit(wiiproto_keymap[i], wdata->input->keybit);
496 514
515 set_bit(FF_RUMBLE, wdata->input->ffbit);
516 if (input_ff_create_memless(wdata->input, NULL, wiimote_ff_play)) {
517 input_free_device(wdata->input);
518 kfree(wdata);
519 return NULL;
520 }
521
497 spin_lock_init(&wdata->qlock); 522 spin_lock_init(&wdata->qlock);
498 INIT_WORK(&wdata->worker, wiimote_worker); 523 INIT_WORK(&wdata->worker, wiimote_worker);
499 524