Hack and / - Wii Will Rock Linux
In my August 2008 column, I wrote about how to use a Wiimote from a Nintendo Wii on a Linux system as a general-purpose wireless joystick. In that column, I covered how to bind use buttons not only on the Wiimote, but also on the Nunchuck and Classic Controller, so that you could use them with a number of different video game emulators. Well, since that column, Rock Band for the Wii was released, and with it three extra peripherals: a wireless guitar, a microphone and a drum set.
Everyone knows that only old people play real guitars, so I couldn't pass up the opportunity to rock out with an entire band of plastic instruments on my Wii. I hadn't read too much beforehand about the instruments that came with Wii's Rock Band, so when I unpacked everything, I was surprised to note that all three instruments were connected to the Wii via USB. That left me with only one question, do these instruments work in Linux?
It turns out that not only do all three Rock Band instruments work in Linux, they also all work with very little extra effort. In this column, I describe how to configure Linux to see these instruments and highlight some applications you can use them with.
Probably the simplest instrument to get working with Linux was the microphone. The moment I plugged it in, I got dmesg output that identified it:
[ 188.006918] usb 1-1: new full speed USB device using uhci_hcd and address 2 [ 188.132102] usb 1-1: configuration #1 chosen from 1 choice [ 188.474088] usbcore: registered new interface driver snd-usb-audio
I then fired up Audacity, one of my favorite sound recording programs, to see if the microphone would work. By default, Audacity was set to my system microphone, so I clicked Edit→Preferences, and under the recording section of the Audio I/O window I chose ALSA: Logitech USB Microphone: USB Audio from the Recording Device drop-down menu. I also changed it to be a Mono device.
After I clicked OK to accept my changes, I clicked the big red Record button on the main Audacity window and started talking. I was able to see my voice in the output immediately, and once I clicked the Stop button and played it back, I definitely was able to hear myself.
Considering how easy it was to use the microphone, I wondered what Linux would make of the wireless guitar. It appeared to connect a lot like a wireless mouse or keyboard with a small USB dongle that had a connect button you could use to sync with the wireless device. When I connected the dongle, I could see in the dmesg output that my Ubuntu Hardy install had detected the device as some sort of USB Human Interface Device (HID):
[ 775.322361] usb 1-1: new full speed USB device using uhci_hcd and address 3 [ 775.369009] usb 1-1: configuration #1 chosen from 1 choice [ 775.525791] usbcore: registered new interface driver hiddev [ 775.531822] input: Licensed by Nintendo of America Harmonix Guitar Controller for Nintendo Wii as /devices/pci0000:00/0000:00:1d.0/usb1/1-1/ ↪1-1:1.0/input/input10 [ 775.545411] input,hidraw0: USB HID v1.11 Gamepad [Licensed by Nintendo of America Harmonix Guitar Controller for Nintendo Wii] on usb-0000:00:1d.0-1 [ 775.545444] usbcore: registered new interface driver usbhid [ 775.545451] /build/buildd/linux-2.6.24/drivers/hid/ ↪usbhid/hid-core.c: v2.6:USB HID core driver
It appeared like a new gamepad device had been installed under /dev/input/js0, so I used the useful jstest utility (packaged by a number of distributions) to test whether the buttons on the guitar generated events. To use jstest, simply execute the program with the joystick device to test as an argument (in my case, /dev/input/js0). Each time a joystick event is registered, the output in the terminal updates. The four lines shown in Figure 2 are examples of the output when I pressed and released the green and red buttons on the guitar, respectively.
If you compare the lines, you can see that the green button corresponded to button 1, and the red button corresponded to button 2. Because the guitar interfaces directly with Linux like a regular joystick device, that means I can use its buttons with any game that supports joysticks.
Of course, probably the best game for the Rock Band guitar on Linux is Frets on Fire. Frets on Fire is an open-source guitar game written in Python and packaged for a number of distributions and operating systems. By default, it is designed to be used with your regular keyboard held in your hands somewhat like a guitar. The F1–F5 keys are frets on the guitar, and the Enter key can be used to strum. That works okay, but it certainly is nicer to use a guitar intended for the purpose, and sure enough, Frets on Fire supports remapping the default keyboard keys to joystick buttons.
To configure Frets on Fire for my guitar, all I needed to do was start the game, go into Settings and then modify the key settings. I just went through each key configured for the game, selected it, and then when it asked me to press a new key to set it to, I chose the corresponding key on the guitar. After you change the keys in this method, you will notice that you can navigate the Frets on Fire game completely from your guitar. You can strum up or down to move through the menus and use the green button to make selections.
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.
|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|
- RSS Feeds
- Dynamic DNS—an Object Lesson in Problem Solving
- Making Linux and Android Get Along (It's Not as Hard as It Sounds)
- Designing Electronics with Linux
- Using Salt Stack and Vagrant for Drupal Development
- New Products
- A Topic for Discussion - Open Source Feature-Richness?
- Drupal Is a Framework: Why Everyone Needs to Understand This
- Validate an E-Mail Address with PHP, the Right Way
- What's the tweeting protocol?
- Kernel Problem
9 hours 24 min ago
- BASH script to log IPs on public web server
13 hours 51 min ago
17 hours 27 min ago
- Reply to comment | Linux Journal
18 hours 6 sec ago
- All the articles you talked
20 hours 23 min ago
- All the articles you talked
20 hours 26 min ago
- All the articles you talked
20 hours 28 min ago
1 day 52 min ago
- Keeping track of IP address
1 day 2 hours ago
- Roll your own dynamic dns
1 day 7 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!
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?