Arcade Box

Figure 1 – ODROID Arcade Box
Figure 1 – ODROID Arcade Box

ODROIDs have better performance than the competitor boards, especially in video rendering, which means that ODROID boards are very suitable for playing games, which many ODROID users do. There are already several game platform operating systems available, such as Lakka (http://bit.ly/1NO8BBC) and ODROID GameStation Turbo (http://bit.ly/1ASFO5O). In order to enjoy our gaming sessions more, we made our own arcade box with simple GPIO buttons and joysticks, and called it the ODROID Arcade Box. We choose an ODROID-XU4 for this project because it has the best GPU performance of all the current ODROID devices. This article describes how to recreate the ODROID Arcade Box for yourself.

Figure 2 – Our first simple prototype
Figure 2 – Our first simple prototype

Requirements

Figure 3 – Tools and parts
Figure 3 – Tools and parts

We decided to make the ODROID Arcade Box using MDF (Medium-Density Fibreboard). The XU4 Shifter Shield is also useful in order to utilize the expansion pins of the ODROID-XU4. Joysticks, buttons and cables were the input components, and an SMPS (Switched-Mode Power Supply) was used for the power supply. The detailed tools and parts list are listed below:

  • 12T MDF Panel
  • 2EA 600×220
  • 2EA 600×75
  • 2EA 220×75
  • Drill
  • Crimper
  • Stripper
  • Measuring tape
  • Utility knife
  • Long Nose Plier
  • ODROID-XU4
  • XU4 Shifter shield
  • SMPS
  • HDMI, USB, Ethernet extenders
  • Power socket & Switch
  • 2EA Hinges
  • Door catcher
  • 4EA foot rubber
  • Screws
  • 19EA Buttons
  • 2EA Joystick
  • Wires
  • Terminals

The ODROID Arcade Box needs a total of 27 inputs (19 inputs for buttons and 8 inputs for joysticks). The ODROID-XU4’s digital 24 GPIO inputs are not sufficient for all 27 inputs, so we created two additional ADC ports for the three additional buttons. The ADC input values are based on input voltage, and the digital and analog input values are processed in the GPIO key daemon, which is described below.

Figure 4 – Expansion ports schematic
Figure 4 – Expansion ports schematic

Design and assembly

The panels of the ODROID Arcade Box must be designed and manufactured so that the buttons and joysticks are well placed. We chose 12T MDF considered for price and durability. Your design can be done with any familiar CAD tool such as Google Sketch or SolidWorks. Although there are many layout templates for joypad panels available, we chose a standard Japanese arcade layout.

Figure 5 - Joypad Layout Blueprint
Figure 5 – Joypad Layout Blueprint

The first step of assembly is to attach the sheet to the MDF panel. This step was easy, but took longer than the other steps. After that, we inserted the joysticks, power socket, switch and buttons on the top MDF panel. The HDMI, Ethernet and USB extenders were inserted on the back of the MDF panel. The next step was to assemble each MDF panel by using a drill to make holes in it, then using screws to hold it together.

Figure 6 – Assembled ODROID Arcade Box Outline
Figure 6 – Assembled ODROID Arcade Box Outline

The last step of assembling the ODROID Arcade Box was wiring the ODROID-XU4 expansion pins to the input components. In this project, we designed the external GPIO inputs, as shown in Figure 5. The Select and Temp buttons are connected to ADC expansion ports, as shown in Figure 3.

Figure 7 – External GPIO mappings for the Buttons and Joysticks
Figure 7 – External GPIO mappings for the Buttons and Joysticks

Figure 8 – ODROID Arcade Box Wiring
Figure 8 – ODROID Arcade Box Wiring

Software Setup

We developed a new GPIO key daemon called gpio_keyd (http://bit.ly/2ljOZKg). The gpio_keyd daemon is able to map GPIO inputs and key events using uinput and wiringPi, which is a pin-based GPIO access library. It’s designed to be familiar to people who have used the Arduino wiring system. Although the upstream wiringPi library supports only Raspberry Pi, Hardkernel offers a wiringPi fork for ODROIDs in its GitHub repository (http://bit.ly/1Eq3UpF). The module uinput is a Linux kernel module that handles the input subsystem from user land. It can be used to create and handle input devices from an application.

We choose ODROID GameStation Turbo (http://bit.ly/1ASFO5O) as the software platform for our ODROID Arcade Box, which has uinput built in. You should make sure the uinput device file exists in your chosen operating system, because some of them do not have uinput devices.

 $ ls /dev/uinput
If your operating system does not have a /dev/uinput device file, then it will be necessary to rebuild and install a new kernel with the INPUT_UINPUT option configuration option set. The Wiki page at http://bit.ly/1YIToBI describes how to build and install the kernel image from source code.
$ make menuconfig

 Device Drivers -> Input device support
 -> Generic input layer
 -> Miscellaneous device
 -> User level driver support <*>
Note that wiringPi must be installed before installing gpio_keyd. On the ODROID GameStation image, the sudo commands must be run as root, because the “odroid” account is not designated as a sudo user.
$ git clone https://github.com/hardkernel/wiringPi.git
$ cd wiringPi
$ sudo ./build
Download the gpio_keyd source code, which is available from our GitHub repository. The gpio_keyd build and installation methods are very simple:
$ git clone https://github.com/bkrepo/gpio_keyd.git
$ cd gpio_keyd
$ make
$ sudo make install
The gpio_keyd script refers to /etc/gpio_keyd.conf as the default for GPIO and key mapping information. The configuration file was modified for 27 inputs of ODROID Arcade Box. Some keys are already used in the game emulator, so we had to change the emulator key settings in order to avoid key collisions between the emulator and GPIO input keys. Note that field in the configuration file refers to the wiringPi number, not the GPIO and pin number (http://bit.ly/2lbzPIB).

Configuration file sample for 27 inputs: /etc/gpio_keyd.conf

# Digital input
#    
# User 1
KEY_LEFT digital 15 0
KEY_RIGHT digital 1 0
KEY_UP digital 4 0
KEY_DOWN digital 16 0
KEY_A digital 2 0
KEY_S digital 3 0
KEY_D digital 30 0
KEY_F digital 21 0
KEY_Z digital 8 0
KEY_X digital 9 0
KEY_C digital 7 0
KEY_V digital 0 0
# User 2
KEY_BACKSLASH digital 12 0
KEY_SLASH digital 13 0
KEY_SEMICOLON digital 14 0
KEY_LEFTBRACE digital 5 0
KEY_Y digital 26 0
KEY_U digital 27 0
KEY_I digital 22 0
KEY_O digital 23 0
KEY_H digital 6 0
KEY_J digital 10 0
KEY_K digital 11 0
KEY_L digital 31 0

# Analog input
#    
KEY_B analog 0 0
KEY_N analog 0 2045
KEY_M analog 1 2045
To run gpio_keyd daemon at every startup is convenient for ODROID Arcade Box.
/etc/init.d/gpio_keyd
#! /bin/sh
### BEGIN INIT INFO
# Provides: gpio_keyd
# Required-Start: $all
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop:
# Short-Description: Run /usr/bin/gpio_keyd if it exist
### END INIT INFO

PATH=/sbin:/usr/sbin:/bin:/usr/bin

. /lib/init/vars.sh
. /lib/lsb/init-functions

do_start() {
 if [ -x /usr/bin/gpio_keyd ]; then
 /usr/bin/gpio_keyd -d
 ES=$?
 [ "$VERBOSE" != no ] && log_end_msg $ES
 return $ES
 fi
}

case "$1" in
start)
do_start
;;
restart|reload|force-reload)
echo "Error: argument '$1' not supported" >&2
exit 3
;;
stop)
killall gpio_keyd
exit 0
;;
*)
echo "Usage: $0 start|stop" >&2
exit 3
;;
Esac
$ sudo chmod +x /etc/init.d/gpio_keyd
$ sudo update-rc.d gpio_keyd defaults
$ sudo reboot
In the above commands, the gpio_keyd script runs as a daemon using the “-d” option. Usage of gpio_keyd can be checked with the “–h” option. Double-check the keys used by the game or the emulator, then set the gpio_keyd settings correctly. Then, you are ready to play and enjoy your games with your new ODROID Arcade Box.

Figure 9 - The King of Fighters 98, John vs. Brian
Figure 9 – The King of Fighters 98, John vs. Brian

Be the first to comment

Leave a Reply