Linux Input/HID development
 help / color / mirror / Atom feed
From: Tom Benham <tomben13@free.fr>
To: linux-input@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Subject: [Bug][Patch] /dev/input/jsX absent for Nintendo Switch Pro controller
Date: Sat, 16 Aug 2025 20:24:10 +0200	[thread overview]
Message-ID: <afab2e44-ff31-4b3f-bfd8-0d5b184423c4@free.fr> (raw)


[-- Attachment #1.1: Type: text/plain, Size: 2447 bytes --]

First and foremost, apologies if this report is not properly done or 
formatted or whatever regarding the kernel development process. Feel 
free to correct me if I did something wrong.

Distribution: ArchLinux

|$ cat /proc/version
Linux version 6.16-arch2-1 (linux@archlinux) (gcc (GCC) 15.2.1 20250813, 
GNU ld (GNU Binutils) 2.45.0) #3 SMP PREEMPT_DYNAMIC Sat, 16 Aug 2025 
16:19:12 +0000
|
Problem description:
When plugging a Nintendo Switch Pro controller, the |/dev/input/js0| 
file does not get created.

Problem analysis:
I think I have pinpointed the bug in the hid-nintendo.c driver.

  * joydev (who is responsible for creating |/dev/input/js0|) is not
    handling the device.
  * However, joydev receives the handling request from input.c only for
    the IMU device (the accelerometer), which is blacklisted (totally
    normal) so we get the following message when activating debug
    messages in joydev:
      o |input input39: joydev: blacklisting 'Nintendo Co., Ltd. Pro
        Controller (IMU)'|
  * joydev is looking for |absbit| and |keybit| in order to match a
    device (defined in |joydev_ids| array)
  * But for the regular device (not IMU), |absbit| and |keybit| are 0
  * The reason is that in |joycon_input_create|, |input_register_device|
    is called BEFORE setting the bits (which happen in |joycon_config_*|)
  * This change was introduced in commit
    94f18bb19945915fcdfd1903841020ef1b6af44a
  * Before that, |input_register_device| was called AFTER setting the bits
  * So, possible regression ? I can't test with older kernels unfortunately

I attached the simple patch that works for me.

Would it also make sense to move the rumble config before the call to 
|input_register_device| ? It was moved after the IMU device creation in 
the same commit, although I am not sure if it NEEDS to be. Let me know 
what you think of that.

Unrelated to the bug but I noticed during my testing that when first 
plugging the controller, when the hid_nintendo module is not loaded, 
hid-generic handles it but then it gets disconnected right after and 
hid_nintendo takes over. I'm very new to kernel debugging so I don't 
know if this behavior is normal but I guess it is. What's funny is that 
because hid-generic doesn't have the same bug, the |/dev/input/js0| 
device gets created and then immediately removed. You can see it if you 
|ls| continuously the |/dev/input| folder. This was very confusing at 
first !

[-- Attachment #1.2: Type: text/html, Size: 3191 bytes --]

[-- Attachment #2: hid_nintendo.patch --]
[-- Type: text/x-patch, Size: 861 bytes --]

diff --git a/drivers/hid/hid-nintendo.c b/drivers/hid/hid-nintendo.c
index fb4985988615..a21618b42c38 100644
--- a/drivers/hid/hid-nintendo.c
+++ b/drivers/hid/hid-nintendo.c
@@ -2138,10 +2138,6 @@ static int joycon_input_create(struct joycon_ctlr *ctlr)
 	ctlr->input->phys = hdev->phys;
 	input_set_drvdata(ctlr->input, ctlr);
 
-	ret = input_register_device(ctlr->input);
-	if (ret)
-		return ret;
-
 	if (joycon_type_is_right_joycon(ctlr)) {
 		joycon_config_right_stick(ctlr->input);
 		joycon_config_buttons(ctlr->input, right_joycon_button_mappings);
@@ -2172,6 +2168,10 @@ static int joycon_input_create(struct joycon_ctlr *ctlr)
 		joycon_config_buttons(ctlr->input, n64con_button_mappings);
 	}
 
+	ret = input_register_device(ctlr->input);
+	if (ret)
+		return ret;
+
 	if (joycon_has_imu(ctlr)) {
 		ret = joycon_imu_input_create(ctlr);
 		if (ret)

                 reply	other threads:[~2025-08-16 18:24 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=afab2e44-ff31-4b3f-bfd8-0d5b184423c4@free.fr \
    --to=tomben13@free.fr \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@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