A key part of the games is obviously being able to control characters, ships, bats, tanks, cars, or other sprites.
The Nintendo WII Controller is great for gaming, especially when using old school emulators and Internet Arcade games from the Internet Archives. The Nintendo WII was a very popular game console when it was first released and for many people, it now sits gathering dust next to the DVD player. Instead of buying a dedicated game controller to play on your Linux machine, why not use the WII Remote?
Of course, the WII controller isn’t the only controller you’ll probably have to wait for and I’ll soon be writing guides for the XBOX controllers and even the OUYA controller.
One advantage of the WII controller is the dpad. It works much better for old school games than the XBOX controller because it’s not as sensitive.
Unfortunately for those of you who are afraid of the command line, there is a lot of terminal work to be done, but fear not as I will do my best to walk you through everything you need to do to get the WII controller working.
Install the Linux software needed to use a Wii Remote
The apps you need to install are as follows:
- lswm
- wminput
- libcwiid1
This guide assumes that you are using a Debian-based distribution such as Debian, Mint, Ubuntu, etc. If you are using an RPM-based distribution, use YUM or a similar tool to get these applications.
Type the following to get the requests:
sudo apt-get install lswm wminput libcwiid1
Find the Bluetooth address of your Wii Remote
The only reason to install lswm is to get the bluetooth address of your WII controller.
Inside the terminal type the following:
lswm
The following will appear on the screen:
» Put Wiimotes in discoverable mode now (press 1+2)….»
Do as the message asks and hold down buttons 1 and 2 on the WII controller at the same time.
If you’ve done it correctly, a set of numbers and letters should appear like this:
00:1B:7A:4F:61:C4
If the letters and numbers do not appear and you are back at the command line, run lswm again and try pressing 1 and 2 together again. Basically, keep trying until it works.
Configure the game controller
To use the WII Controller as a gamepad you will need to set up a configuration file to map the buttons to the keys.
Type the following in the terminal window:
sudo nano /etc/cwiid/wminput/gamepad
This file should already have some text in it along the lines of this:
# gameport
Classic.Dpad.X = ABS_X
>.Classic.Dpad.Y = ABS_Y
>.A = BTN_A
You will need to add more lines to this file to make the gamepad work as you want.
The basic format of each line of the file is the WII Controller button on the left and the keyboard button on the right.
For example:
Wiimote.up = KEY_UP
The above command maps the up button on the WII remote to the up arrow on the keyboard.
Here’s a quick tip. The Wii Remote is usually on its side when you play, and therefore the Wii Remote’s up arrow has to map to the keyboard’s left arrow.
At the end of this article, I’m going to list all possible WII mappings and a number of sensible keyboard mappings.
For now though, here’s a quick and simple set of mappings:
Wiimote.up = KEY_LEFT
Wiimote.Down = KEY_RIGHT
Wiimote.Left = KEY_DOWN
Wiimote.Right = KEY_UP
Wiimote.1 = KEY_SPACE
Wiimote.2 = KEY_LEFTCTRL
Wiimote.A = KEY_LEFTALT
Wiimote.B = KEY_RIGHTCTRL
Wiimote.Plus = KEY_LEFTSHIFT
The above maps the left arrow key on the keyboard to the up button on the WII controller, the right key to the down button, the down arrow to the left button, the up arrow to the right button, the space bar to the button 1, left CTRL key to button 2, left ALT key to button A, right CTRL key to button B, and left shift key to Plus button.
If you are using retro arcade games from the internet archive they will usually tell you which keys need to be mapped. You can have different gamepad files for different games so that you can use the WII keyboard settings for each game.
If you are using emulators for older game consoles like Sinclair Spectrum, Commodore 64, Commodore Amiga and Atari ST, games often allow you to remap keys and thus you can map game keys to your gamepad file.
For more modern games they often allow the use of the mouse to control them or even the keys so you can set your gamepad file to match the keys needed to play the games.
To save the gamepad file press CTRL and O at the same time. Press CTRL and X to exit nano.
connect controller
To connect the controller to use the gamepad file, run the following command:
sudo wminput -c /etc/cwiid/wminput/gamepad
You will be prompted to press keys 1 + 2 at the same time to pair the controller with your computer.
The word “ready” will appear if your connection has been successful.
Now all you have to do is start the game you want to play.
Enjoy!!!
Appendix A – Possible WII Remote Buttons
The following table shows all the buttons on the WII remote that can be configured in the gamepad file:
- wiimote.up
- wiimote.down
- Wiimote.left
- Wiimote.right
- Wiimote.A
- Wiimote.B
- Wiimote.1
- Wiimote.2
- wiimote.plus
- Wiimote.less
- Wiimote.Home
- Wiimote.Dpad.X
- Wiimote.Dpad.Y
- Nunchuk.C
- Nunchuk.Z
- Nunchuk.Stick.X
- Nunchuk.Stick.Y
- Classic.up
- Classic Down
- Left Classic
- classical right
- Classic.less
- Classic.Plus
- classic house
- Classic.A
- Classic.B
- Classic.X
- Classic.Y
- Classic.ZL
- Classic.ZR
- Classic.L
- Classic.R
- Classic.Dpad.X
- Classic.Dpad.Y
- Classic.LStick.X
- Classic.LStick.Y
- Classic.RStick.X
- Classic.RStick.Y
- Classic.LAnalog
- Classic.RAnalog
Appendix B – Keyboard Assignments
This is a list of sensible keyboard assignments
KeyCodeEscapeKEY_ESC0KEY_01KEY_12KEY_23KEY_34KEY_45KEY_56KEY_67KEY_78KEY_89KEY_9- (minus symbol) KEY_MINUS = (equal to the symbol) KEY_EQUALBackSpaceKEY_BACKSPACETABKEY_TABQKEY_QWKEY_WEKEY_ERKEY_RTKEY_TYKEY_YUKEY_UIKEY_IOKEY_IOKEY_OPKEY_P [KEY_LEFTBRACE] KEY_RBRACEEnterKEY_ENTERIGHT_ENTERCTRL (left side of the keyboard) KEY_LEFTCTRLAKEY_ASKEY_SDKEY_DFKEY_FGKEY_GHKEY_HJKEY_JKKEY_KLKEY_L; (Semi Colon)KEY_SEMICOLON’ (Apostrophe)KEY_APOSTROPHE)#Shift (Left side of the keyboard)KEY_LEFTSHIFTKEY_BACKSLASHZKEY_ZXKEY_XCKEY_CVKEY_VBKEY_BKEY_BNKEY_NMKEY_M, (comma)KEY_COMMA. (full stop)KEY_DOT/ (forward slash)KEY_SLASHShift (right side of keyboardKEY_RIGHTSHIFTALT (left side of keyboard)
KEY_LEFTALT
Space barKEY_SPACECaps LockKEY_CAPSLOCKF1KEY_F1F2F2KEY_F2F3KEY_F3F4F4KEY_F4F5KEY_F5F6KEY_F6F7F7KEY_F7F8KEY_F8F9KEY_F9F10KEY_F10F11KEY_F11KEY_F12KEY_F12Num Kockkey_NUMLOCKShift LockKEY_SHIFTLOCK0 (keyboard) KEY_KP01 (keyboard) KEY_KP12 (keyboard) KEY_KP23 (keyboard) KEY_KP34 (keyboard) KEY_KP45 (keyboard) KEY_KP56 (keyboard) KEY_KP67 (keyboard) KEY_KP78 (keyboard) KEY_KP8 (keyboard) KEY_KP89 (keyboard) KEY_KP9. (keyboard dot)KEY_KPDOT+ (keyboard plus symbol)KEY_KPPLUS- (keyboard plus symbol)KEY_KPPLUS-) (keyboard minus symbol)KEY_KPMINUSLeft ArrowKEY_LEFFRight ArrowRight ArrowUp ArrowKEY_UPDownUp ArrowKEY_DOWNHomeKEY_HOMEInsertKEY_INSERTDeleteKEY_DELETEPage UpKEY_PAGEUPPage DownKEY_PAGEDOWNPotential Nintendo WII Controller to Keyboard Mappings