From patchwork Sun Jun 12 19:29:37 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christopher Snowhill X-Patchwork-Id: 873172 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p5CJTmin014469 for ; Sun, 12 Jun 2011 19:29:48 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752542Ab1FLT3r (ORCPT ); Sun, 12 Jun 2011 15:29:47 -0400 Received: from mail-px0-f179.google.com ([209.85.212.179]:44284 "EHLO mail-px0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752411Ab1FLT3r (ORCPT ); Sun, 12 Jun 2011 15:29:47 -0400 Received: by pxi2 with SMTP id 2so2553282pxi.10 for ; Sun, 12 Jun 2011 12:29:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:subject:from:to:cc:date:content-type:x-mailer :content-transfer-encoding:message-id:mime-version; bh=t9TXmorT4vm5G66Ox/qj1AGapd41b0jWYRaY3PnVx5M=; b=dGl7VECkFykcFKv+6glW6Z2hg/yPF4wp/ucVBRm3qYrY58EZwvj9+B4x/CPKZLTEE8 fCkH+KkxoiA6nPtOCPvdV2CKLJhf5F8pOFTAH5OT1BEXx9s28fTSsAwgQb8pRrCaiEKP cxHmv6/6c7FjtcLpvvDzUBAQPfo5P5FKDgSIU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=subject:from:to:cc:date:content-type:x-mailer :content-transfer-encoding:message-id:mime-version; b=CSVz4CPCqnH55A3nW9IW3rso4dlN/r4yeNgQ7olDZkFbaYrmebtHwIGJEdOkG2XKuH 8WqBEA0dv31X/aOxkgLC9UAMB0ZP+D16iV7dJNx1ARnRg9mG4PcCdiYUcL5JtwMFwFmH czvEwxa/H4pj3ZHAiJaUwYtK//VWEIiXE6/pg= Received: by 10.68.16.130 with SMTP id g2mr1694623pbd.238.1307906986303; Sun, 12 Jun 2011 12:29:46 -0700 (PDT) Received: from [192.168.11.6] (99-130-104-166.lightspeed.irvnca.sbcglobal.net [99.130.104.166]) by mx.google.com with ESMTPS id o2sm4017168pbj.49.2011.06.12.12.29.44 (version=SSLv3 cipher=OTHER); Sun, 12 Jun 2011 12:29:44 -0700 (PDT) Subject: [PATCH 2.6.38.7] xpad: Implemented rumble support for wireless controllers From: Chris Moeller To: dmitry.torokhov@gmail.com Cc: linux-input@vger.kernel.org Date: Sun, 12 Jun 2011 12:29:37 -0700 X-Mailer: Evolution 3.0.2 (3.0.2-2.fc15) Message-ID: <1307906984.3478.13.camel@sabin.lan> Mime-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Sun, 12 Jun 2011 19:29:48 +0000 (UTC) Implements rumble support for XBox360 Wireless Controllers. Signed-off-by: Chris Moeller --- I finally returned from my weeks of idling around in Windows to actually get some Linux development done. It was easier than I thought to split out just the rumble support, which requires minimal changes to the driver. Implementing XBox360 Wireless LED support will require a bit more work to pull off properly, since it seems to hate that bulk interface method completely. The LED output function should not require any more synchronization than it already has, although the initial LED send command will have to be separated out, since it can't be locked at all. I presume that won't be a problem as there should be no rumble commands to collide with it when the controller is just being reported as present. I will probably limit it to working if the CONFIG_JOYSTICK_XPAD_LEDS macro is defined, as that is one of the minimum requirements for the IRQ out interface to be enabled. -- To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html --- linux/drivers/input/joystick/xpad.c.orig 2011-06-11 19:49:56.964914370 -0700 +++ linux/drivers/input/joystick/xpad.c 2011-06-12 12:02:32.732131132 -0700 @@ -545,7 +545,7 @@ static int xpad_init_output(struct usb_i struct usb_endpoint_descriptor *ep_irq_out; int error; - if (xpad->xtype != XTYPE_XBOX360 && xpad->xtype != XTYPE_XBOX) + if (xpad->xtype == XTYPE_UNKNOWN) return 0; xpad->odata = usb_alloc_coherent(xpad->udev, XPAD_PKT_LEN, @@ -579,13 +579,13 @@ static int xpad_init_output(struct usb_i static void xpad_stop_output(struct usb_xpad *xpad) { - if (xpad->xtype == XTYPE_XBOX360 || xpad->xtype == XTYPE_XBOX) + if (xpad->xtype != XTYPE_UNKNOWN) usb_kill_urb(xpad->irq_out); } static void xpad_deinit_output(struct usb_xpad *xpad) { - if (xpad->xtype == XTYPE_XBOX360 || xpad->xtype == XTYPE_XBOX) { + if (xpad->xtype != XTYPE_UNKNOWN) { usb_free_urb(xpad->irq_out); usb_free_coherent(xpad->udev, XPAD_PKT_LEN, xpad->odata, xpad->odata_dma); @@ -632,6 +632,23 @@ static int xpad_play_effect(struct input return usb_submit_urb(xpad->irq_out, GFP_ATOMIC); + case XTYPE_XBOX360W: + xpad->odata[0] = 0x00; + xpad->odata[1] = 0x01; + xpad->odata[2] = 0x0F; + xpad->odata[3] = 0xC0; + xpad->odata[4] = 0x00; + xpad->odata[5] = strong / 256; + xpad->odata[6] = weak / 256; + xpad->odata[7] = 0x00; + xpad->odata[8] = 0x00; + xpad->odata[9] = 0x00; + xpad->odata[10] = 0x00; + xpad->odata[11] = 0x00; + xpad->irq_out->transfer_buffer_length = 12; + + return usb_submit_urb(xpad->irq_out, GFP_ATOMIC); + default: dbg("%s - rumble command sent to unsupported xpad type: %d", __func__, xpad->xtype); @@ -644,7 +661,7 @@ static int xpad_play_effect(struct input static int xpad_init_ff(struct usb_xpad *xpad) { - if (xpad->xtype != XTYPE_XBOX360 && xpad->xtype != XTYPE_XBOX) + if (xpad->xtype == XTYPE_UNKNOWN) return 0; input_set_capability(xpad->dev, EV_FF, FF_RUMBLE);