Using wii remote or classic controller on OUYA

As everyone knows, OUYA supports the Wii and Wii U classic controller, but only on Robert Broglia emulators. They are all those that end in “.emu” in the OUYA store, as in the case of MD.emu.

Well … it turns out that it is not quite like that …

I was looking for something about using the wii classic controller on Ouya and I came across this topic on the Ouya forum: Wiimotes in OUYA

Basically it sends access to OUYA via adb (it can be via network) and as a super user run the command “wminput -d &” and then pair the wiimote and that’s it, wiimote working in OUYA. Strange … but not so much.

Inside the folder “etc” in OUYA we have the file “button” with the following content:

#buttons

'# Wiimote can be extended with various additional controllers.
'# At this point, Nunchuk and Classic Controller are supported.
'# When adding new event codes and/or updating existing event codes,
'# please try to keep codes distinct.
'# Only exception may be allowed for events which are identical in nature.
'# At this point, even d-pads are made to report different codes.
'# All entries (including the commented ones) have been tested.

'# Wiimote Buttons
Wiimote.Up = KEY_UP
Wiimote.Down = KEY_DOWN
Wiimote.Left = KEY_LEFT
Wiimote.Right = KEY_RIGHT
Wiimote.A = KEY_ENTER
Wiimote.B = KEY_BACK
Wiimote.Minus = KEY_SELECT
Wiimote.Plus = KEY_FORWARD
Wiimote.Home = KEY_HOME
Wiimote.1 = KEY_PROG1
Wiimote.2 = KEY_PROG2

'# Wiimote Axes
'# Only axes on Wiimote are D-pad axes, which range from -1 to 1.
'# Hence, there is no point in using them.
'#Wiimote.Dpad.X = ABS_HAT1X
'#Wiimote.Dpad.Y = ABS_HAT1Y

'# Nunchuk Buttons
Nunchuk.C = BTN_C
Nunchuk.Z = BTN_Z

'# Nunchuk Axes
Nunchuk.Stick.X = ABS_TILT_X
Nunchuk.Stick.Y = ABS_TILT_Y

'# Classic Controller Buttons
'# Originally, Classic.Up/Down/Left/Right used KEY_UP/DOWN/LEFT/RIGHT values.
'# Since these values are also used by the WiiMote configuration, Classic gets
'# to use generic button codes, that get correctly translated via .kl file.
'# This way event codes are independent.
'# Hence, changes for WiiMote will not affect Classic’s behavior and vice versa.
'# Moreover, Classic’s codes will be similar to those of other gamepads.
'# However, since D-pad on Classic controller will be supported
'# via HAT_X and HAX_Y axes, do not send events for key presses.
'#Classic.Up = BTN_1
'#Classic.Down = BTN_2
'#Classic.Left = BTN_3
'#Classic.Right = BTN_4
Classic.Minus = BTN_SELECT
Classic.Plus = BTN_START
Classic.Home = BTN_MODE
Classic.A = BTN_A
Classic.B = BTN_B
Classic.X = BTN_X
Classic.Y = BTN_Y
Classic.ZL = BTN_TL2
Classic.ZR = BTN_TR2
Classic.L = BTN_TL
Classic.R = BTN_TR

'# Classic Controller Axes
Classic.Dpad.X = ABS_HAT0X
'# Report D-pad Y as inverted to mimic other controllers
Classic.Dpad.Y = -ABS_HAT0Y
Classic.LStick.X = ABS_X
'# Report left Y as inverted to mimic other controllers
Classic.LStick.Y = -ABS_Y
Classic.RStick.X = ABS_Z
'# Report right Y as inverted to mimic other controllers
Classic.RStick.Y = -ABS_RZ
'# Upper buttons provide trigger axes, but are only in range from 0 to 1.
'# Hence, there is no point in using them.
'#Classic.LAnalog = ABS_RX
'#Classic.RAnalog = ABS_RY

It would be the configuration of wiimote buttons and the classic controller for OUYA, only this file does nothing.
BUT in “/ system / usr / keylayout” we have the file “Vendor_057e_Product_0306.kl”, which has the wiimote button configuration.
Kl files are the layout files that android uses to map a device such as a keyboard or control. The file name is the device ID.
Finally, OUYA has wminput, which is nothing more than “wminput is a Linux event, mouse, and joystick driver for the wiimote using the uinput system.”, According to his page:WMINPUT.

What happens is that OUYA has always supported wiimote and wii classic controller, the OUYA team just didn’t make it automatic and active by default and I suspect that Robert Broglia emulators do just that, call this little program (wminput) with a “wminput -d &” when you have a wiimote mapped and done. But the control also works on the OUYA interface itself and in other programs, such as BOMBSQUAD, Mupen64Plus, Retroarch, SPMC, it is fully functional because of the “Vendor_057e_Product_0306.kl” file.

So let’s leave the support for wiimote automatic and when you turn on OUYA just need to pair the control:

FIRST:

Root the OUYA as explained here: https://www.s-config.com/root-the-ouya-google-play/

ATTENTION: Don’t install the google play or the mod collection and don’t use the busybox from there, instead use the busybox from the links below:

adb install busybox-1.31.1-46.apk
(https://github.com/meefik/busybox/releases)

adb install Universal-initd.apk
(https://github.com/Androguide/Universal-init.d/blob/master/Universal-initd.apk)

SO:

download wiimoted script from here:

adb shell

su

mount -o rw,remount -t ext4 /dev/block/platform/sdhci-tegra.3/by-name/APP

cd /system/etc

mkdir init.d

chmod -R 755 init.d

cd init.d/

vi wiimoted

Press “i” in your keyboard and copy and paste the script code

Use the command :wq to save the file and exit of vi.

chmod 755 wiimoted

cd /

mount -o ro,remount -t ext4 /dev/block/platform/sdhci-tegra.3/by-name/APP

AFTER:

exit
exit

FINALLY:

Start Universal Init.d, give root permission to it and run the wiimoted script whenever you want to use it or set it to run at startup (the ON / OFF option in Universal Init.d). If everything is correct, you will see that there are controllers connected, even without the OUYA controller pairing or with just one controller actually connected.

Press 1 + 2 on the wii mote to pair.

FINAL CONSIDERATIONS:

  • Inside the wiimoted script, in the line where we have “if [$ (ps | grep wminput | wc -l) -lt 4]”, 4 is how many instances of wminput will be running, is necessary one for each connected wiimote. Before copying the script, edit to the number to match with the number of wiimotes which you have.

  • If you leave it with 4 instances and use the official OUYA control, the LED on the control will not turn on because the system expects a maximum of 4 controls and the OUYA would be the 5th control connected,

  • In Retroarch, the wiimote doesn’t work well, the D-PAD doesn’t work, but the classic controller and wii classic pro controller works fine.

SOURCES


1 Like

Holy crap! This is some GOOD stuff, @ZacharyFoxx! Bombsquad with wiimote would be awesome. Gonna have to try this out for myself soon. (Wife vastly prefers her wiimotes to other controllers).

1 Like

Hi!

I made some changes in the tutorial.

This is great @ZacharyFoxx!

Just wanted to give a shout out to PanReyes (PixJuegos / RAWR Labs) for authoring the original thread over at the old ouyaforum.

He was with us on the OUYA Saviors Project but has since been absent.

1 Like

I just took the information and put it here! All credit should go to whoever created the original post and wrote the script.

One thing, I tried to run the script after initialization, and when I did, “Universal Init.d” froze. I had to force the exit (U button twice ", but the script worked !!!

I think it would be better to create icons to star and interrupt the script, placing it inside the SD card, it would be less invasive.

1 Like