Difference between revisions of "Arcade Machine"

From Technologia Incognita
Jump to: navigation, search
(Writing our own input driver)
Line 47: Line 47:
  
 
See the "Writing out own input driver" below for more details.
 
See the "Writing out own input driver" below for more details.
 +
 +
Basic instructions:
 +
 +
  xinput disable $(xinput list --id-only "keyboard:Composite USB PS2 Converter USB to PS2 Adaptor  v1.12")
 +
  cd uinput-mapper/
 +
  sudo ./a.out
  
 
==== Other Input ====
 
==== Other Input ====
Line 94: Line 100:
 
* Creates two joystick input devices in /dev/input
 
* Creates two joystick input devices in /dev/input
 
* Both joystick devices are mapped sanely.
 
* Both joystick devices are mapped sanely.
* HAT0X / HAT0Y doesn't seem to work in some programs yet, but it definitely passed and works in jstest.
+
* HAT0X / HAT0Y seem to work now that we specified absmin and absmax.
 +
 
 +
Keys are mapped like this:
 +
 
 +
  HAT -> HAT0X, HAT0Y
 +
  Red Buttons, left to right: BTN_0, BTN_1, BTN_2
 +
  Yellow Button: BTN_3
 +
 
  
 
TODO:
 
TODO:
Line 110: Line 123:
 
- Turn input from one keyboard into several virtual input devices.
 
- Turn input from one keyboard into several virtual input devices.
  
Key mapping (in Keyboard)
+
Key mapping (in Keyboard); only relevant for developers:
  
 
==== Left ====
 
==== Left ====

Revision as of 16:06, 4 December 2012

Projects
Participants Control-k, Maijin, Realitygaps, Wizzup
Skills Programming
Status Active
Niche Software
Purpose Fun

Arcade Machine

We now own a <MODEL> Arcade Machine. The plan is to bring new life into the machine by putting a computer in there and hooking that computer to the joystick input and screens. The computer will run MAME and other emulators, such as Amiga or SNES emulators.

PS: I set the niche mostly to software because the electronics/mechanics are probably quite simple in this case.

Getting it to work

There's a basic UvA machine in the Arcade Box; with Wake on Lan. Just send the WOL packet to the right mac address, which can be found on the machine:

 00:21:70:03:31:1b

Here is an example command line that will turn on the machine (etherwake defaults to eth0, so wlan0 is specified)

 sudo etherwake 00:21:70:03:31:1b -i wlan0

Input

Arcade Machine input

The input can be read as PS2 (and USB); using a chip that we got alongside the Arcade Machine:

http://www.ultimarc.com/jpac.html http://www.ultimarc.com/jpac2.html

The Arcade Machine input exposes itself as a single keyboard over USB and PS/2. This is problematic for most games, with the exception of MAME and a few emulators.

The chip does not expose more than one HID, we will have to fiddle around a bit to get all the software to read from the input devices as two seperate devices. MAME is known to handle the basic PS2 input just fine (AFAIK), but for other emulators this can be a problem. Solutions include writing our own input driver or perhaps faking a device in X.

See the "Writing out own input driver" below for more details.

Basic instructions:

 xinput disable $(xinput list --id-only "keyboard:Composite USB PS2 Converter USB to PS2 Adaptor  v1.12")
 cd uinput-mapper/
 sudo ./a.out

Other Input

We attached two PlayStation controllers, but I (Wizzup) am not a big fan of them. Regardless, there's a USB hub so feel free to plug in other controllers! It would be nice to have proper SNES ones.

This may be useful: https://www.thinkgeek.com/product/f08d/ and http://www.amazon.com/Classic-USB-Super-Nintendo-Controller-PC/dp/B002JAU20W Or we can make our own.

Coin Input

This should be handled by the Input over PS2/USB as well. It is probably mapped to a key.

Video

We replaced the built-in monitor with a TFT monitor.

Sound

The sound works and is connected to the computer as well.

Games

Emulators:

  • ZSNES (SNES)
  • UAE (Amiga)
  • MAME
  • ...

Writing our own input driver

Code: https://github.com/MerlijnWajer/uinput-mapper

Compile:

 bash genkeys.sh
 gcc map.c
 ./a.out


Basic proof of concept works:

  • Creates two joystick input devices in /dev/input
  • Both joystick devices are mapped sanely.
  • HAT0X / HAT0Y seem to work now that we specified absmin and absmax.

Keys are mapped like this:

 HAT -> HAT0X, HAT0Y
 Red Buttons, left to right: BTN_0, BTN_1, BTN_2
 Yellow Button: BTN_3


TODO:

  • Make more general; allow files that describe what to map to what.

Will be installed onto the machine later.

Notes / Future usage:

  • xinput disable <ID> (where ID = the id of the ``fake keyboard; we need to do this so isn't used as keyboard anymore)
  • ./mapper &
  • Run your emulator

What uinput-mapper does is the following: - Turn input from one keyboard into several virtual input devices.

Key mapping (in Keyboard); only relevant for developers:

Left

   KEY_LEFT, KEY_UP, KEY_RIGHT, KEY_DOWN (type=EV_KEY, value={0,1})
   Red:
       0: KEY_LEFTCTRL
       1: KEY_LEFTALT
       2: KEY_SPACE
   Yellow:
       3: KEY_1

Right

   KEY_D, KEY_R, KEY_G, KEY_F (type=EV_KEY, value={0,1})
   Red:
       0: KEY_A
       1: KEY_S
       2: KEY_Q
   Yellow:
       3: KEY_2

Other uses

  • We can use it to control a variety of stuff. (light, sound)
  • We can hook other consoles into it.
  •  ???