Ihis is a fork of the main WSL2 kernel that has been modified in order to use a USB gamepad controller.
I followed instructions from this issue:
I forked the WSL2 kernel repo, cloned it to WSL2, modified a few lines of Microsoft/config-wsl
(a Makefile) and then rebuilt the kernel
make KCONFIG_CONFIG=Microsoft/config-wsl -j15
where the number following j is the number of threads to be used compiling the kernel
I then followed the end of this tutorial to configure windows to use the new kernel for WSL2:
cp vmlinux /mnt/c/Users/<winUserName>/
, where winUserName
is the name of your Windows profile
exit
create a new file called .wslconfig
in your user folder on windows: C:\Users\<winUserName>\.wslconfig
populate the file with the following:
[wsl2]
kernel=C:\\Users\\<winUserName>\\vmlinux
Then, shutdown WSL2, and hopefully next time you start it you will be running your customized kernel
In powershell wsl --shutdown Ubuntu
wait a few seconds, and then boot up WSL2 ubuntu
you can check to see what kernel you are running in bash using uname -r
or something more extra like neofetch
In order to make the gamepad be recognized, in addition to passing through the device to wsl2 using usbipd, I also had to follow these steps to change the device permissions:
sudo chmod 666 /dev/input/js0
when running jstest-gtk
to test out the controller, I have found issues with the mappings of old XBOX controllers, such as a MadCatz. I have found the horizontal axis of the right thumbstick to not work, and to be mapped to the left trigger. I've had this issue on normally installed Ubuntu on a different machine, so I configured jscal and permissions to be changed automatically with udev rules from my repo here.
This particular repo's version of the WSL2 kernel may become out of date, but these instructions should still apply to future kernels.
The WSL2-Linux-Kernel repo contains the kernel source code and configuration files for the WSL2 kernel.
If you discover an issue relating to WSL or the WSL2 kernel, please report it on the WSL GitHub project. It is not possible to report issues on the WSL2-Linux-Kernel project.
If you're able to determine that the bug is present in the upstream Linux kernel, you may want to work directly with the upstream developers. Please note that there are separate processes for reporting a normal bug and a security bug.
Is there a missing feature that you'd like to see? Please request it on the WSL GitHub project.
If you're able and interested in contributing kernel code for your feature request, we encourage you to submit the change upstream.
Instructions for building an x86_64 WSL2 kernel with an Ubuntu distribution are as follows:
- Install the build dependencies:
$ sudo apt install build-essential flex bison dwarves libssl-dev libelf-dev
- Build the kernel using the WSL2 kernel configuration:
$ make KCONFIG_CONFIG=Microsoft/config-wsl
Please see the documentation on the .wslconfig configuration file for information on using a custom built kernel.