Search code examples
linuxlinux-device-driverwindows-subsystem-for-linuxwsl-2

How do I access input devices on WSL2?


When i type cat /dev/input, there is no directory.

When i type cat /proc/bus/input/devices, there is nothing there too.

Cause I used to type these commands on my VMWare Ubuntu, and they work just fine.

I even wrote a simple driver modules as input device just for test, still nothing, but insmoding the module successfully.

So where is my mouse or keyboard devices? Where does the system store them?

BTW I am using WSL2, ubuntu 20.04, and the WSL2 kernel has been compiled by default except some VERSION info, if that matters.


Solution

  • This is an expected behaviour as Windows does not have yet the feature to automatically connect USB devices to other machines, e.g. WSL 2.

    However, there is an open-source project called usbipd-win which allows sharing locally connected USB devices to other machines, including Hyper-V and WSL 2.

    Here is an instruction to connect a USB device to a Linux distribution running on WSL 2.

    Once you connect your device to a Linux on WSL 2, you can check the ID, BUS and Device number with lsubs command.