[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <alpine.LRH.0.98.0705032326440.22353@twin.jikos.cz>
Date: Thu, 3 May 2007 23:41:16 +0200 (CEST)
From: Jan Kratochvil <honza@...os.cz>
To: Greg Kroah-Hartman <gregkh@...e.de>,
Dmitry Torokhov <dmitry.torokhov@...il.com>
cc: linux-input@...ey.karlin.mff.cuni.cz,
linux-usb-devel@...ts.sourceforge.net,
linux-kernel@...r.kernel.org, Jiri Kosina <jkosina@...e.cz>
Subject: Re: [PATCH 3/3] xpad.c: Added Xbox360 gamepad rumble support.
Hi again,
what do you think about this? (This patch will work only against last
gamepad rumble support patch)
Thanks for your time
Jan Kratochvil
BigX button on xbox360 gamepad is surrounded by 4 green leds. This
patch adds support to control them.
This device understand to 14 messages (described at
http://www.free60.org/wiki/Gamepad#LED_Control).
Control is done through event interface, message type EV_LED. EV_LED isn't
perfect match because you are actualy not turning some led on or off but
more likely you are telling the gamepad what "flash effect" it should
play.
Signed-off-by: Jan Kratochvil <honza@...os.cz>
---
drivers/usb/input/xpad.c | 31 ++++++++++++++++++++++++++++---
1 files changed, 28 insertions(+), 3 deletions(-)
diff --git a/drivers/usb/input/xpad.c b/drivers/usb/input/xpad.c
index d117e71..8b38990 100644
--- a/drivers/usb/input/xpad.c
+++ b/drivers/usb/input/xpad.c
@@ -397,13 +397,33 @@ int xpad_play_effect(struct input_dev *d
return 0;
}
+int xpad_input_event(struct input_dev *dev, unsigned int type,
+ unsigned int code, int value)
+{
+ switch (type) {
+ case EV_FF:
+ return input_ff_event(dev,type,code,value);
+ case EV_LED: {
+ struct usb_xpad *xpad = dev->private;
+ change_bit(code,dev->led);
+ xpad->odata[0] = 0x01;
+ xpad->odata[1] = 0x03;
+ xpad->odata[2] = code;
+ usb_submit_urb(xpad->irq_out, GFP_KERNEL);
+ return 0;
+ }
+ default:
+ return -EINVAL;
+ }
+}
+
static int xpad_init_ff(struct usb_interface *intf, struct usb_xpad *xpad)
{
if (xpad->xtype == TYPE_XBOX360) {
struct usb_endpoint_descriptor *ep_irq_out;
- int rv;
+ int i;
- xpad->dev->evbit[0] |= BIT(EV_FF);
+ xpad->dev->evbit[0] |= BIT(EV_FF) | BIT(EV_LED);
xpad->odata = usb_buffer_alloc(xpad->udev, XPAD_PKT_LEN,
GFP_ATOMIC, &xpad->odata_dma );
@@ -422,11 +442,16 @@ static int xpad_init_ff(struct usb_inter
xpad->irq_out->transfer_dma = xpad->odata_dma;
xpad->irq_out->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
- set_bit( FF_RUMBLE, xpad->dev->ffbit );
+ set_bit(FF_RUMBLE, xpad->dev->ffbit);
+ for (i=0;i<16;++i)
+ set_bit(i, xpad->dev->ledbit);
+
if (input_ff_create_memless(xpad->dev, NULL, xpad_play_effect)) {
goto fail2;
}
+ xpad->dev->event = xpad_input_event;
+
return 0;
fail2: usb_buffer_free(xpad->udev, XPAD_PKT_LEN, xpad->odata, xpad->odata_dma);
--
1.4.3.4
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists