en-us pt-br

Configuring a Wiimote as a classic gamepad

banner

The Nintendo Wii Remote (aka wiimote) is one of my preferred gamepad to play old console emulators.

Why? Well, it uses bluetooth, probably you already have one (if you had a Wii), and if you hold it in the landscape position, it mimics a 8-bit gamepad. And additionally to the side buttons 1 and 2, it offers buttons like A, B, Home, + and -. Perfect to play NES, Sega Master System, Sega Genesis, NeoGeo and others that do not require more buttons than that.

XWiimote

In the past, Linux (mainly Ubuntu) offered several ways to support wiimote, all using custom event handling: CWiiD, Wiiuse, WiiCan and others.

Some of them are a bit abandoned, and do not rely on Linux event handling.

It’s where XWiimote comes to the rescue. According the official page:

XWiimote is an open-source linux device driver for Nintendo Wii / Wii U Remotes … that tries to supercede cwiid, wiiuse and others by integrating the driver into existing linux infrastructure.

xf86-input-xwiimote

The problem: XWiimote is a raw driver. It doesn’t care about how you want to use the wiimote. I.e: if you want to use the wiimote as a classic gamepad, it’ll not work.

For this purpose, we’ll use xf86-input-xwiimote, which is a X.Org input driver for the wiimote based on the XWiimote.

Install

We can find both programs available in default Ubuntu 16.04 (Xenial) install.

Unfortunatelly, on 14.04 (Trusty) package xwiimote is an old version and xf86-input-xwiimote is not available (because it relies on xwiimote version 2). I tried to compile xwiimote (version 2) and xf86-input-xwiimote, but the later didn’t work (always crashing).

So, if you’re using 16.04 (Xenial) install both with:

sudo apt-get install xwiimote xserver-xorg-input-xwiimote

Configuration

Now we’ll configure the wiimote to fire some keyboard keys while buttons are pressed. This will make it work in every program that supports keyboard as control.

Using sudo (or root) edit /usr/share/X11/xorg.conf.d/60-xorg-xwiimote.conf file, adding all below lines in the Identifier "Nintendo Wii Remote" section:

        Option "MapLeft" "KEY_DOWN"
        Option "MapRight" "KEY_UP"
        Option "MapUp" "KEY_LEFT"
        Option "MapDown" "KEY_RIGHT"
        Option "MapA" "KEY_A"
        Option "MapB" "KEY_B"
        Option "MapPlus" "KEY_EQUAL"
        Option "MapMinus" "KEY_MINUS"
        Option "MapHome" "KEY_ESC"

Save it.

Your 60-xorg-xwiimote.conf file should be now similar to this:

# X11 xorg xf86-input-xwiimote config
# Load correct xwiimote driver for all connected Nintendo Wii Remotes.
# Overwrite previous blacklist.
# We do not load the driver on unsupported extensions. This currently includes
# independent extension like classic-controller and pro-controller. Instead, the
# evdev driver is loaded (there is no way to negate InputClass Match* rules..)

Section "InputClass"
        Identifier "Nintendo Wii Remote"
        MatchProduct "Nintendo Wii Remote"
        MatchDevicePath "/dev/input/event*"
        Option "Ignore" "off"
        Driver "xwiimote"
        Option "MapLeft" "KEY_DOWN"
        Option "MapRight" "KEY_UP"
        Option "MapUp" "KEY_LEFT"
        Option "MapDown" "KEY_RIGHT"
        Option "MapA" "KEY_A"
        Option "MapB" "KEY_B"
        Option "MapPlus" "KEY_EQUAL"
        Option "MapMinus" "KEY_MINUS"
        Option "MapHome" "KEY_ESC"
EndSection

Section "InputClass"
        Identifier "Nintendo Wii Remote Classic Controller Whitelist"
        MatchProduct "Nintendo Wii Remote Classic Controller"
        MatchDevicePath "/dev/input/event*"
        Option "Ignore" "off"
        Driver "evdev"
EndSection

Section "InputClass"
        Identifier "Nintendo Wii Remote Pro Controller Whitelist"
        MatchProduct "Nintendo Wii Remote Pro Controller"
        MatchDevicePath "/dev/input/event*"
        Option "Ignore" "off"
        Driver "evdev"
EndSection

Restart X.org

You’ll need to restart your X.org to get all changes working. Usually in Ubuntu, a logout/login is enough.


Ubuntu 16.04 on Dell Precision M3800

banner

It’s time to install new Ubuntu LTS version, 16.04 Xenial Xerus.

I’ve downloaded the .iso and created a bootable USB stick using the Startup Disk Creator.

Then I’ve restarted M3800 with the USB stick inserted and pressed F12 to select the boot device.

Booting with UEFI

The USB stick created using Startup Disk Creator already supports UEFI, so if you want to use UEFI, you can just add the USB stick in the list of trusted devices, reboot and start the install process (I don’t use UEFI, as Ubuntu is the only operating system installed in my machine).

Booting without UEFI

If BIOS is configured in legacy moeo, after start the installer, you’ll see this message: Failed to load COM32 file menu.c32.

Don’t worry, press Tab and you’ll see options to boot. Type live-install and continue.

In case you get a frozen system after enable wifi during the install process, restart but now don’t enable it during the process.

After Install

Few post install issues:

  • webcam with a too dark image;
  • wifi was not reconnecting after resume from suspend.

Fortunately, all easy to solve.

Webcam with a too dark image

To change brightness and contrast for your webcam, we need to install a tool called guvcview:

sudo apt-get install guvcview

Start guvcview from Dash, and now fix brightness and contrast.

Wifi

To make wifi automatically reconnect after a suspend, I followed this recipe from StackOverflow:

As sudo, create a file name /etc/systemd/system/wifi-resume.service and add the following content:

[Unit]
Description=Local system resume actions
After=suspend.target

[Service]
Type=oneshot
ExecStart=/bin/systemctl restart network-manager.service

[Install]
WantedBy=suspend.target

Save. Now enable the service on systemd:

sudo systemctl enable wifi-resume.service

Done!

Additional Drivers

If you want to use binary/proprietary drivers, open Additional Drivers on Dash:

Additional Drivers on Dash

Then enable drivers for NVidia Quadro and the firmware for the Intel CPU:

Additional Drivers

Click on Apply Changes and restart.


Updating BIOS with Ubuntu

banner

One of the first things I do after get a new machine is to verify in the manufacturers site for new BIOS versions. In case of Dell, the BIOS updates are .exe files, and they run under Microsoft DOS.

So, the question is: how to update BIOS using Ubuntu?

Answer is: using a pendrive with FreeDOS.

In the Wiki do Ubuntu, there are other procedures to use, but this is the one which is closest to the original procedure (update the BIOS under DOS).

Before start, we need to discover which is the service tag for your machine, in order to use it to get check for newer BIOS versions.

Obtaining BIOS version and Service Tag

The service tag is saved in your BIOS. If you want to query it under Linux, you’ll need to install the dmidecode program, which is a program to return several BIOS values, including the version too.

Install with:

sudo apt-get install dmidecode

Then, query the BIOS version with:

sudo dmidecode -s bios-version

And finally, query the service tag with:

sudo dmidecode -s system-serial-number

Looking for newer BIOS versions

Now with your service tag in hands, go to Dell support website, then find the Enter a Service Tag or Express Service Code section. Insert your service tag and press Enter to submit.

At the Product Support page, click on Drivers & Downloads.

Then click on Find it myself tab. Click to expand BIOS section and then download the file clicking on Download file.

BIOS Download

Save the file. If compressed, extract it.

Download FreeDOS

In http://www.chtaube.eu/computers/freedos/bootable-usb/#download site, there are 3 FreeDOS images: one to boot over the network; other for pendrive with storage between 256MB and 2GB; the latest one to sticks larger than 2GB.

FreeDOS Download

I’ve downloaded FreeDOS-1.1-memstick-2-2048M.img.bz2 file, as my USB stick has more than 2GB.

Of course, download the one according the size of your pendrive.

Now extract FreeDOS.

Creating a bootable FreeDOS USB flash drive

Now insert your stick in the USB port. And open the Startup Disk Creator:

Startup Disk Creator on Dash

Go to Source disc image (.iso) or CD section and:

  1. click on the Other button
  2. in the file selection dialog, filter by Disk Images
  3. select FreeDOS-1.1-memstick-2-2048M.img file

Now in the Disk to Use section at the bottom, select your stick (in case it’s not automatically selected).

Click on the Make Startup Disk.

Startup Disk Creator ready

This will take a while. At the end of the process, it’ll ask your password to create the boot section in the USB stick.

After finish the process, it’ll display a success dialog and close.

Now, safely remove the USB pendrive.

Copy the new BIOS to the USB flash drive

Plug your USB in your computer again, and now copy the new BIOS to it. Make sure you’re copying the extracted file (the one with .exe extension).

After make sure the file was copied, it’s time to restart your machine.

Updating BIOS

After restart your machine (and make sure BIOS is configured to boot using USB drive), syslinux will display few boot options (fdos, odin, memtest). Just press Enter to load the default option (fdos).

Next, you’ll see the following FreeDOS options:

1 - Load FreeDOS with JEMMEX, no EMS (most UMBs), max RAM free
2 - Load FreeDOS with EMM386 (Expanded Memory) and SHARE loaded
3 - Load FreeDOS including XMGR XMS-memory driver
4 - Load FreeDOS without drivers

Select option 4 - Load FreeDOS without drivers.

Now check the files inside the flash drive, using the dir command:

dir

And the newest BIOS must be displayed in the list, with the .EXE extension.

Type the full file name and press Enter: the update process will begin.

Wait until it finishes (it’ll go back to FreeDOS). Done, you can remove the USB stick and restart your machine.


See all