Mapping Wiimote tilt as controller input
-
Wiimote Tilt
Wiimotes are a whimsical way to add a bit of fun to retro nostalgia, but on a Linux box it can be hit or miss for plenty of users to configure correctly.
On Windows you have touchmote which makes it a breeze to configure your Wiimotes and accessories alike by mapping them to keys on your keyboard or to an xinput gamepad. This allows Windows to expose your Wiimote including tilt functions to almost any emulator as if it were a keyboard, controller, or lightgun. You could play Gamecube/GBA Monkey Ball by tilting your Wiimote in hand, or jump into a PSX emulator and race GTR with a Wiimote steering wheel.
Unfortunately it doesn't work that easily for Raspberry Pi - RetroPie users or Linux users as a whole. I also may be missing a crucial piece of documentation telling me how this is done rendering this post moo 🐮.If you follow retropie docs for setting up your Wiimotes using
method 1
you will undoubtedly have a controller that connects with no problems and you can map it in EmulationStation with both vertical or horizontal layouts with your choice of button mapping. Great 🙂, we have the D-pad and buttons all working with hotkeys set correctly and able to set per ROM key mappings by creating aRetroPie/roms/psx/game-title.bin.cfg
.As far as I can tell no Wiimote's tilt output can be mapped to a key input in the EmulationStation GUI controller setup, or manually entered into a
input.cfg
? <-- "Is this correct?"I would like to use this post to start a conversation around how to solve the issue of how to configure a Wiimote's tilt output as RetroPie controller input . Once resolved, I will create a new post (referencing this post ) with a clear and definitive guide on how to configure a Wiimote with tilt for RetroPie.
("
For the sake of finding a solution to mapping a Wiimote's tilt as controller input let's assume the controller is a OEM WiimoteNintendo RVL-CNT-01
. Also, the system has a supported bluetooth adapter that allows for successful connection of controllers. Seehttp://elinux.org/RPi_USB_Bluetooth_adapters#Working_Bluetooth_adapters
if needed.")
Clean Slate
Will be used as a shorthand to describe a "Reset" of the system where bluetooth is
on
and working, no Wiimotes have been connected, and you have a clean install of RetroPie currently installed.cd RetroPie-Setup/ sudo ./retropie_setup.sh
RetroPie-Setup script (option
U
) first. After that's done, (OptionI
) and choose Binary-based installation.
Setting It Up
Before beginning, I came across
3
ways most people were connecting Wiimotes to RetroPie. Well actually connecting Wiimotes to the Linux system for RetroPie to use.Testing Tools
joystick
is a package in the Debian and Ubuntu universe repository and is a set of testing and calibration tools for joysticks which include:evdev-joystick
- joystick calibration toolffcfstress
- force-feedback stress testffmvforce
- force-feedback orientation testffset
- force-feedback configuration toolfftest
- general force-feedback testjstest
- joystick test cli utilityjscal
- joystick calibration tool
There is a GTK application for testing buttons and axises on a joystick, as well as recaliberating devices to fine tune them and remove deadzones called
jstest-gtk
. It is also available in the Debian and Ubuntu universe repository. Find out more on their gitlab pagehttps://jstest-gtk.gitlab.io
.
Clean Slate
First
Use
method 1
directly from RetroPie Docs.This method requires you to install
bluetooth vorbis-tools python-cwiid wminput
. The two packages that stand out here arepython-cwiid
andwminput
.python-cwiid
- CWiid Wiimote Interface provides:libcwiid
- wiimote API.cwiid module
- python interface to libcwiid.
wminput
- an event/joystick/mouse driver for the wiimote."CWiid is a userspace driver along with various applications implementing event drivers, multiple wiimote connectivity, gesture recognition, and other Wiimote-based functionality."
With these basic components and a udev rule allowing non-root interaction with the input device you are able to connect the remote and setup the contoller in EmulationStation. If you open
jstest-gtk
you can observe your system registering button presses and seeing the input from x-axis and y-axis of the Wiimote.
Your controller now connects to the system and can be configured by EmulationStation's automatic GUI configuration tool and places its snippet ines_input.cfg
.<inputConfig type="joystick" deviceName="Nintendo Wiimote"> <input name="pagedown" type="button" id="5" value="1"/> <input name="start" type="button" id="9" value="1"/> <input name="pageup" type="button" id="4" value="1"/> <input name="up" type="axis" id="1" value="1"/> <input name="a" type="button" id="0" value="1"/> <input name="b" type="button" id="1" value="1"/> <input name="down" type="axis" id="1" value="-1"/> <input name="right" type="axis" id="0" value="1"/> <input name="select" type="button" id="8" value="1"/> <input name="left" type="axis" id="0" value="-1"/> </inputConfig>
You can now easily define per ROM controller configurations by placing a
~/RetroPie/roms/psx/game-name.bin.cfg
with vertical or horizontal layouts and your choice of button configurations.First Conclusion
I have installed the needed drivers to use the Wiimote, a udev rule is in place giving your user permssion to manage the controller, and
jstest-gtk
can see the remote and events from your x-axis/y-axis.
With all of this working how come the tilt output can't be mapped to a controller input?. Am I missing something?
Clean Slate
Second
The second option is to use MoltenGamepad.
MoltenGamepad creates virtual game pad devices, known as output slots, and they are read by your other software i.e. emulators. To be fair I didn't give this route a fair enough shake other than installing and attempting to configure a controller. This uses the kernel driver, not a Wiimote library like cwiid. If using MoltenGamepad with wiimotes, do not use cwiid and wminput.
If you compile and run MoltenGamepad it is a bare bones service with Wiimote support and that is the route I took. I was able to once again get full D-pad support and buttons were working, no tilt output could be registered with EmulationStation (even with manual editing of es_input.cfg). Within jstest-gtk I can see the registering of x/y-axis outputs. 💢 "Why come? 💥bangs head "Notes:
MoltenGamepad has different "modes" that can be configured, and the install scripts provided in the repository have two viable ways to configure it:systemuser
- Creates a gamepad user with only required permissions to manage game pads. Your user will only ever see the game pads exposed by MoltenGamepad.singleuser
- When MoltenGamepad is stopped the system falls back to default input control. When running all controller devices become owned by your user account.
("
As I am writing this post my feeling is that this should have been sufficient to expose x/y-axis outputs. Maybe I am missing a subtl configuration change?")
Second Conclusion
I was able to get the service running and have proper permissions over the game pad, and created a
output slot
of the controller which I was able to map in EmulationStation. Maybe I didn't grasp MoltenGamepad and should take a run at this tool again.
Clean Slate
Third
The third option xwiimote does feel like a more complete solution for managing Wiimotes. Once I had this installed and connected the device over bluetooth I was able to immediately control my desktop cursor with tilting the Wiimote on the x/y-axis.
This method requires you to install
libncurses5-dev dh-autoreconf
, and compile the tool yourself.git clone https://github.com/dvdhrm/xwiimote.git cd xwiimote/ ./configure --prefix=/usr sudo ./autogen.sh --prefix=/usr
xwiimote
contains tools and libraries which work together with the official hid-wiimote
kernel driver:libxwiimote.so
- A userspace library which helps accessing connected Wii
Remotes in the system.xwiishow
- A test application which lists all connected Wii Remotes.50-xorg-fix-xwiimote.conf
- "It adds all Wii Remotes to the input blacklist of the X-server. This is needed since the raw Wii Remote kernel interface is useless (even irritating) to the X-server. Instead the xf86-input-xwiimote driver should be used."
("
Getting desktop cursor control with the xorg correction was nice and being able to ONCE AGAIN get D-pad and button support makes it not a total loss. 🦧 scratch head & under arm")
Third Conclusion
Successfully connected the Wiimotes but still the same outcome. I am feeling very confused and like it is a glaring oversight on my part. Why can I not get these axeses to work with my emulators.
Phew! 😤
Okay, so what am I missing?
-
retropie 4b 8gb
sd image made from retropie.org
retropie 4.7***I am using an oem nintendo wii sensor bar that was modded to work in a standard usb A ports and NOT a Dolphin bar. This was done by cutting off the wii proprietary connector and soldering the wires into a usb A connector as well as removing 4 LEDs out of ten to bring the voltage down to under 5v. It works perfectly fine for wiimote tracking.
Almost all the guide I see for using wiimotes in lightgun games such as duck hunt use a dolphin bar and not a standard wii sensor bar. why am i using an oem sensor bar? because the dolphin bar went way up in price after the tariff war with china, and I have quite a few oem wii sensor bars so why not.
Have you figured this out yet? Using wminput method I was able to get the wiimote to work as a mouse tilt wiimote up and down side to side left mouse button mapped to wiimote button b and right mouse button mapped to wiimote button a. the other buttons and d pad on the wiimote are mapped to keyboard keys. No thanx to the guide I followed which you referenced here with the 3 different methods on it.
You have to read up on the wminput github page as to how to get the wiimote to map as a mouse/keybpard vs a joystick. You need to use Plugin.acc.X = REL_X
Plugin.acc.Y = REL_Y and map at least a left mouse button to a wiimote button. This turns the wiimote into a mouse/keyboard configuration and this works in lxde in the Retropie menu and in the retroarch menu in game but wont work as a controller or mouse to use in games such as duck hunt.I could also use the motion/tilt as a joystick input using Plugin.ir_ptr.X = ~ABS_X and Plugin.ir_ptr.Y = ~ABS_Y in the wii button mapping config file. This works in retropie menu and in the retorarch menu as well as being able to somewhat control a game in an emulator BUT still doesnt work as a pointer or mouse in duck hunt. So you still can't use it as a shooting device.
I have tried a couple different new emulators along with different configurations in retroarch to try to get this wiimote to work as a mouse in the duck hunt game. It works fine everywhere else as mentioned but not in the game. This is so frustrating.
Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.
Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.