public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Brenton Simpson <appsforartists@google.com>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	Hans de Goede <hdegoede@redhat.com>
Cc: Cameron Gutman <aicommander@gmail.com>,
	Erica Taylor <rickytaylor26@gmail.com>,
	 Ismael Ferreras Morezuelas <swyterzone@gmail.com>,
	Jonathan Frederick <doublej472@gmail.com>,
	 Matthias Benkmann <matthias.benkmann@gmail.com>,
	Matthias Berndt <matthias_berndt@gmx.de>,
	nate@yocom.org,  Sam Lantinga <slouken@libsdl.org>,
	Vicki Pfau <vi@endrift.com>,
	linux-input@vger.kernel.org,  linux-kernel@vger.kernel.org,
	trivial@kernel.org,  Brenton Simpson <appsforartists@google.com>
Subject: [PATCH] Input: xpad - add Lenovo Legion Go controllers
Date: Thu, 18 Jan 2024 18:35:46 +0000	[thread overview]
Message-ID: <20240118183546.418064-1-appsforartists@google.com> (raw)
In-Reply-To: <CAAL3-=88exVfuL1Y-kvPNbsU+d-UTfDLFViWVObFLtbC4xueeA@mail.gmail.com>

The Lenovo Legion Go is a handheld gaming system, similar to a Steam Deck.
It has a gamepad (including rear paddles), 3 gyroscopes, a trackpad,
volume buttons, a power button, and 2 LED ring lights.

The Legion Go firmware presents these controls as a USB hub with various
devices attached.  In its default state, the gamepad is presented as an
Xbox controller connected to this hub.  (By holding a combination of
buttons, it can be changed to use the older DirectInput API.)

This patch teaches the existing Xbox controller module `xpad` to bind to
the controller in the Legion Go, which enables support for the:

- directional pad,
- analog sticks (including clicks),
- X, Y, A, B,
- start and select (or menu and capture),
- shoulder buttons, and
- rumble.

The trackpad, touchscreen, volume controls, and power button are already
supported via existing kernel modules.  Two of the face buttons, the
gyroscopes, rear paddles, and LEDs are not.

After this patch lands, the Legion Go will be mostly functional in Linux,
out-of-the-box.  The various components of the USB hub can be synthesized
into a single logical controller (including the additional buttons) in
userspace with [Handheld Daemon](https://github.com/hhd-dev/hhd), which
makes the Go fully functional.

Signed-off-by: Brenton Simpson <appsforartists@google.com>
---
 drivers/input/joystick/xpad.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
index f5c21565bb3c..ecfcea8740a0 100644
--- a/drivers/input/joystick/xpad.c
+++ b/drivers/input/joystick/xpad.c
@@ -127,6 +127,7 @@ static const struct xpad_device {
 	u8 mapping;
 	u8 xtype;
 } xpad_device[] = {
+	{ 0x17ef, 0x6182, "Lenovo Legion Controller for Windows", 0, XTYPE_XBOX360 },
 	{ 0x0079, 0x18d4, "GPD Win 2 X-Box Controller", 0, XTYPE_XBOX360 },
 	{ 0x03eb, 0xff01, "Wooting One (Legacy)", 0, XTYPE_XBOX360 },
 	{ 0x03eb, 0xff02, "Wooting Two (Legacy)", 0, XTYPE_XBOX360 },
@@ -459,6 +460,7 @@ static const signed short xpad_btn_paddles[] = {
 
 static const struct usb_device_id xpad_table[] = {
 	{ USB_INTERFACE_INFO('X', 'B', 0) },	/* Xbox USB-IF not-approved class */
+	XPAD_XBOX360_VENDOR(0x17ef),		/* Lenovo */
 	XPAD_XBOX360_VENDOR(0x0079),		/* GPD Win 2 controller */
 	XPAD_XBOX360_VENDOR(0x03eb),		/* Wooting Keyboards (Legacy) */
 	XPAD_XBOXONE_VENDOR(0x03f0),		/* HP HyperX Xbox One controllers */
-- 
2.43.0.275.g3460e3d667-goog


  parent reply	other threads:[~2024-01-18 18:35 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-16 17:45 [PATCH] Input: xpad - add Lenovo Legion Go controllers Brenton Simpson
2023-11-16 18:20 ` Hans de Goede
2024-01-18 18:35 ` Brenton Simpson [this message]
2024-01-18 18:41   ` Brenton Simpson
2024-01-19  6:16   ` Vicki Pfau
2024-01-19  8:22     ` Brenton Simpson
2024-01-30 22:32       ` Dmitry Torokhov
2024-01-30 23:19         ` [PATCH] Input: xpad - sort xpad_device by vendor and product ID Brenton Simpson
2024-02-09 18:56           ` Dmitry Torokhov
2024-02-09 19:27             ` Brenton Simpson

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=20240118183546.418064-1-appsforartists@google.com \
    --to=appsforartists@google.com \
    --cc=aicommander@gmail.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=doublej472@gmail.com \
    --cc=hdegoede@redhat.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matthias.benkmann@gmail.com \
    --cc=matthias_berndt@gmx.de \
    --cc=nate@yocom.org \
    --cc=rickytaylor26@gmail.com \
    --cc=slouken@libsdl.org \
    --cc=swyterzone@gmail.com \
    --cc=trivial@kernel.org \
    --cc=vi@endrift.com \
    /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