linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Saihaj Johal <personal@sjohal.net>
To: Aditya Garg <gargaditya08@live.com>,
	linux-input@vger.kernel.org, linux@emily.st
Cc: "Daniel J. Ogorchock" <djogorchock@gmail.com>,
	Nadia Holmquist Pedersen <nadia@nhp.sh>,
	Ryan McClelland <rymcclel@gmail.com>,
	Jiri Kosina <jikos@kernel.org>,
	Benjamin Tissoires <bentiss@kernel.org>
Subject: Re: hid_nintendo Switch 2 Pro Controller support - where to start?
Date: Mon, 07 Jul 2025 16:22:42 +0100	[thread overview]
Message-ID: <2753963.lGaqSPkdTl@saihaj-mainpc> (raw)
In-Reply-To: <0bc102b6-cdd0-4f1f-910d-db752c52eb85@app.fastmail.com>

On Sunday, 6 July 2025 22:48:43 British Summer Time linux@emily.st wrote:
> On Sat, Jul 5, 2025, at 23:27, Aditya Garg wrote:
> > On 06-07-2025 12:18 am, Saihaj Johal wrote:
> >> Hello,
> >> I recently got a Nintendo Switch 2 Pro Controller that is not currently
> >> directly supported by the kernel like how the Switch 1 controllers are.
> >> Looking in "hid-ids.h", there is no product ID for the new controller
> >> (got
> >> 0x2069 from "lsusb -v"). The device class shows as miscellaneous device,
> >> and the controller does not show the player LEDs to show it is active
> >> (it only charges over USB, alongside showing in "lsusb" as well as
> >> showing as a USB audio device for the headphone jack on the bottom).
> >> However, I have managed to get it to work as a HID device using this
> >> website (https://
> >> handheldlegend.github.io/procon2tool/) which uses WebUSB to send the
> >> right
> >> commands to make the controller turn on fully. After enabling, this setup
> >> seemingly works with the existing evdev system, although with some
> >> bizarre
> >> changes like the left stick's up and down being reversed (at least in
> >> KDE's
> >> game controller settings). The first step would likely be to add the
> >> device ID to "hid-ids.h", but from there where should I go in order to
> >> perhaps work on full support? I assume anything would work on the things
> >> discovered already by the WebUSB enabler tool, however I am very new to
> >> C and kernel development in general.
> > 
> > Simply mailing the mailing list won't get you replies. You should also
> > email relevant maintainers.
> > 
> > Ccing them
> 
> Hi, in 2022 I spent some time customizing the existing `hid_nintendo` driver
> to add support for a few more first-party Nintendo controllers made for the
> Nintendo Switch. I no longer work on this, since my day job keeps me very
> busy, but I can try to share a little bit about the obstacles I
> encountered.
> 
> When I first encountered the `hid_nintendo` driver, it was written very
> specifically to handle the original first-party Nintendo Switch
> controllers, most specifically the Joy-Cons. Part of what I did was to
> attempt to generalize the driver somewhat to make it easier to add support
> for other kinds of controllers. I did **not** succeed in completing this
> work, but I did make enough progress to succeed in my goal of supporting
> the N64 and Genesis controllers. And I know that some people were
> successful in using the driver that I forked.
> 
> Although I was not directly involved in incorporating this code into the
> Linux kernel again, I am gratified that people found it useful enough to
> incorporate.
> 
> I don't really know to what extent it's going to be necessary to rework the
> existing driver, or whether it's appropriate to create a new driver for the
> second generation of the Nintendo Switch input peripherals. Since this is a
> new generation of hardware device, there may be some differences in how it
> communicates over USB or Bluetooth. That is a bit beyond my knowledge, and
> I don't know if that information has been fully reverse engineered yet. It
> probably should not be taken for granted that what worked with the original
> Nintendo Switch controllers will work with the second generation as well. I
> would defer to the experts on this list.
> 
> Assuming that you want to experiment simply with trying to adapt the current
> driver to handle the newer peripherals, you will first need to modify the
> device IDs, as you've already discovered, in `hid-ids.h`. You will also
> need to modify the driver slightly to "claim" those peripherals (to tell
> the input subsystem which driver handles those device inputs). If you are
> successful in allowing the existing driver to talk to the new Switch 2
> controllers, then you must determine the numerical codes the controller
> emits when certain inputs are used and to map those to the actual buttons
> being used. Specifically, you must find a way to intercept the numerical
> codes that are coming from the controller, determine which inputs those
> control codes map to, and then calling the API of the kernel to create the
> correct inputs. I recall that when I did this, I think I read the codes out
> of the raw input device exposed by the kernel (somewhere in /dev/input, I
> think?), and then wrote down on paper which codes I saw when I pressed
> which buttons. Then I followed the existing pattern of how the kernel
> driver mapped those input codes to the existing kernel inputs. The current
> driver has many good examples of this in action.
> 
> **Take all this with a grain of salt.** I did this work years ago. I was
> never really a Linux kernel developer, and I am very rusty on how the
> driver worked. I can only remember the generalities, and I would again
> defer to the experts on this list to correct any mistakes I've
> inadvertently added here. I hope this helps since I was doing a very
> similar thing to what you're doing now. Best of luck.
Hi,
Thank you for the advice on trying to make the driver work. I have now 
attempted adding the IDs to the existing hid_nintendo driver, however to no 
avail. The driver definitely was doing something, considering the WebUSB 
enabler stopped working when that changed driver was in use, but not enough. 
It seems it would likely be best for the Switch 2 peripherals to be part of a 
new driver, as they seem to communicate in an entirely different way. From what 
I can gather from the documentation of the developer of the WebUSB enabler 
tool (https://docs.handheldlegend.com/s/link-zone/doc/usb-initialization-fisHohwe4m) the Switch 2 controllers, at least over USB, send a HID command to 
enable the controller, also containing the console's MAC address (guess we 
could use all zeroes for the kernel driver?) probably to pair the controller 
to the console. Then, another HID command sets the player LED to make the 
controller fully functional. After that, however, it seems like it would 
function like a generic HID controller based on the behaviour with the enabler 
(so not much driver work needed there), although we would need to configure the 
inputs in this new driver to send the right buttons to the rest of the system.  
The documentation says some of the HID commands needed to make it work, but 
either there is more needed that the enabler does or I'm struggling with 
sending HID commands properly to the controller (trying hidapitester as well 
as just echo to /dev/hidraw6) , so I've hit a dead end, as the controller does 
nothing without those commands being sent. This would likely be something to 
pick up for someone who has the experience in working with raw HID commands. 
Thank you for your assistance,
Saihaj



  reply	other threads:[~2025-07-07 16:35 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-05 18:48 hid_nintendo Switch 2 Pro Controller support - where to start? Saihaj Johal
2025-07-06  6:27 ` Aditya Garg
2025-07-06 21:48   ` linux
2025-07-07 15:22     ` Saihaj Johal [this message]
2025-07-16 23:54       ` Vicki Pfau

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=2753963.lGaqSPkdTl@saihaj-mainpc \
    --to=personal@sjohal.net \
    --cc=bentiss@kernel.org \
    --cc=djogorchock@gmail.com \
    --cc=gargaditya08@live.com \
    --cc=jikos@kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux@emily.st \
    --cc=nadia@nhp.sh \
    --cc=rymcclel@gmail.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;
as well as URLs for NNTP newsgroup(s).