linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Anssi Hannula <anssi.hannula@gmail.com>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: linux-input@vger.kernel.org, Anssi Hannula <anssi.hannula@gmail.com>
Subject: [patch 4/7] xpad: do not report nonexistent buttons for xbox360
Date: Mon, 17 Mar 2008 21:22:54 +0200	[thread overview]
Message-ID: <20080317192845.727304310@gmail.com> (raw)
In-Reply-To: 20080317192250.208635026@gmail.com

[-- 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

  parent reply	other threads:[~2008-03-17 19:29 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 ` Anssi Hannula [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080317192845.727304310@gmail.com \
    --to=anssi.hannula@gmail.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).