Specifications

Wiimote down or up, the mouse will move down or
up, respectively, and if you roll the Wiimote to the left
or right, the mouse will move left or right, respectively.
If you look at /etc/cwiid/wminput/buttons, you can
see the default mappings:
Wiimote.A = BTN_LEFT
Wiimote.B = BTN_RIGHT
Wiimote.Up = KEY_UP
Wiimote.Down = KEY_DOWN
Wiimote.Left = KEY_LEFT
Wiimote.Right = KEY_RIGHT
Wiimote.Minus = KEY_BACK
Wiimote.Plus = KEY_FORWARD
Wiimote.Home = KEY_HOME
Wiimote.1 = KEY_PROG1
Wiimote.2 = KEY_PROG2
...
By default, wminput reads the configuration
listed in /etc/cwiid/wminput/default to get its
mappings. In this file you will see:
#acc_ptr
include buttons
Plugin.acc.X = REL_X
Plugin.acc.Y = REL_Y
Essentially, this file includes the buttons file
for keybindings, and it also enables the use
of the accelerometers for X and Y movements.
The great thing about wminput is that all these
mappings are completely configurable. If you look
in /etc/cwiid/wminput, you should see a number of
other example mappings you can use as inspiration.
You also can store custom mappings in your home
directory under ~/.cwiid/wminput. The button map-
pings use standard names for keys and mouse buttons
that can be found in /usr/include/linux/input.h, but
most of the names are pretty straightforward.
Wiimotes for NES Emulation
One of the first things I wanted to do with my
Wiimote after it was connected was to use it as a
controller for my various game system emulators.
But, before I go any further, if you do use a game
system emulator like nestra, fceu, snes9x or MAME,
be sure you have full rights to use any ROMs you
might have. Make an appointment with your lawyer
for details, but essentially, to play a commercial
ROM, you should own the corresponding game.
With the legal disclaimers aside, the Wiimote
makes a great wireless NES (Nintendo Entertainment
System) controller. All the basic buttons are there,
and all that’s left to do is re-arrange the button
mappings to work with either nestra or fceu NES
emulators. Both programs use slightly different
mappings, so I created files called buttons-fceu and
buttons-nestra and placed them in ~/.cwiid/wminput.
First, buttons-nestra:
Wiimote.A = KEY_0
Wiimote.B = KEY_1
Wiimote.Up = KEY_LEFT
Wiimote.Down = KEY_RIGHT
Wiimote.Left = KEY_DOWN
Wiimote.Right = KEY_UP
Wiimote.Minus = KEY_TAB
Wiimote.Plus = KEY_ENTER
Wiimote.Home = KEY_PAUSE
Wiimote.1 = KEY_Z
Wiimote.2 = KEY_SPACE
After I set the regular NES buttons, I had a few
extra to bind, so I bound the A button to pause
the emulator, the B button to set nestra to normal
speed and the home button to reset the game.
The fceu emulator had completely different
keybindings, so here is my buttons-fceu file:
Wiimote.A = KEY_F7
Wiimote.B = KEY_F5
Wiimote.Up = KEY_A
Wiimote.Down = KEY_S
Wiimote.Left = KEY_Z
Wiimote.Right = KEY_W
Wiimote.Minus = KEY_TAB
Wiimote.Plus = KEY_ENTER
Wiimote.Home = KEY_F10
Wiimote.1 = KEY_KP2
Wiimote.2 = KEY_KP3
In addition to the standard buttons, I bound
the B button to save a game state, A to restore
and home to reset the game.
Now, to use either of these configuration files, all I
need to do is tell wminput to load these files instead:
greenfly@minimus:~/$ wminput -c ~/.cwiid/wminput/buttons-nestra
Put Wiimote in discoverable mode now (press 1+2)...
Ready.
Because wminput sends regular keyboard events,
I don’t have to do anything special to nestra or fceu.
Wiimotes for SNES Emulation
The Wiimote worked great for NES games, but how
about SNES (Super Nintendo) emulation? I actually
purchased a few different SNES games for the
Wii virtual console, and I also bought a Classic
Controller so I would have all the standard SNES
buttons. It turns out that wminput also can bind
www.linuxjournal.com august 2008
| 33