Table of Contents

Introduction

The Universal-Motion-Joypad is a product similar functionality with a “Nintendo Wii”. It is based on the USB IO Board and a motion sensor. The games you enjoy with mobile phone is still enjoyable for you just having with ODROID-BOARD if you use Universal-Motion-Joypad. In addition, It is extremely comfortable at the point that users can freely customize the keypad of Universal-Motion-Joypad adjusting a simple file(boot.ini file in ODROID-BOARD) without any process such as compiling. This enables users to enjoy games which is perfectly fitted for them with joypad.

Package include

Operating system support

To use the Joypad, you first need to update the Android operating system to the following version or higher.

Getting Started

Configure your ODROID-BOARD

To use the Universal Motion Joypad, it’s first necessary to configure the parameters of “acc_orientation”, “button_map” and “usbhid.quirks” in the boot.ini file on the Android FAT32 partition. After saving the file, reboot the ODROID for the new parameters to take effect.

1. Insert your android eMMC or micro-SDcard into a HOST PC.
2. Add following the parameters to the boot.ini file in VFAT area.

...
 
setenv orientation "3"
setenv bts "0:M:L,1:M:U,2:M:R,3:M:D,4:T:71:203,5:K:102,6:T:1214:212,7:T:1253:43,8:M:l,9:M:r"
setenv bootargs    "... acc_orientation=${orientation} button_map=${bts} usbhid.quirks=0x04d8:0x003f:0x0004"
 
...

3. Connect the joypad to your ODROID-BOARD via micro USB cable.
4. Boot & Play

Playing Beach buggy racing

One of our favorite Android racing games is Beach Buggy Racing. It’s a Mario Kart style game that features amazing graphics, smooth gameplay and up to 4 player action. The game is compatible with many USB joysticks and HDMI touchscreens, but is much more fun and easy to drive using the Universal Motion Joypad!

You can use google “Play Store” to download the Beach buggy racing.

If you have not “Play Store”, refer to following link.
http://codewalkerster.blogspot.kr/2013/11/universal-1-click-gapps-installer-for.html

Run Beach buggy racing and set type of steering “Tilt”.

Demo video
Check out the Universal Motion Joypad in action at http://youtu.be/xSlPJzXEsIo

Custom Joypad

To use the custom Universal Motion Joypad, you need to configure the parameters of “acc_orientation”, “button_map” and “usbhid.quirks” in the boot.ini file on the Android FAT32 partition.

The boot.ini file can transmit the boot parameters to the kernel when the OS boots. We can send three parameters to the kernel for key mapping.

In the boot.ini

...
 
setenv orientation "3"
setenv bts "0:M:L,1:M:U,2:M:R,3:M:D,4:T:71:203,5:K:102,6:T:1214:212,7:T:1253:43,8:M:l,9:M:r"
 
setenv bootargs "... acc_orientation=${orientation} button_map=${bts} usbhid.quirks=0x04d8:0x003f:0x0004"
 
...

At first, acc_orientation value helps users control just fine in any orientations. The button_map parameter can set the key mapping of each button. The usbhid.quirks parameter forces to work the USB IO Board as a generic input driver instead of the standard HID device.

More detail explanation of acc_orientation and button_map parameter is as a following links.

Technical details

Documents

Universal motion joypad schemetic
BMA150 datasheet

Source code

You can learn how to implement the sensor interface HAL, and find out what was changed in the source code in order to add the drivers to Android, by reviewing the following GitHub commits

ODROID-XU3/4

ODROID-C1

USB IO Board firmware for Joypad

Hardware

The Universal Motion Joypad is composed of a simple hardware structure. The PIC18F45K50 MCU in the USB IO Board reads the keypad switches, BMA150 accelerometer sensor, and controls the status LEDs.

Joypad interfac dagram

As shown in the interface diagram, the GPIO and I2C are used to control Universal Motion Joypad. The USB IO Board reads the signal of key switches through the GPIO ports. The switches normally show a HIGH state, and reports a LOW state when pressed.

The accelerometer sensor is connected to the I2C bus. When the MCU boots up, the corresponding registers initialized. Each keypad and accelerometer sensor frequently reads the values at regular intervals using the MCU’s timer, and the values arestored as 10-byte packets and transmitted to the ODROID via USB interface.

Joypad data packet byte mappings

Each 10-byte packet contains a header and tail taking 1 byte each, along with 8 data bytes. The data consists of 6 bytes of acceleration sensor data, and 2 bytes of keypad data. The PCB labels KEY0 - KEY9 values are mapped to the corresponding GPIO as shown in the packet structure, with the option to use additional input ports. The GPIO port and key mapping are easily configured using the boot.ini file of the ODROID.

Android framework

Android framework diagram for the Joypad drivers

As shown in the android framework diagram, the application framework is an application uses the sensor framework to obtain the sensor's data. It communicates with the C++ layer through the Java native interface(JNI). The sensor library middle layer mainly consists of the sensor manager, sensor service and sensor hardware abstraction layer.

The input subsystem is a generic Linux framework for all input devices like keyboard, mouse, and touchscreen, which defines a standard set of events. It interfaces to the user space through the /sys/class/input interface. The event device (Evdev) provides a generic way for input device events to be accessible under /dev/input/eventX. The sensor interface driver communicates with the USB IO Board via USB bus.