Hack and / - Wiimote Control
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 rearrange 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.
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 keys to the Nunchuck and Classic Controller attachments, so all I had to do for it to work with snes9x was create a new configuration file that mapped all the keys. Here is my buttons-snes9x file:
Wiimote.A = KEY_X Wiimote.B = KEY_S 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_ESC Wiimote.1 = KEY_C Wiimote.2 = KEY_D Nunchuk.C = BTN_LEFT Nunchuk.Z = BTN_RIGHT Classic.Up = KEY_UP Classic.Down = KEY_DOWN Classic.Left = KEY_LEFT Classic.Right = KEY_RIGHT Classic.Minus = KEY_SPACE Classic.Plus = KEY_ENTER Classic.Home = KEY_ESC Classic.A = KEY_D Classic.B = KEY_C Classic.X = KEY_S Classic.Y = KEY_X #Classic.ZL = #Classic.ZR = Classic.L = KEY_A Classic.R = KEY_Z
Even though I planned to use the Classic Controller, I tried to map as many of the regular Wiimote keys to buttons that made sense, so you could potentially play at least some games with the regular Wiimote as well. If you notice, I also left bindings for the special ZL and ZR keys blank, so you could bind them to extra keys.
One of the best game system emulators out there is MAME. MAME emulates classic arcade games, and there are many guides out there (including in Linux Journal itself) on how to use MAME to create your own arcade cabinet. Well, I haven't cleared away the time for that project yet, but I did want to use my Wiimote and Classic Controller attachment for MAME games. MAME has a large number of bindings (press Tab in MAME to see a list), so it was difficult to choose which to bind to the extra keys. Here is a sample buttons-xmame file I created:
Wiimote.A = KEY_P Wiimote.B = KEY_5 Wiimote.Up = KEY_LEFT Wiimote.Down = KEY_RIGHT Wiimote.Left = KEY_DOWN Wiimote.Right = KEY_UP Wiimote.Minus = KEY_2 Wiimote.Plus = KEY_1 Wiimote.Home = KEY_F3 Wiimote.1 = KEY_LEFTCTRL Wiimote.2 = KEY_LEFTALT Nunchuk.C = BTN_LEFT Nunchuk.Z = BTN_RIGHT Classic.Up = KEY_UP Classic.Down = KEY_DOWN Classic.Left = KEY_LEFT Classic.Right = KEY_RIGHT Classic.Minus = KEY_2 Classic.Plus = KEY_1 Classic.Home = KEY_F3 Classic.A = KEY_LEFTCTRL Classic.B = KEY_LEFTALT Classic.X = KEY_SPACE Classic.Y = KEY_LEFTSHIFT Classic.ZL = KEY_5 Classic.ZR = KEY_P Classic.L = KEY_Z Classic.R = KEY_X
In addition to the standard bindings you might expect, the home key resets MAME; the plus key selects single player; minus selects two players; ZL on the Classic Controller and B on the Wiimote insert a coin; and ZR on the Classic Controller and A on the Wiimote pause. These are by no means perfect bindings, so I recommend you experiment with different keys that work better for you.
The possibilities with wminput go much further than what I've presented here. There also are configuration files that use the analog joystick inputs on the Classic Controller, the IR sensors on the Wiimote and the accelerometers on the Nunchuck. Wminput isn't just a handy way to play video games on your laptop or desktop. The fact that the connection to the computer is wireless makes the Wiimote a great gaming input for a MythTV client or other computer connected to your PC. As for me, I think I'll be spending a few more days trying to beat this impossible Super Mario Brothers hack that has been floating around the Internet.
Kyle Rankin is a Senior Systems Administrator in the San Francisco Bay Area and the author of a number of books, including Knoppix Hacks and Ubuntu Hacks for O'Reilly Media. He is currently the president of the North Bay Linux Users' Group.
Kyle Rankin is a systems architect; and the author of DevOps Troubleshooting, The Official Ubuntu Server Book, Knoppix Hacks, Knoppix Pocket Reference, Linux Multimedia Hacks, and Ubuntu Hacks.
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Sponsored by AMD
Built-in forensics, incident response, and security with Red Hat Enterprise Linux 6
Every security policy provides guidance and requirements for ensuring adequate protection of information and data, as well as high-level technical and administrative security requirements for a system in a given environment. Traditionally, providing security for a system focuses on the confidentiality of the information on it. However, protecting the data integrity and system and data availability is just as important. For example, when processing United States intelligence information, there are three attributes that require protection: confidentiality, integrity, and availability.
Learn more about catching the bad guy in this free white paper.
Sponsored by DLT Solutions
| Designing Electronics with Linux | May 22, 2013 |
| Dynamic DNS—an Object Lesson in Problem Solving | May 21, 2013 |
| Using Salt Stack and Vagrant for Drupal Development | May 20, 2013 |
| Making Linux and Android Get Along (It's Not as Hard as It Sounds) | May 16, 2013 |
| Drupal Is a Framework: Why Everyone Needs to Understand This | May 15, 2013 |
| Home, My Backup Data Center | May 13, 2013 |
- New Products
- Linux Systems Administrator
- Senior Perl Developer
- Technical Support Rep
- UX Designer
- Web & UI Developer (JavaScript & j Query)
- Designing Electronics with Linux
- Dynamic DNS—an Object Lesson in Problem Solving
- Making Linux and Android Get Along (It's Not as Hard as It Sounds)
- Using Salt Stack and Vagrant for Drupal Development
- Reply to comment | Linux Journal
6 hours 33 sec ago - Nice article, thanks for the
16 hours 41 min ago - I once had a better way I
22 hours 27 min ago - Not only you I too assumed
22 hours 44 min ago - another very interesting
1 day 37 min ago - Reply to comment | Linux Journal
1 day 2 hours ago - Reply to comment | Linux Journal
1 day 9 hours ago - Reply to comment | Linux Journal
1 day 9 hours ago - Favorite (and easily brute-forced) pw's
1 day 11 hours ago - Have you tried Boxen? It's a
1 day 17 hours ago
Enter to Win an Adafruit Pi Cobbler Breakout Kit for Raspberry Pi

It's Raspberry Pi month at Linux Journal. Each week in May, Adafruit will be giving away a Pi-related prize to a lucky, randomly drawn LJ reader. Winners will be announced weekly.
Fill out the fields below to enter to win this week's prize-- a Pi Cobbler Breakout Kit for Raspberry Pi.
Congratulations to our winners so far:
- 5-8-13, Pi Starter Pack: Jack Davis
- 5-15-13, Pi Model B 512MB RAM: Patrick Dunn
- 5-21-13, Prototyping Pi Plate Kit: Philip Kirby
- Next winner announced on 5-27-13!
Featured Jobs
| Linux Systems Administrator | Houston and Austin, Texas | Host Gator |
| Senior Perl Developer | Austin, Texas | Host Gator |
| Technical Support Rep | Houston and Austin, Texas | Host Gator |
| UX Designer | Austin, Texas | Host Gator |
| Web & UI Developer (JavaScript & j Query) | Austin, Texas | Host Gator |
Free Webinar: Hadoop
How to Build an Optimal Hadoop Cluster to Store and Maintain Unlimited Amounts of Data Using Microservers
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Some of key questions to be discussed are:
- What is the “typical” Hadoop cluster and what should be installed on the different machine types?
- Why should you consider the typical workload patterns when making your hardware decisions?
- Are all microservers created equal for Hadoop deployments?
- How do I plan for expansion if I require more compute, memory, storage or networking?




Comments
Switching?
Okay, so you've got a script for fceu, one for snes9x, etc. That's cool, but it seems that you have to restart wminput manually every time you want to switch config files, which really inhibits its usefulness as a remote control for an HTPC. I'd like to be able to use my remote to select an NES game in my MythGame list, then turn it sideways and use it as an NES controller -- without resorting to hacks like, say, setting the Up arrow key to work as Left on the NES D-Pad, or setting up a shell script that restarts wminput with a different config file and then launches the program (but requires me to re-pair).
Doesn't look like there are any plugins as yet to let the program reload the config file when a certain program is launched, but please correct me if I'm wrong.
Key Combo?
is it possible to use key combinations for this? CTRL+ALT+LEFT ARROW
And what about Slackware?
Did anyone think of trying this on Slackware? Either 11.0 or 12.1 or Current.
Re:Did anyone think of trying this on Slackware? Either 11.0 or
Well it works after remembering to reset the BT dongle. Slackware is stil the best OS for the enterprise.
Ubuntu Intrepid
Works great on Ubuntu Hardy, but has anyone got it to work on Ubuntu Intrepid?
something to do with uinput version...?
Gens Control
I don't even have a Wii and I had to buy one of these controllers! They are totally awesome!
Though this may be sacrilegious, in addition to the NES emulators I use mine with the Sega emulator Gens. Here is my configuration!
# Wiimote Gens
Wiimote.A = KEY_F5
Wiimote.B = KEY_F5
Wiimote.Up = KEY_LEFT
Wiimote.Down = KEY_RIGHT
Wiimote.Left = KEY_DOWN
Wiimote.Right = KEY_UP
Wiimote.Minus = KEY_TAB
Wiimote.Plus = KEY_ESC
Wiimote.Home = KEY_ENTER
Wiimote.1 = KEY_A
Wiimote.2 = KEY_S
Thanks for the article.