Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Input: xpad - fix support for some third-party controllers

Some third-party controllers, such as the HORPIAD FPS for Nintendo Switch and
Gamesir-G3w, require a specific packet that the first-party XInput driver sends
before it will start sending reports. It's not currently known what this packet
does, but since the first-party driver always sends it's unlikely that this
could cause issues with existing controllers.

Co-authored-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Vicki Pfau <vi@endrift.com>
Link: https://lore.kernel.org/r/20230324040446.3487725-3-vi@endrift.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

authored by

Vicki Pfau
Andrey Smirnov
and committed by
Dmitry Torokhov
db7220c4 8fb1bcd0

+23
+23
drivers/input/joystick/xpad.c
··· 264 264 { 0x0f0d, 0x0067, "HORIPAD ONE", 0, XTYPE_XBOXONE }, 265 265 { 0x0f0d, 0x0078, "Hori Real Arcade Pro V Kai Xbox One", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOXONE }, 266 266 { 0x0f0d, 0x00c5, "Hori Fighting Commander ONE", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOXONE }, 267 + { 0x0f0d, 0x00dc, "HORIPAD FPS for Nintendo Switch", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 }, 267 268 { 0x0f30, 0x010b, "Philips Recoil", 0, XTYPE_XBOX }, 268 269 { 0x0f30, 0x0202, "Joytech Advanced Controller", 0, XTYPE_XBOX }, 269 270 { 0x0f30, 0x8888, "BigBen XBMiniPad Controller", 0, XTYPE_XBOX }, ··· 2012 2011 */ 2013 2012 error = -ENODEV; 2014 2013 goto err_free_in_urb; 2014 + } 2015 + 2016 + if (xpad->xtype == XTYPE_XBOX360) { 2017 + /* 2018 + * Some third-party controllers Xbox 360-style controllers 2019 + * require this message to finish initialization. 2020 + */ 2021 + u8 dummy[20]; 2022 + 2023 + error = usb_control_msg_recv(udev, 0, 2024 + /* bRequest */ 0x01, 2025 + /* bmRequestType */ 2026 + USB_TYPE_VENDOR | USB_DIR_IN | 2027 + USB_RECIP_INTERFACE, 2028 + /* wValue */ 0x100, 2029 + /* wIndex */ 0x00, 2030 + dummy, sizeof(dummy), 2031 + 25, GFP_KERNEL); 2032 + if (error) 2033 + dev_warn(&xpad->dev->dev, 2034 + "unable to receive magic message: %d\n", 2035 + error); 2015 2036 } 2016 2037 2017 2038 ep_irq_in = ep_irq_out = NULL;