Tag Archives: wii remote

Linux Wii Remote Driver Updates

Linux Bluetooth HID handling has been slightly broken in the kernel since several years. Reconnecting devices caused a kernel oops nearly every time you tried. Two months ago I sat down and rewrote the HIDP session handling and fixed several bugs. The series now got merged and will be part of linux-3.10. If you still encounter bugs please leave me a note.

Based on this I tried recovering my hid-wiimote work. Since the last time I reverse-engineered Nintendo devices, a lot has happened. The most significant change is probably the release of the Wii U. While the Gamepad is still an ongoing target for r/e, other devices were much easier to get working. Motivated by the new hardware I just got, I finally figured out a reliable way for extension hotplugging. This wasn’t supported in the kernel until now and required nasty polling-techniques to work around race-conditions in the proprietary protocol (who designs asynchronous protocols without protocol barriers?). So I rewrote most of the core device handling and moved the input parsers to a module based infrastructure. This allows us to easily extend the hid-wiimote driver to support new devices that are based on the same protocol.

The series is still pending on the linux-input ML but I hope to get basic hotplugging support into linux-3.10. Further support for the built-in speaker device or the Wii U Pro Controller will hopefully follow with 3.11.

The xwiimote user-space stack has already been updated and I will push the changes this weekend.

Advertisement

xf86-input-xwiimote-0.2

During Google Summer of Code (GSoC) 2011 I developed a Linux kernel driver for the Nintendo Wii Remote. With linux-3.1 release the driver was released with the upstream kernel sources and in a few weeks with linux-3.3 extension-support will be available. I tested the driver for a while now and despite several Bluetooth HIDP bugs I didn’t find any bugs in the hid-wiimote driver. The Bluetooth core is currently undergoing heavy changes and it might take a few weeks until the HIDP driver is stable but it works quite reliable for me.

Although the driver is available in most mainstream distributions the user-space part lagged behind for half a year. So I decided to write an X11 driver that works with the kernel Wii Remote driver. The first step was creating the xwiimote tools which provide a user-space library that allows very easy access to connected Wii Remotes and some debugging tools for connection tests. The library is still under development but the Core, Accelerometer and IR interfaces of Wii Remotes are supported. Based on this library I started the X11 input driver and released the version 0.2 yesterday. It currently only supports button input but the most challenging part was getting the X.Org module right and working around some epoll+O_SETSIG bugs.

Anyway, if you own a Nintendo Wii Remote there’s few steps you need to do to connect your Wii Remote:

  1. Install the xf86-input-xwiimote driver (this requires installing the xwiimote-tools). If you use ArchLinux they are available in the AUR. Make sure the hid-wiimote kernel driver is loaded.
  2. Install the BlueZ Bluetooth stack (this is the official Linux Bluetooth stack). See your distribution for more information.
  3. Start your Bluetooth-Applet of choice (like gnome-bluetooth, blueman or bluez-simple-agent)
  4. Search for nearby devices (device inquiry) and connect to your Wii Remote (it is called Nintendo RVL-CNT-1). If you use bluez-4.96 or newer than everything should work out-of-the box. However, if you are asked for PIN-input then you either use an older version or your Wii Remote is not detected. Simply connect to the device without Pairing/Bonding and everything should work fine. Pairing with Wii Remotes is only supported since bluez-4.96 as the Wii Remote does not follow the standards and needs special BlueZ-plugins.
  5. If your Wii Remote is connected dmesg should show some information about the Wii Remote. You can also use the xwiishow tool from the xwiimote-tools project (See man xwiishow).
  6. Your X-Server should automatically pick up the Wii Remote and load the xwiimote driver. The D-Pad should work as Left/Right/Up/Down keys and the other keys should also have useful mappings. Seeman xorg-xwiimote for configuration options.

That’s all you need to do to enable your Wii Remote as input device. I must admit that the most interesting parts (getting the IR cam and accelerometer as mouse-emulation, sound support, extension support) are still not supported by the X.Org driver. However, the kernel driver does support all this (except sound support) so it shouldn’t be very difficult to add support for these to xf86-input-xwiimote. At least the Linux user-space now has support for Nintendo Wii Remotes based on the hid-wiimote kernel driver and the most requested feature (button/key input) is now available and can be mapped to arbitrary buttons/keys.

If the software is not working on your distribution, please don’t hesitate to fill bug reports at http://github.com/dvdhrm/xwiimote or contact me directly per email.