2

I want to use a Wii Remote as a media controller. There is an X driver that supports this: xf86-input-xwiimote. It maps the arrow keys to normal keyboard arrow keys, A to enter (for activating highlighted buttons), B to space (for playing/pausing media), and some other useful bindings.

How do I do the same thing in Wayland?

What I've found so far:

  • Simply connecting a Wii remote without configuring it is not good enough. I tried on Gnome Wayland, which uses libinput. libinput detected the remote as a keyboard with only arrow keys. The d-pad works as arrow keys, but no other buttons are detected.

  • Wii remotes are natively supported in the kernel, but it's the wrong layer for mapping buttons to desktop input. Individual applications can use Wii remotes and other gamepads for input using the kernel interfaces.

  • This link suggests that X input drivers don't do anything in Wayland, and that Wayland uses libinput instead. It also says that libinput doesn't offer a way to configure devices similar to how devices can be configured in X with .conf files.

  • I've searched for software similar to xf86-input-xwiimote but for Wayland. As far as I can tell it doesn't exist. If someone were to write something similar, how would that work in the Wayland/libinput stack?

3
  • 1
    If you execute libinput debug-events --verbose and press A and B do you see any text appear? If no, then please try the same with evemu-record command: do you see anything?
    – Hi-Angel
    Aug 2 '20 at 8:52
  • @Hi-Angel I do see something! I previously tried xev, which I understand uses xf86-input-libinput when run in XWayland. libinput debug-events shows that the arrow keys are detected as keyboard arrow keys, + and - are detected as keyboard "next" and "previous" keys, and other keys print libinput bug: Event for missing capability CAP_POINTER on device "Nintendo Wii Remote"
    – xordspar0
    Aug 2 '20 at 15:59
  • 1
    Great! About the "bug" print: please test if it's reproducible with latest libinput, and if it is then please report it. Regarding the rest of the keys, I think you can map them now with keyboard settings of your Wayland compositor to whatever action you like. And about xev: it definitely would not be able to print as much as libinput utility, just because events it get have already been preprocessed by libinput (which means, libinput could've skipped some events, like for debounce algorithm, or for touchpad hysteresis, etc)
    – Hi-Angel
    Aug 2 '20 at 18:26
1

I filed a bug with libinput, and the response was that Wii remotes and other joysticks and gamepads are not intended to be supported by libinput at all. As far as I know, this rules out any Wayland-specific solutions.

I've searched for software similar to xf86-input-xwiimote but for Wayland. As far as I can tell it doesn't exist. If someone were to write something similar, how would that work in the Wayland/libinput stack?

Instead of writing something for Wayland and/or libinput, the developer who responded to my bug report suggested writing an adapter that uses the kernel's uinput interface to emulate keyboard events. I found one project that does this for any game controller: MoltenGamepad. A solution like this will work with Wayland, X, or even the Linux VT.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.