atticusrussell / WSL2-Linux-Kernel

The source for the Linux kernel used in Windows Subsystem for Linux 2 (WSL2) - modified to include xpad to enable controller support

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Game Controllers

Modifications

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

Final steps

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

Notes

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.

Last notes

This particular repo's version of the WSL2 kernel may become out of date, but these instructions should still apply to future kernels.

WSL2-Linux-Kernel OG README

Introduction

The WSL2-Linux-Kernel repo contains the kernel source code and configuration files for the WSL2 kernel.

Reporting Bugs

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.

Feature Requests

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.

Build Instructions

Instructions for building an x86_64 WSL2 kernel with an Ubuntu distribution are as follows:

  1. Install the build dependencies:
    $ sudo apt install build-essential flex bison dwarves libssl-dev libelf-dev
  2. Build the kernel using the WSL2 kernel configuration:
    $ make KCONFIG_CONFIG=Microsoft/config-wsl

Install Instructions

Please see the documentation on the .wslconfig configuration file for information on using a custom built kernel.

About

The source for the Linux kernel used in Windows Subsystem for Linux 2 (WSL2) - modified to include xpad to enable controller support

License:Other


Languages

Language:C 98.2%Language:Assembly 0.9%Language:Shell 0.3%Language:Makefile 0.2%Language:Python 0.1%Language:Perl 0.1%Language:C++ 0.0%Language:Roff 0.0%Language:SmPL 0.0%Language:Yacc 0.0%Language:Lex 0.0%Language:Awk 0.0%Language:UnrealScript 0.0%Language:Gherkin 0.0%Language:Raku 0.0%Language:M4 0.0%Language:Clojure 0.0%Language:XS 0.0%Language:sed 0.0%