linux
linux copied to clipboard
Joycon assigned incorrectly as pro controller
Hi @DanielOgorchock !
I've got a little question: i've got a pair of joycons that the system is recognizing as:
Left:
Input device ID: bus 0x5 vendor 0x57e product 0x2009 version 0x8001
Input device name: "Nintendo Switch Pro Controller"
Right:
Input device ID: bus 0x5 vendor 0x57e product 0x2009 version 0x8001
Input device name: "Nintendo Switch Pro Controller"
From hid-ids.h
:
#define USB_VENDOR_ID_NINTENDO 0x057e
#define USB_DEVICE_ID_NINTENDO_WIIMOTE 0x0306
#define USB_DEVICE_ID_NINTENDO_WIIMOTE2 0x0330
#define USB_DEVICE_ID_NINTENDO_JOYCONL 0x2006
#define USB_DEVICE_ID_NINTENDO_JOYCONR 0x2007
#define USB_DEVICE_ID_NINTENDO_PROCON 0x2009 <---- are getting this global var
#define USB_DEVICE_ID_NINTENDO_CHRGGRIP 0x200E
So apparently there is no difference between them on product id or version id, and also as being recongized as Pro Controllers it complicates things because the SR/SL buttons of the joycons are not getting mapped/detected by the kernel.
evdev output for left:
Supported events:
Event type 0 (EV_SYN)
Event type 1 (EV_KEY)
Event code 309 (BTN_Z)
Event code 310 (BTN_TL)
Event code 312 (BTN_TL2)
Event code 314 (BTN_SELECT)
Event code 317 (BTN_THUMBL)
Event type 3 (EV_ABS)
Event code 0 (ABS_X)
Value 1048
Min -32767
Max 32767
Fuzz 250
Flat 500
Event code 1 (ABS_Y)
Value -1026
Min -32767
Max 32767
Fuzz 250
Flat 500
Event code 16 (ABS_HAT0X)
Value 0
Min -1
Max 1
Event code 17 (ABS_HAT0Y)
Value 0
Min -1
Max 1
Event type 21 (EV_FF)
Event code 80 (FF_RUMBLE)
Event code 81 (FF_PERIODIC)
Event code 88 (FF_SQUARE)
Event code 89 (FF_TRIANGLE)
Event code 90 (FF_SINE)
Event code 96 (FF_GAIN)
evdev output for right:
Supported events:
Event type 0 (EV_SYN)
Event type 1 (EV_KEY)
Event code 304 (BTN_SOUTH)
Event code 305 (BTN_EAST)
Event code 307 (BTN_NORTH)
Event code 308 (BTN_WEST)
Event code 311 (BTN_TR)
Event code 313 (BTN_TR2)
Event code 315 (BTN_START)
Event code 316 (BTN_MODE)
Event code 318 (BTN_THUMBR)
Event type 3 (EV_ABS)
Event code 3 (ABS_RX)
Value 1048
Min -32767
Max 32767
Fuzz 250
Flat 500
Event code 4 (ABS_RY)
Value -1026
Min -32767
Max 32767
Fuzz 250
Flat 500
Event type 21 (EV_FF)
Event code 80 (FF_RUMBLE)
Event code 81 (FF_PERIODIC)
Event code 88 (FF_SQUARE)
Event code 89 (FF_TRIANGLE)
Event code 90 (FF_SINE)
Event code 96 (FF_GAIN)
But i've also saw in the code of hid-nintendo.c
these lines:
(1624:1628)
switch (hdev->product) {
case USB_DEVICE_ID_NINTENDO_PROCON:
name = "Nintendo Switch Pro Controller";
imu_name = "Nintendo Switch Pro Controller IMU";
break;
That sets the device name but this took my attention too: (483:501)
#define jc_type_is_joycon(ctlr) \
(ctlr->hdev->product == USB_DEVICE_ID_NINTENDO_JOYCONL || \
ctlr->hdev->product == USB_DEVICE_ID_NINTENDO_JOYCONR || \
ctlr->hdev->product == USB_DEVICE_ID_NINTENDO_CHRGGRIP)
#define jc_type_is_procon(ctlr) \
(ctlr->hdev->product == USB_DEVICE_ID_NINTENDO_PROCON)
#define jc_type_is_chrggrip(ctlr) \
(ctlr->hdev->product == USB_DEVICE_ID_NINTENDO_CHRGGRIP)
/* Does this controller have inputs associated with left joycon? */
#define jc_type_has_left(ctlr) \
(ctlr->ctlr_type == JOYCON_CTLR_TYPE_JCL || \
ctlr->ctlr_type == JOYCON_CTLR_TYPE_PRO)
/* Does this controller have inputs associated with right joycon? */
#define jc_type_has_right(ctlr) \
(ctlr->ctlr_type == JOYCON_CTLR_TYPE_JCR || \
ctlr->ctlr_type == JOYCON_CTLR_TYPE_PRO)
Because later (at 1308 aprox the first recurrence) asks again if it's a joycon to report and set capability of the S buttons, which that seems to be the problem.
So, there is a way to get more information of the joycon in order to diferentiate them, additionaly to the product/version ids? How can i get this info? I see that you gets ctlr_type
which i cannot find in the device info using the console so i assume there are more info that i'm not seeing.
Thanks in advance for reading!
For someone wondering, this is a solution i came with but i'm still testing it, unfortunatelly i don't have any other controllers to test the other paths but for now at least for this 3rd party Joycons it works:
Then in hid-nintendo.c
(:1605)
static int joycon_input_create(struct joycon_ctlr *ctlr)
{
struct hid_device *hdev;
const char *name;
const char *imu_name;
int ret;
int i;
/*Some 3rd party Switch Pro controllers report Product ID 0x2006
instead of 0x2009.
Check reported controller type and force Product ID to PROCON.
Additionally some 3rd party Joycons are reported as Pro Controllers
so if the ctlr_type is left or right we force JOYCONL or JOYCONR.
*/
if(ctlr->ctlr_type == JOYCON_CTLR_TYPE_PRO &&
ctlr->hdev->product != USB_DEVICE_ID_NINTENDO_PROCON){
ctlr->hdev->product = USB_DEVICE_ID_NINTENDO_PROCON;
}
else if (ctlr->ctlr_type == JOYCON_CTLR_TYPE_JCL &&
ctlr->hdev->product == USB_DEVICE_ID_NINTENDO_PROCON) {
ctlr->hdev->product = USB_DEVICE_ID_NINTENDO_JOYCONL;
}
else if (ctlr->ctlr_type == JOYCON_CTLR_TYPE_JCR &&
ctlr->hdev->product == USB_DEVICE_ID_NINTENDO_PROCON) {
ctlr->hdev->product = USB_DEVICE_ID_NINTENDO_JOYCONR;
}
Before only the first validation was made to force the Pro Controller product id if the controller type was PRO, but now i added the two additional clauses to force if the controller type is JC left or JC right (and the product id is 0x2009 PROCON) it will force the product id of the controller to their respective joycons L/R product ids.
I can open a PR for your evaluation. Thanks!