* [patch 0/7] updates for xpad
@ 2008-03-17 19:22 Anssi Hannula
2008-03-17 19:22 ` [patch 1/7] xpad: fix dpad handling of unknown devices Anssi Hannula
` (7 more replies)
0 siblings, 8 replies; 11+ messages in thread
From: Anssi Hannula @ 2008-03-17 19:22 UTC (permalink / raw)
To: Dmitry Torokhov; +Cc: linux-input
What follows is a few patches for xpad fixing some issues, adding new
ids, and Brian's xbox360 wireless patch adapted for current xpad.c.
They are against current mm, i.e. 'match xbox 360 devices with
interface info' should be applied first.
--
Anssi Hannula
^ permalink raw reply [flat|nested] 11+ messages in thread
* [patch 1/7] xpad: fix dpad handling of unknown devices
2008-03-17 19:22 [patch 0/7] updates for xpad Anssi Hannula
@ 2008-03-17 19:22 ` Anssi Hannula
2008-03-17 19:22 ` [patch 2/7] xpad: fix inverted Y and RY axes on xbox360 devices Anssi Hannula
` (6 subsequent siblings)
7 siblings, 0 replies; 11+ messages in thread
From: Anssi Hannula @ 2008-03-17 19:22 UTC (permalink / raw)
To: Dmitry Torokhov; +Cc: linux-input, Anssi Hannula
[-- Attachment #1: xpad-fix-unknown-dpad-handling.diff --]
[-- Type: text/plain, Size: 2006 bytes --]
For devices not specifically listed in xpad.c, xpad->dpad_mapping
is initially set to MAP_DPAD_UNKNOWN. In xpad_probe() it gets changed
to either MAP_DPAD_TO_BUTTONS or MAP_DPAD_TO_AXES, depending on the
module parameter dpad_to_buttons.
However, MAP_DPAD_UNKNOWN is defined as -1, while the field is u8.
This results in actual value of 255, causing the MAP_DPAD_UNKNOWN
check in xpad_probe() to fail.
Fix that by defining MAP_DPAD_UNKNOWN as 2 instead.
Also, setting module parameter dpad_to_buttons to 1 should obviously
map dpad to buttons, while the default behaviour (0) should be to map
dpad to axes. However, dpad_to_buttons is directly assigned to
xpad->dpad_mapping, and as MAP_DPAD_TO_BUTTONS is 0, the actual
behaviour is reversed.
Fix that by negating dpad_to_buttons in assignment.
Signed-off-by: Anssi Hannula <anssi.hannula@gmail.com>
---
drivers/input/joystick/xpad.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
Index: linux-2.6.25-rc3-mm1-xpad/drivers/input/joystick/xpad.c
===================================================================
--- linux-2.6.25-rc3-mm1-xpad.orig/drivers/input/joystick/xpad.c 2008-03-05 01:48:17.000000000 +0200
+++ linux-2.6.25-rc3-mm1-xpad/drivers/input/joystick/xpad.c 2008-03-05 01:52:52.000000000 +0200
@@ -87,7 +87,7 @@
but we map them to axes when possible to simplify things */
#define MAP_DPAD_TO_BUTTONS 0
#define MAP_DPAD_TO_AXES 1
-#define MAP_DPAD_UNKNOWN -1
+#define MAP_DPAD_UNKNOWN 2
#define XTYPE_XBOX 0
#define XTYPE_XBOX360 1
@@ -653,7 +653,7 @@ static int xpad_probe(struct usb_interfa
xpad->dpad_mapping = xpad_device[i].dpad_mapping;
xpad->xtype = xpad_device[i].xtype;
if (xpad->dpad_mapping == MAP_DPAD_UNKNOWN)
- xpad->dpad_mapping = dpad_to_buttons;
+ xpad->dpad_mapping = !dpad_to_buttons;
if (xpad->xtype == XTYPE_UNKNOWN)
xpad->xtype = (intf->cur_altsetting->desc.bInterfaceClass == USB_CLASS_VENDOR_SPEC);
xpad->dev = input_dev;
--
Anssi Hannula
^ permalink raw reply [flat|nested] 11+ messages in thread
* [patch 2/7] xpad: fix inverted Y and RY axes on xbox360 devices
2008-03-17 19:22 [patch 0/7] updates for xpad Anssi Hannula
2008-03-17 19:22 ` [patch 1/7] xpad: fix dpad handling of unknown devices Anssi Hannula
@ 2008-03-17 19:22 ` Anssi Hannula
2008-03-28 18:07 ` [patch 2/7, rev2] xpad: fix inverted Y and RY axes Anssi Hannula
2008-03-17 19:22 ` [patch 3/7] xpad: add more xbox 360 controller ids Anssi Hannula
` (5 subsequent siblings)
7 siblings, 1 reply; 11+ messages in thread
From: Anssi Hannula @ 2008-03-17 19:22 UTC (permalink / raw)
To: Dmitry Torokhov; +Cc: linux-input, Brian Magnuson, Anssi Hannula
[-- Attachment #1: xpad-flip-xbox360-stick-y-axis.diff --]
[-- Type: text/plain, Size: 1421 bytes --]
The commit ae91d10aab2762f81733e9194cb56eff99c8d808 inverted Y and RY
axes so that up is positive and down is negative.
This is wrong, as axes on game controllers have up as negative per
convention. Also, even xpad itself reports HAT0X with up as negative.
Fix that by inverting them again.
Cc: Brian Magnuson <bdmagnuson@gmail.com>
Signed-off-by: Anssi Hannula <anssi.hannula@gmail.com>
---
drivers/input/joystick/xpad.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
Index: linux-2.6.25-rc3-mm1-xpad/drivers/input/joystick/xpad.c
===================================================================
--- linux-2.6.25-rc3-mm1-xpad.orig/drivers/input/joystick/xpad.c 2008-03-05 01:52:52.000000000 +0200
+++ linux-2.6.25-rc3-mm1-xpad/drivers/input/joystick/xpad.c 2008-03-05 15:24:14.000000000 +0200
@@ -330,13 +330,13 @@ static void xpad360_process_packet(struc
input_report_abs(dev, ABS_X,
(__s16) le16_to_cpup((__le16 *)(data + 6)));
input_report_abs(dev, ABS_Y,
- (__s16) le16_to_cpup((__le16 *)(data + 8)));
+ ~(__s16) le16_to_cpup((__le16 *)(data + 8)));
/* right stick */
input_report_abs(dev, ABS_RX,
(__s16) le16_to_cpup((__le16 *)(data + 10)));
input_report_abs(dev, ABS_RY,
- (__s16) le16_to_cpup((__le16 *)(data + 12)));
+ ~(__s16) le16_to_cpup((__le16 *)(data + 12)));
/* triggers left/right */
input_report_abs(dev, ABS_Z, data[4]);
--
Anssi Hannula
^ permalink raw reply [flat|nested] 11+ messages in thread
* [patch 3/7] xpad: add more xbox 360 controller ids
2008-03-17 19:22 [patch 0/7] updates for xpad Anssi Hannula
2008-03-17 19:22 ` [patch 1/7] xpad: fix dpad handling of unknown devices Anssi Hannula
2008-03-17 19:22 ` [patch 2/7] xpad: fix inverted Y and RY axes on xbox360 devices Anssi Hannula
@ 2008-03-17 19:22 ` Anssi Hannula
2008-03-17 19:22 ` [patch 4/7] xpad: do not report nonexistent buttons for xbox360 Anssi Hannula
` (4 subsequent siblings)
7 siblings, 0 replies; 11+ messages in thread
From: Anssi Hannula @ 2008-03-17 19:22 UTC (permalink / raw)
To: Dmitry Torokhov; +Cc: linux-input, Anssi Hannula
[-- Attachment #1: xpad-new-xbox360-ids.diff --]
[-- Type: text/plain, Size: 2614 bytes --]
Add Mad Catz and 0x0e6f xbox360 controllers which are already found
in xpad_device[] table in xpad.c into the vendor id list. Also add
Logitech into the vendor list for Logitech Chillstream gamepads.
Also add the RedOctane Guitar Hero X-plorer.
Signed-off-by: Anssi Hannula <anssi.hannula@gmail.com>
---
drivers/input/joystick/xpad.c | 6 ++++++
1 file changed, 6 insertions(+)
Index: linux-2.6.25-rc3-mm1-xpad/drivers/input/joystick/xpad.c
===================================================================
--- linux-2.6.25-rc3-mm1-xpad.orig/drivers/input/joystick/xpad.c 2008-03-05 15:24:14.000000000 +0200
+++ linux-2.6.25-rc3-mm1-xpad/drivers/input/joystick/xpad.c 2008-03-06 23:33:41.000000000 +0200
@@ -110,6 +110,7 @@ static const struct xpad_device {
{ 0x045e, 0x0287, "Microsoft Xbox Controller S", MAP_DPAD_TO_AXES, XTYPE_XBOX },
{ 0x0c12, 0x8809, "RedOctane Xbox Dance Pad", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX },
{ 0x044f, 0x0f07, "Thrustmaster, Inc. Controller", MAP_DPAD_TO_AXES, XTYPE_XBOX },
+ { 0x046d, 0xc242, "Logitech Chillstream Controller", MAP_DPAD_TO_AXES, XTYPE_XBOX360 },
{ 0x046d, 0xca84, "Logitech Xbox Cordless Controller", MAP_DPAD_TO_AXES, XTYPE_XBOX },
{ 0x046d, 0xca88, "Logitech Compact Controller for Xbox", MAP_DPAD_TO_AXES, XTYPE_XBOX },
{ 0x05fd, 0x1007, "Mad Catz Controller (unverified)", MAP_DPAD_TO_AXES, XTYPE_XBOX },
@@ -136,6 +137,7 @@ static const struct xpad_device {
{ 0x0f30, 0x8888, "BigBen XBMiniPad Controller", MAP_DPAD_TO_AXES, XTYPE_XBOX },
{ 0x102c, 0xff0c, "Joytech Wireless Advanced Controller", MAP_DPAD_TO_AXES, XTYPE_XBOX },
{ 0x12ab, 0x8809, "Xbox DDR dancepad", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX },
+ { 0x1430, 0x4748, "RedOctane Guitar Hero X-plorer", MAP_DPAD_TO_AXES, XTYPE_XBOX360 },
{ 0x1430, 0x8888, "TX6500+ Dance Pad (first generation)", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX },
{ 0x045e, 0x028e, "Microsoft X-Box 360 pad", MAP_DPAD_TO_AXES, XTYPE_XBOX360 },
{ 0xffff, 0xffff, "Chinese-made Xbox Controller", MAP_DPAD_TO_AXES, XTYPE_XBOX },
@@ -188,6 +190,10 @@ static const signed short xpad_abs_pad[]
static struct usb_device_id xpad_table [] = {
{ USB_INTERFACE_INFO('X', 'B', 0) }, /* X-Box USB-IF not approved class */
{ XPAD_XBOX360_VENDOR(0x045e) }, /* Microsoft X-Box 360 controllers */
+ { XPAD_XBOX360_VENDOR(0x046d) }, /* Logitech X-Box 360 style controllers */
+ { XPAD_XBOX360_VENDOR(0x0738) }, /* Mad Catz X-Box 360 controllers */
+ { XPAD_XBOX360_VENDOR(0x0e6f) }, /* 0x0e6f X-Box 360 controllers */
+ { XPAD_XBOX360_VENDOR(0x1430) }, /* RedOctane X-Box 360 controllers */
{ }
};
--
Anssi Hannula
^ permalink raw reply [flat|nested] 11+ messages in thread
* [patch 4/7] xpad: do not report nonexistent buttons for xbox360
2008-03-17 19:22 [patch 0/7] updates for xpad Anssi Hannula
` (2 preceding siblings ...)
2008-03-17 19:22 ` [patch 3/7] xpad: add more xbox 360 controller ids Anssi Hannula
@ 2008-03-17 19:22 ` Anssi Hannula
2008-03-17 19:22 ` [patch 5/7] xpad: enable force feedback on xbox 360 controllers only Anssi Hannula
` (3 subsequent siblings)
7 siblings, 0 replies; 11+ messages in thread
From: Anssi Hannula @ 2008-03-17 19:22 UTC (permalink / raw)
To: Dmitry Torokhov; +Cc: linux-input, Anssi Hannula
[-- Attachment #1: xpad-do-not-report-nonexistent-buttons.diff --]
[-- Type: text/plain, Size: 2165 bytes --]
The buttons BTN_C and BTN_Z are only used in the original xbox
controller, not in xbox360 controller. Therefore only add them to
keybit when the controller is a non-360 one.
Signed-off-by: Anssi Hannula <anssi.hannula@gmail.com>
---
drivers/input/joystick/xpad.c | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
Index: linux-2.6.25-rc3-mm1-xpad/drivers/input/joystick/xpad.c
===================================================================
--- linux-2.6.25-rc3-mm1-xpad.orig/drivers/input/joystick/xpad.c 2008-03-05 02:17:49.000000000 +0200
+++ linux-2.6.25-rc3-mm1-xpad/drivers/input/joystick/xpad.c 2008-03-05 02:25:29.000000000 +0200
@@ -142,12 +142,19 @@ static const struct xpad_device {
{ 0x0000, 0x0000, "Generic X-Box pad", MAP_DPAD_UNKNOWN, XTYPE_UNKNOWN }
};
-static const signed short xpad_btn[] = {
- BTN_A, BTN_B, BTN_C, BTN_X, BTN_Y, BTN_Z, /* "analog" buttons */
+/* buttons shared with xbox and xbox360 */
+static const signed short xpad_common_btn[] = {
+ BTN_A, BTN_B, BTN_X, BTN_Y, /* "analog" buttons */
BTN_START, BTN_BACK, BTN_THUMBL, BTN_THUMBR, /* start/back/sticks */
-1 /* terminating entry */
};
+/* original xbox controllers only */
+static const signed short xpad_btn[] = {
+ BTN_C, BTN_Z, /* "analog" buttons */
+ -1 /* terminating entry */
+};
+
/* only used if MAP_DPAD_TO_BUTTONS */
static const signed short xpad_btn_pad[] = {
BTN_LEFT, BTN_RIGHT, /* d-pad left, right */
@@ -676,11 +683,14 @@ static int xpad_probe(struct usb_interfa
input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
/* set up buttons */
- for (i = 0; xpad_btn[i] >= 0; i++)
- set_bit(xpad_btn[i], input_dev->keybit);
+ for (i = 0; xpad_common_btn[i] >= 0; i++)
+ set_bit(xpad_common_btn[i], input_dev->keybit);
if (xpad->xtype == XTYPE_XBOX360)
for (i = 0; xpad360_btn[i] >= 0; i++)
set_bit(xpad360_btn[i], input_dev->keybit);
+ else
+ for (i = 0; xpad_btn[i] >= 0; i++)
+ set_bit(xpad_btn[i], input_dev->keybit);
if (xpad->dpad_mapping == MAP_DPAD_TO_BUTTONS)
for (i = 0; xpad_btn_pad[i] >= 0; i++)
set_bit(xpad_btn_pad[i], input_dev->keybit);
--
Anssi Hannula
^ permalink raw reply [flat|nested] 11+ messages in thread
* [patch 5/7] xpad: enable force feedback on xbox 360 controllers only
2008-03-17 19:22 [patch 0/7] updates for xpad Anssi Hannula
` (3 preceding siblings ...)
2008-03-17 19:22 ` [patch 4/7] xpad: do not report nonexistent buttons for xbox360 Anssi Hannula
@ 2008-03-17 19:22 ` Anssi Hannula
2008-03-17 19:22 ` [patch 6/7] xpad: drop obsolete driver versioning Anssi Hannula
` (2 subsequent siblings)
7 siblings, 0 replies; 11+ messages in thread
From: Anssi Hannula @ 2008-03-17 19:22 UTC (permalink / raw)
To: Dmitry Torokhov; +Cc: linux-input, Anssi Hannula
[-- Attachment #1: xpad-fix-false-ev_ff-bit.diff --]
[-- Type: text/plain, Size: 1043 bytes --]
Commit 4994cd8dadcf9d484ab3ec19f3c7c7a4e5353c1c introduced a
regression which causes xpad to report force feedback cababilities
for non-360 controllers too, even while there is no actual support
for those.
Fix that by adding a check for XTYPE_XBOX360 to xpad_init_ff().
Signed-off-by: Anssi Hannula <anssi.hannula@gmail.com>
---
drivers/input/joystick/xpad.c | 3 +++
1 file changed, 3 insertions(+)
Index: linux-2.6.25-rc3-mm1-xpad/drivers/input/joystick/xpad.c
===================================================================
--- linux-2.6.25-rc3-mm1-xpad.orig/drivers/input/joystick/xpad.c 2008-03-05 03:21:12.000000000 +0200
+++ linux-2.6.25-rc3-mm1-xpad/drivers/input/joystick/xpad.c 2008-03-05 03:28:49.000000000 +0200
@@ -497,6 +497,9 @@ static int xpad_play_effect(struct input
static int xpad_init_ff(struct usb_xpad *xpad)
{
+ if (xpad->xtype != XTYPE_XBOX360)
+ return 0;
+
input_set_capability(xpad->dev, EV_FF, FF_RUMBLE);
return input_ff_create_memless(xpad->dev, NULL, xpad_play_effect);
--
Anssi Hannula
^ permalink raw reply [flat|nested] 11+ messages in thread
* [patch 6/7] xpad: drop obsolete driver versioning
2008-03-17 19:22 [patch 0/7] updates for xpad Anssi Hannula
` (4 preceding siblings ...)
2008-03-17 19:22 ` [patch 5/7] xpad: enable force feedback on xbox 360 controllers only Anssi Hannula
@ 2008-03-17 19:22 ` Anssi Hannula
2008-03-17 19:22 ` [patch 7/7] xpad: add support for wireless xbox360 controllers Anssi Hannula
2008-04-03 20:26 ` [patch 0/7] updates for xpad Dmitry Torokhov
7 siblings, 0 replies; 11+ messages in thread
From: Anssi Hannula @ 2008-03-17 19:22 UTC (permalink / raw)
To: Dmitry Torokhov; +Cc: linux-input, Anssi Hannula
[-- Attachment #1: xpad-drop-driver-version.diff --]
[-- Type: text/plain, Size: 1595 bytes --]
The driver version numbers and changelog have not been updated in a
long while to reflect actual changes. Remove the version number and
add a notice that later changes can be tracked in SCM.
Signed-off-by: Anssi Hannula <anssi.hannula@gmail.com>
---
drivers/input/joystick/xpad.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
Index: linux-2.6.25-rc3-mm1-xpad/drivers/input/joystick/xpad.c
===================================================================
--- linux-2.6.25-rc3-mm1-xpad.orig/drivers/input/joystick/xpad.c 2008-03-06 23:15:14.000000000 +0200
+++ linux-2.6.25-rc3-mm1-xpad/drivers/input/joystick/xpad.c 2008-03-06 23:22:44.000000000 +0200
@@ -1,5 +1,5 @@
/*
- * X-Box gamepad - v0.0.6
+ * X-Box gamepad driver
*
* Copyright (c) 2002 Marko Friedemann <mfr@bmx-chemnitz.de>
* 2004 Oliver Schwartz <Oliver.Schwartz@gmx.de>,
@@ -68,6 +68,8 @@
* - dance pads will map D-PAD to buttons, not axes
* - pass the module paramater 'dpad_to_buttons' to force
* the D-PAD to map to buttons if your pad is not detected
+ *
+ * Later changes can be tracked in SCM.
*/
#include <linux/kernel.h>
@@ -77,7 +79,6 @@
#include <linux/module.h>
#include <linux/usb/input.h>
-#define DRIVER_VERSION "v0.0.6"
#define DRIVER_AUTHOR "Marko Friedemann <mfr@bmx-chemnitz.de>"
#define DRIVER_DESC "X-Box pad driver"
@@ -769,7 +770,7 @@ static int __init usb_xpad_init(void)
{
int result = usb_register(&xpad_driver);
if (result == 0)
- info(DRIVER_DESC ":" DRIVER_VERSION);
+ info(DRIVER_DESC);
return result;
}
--
Anssi Hannula
^ permalink raw reply [flat|nested] 11+ messages in thread
* [patch 7/7] xpad: add support for wireless xbox360 controllers
2008-03-17 19:22 [patch 0/7] updates for xpad Anssi Hannula
` (5 preceding siblings ...)
2008-03-17 19:22 ` [patch 6/7] xpad: drop obsolete driver versioning Anssi Hannula
@ 2008-03-17 19:22 ` Anssi Hannula
2008-04-03 20:26 ` [patch 0/7] updates for xpad Dmitry Torokhov
7 siblings, 0 replies; 11+ messages in thread
From: Anssi Hannula @ 2008-03-17 19:22 UTC (permalink / raw)
To: Dmitry Torokhov; +Cc: linux-input, Brian Magnuson, Anssi Hannula
[-- Attachment #1: xpad-xbox360-wireless.diff --]
[-- Type: text/plain, Size: 9742 bytes --]
From: Brian Magnuson <bdmagnuson@gmail.com>
Add support for wireless xbox360 controllers.
Signed-off-by: Brian Magnuson <bdmagnuson@gmail.com>
Signed-off-by: Anssi Hannula <anssi.hannula@gmail.com>
---
This is Brian's last patch from linux-input@ slightly adapted for
current xpad.c. I didn't see any further discussion, was there a
reason this wasn't applied last time?
I don't have the hardware to actually test it, though.
drivers/input/joystick/xpad.c | 164 +++++++++++++++++++++++++++++++++++++-----
1 file changed, 148 insertions(+), 16 deletions(-)
Index: linux-2.6.25-rc3-mm1-xpad/drivers/input/joystick/xpad.c
===================================================================
--- linux-2.6.25-rc3-mm1-xpad.orig/drivers/input/joystick/xpad.c 2008-03-06 23:33:58.000000000 +0200
+++ linux-2.6.25-rc3-mm1-xpad/drivers/input/joystick/xpad.c 2008-03-06 23:35:49.000000000 +0200
@@ -92,7 +92,8 @@
#define XTYPE_XBOX 0
#define XTYPE_XBOX360 1
-#define XTYPE_UNKNOWN 2
+#define XTYPE_XBOX360W 2
+#define XTYPE_UNKNOWN 3
static int dpad_to_buttons;
module_param(dpad_to_buttons, bool, S_IRUGO);
@@ -109,6 +110,7 @@ static const struct xpad_device {
{ 0x045e, 0x0289, "Microsoft X-Box pad v2 (US)", MAP_DPAD_TO_AXES, XTYPE_XBOX },
{ 0x045e, 0x0285, "Microsoft X-Box pad (Japan)", MAP_DPAD_TO_AXES, XTYPE_XBOX },
{ 0x045e, 0x0287, "Microsoft Xbox Controller S", MAP_DPAD_TO_AXES, XTYPE_XBOX },
+ { 0x045e, 0x0719, "Xbox 360 Wireless Receiver", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360W },
{ 0x0c12, 0x8809, "RedOctane Xbox Dance Pad", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX },
{ 0x044f, 0x0f07, "Thrustmaster, Inc. Controller", MAP_DPAD_TO_AXES, XTYPE_XBOX },
{ 0x046d, 0xc242, "Logitech Chillstream Controller", MAP_DPAD_TO_AXES, XTYPE_XBOX360 },
@@ -186,22 +188,25 @@ static const signed short xpad_abs_pad[]
/* Xbox 360 has a vendor-specific class, so we cannot match it with only
* USB_INTERFACE_INFO (also specifically refused by USB subsystem), so we
- * match against vendor id as well. Also, some Xbox 360 devices have multiple
- * interface protocols, we only need protocol 1. */
-#define XPAD_XBOX360_VENDOR(vend) \
+ * match against vendor id as well. Wired Xbox 360 devices have protocol 1,
+ * wireless controllers have protocol 129. */
+#define XPAD_XBOX360_VENDOR_PROTOCOL(vend,pr) \
.match_flags = USB_DEVICE_ID_MATCH_VENDOR | USB_DEVICE_ID_MATCH_INT_INFO, \
.idVendor = (vend), \
.bInterfaceClass = USB_CLASS_VENDOR_SPEC, \
.bInterfaceSubClass = 93, \
- .bInterfaceProtocol = 1
+ .bInterfaceProtocol = (pr)
+#define XPAD_XBOX360_VENDOR(vend) \
+ { XPAD_XBOX360_VENDOR_PROTOCOL(vend,1) }, \
+ { XPAD_XBOX360_VENDOR_PROTOCOL(vend,129) }
static struct usb_device_id xpad_table [] = {
{ USB_INTERFACE_INFO('X', 'B', 0) }, /* X-Box USB-IF not approved class */
- { XPAD_XBOX360_VENDOR(0x045e) }, /* Microsoft X-Box 360 controllers */
- { XPAD_XBOX360_VENDOR(0x046d) }, /* Logitech X-Box 360 style controllers */
- { XPAD_XBOX360_VENDOR(0x0738) }, /* Mad Catz X-Box 360 controllers */
- { XPAD_XBOX360_VENDOR(0x0e6f) }, /* 0x0e6f X-Box 360 controllers */
- { XPAD_XBOX360_VENDOR(0x1430) }, /* RedOctane X-Box 360 controllers */
+ XPAD_XBOX360_VENDOR(0x045e), /* Microsoft X-Box 360 controllers */
+ XPAD_XBOX360_VENDOR(0x046d), /* Logitech X-Box 360 style controllers */
+ XPAD_XBOX360_VENDOR(0x0738), /* Mad Catz X-Box 360 controllers */
+ XPAD_XBOX360_VENDOR(0x0e6f), /* 0x0e6f X-Box 360 controllers */
+ XPAD_XBOX360_VENDOR(0x1430), /* RedOctane X-Box 360 controllers */
{ }
};
@@ -211,10 +216,15 @@ struct usb_xpad {
struct input_dev *dev; /* input device interface */
struct usb_device *udev; /* usb device */
+ int pad_present;
+
struct urb *irq_in; /* urb for interrupt in report */
unsigned char *idata; /* input data */
dma_addr_t idata_dma;
+ struct urb *bulk_out;
+ unsigned char *bdata;
+
#if defined(CONFIG_JOYSTICK_XPAD_FF) || defined(CONFIG_JOYSTICK_XPAD_LEDS)
struct urb *irq_out; /* urb for interrupt out report */
unsigned char *odata; /* output data */
@@ -359,6 +369,39 @@ static void xpad360_process_packet(struc
input_sync(dev);
}
+/*
+ * xpad360w_process_packet
+ *
+ * Completes a request by converting the data into events for the
+ * input subsystem. It is version for xbox 360 wireless controller.
+ *
+ * Byte.Bit
+ * 00.1 - Status change: The controller or headset has connected/disconnected
+ * Bits 01.7 and 01.6 are valid
+ * 01.7 - Controller present
+ * 01.6 - Headset present
+ * 01.1 - Pad state (Bytes 4+) valid
+ *
+ */
+
+static void xpad360w_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char *data)
+{
+ /* Presence change */
+ if (data[0] & 0x08) {
+ if (data[1] & 0x80) {
+ xpad->pad_present = 1;
+ usb_submit_urb(xpad->bulk_out, GFP_ATOMIC);
+ } else
+ xpad->pad_present = 0;
+ }
+
+ /* Valid pad data */
+ if (!(data[1] & 0x1))
+ return;
+
+ xpad360_process_packet(xpad, cmd, &data[4]);
+}
+
static void xpad_irq_in(struct urb *urb)
{
struct usb_xpad *xpad = urb->context;
@@ -381,10 +424,16 @@ static void xpad_irq_in(struct urb *urb)
goto exit;
}
- if (xpad->xtype == XTYPE_XBOX360)
+ switch (xpad->xtype) {
+ case XTYPE_XBOX360:
xpad360_process_packet(xpad, 0, xpad->idata);
- else
+ break;
+ case XTYPE_XBOX360W:
+ xpad360w_process_packet(xpad, 0, xpad->idata);
+ break;
+ default:
xpad_process_packet(xpad, 0, xpad->idata);
+ }
exit:
retval = usb_submit_urb (urb, GFP_ATOMIC);
@@ -422,6 +471,23 @@ exit:
__FUNCTION__, retval);
}
+static void xpad_bulk_out(struct urb *urb)
+{
+ switch (urb->status) {
+ case 0:
+ /* success */
+ break;
+ case -ECONNRESET:
+ case -ENOENT:
+ case -ESHUTDOWN:
+ /* this urb is terminated, clean up */
+ dbg("%s - urb shutting down with status: %d", __FUNCTION__, urb->status);
+ break;
+ default:
+ dbg("%s - nonzero urb status received: %d", __FUNCTION__, urb->status);
+ }
+}
+
static int xpad_init_output(struct usb_interface *intf, struct usb_xpad *xpad)
{
struct usb_endpoint_descriptor *ep_irq_out;
@@ -600,6 +666,10 @@ static int xpad_open(struct input_dev *d
{
struct usb_xpad *xpad = input_get_drvdata(dev);
+ /* URB was submitted in probe */
+ if(xpad->xtype == XTYPE_XBOX360W)
+ return 0;
+
xpad->irq_in->dev = xpad->udev;
if (usb_submit_urb(xpad->irq_in, GFP_KERNEL))
return -EIO;
@@ -611,7 +681,8 @@ static void xpad_close(struct input_dev
{
struct usb_xpad *xpad = input_get_drvdata(dev);
- usb_kill_urb(xpad->irq_in);
+ if(xpad->xtype != XTYPE_XBOX360W)
+ usb_kill_urb(xpad->irq_in);
xpad_stop_output(xpad);
}
@@ -671,8 +742,15 @@ static int xpad_probe(struct usb_interfa
xpad->xtype = xpad_device[i].xtype;
if (xpad->dpad_mapping == MAP_DPAD_UNKNOWN)
xpad->dpad_mapping = !dpad_to_buttons;
- if (xpad->xtype == XTYPE_UNKNOWN)
- xpad->xtype = (intf->cur_altsetting->desc.bInterfaceClass == USB_CLASS_VENDOR_SPEC);
+ if (xpad->xtype == XTYPE_UNKNOWN) {
+ if (intf->cur_altsetting->desc.bInterfaceClass == USB_CLASS_VENDOR_SPEC) {
+ if (intf->cur_altsetting->desc.bInterfaceProtocol == 129)
+ xpad->xtype = XTYPE_XBOX360W;
+ else
+ xpad->xtype = XTYPE_XBOX360;
+ } else
+ xpad->xtype = XTYPE_XBOX;
+ }
xpad->dev = input_dev;
usb_make_path(udev, xpad->phys, sizeof(xpad->phys));
strlcat(xpad->phys, "/input0", sizeof(xpad->phys));
@@ -692,7 +770,7 @@ static int xpad_probe(struct usb_interfa
/* set up buttons */
for (i = 0; xpad_common_btn[i] >= 0; i++)
set_bit(xpad_common_btn[i], input_dev->keybit);
- if (xpad->xtype == XTYPE_XBOX360)
+ if ((xpad->xtype == XTYPE_XBOX360) || (xpad->xtype == XTYPE_XBOX360W))
for (i = 0; xpad360_btn[i] >= 0; i++)
set_bit(xpad360_btn[i], input_dev->keybit);
else
@@ -734,8 +812,57 @@ static int xpad_probe(struct usb_interfa
goto fail4;
usb_set_intfdata(intf, xpad);
+
+ /*
+ * Submit the int URB immediatly rather than waiting for open
+ * because we get status messages from the device whether
+ * or not any controllers are attached. In fact, it's
+ * exactly the message that a controller has arrived that
+ * we're waiting for.
+ */
+ if (xpad->xtype == XTYPE_XBOX360W) {
+ xpad->irq_in->dev = xpad->udev;
+ error = usb_submit_urb(xpad->irq_in, GFP_KERNEL);
+ if (error)
+ goto fail4;
+
+ /*
+ * Setup the message to set the LEDs on the
+ * controller when it shows up
+ */
+ xpad->bulk_out = usb_alloc_urb(0, GFP_KERNEL);
+ if(!xpad->bulk_out)
+ goto fail5;
+
+ xpad->bdata = kzalloc(XPAD_PKT_LEN, GFP_KERNEL);
+ if(!xpad->bdata)
+ goto fail6;
+
+ xpad->bdata[2] = 0x08;
+ switch (intf->cur_altsetting->desc.bInterfaceNumber) {
+ case 0:
+ xpad->bdata[3] = 0x42;
+ break;
+ case 2:
+ xpad->bdata[3] = 0x43;
+ break;
+ case 4:
+ xpad->bdata[3] = 0x44;
+ break;
+ case 6:
+ xpad->bdata[3] = 0x45;
+ }
+
+ ep_irq_in = &intf->cur_altsetting->endpoint[1].desc;
+ usb_fill_bulk_urb(xpad->bulk_out, udev,
+ usb_sndbulkpipe(udev, ep_irq_in->bEndpointAddress),
+ xpad->bdata, XPAD_PKT_LEN, xpad_bulk_out, xpad);
+ }
+
return 0;
+ fail6: usb_free_urb(xpad->bulk_out);
+ fail5: usb_kill_urb(xpad->irq_in);
fail4: usb_free_urb(xpad->irq_in);
fail3: xpad_deinit_output(xpad);
fail2: usb_buffer_free(udev, XPAD_PKT_LEN, xpad->idata, xpad->idata_dma);
@@ -754,6 +881,11 @@ static void xpad_disconnect(struct usb_i
xpad_led_disconnect(xpad);
input_unregister_device(xpad->dev);
xpad_deinit_output(xpad);
+ if (xpad->xtype == XTYPE_XBOX360W) {
+ usb_kill_urb(xpad->bulk_out);
+ usb_free_urb(xpad->bulk_out);
+ usb_kill_urb(xpad->irq_in);
+ }
usb_free_urb(xpad->irq_in);
usb_buffer_free(xpad->udev, XPAD_PKT_LEN,
xpad->idata, xpad->idata_dma);
--
Anssi Hannula
^ permalink raw reply [flat|nested] 11+ messages in thread
* [patch 2/7, rev2] xpad: fix inverted Y and RY axes
2008-03-17 19:22 ` [patch 2/7] xpad: fix inverted Y and RY axes on xbox360 devices Anssi Hannula
@ 2008-03-28 18:07 ` Anssi Hannula
0 siblings, 0 replies; 11+ messages in thread
From: Anssi Hannula @ 2008-03-28 18:07 UTC (permalink / raw)
To: Dmitry Torokhov; +Cc: linux-input, Brian Magnuson
The commit ae91d10aab2762f81733e9194cb56eff99c8d808 inverted Y and RY
axes on xbox360 so that up is positive and down is negative.
This is wrong, as axes on game controllers have up as negative per
convention. Also, even xpad itself reports HAT0X with up as negative.
Fix that by inverting them again.
Also, according to http://bugzilla.kernel.org/show_bug.cgi?id=10337 the
original xbox controllers also have the Y and RY axes inverted.
Fix that by inverting them as well.
Cc: Brian Magnuson <bdmagnuson@gmail.com>
Signed-off-by: Anssi Hannula <anssi.hannula@gmail.com>
---
Updated this patch according to info from
http://bugzilla.kernel.org/show_bug.cgi?id=10337
drivers/input/joystick/xpad.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
Index: linux-2.6.25-rc3-mm1-xpad/drivers/input/joystick/xpad.c
===================================================================
--- linux-2.6.25-rc3-mm1-xpad.orig/drivers/input/joystick/xpad.c 2008-03-05 01:52:52.000000000 +0200
+++ linux-2.6.25-rc3-mm1-xpad/drivers/input/joystick/xpad.c 2008-03-28 19:59:19.000000000 +0200
@@ -236,13 +236,13 @@ static void xpad_process_packet(struct u
input_report_abs(dev, ABS_X,
(__s16) le16_to_cpup((__le16 *)(data + 12)));
input_report_abs(dev, ABS_Y,
- (__s16) le16_to_cpup((__le16 *)(data + 14)));
+ ~(__s16) le16_to_cpup((__le16 *)(data + 14)));
/* right stick */
input_report_abs(dev, ABS_RX,
(__s16) le16_to_cpup((__le16 *)(data + 16)));
input_report_abs(dev, ABS_RY,
- (__s16) le16_to_cpup((__le16 *)(data + 18)));
+ ~(__s16) le16_to_cpup((__le16 *)(data + 18)));
/* triggers left/right */
input_report_abs(dev, ABS_Z, data[10]);
@@ -330,13 +330,13 @@ static void xpad360_process_packet(struc
input_report_abs(dev, ABS_X,
(__s16) le16_to_cpup((__le16 *)(data + 6)));
input_report_abs(dev, ABS_Y,
- (__s16) le16_to_cpup((__le16 *)(data + 8)));
+ ~(__s16) le16_to_cpup((__le16 *)(data + 8)));
/* right stick */
input_report_abs(dev, ABS_RX,
(__s16) le16_to_cpup((__le16 *)(data + 10)));
input_report_abs(dev, ABS_RY,
- (__s16) le16_to_cpup((__le16 *)(data + 12)));
+ ~(__s16) le16_to_cpup((__le16 *)(data + 12)));
/* triggers left/right */
input_report_abs(dev, ABS_Z, data[4]);
--
Anssi Hannula
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [patch 0/7] updates for xpad
2008-03-17 19:22 [patch 0/7] updates for xpad Anssi Hannula
` (6 preceding siblings ...)
2008-03-17 19:22 ` [patch 7/7] xpad: add support for wireless xbox360 controllers Anssi Hannula
@ 2008-04-03 20:26 ` Dmitry Torokhov
2008-04-03 20:44 ` Anssi Hannula
7 siblings, 1 reply; 11+ messages in thread
From: Dmitry Torokhov @ 2008-04-03 20:26 UTC (permalink / raw)
To: Anssi Hannula; +Cc: linux-input
Hi Anssi,
On Mon, Mar 17, 2008 at 09:22:50PM +0200, Anssi Hannula wrote:
> What follows is a few patches for xpad fixing some issues, adding new
> ids, and Brian's xbox360 wireless patch adapted for current xpad.c.
>
> They are against current mm, i.e. 'match xbox 360 devices with
> interface info' should be applied first.
>
I applied everything to xpad branch of my tree. Please take a look and
see if I am missing anything and I will merge it into master.
Thank you.
--
Dmitry
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [patch 0/7] updates for xpad
2008-04-03 20:26 ` [patch 0/7] updates for xpad Dmitry Torokhov
@ 2008-04-03 20:44 ` Anssi Hannula
0 siblings, 0 replies; 11+ messages in thread
From: Anssi Hannula @ 2008-04-03 20:44 UTC (permalink / raw)
To: Dmitry Torokhov; +Cc: linux-input
Dmitry Torokhov wrote:
> Hi Anssi,
>
> On Mon, Mar 17, 2008 at 09:22:50PM +0200, Anssi Hannula wrote:
>> What follows is a few patches for xpad fixing some issues, adding new
>> ids, and Brian's xbox360 wireless patch adapted for current xpad.c.
>>
>> They are against current mm, i.e. 'match xbox 360 devices with
>> interface info' should be applied first.
>>
>
> I applied everything to xpad branch of my tree. Please take a look and
> see if I am missing anything and I will merge it into master.
>
> Thank you.
They seem ok :)
BTW, "xpad - enable force feedback on xbox 360 controllers only" seems
to fix a null pointer dereference, I got a report from Edgar Simo that
he experienced system hang when trying to use force feedback with a
non-360 controller.
Maybe you should push it to the current stable trees as well?
--
Anssi Hannula
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2008-04-03 20:44 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-03-17 19:22 [patch 0/7] updates for xpad Anssi Hannula
2008-03-17 19:22 ` [patch 1/7] xpad: fix dpad handling of unknown devices Anssi Hannula
2008-03-17 19:22 ` [patch 2/7] xpad: fix inverted Y and RY axes on xbox360 devices Anssi Hannula
2008-03-28 18:07 ` [patch 2/7, rev2] xpad: fix inverted Y and RY axes Anssi Hannula
2008-03-17 19:22 ` [patch 3/7] xpad: add more xbox 360 controller ids Anssi Hannula
2008-03-17 19:22 ` [patch 4/7] xpad: do not report nonexistent buttons for xbox360 Anssi Hannula
2008-03-17 19:22 ` [patch 5/7] xpad: enable force feedback on xbox 360 controllers only Anssi Hannula
2008-03-17 19:22 ` [patch 6/7] xpad: drop obsolete driver versioning Anssi Hannula
2008-03-17 19:22 ` [patch 7/7] xpad: add support for wireless xbox360 controllers Anssi Hannula
2008-04-03 20:26 ` [patch 0/7] updates for xpad Dmitry Torokhov
2008-04-03 20:44 ` Anssi Hannula
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).