From: Chris Ye <lzye@google.com>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Chris Ye <linzhao.ye@gmail.com>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
trivial@kernel.org, kernel-team@android.com,
Chris Ye <lzye@google.com>
Subject: [PATCH] Input: Add "Share" button to Microsoft Xbox One controller.
Date: Thu, 25 Feb 2021 04:00:32 +0000 [thread overview]
Message-ID: <20210225040032.684590-1-lzye@google.com> (raw)
Add "Share" button input capability and input event mapping for
Microsoft Xbox One controller.
Fixed Microsoft Xbox One controller share button not working under USB
connection.
Signed-off-by: Chris Ye <lzye@google.com>
---
drivers/input/joystick/xpad.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
index 9f0d07dcbf06..08c3e93ccb2f 100644
--- a/drivers/input/joystick/xpad.c
+++ b/drivers/input/joystick/xpad.c
@@ -368,6 +368,14 @@ static const signed short xpad360_btn[] = { /* buttons for x360 controller */
-1
};
+static const signed short xpad_xboxone_btn[] = {
+ /* buttons for xbox one controller */
+ BTN_TL, BTN_TR, /* Button LB/RB */
+ BTN_MODE, /* The big X button */
+ KEY_RECORD, /* The share button */
+ -1
+};
+
static const signed short xpad_abs[] = {
ABS_X, ABS_Y, /* left stick */
ABS_RX, ABS_RY, /* right stick */
@@ -862,6 +870,7 @@ static void xpadone_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char
/* menu/view buttons */
input_report_key(dev, BTN_START, data[4] & 0x04);
input_report_key(dev, BTN_SELECT, data[4] & 0x08);
+ input_report_key(dev, KEY_RECORD, data[22] & 0x01);
/* buttons A,B,X,Y */
input_report_key(dev, BTN_A, data[4] & 0x10);
@@ -1668,10 +1677,13 @@ static int xpad_init_input(struct usb_xpad *xpad)
input_set_capability(input_dev, EV_KEY, xpad_common_btn[i]);
/* set up model-specific ones */
- if (xpad->xtype == XTYPE_XBOX360 || xpad->xtype == XTYPE_XBOX360W ||
- xpad->xtype == XTYPE_XBOXONE) {
+ if (xpad->xtype == XTYPE_XBOX360 || xpad->xtype == XTYPE_XBOX360W) {
for (i = 0; xpad360_btn[i] >= 0; i++)
input_set_capability(input_dev, EV_KEY, xpad360_btn[i]);
+ } else if (xpad->xtype == XTYPE_XBOXONE) {
+ for (i = 0; xpad_xboxone_btn[i] >= 0; i++)
+ input_set_capability(input_dev, EV_KEY,
+ xpad_xboxone_btn[i]);
} else {
for (i = 0; xpad_btn[i] >= 0; i++)
input_set_capability(input_dev, EV_KEY, xpad_btn[i]);
--
2.30.0.617.g56c4b15f3c-goog
next reply other threads:[~2021-02-25 4:00 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-25 4:00 Chris Ye [this message]
2021-02-25 4:32 ` [PATCH] Input: Add "Share" button to Microsoft Xbox One controller Dmitry Torokhov
2021-02-25 4:44 ` Chris Ye
2021-02-25 6:26 ` Dmitry Torokhov
2021-02-28 1:34 ` Cameron Gutman
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=20210225040032.684590-1-lzye@google.com \
--to=lzye@google.com \
--cc=dmitry.torokhov@gmail.com \
--cc=kernel-team@android.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linzhao.ye@gmail.com \
--cc=trivial@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