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 <[email protected]>
---
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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[Index of Archives]
[Kernel Newbies]
[Netfilter]
[Bugtraq]
[Photo]
[Stuff]
[Gimp]
[Yosemite News]
[MIPS Linux]
[ARM Linux]
[Linux Security]
[Linux RAID]
[Video 4 Linux]
[Linux for the blind]
[Linux Resources]