Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gamepad support in WSL2 (/dev/jsx) #7747

Open
Aerocatia opened this issue Nov 23, 2021 · 8 comments
Open

Gamepad support in WSL2 (/dev/jsx) #7747

Aerocatia opened this issue Nov 23, 2021 · 8 comments
Labels

Comments

@Aerocatia
Copy link

Is your feature request related to a problem? Please describe.
It would be nice to have gamepads exposed to Linux guests for the convince of running and testing cross platform programs that can make use of gamepads solely on Windows using WSLg. You can already attach USB gamepads to the WSL2 instance using usbipd-win, however the system dsitro does not have gamepad support enabled since this use-case was not considered.

Describe the solution you'd like
The system distro to have USB gamepad support enabled by default.

Describe alternatives you've considered
It is possible to modify the system distro kernel to enable USB gamepad support, however this is a rather large maintenance burden for such a dinky little feature since you have to continuously keep the custom kernel up to date.

@Aerocatia
Copy link
Author

Aerocatia commented Nov 23, 2021

Actually I am pretty sure this is tied to the Linux HID subsystem so I am sure there are more serious potential use cases by having this enabled. It would apply for any USB input device.

@musantos
Copy link

I have been facing the same.
I have switched my PC to Win 11 in order to install and Run some ROS GUI apps, which is not possible in Win 10 and some heat issues on Ubuntu.
But I need the USB to control the Robot and I could not make my Joypad work.

@SCIEN-00
Copy link

SCIEN-00 commented Oct 14, 2022

I got xbox controller attached to wsl2 using usbipd and it appears under /dev/bus/usb/00x/ devices but not under /dev/input/jsx device. Is it some driver issue or what?
I see that there is xpad driver in wsl kernel https://github.com/microsoft/WSL2-Linux-Kernel/blob/master/drivers/input/joystick/xpad.c. How should I make that device under dev/bus/usb/00x to use this xpad driver?

@eyal-friedman
Copy link

Have the same problem.
Did you figure it out?

@kotC9
Copy link

kotC9 commented Nov 27, 2022

Hello, i temporarily solved missing xpad by rebuilding kernel:

  1. clone your kernel version from this
  2. replace Microsoft/config-wsl with config-wsl from archive
    kernel-xpad.zip
  3. make KCONFIG_CONFIG=Microsoft/config-wsl

if u don't want to build kernel yourself:

  1. wsl --shutdown
  2. add in your .wslconfig line kernel=C:\\Path\\To\\bzImage with path to bzImage from archive.
  3. PROFIT

i using kernel 5.10.102.1 and add to config these lines:

CONFIG_LOCALVERSION="-kotc9"
CONFIG_INPUT_JOYDEV=y
CONFIG_INPUT_EVDEV=y
CONFIG_INPUT_JOYSTICK=y
CONFIG_JOYSTICK_ANALOG=y
CONFIG_JOYSTICK_XPAD=y
CONFIG_JOYSTICK_XPAD_FF=y

link that might help:
https://microhobby.com.br/blog/2019/09/21/compiling-your-own-linux-kernel-for-windows-wsl2/

hope this helps you too!

изображение

kernel-xpad.zip

@fenix00853
Copy link

fenix00853 commented Dec 7, 2022

Add kernel-parport please.
I don't want to build kernel.
Thank you.

@billyliuschill
Copy link

billyliuschill commented Dec 15, 2022

Hello, i temporarily solved missing xpad by rebuilding kernel:

  1. clone your kernel version from this
  2. replace Microsoft/config-wsl with config-wsl from archive
    kernel-xpad.zip
  3. make KCONFIG_CONFIG=Microsoft/config-wsl

if u don't want to build kernel yourself:

  1. wsl --shutdown
  2. add in your .wslconfig line kernel=C:\\Path\\To\\bzImage with path to bzImage from archive.
  3. PROFIT

i using kernel 5.10.102.1 and add to config these lines:

CONFIG_LOCALVERSION="-kotc9"
CONFIG_INPUT_JOYDEV=y
CONFIG_INPUT_EVDEV=y
CONFIG_INPUT_JOYSTICK=y
CONFIG_JOYSTICK_ANALOG=y
CONFIG_JOYSTICK_XPAD=y
CONFIG_JOYSTICK_XPAD_FF=y

link that might help: https://microhobby.com.br/blog/2019/09/21/compiling-your-own-linux-kernel-for-windows-wsl2/

hope this helps you too!

изображение

kernel-xpad.zip

This solution worked great for me, thanks for the help!

Just to add on a little bit to the solution to get my xbox elite series 1 controller working (wired):

Without the changes to the kernel, my xbox controller would not show up under /dev/input.

I ran lsusb and found the device not present in WSL. To get the device passed from W11 -> Ubuntu (WSL) -> Docker, I enlisted the help of usbipd. Using this, I attached to the device to the usb bus into my WSL instance. You will know it's working when your lsusb output it the same in both docker and WSL.

After that, I ran jstest and commands are showing up just fine. However, for my application, it still wasn't detected. If that's the case, run sudo chmod 777 event0 and sudo chmod 777 js0. Everything starts talking beautifully after that. It was something to do with permission issue on my end after plugging in the device.

@atticusrussell
Copy link

atticusrussell commented Feb 27, 2023

I made the discussed edits to the most recent kernel in this repo.
Feel free to expand upon the explanation I put in the README, or let me know how to improve the repo as a resource via PRs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

8 participants