Message ID | 20240118183546.418064-1-appsforartists@google.com |
---|---|
State | New |
Headers | show |
Series | Input: xpad - add Lenovo Legion Go controllers | expand |
A bunch of internal wrangling and one holiday codefreeze later, my git alias has finally been enabled for send-email. Sorry for the hassle, and thanks for your help. On Thu, Jan 18, 2024 at 10:35 AM Brenton Simpson <appsforartists@google.com> wrote: > > 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 >
Hi Brenton, On 1/18/24 10:35, Brenton Simpson wrote: > 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 }, Please keep the items in this list sorted. > @@ -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 */ Ditto here. Dmitry will sometimes take patches and fix the sorting after they're submitted so you might not to resubmit, but for future reference, this list is intended to be sorted. Vicki
Thanks Vicki. I didn't realize they were meant to be sorted. Would it be appropriate to add comments explaining the sorting? The second stanza, in particular, is sorted by the IDs rather than lexicographically. If someone sorted it naively, they'd end up with a bigger diff than expected. It looks like a few others have escaped sorting; for instance, "Microsoft X-Box One Elite 2 pad" appears in the wrong place. If Dmitry wants to land this and then follow on with a sort + comment commit (or do that first and then rebase this on top), that would be great. I can take a stab too if that's helpful. On Thu, Jan 18, 2024 at 10:16 PM Vicki Pfau <vi@endrift.com> wrote: > > Hi Brenton, > > On 1/18/24 10:35, Brenton Simpson wrote: > > 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 }, > > Please keep the items in this list sorted. > > > @@ -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 */ > > Ditto here. > > Dmitry will sometimes take patches and fix the sorting after they're > submitted so you might not to resubmit, but for future reference, this > list is intended to be sorted. > > Vicki
Hi Brenton, On Fri, Jan 19, 2024 at 12:22:45AM -0800, Brenton Simpson wrote: > Thanks Vicki. I didn't realize they were meant to be sorted. Please try avoid top posting. > > Would it be appropriate to add comments explaining the sorting? The > second stanza, in particular, is sorted by the IDs rather than > lexicographically. If someone sorted it naively, they'd end up with a > bigger diff than expected. Yes, we usually sort by VID/PID rather than the name of the device. > > It looks like a few others have escaped sorting; for instance, > "Microsoft X-Box One Elite 2 pad" appears in the wrong place. Yep, sometimes we mess up. > > If Dmitry wants to land this and then follow on with a sort + comment > commit (or do that first and then rebase this on top), that would be > great. I can take a stab too if that's helpful. I applied the patch (moving the entires to the right place). If someone would send a patch fixing the Elite 2 entry and noting the sorting rules I'd be happy to apply it. Thanks.
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 */
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(+)