Showing posts with label linux. Show all posts
Showing posts with label linux. Show all posts

Friday, November 15, 2013

Arcade controls for my homebrew arcade machine


Sticks and buttons

I got my stick and buttons off an online auction site (www.trademe.co.nz). They are all genuine arcade parts. I bought one Sanwa 8 way joystick, and four Streetfighter style buttons (which are concave, rather than convex). I prefer those buttons, as most arcade machines I played on had that style of button. I also bought two player 1/player 2 buttons with the intention of having a seperate (home made) coin mech for credits.








I only bought 4 buttons because I don't like fighting games, which usually require 6. There is a web page (I can't find it again) which shows stats for the number of buttons used, by far 3 or 4 buttons was the most common. I also bought only one stick, for a couple of reasons. Mostly, it was quite expensive, and I wasn't sure how successful my hack would be. Given the issues I've since had with the keyboard hack, I think if I was doing a multi-player cabinet I would get some actual joysticks. Keyboards don't seem to be designed for too many key inputs at once.

The keyboard that I used had a limited number of buttons which could be pressed at once, due to the way the key matrix is set up. I'd say that most keyboards are like that.

However, if I can modify my control panel so the buttons are removable, then I would happily set up something which would hot-swap a button/joystick panel for twinstick shooters.

Wiring a keyboard as a joystick + buttons:

I pulled apart an old ps2 keyboard. You could equally pull apart (or use) a USB joystick. I thought about buying one of -these- USB joysticks and putting it part, but ultimately decided to go with a keybaord.

Inside, there is a board which allows each key press to be interpreted as a letter.


I took 3 goes before I finally wired my keyboard correctly! I got instructions for wiring the keyboard from this instructible and soldered  it up. However, I skipped step 4 (which requires using a multimeter to get the keycodes) and hooked the keyboard up to my computer. Using a bit of wire, I simulated pressing a key by shorting the contacts for each key, and mapped out each key on a piece of paper, in a grid.



I found out the keys pressed by running testkeys from the mame-tools package. This is better than just pressing keys on the console or a text editor, as it will display non-printing characters, such as shift (and even say if its left or right shift). The reason I took so many tries to do the joystick was because some of the keys would block other keys from being pressed. Eg (use example from the keycode matrix)

This page explains how keyboard matricies work. Effectively, I had hooked up my keyboard so the key A1 and A3 could be pressed at once: A1 was
"joystick left" and Button 2 was A3. The keyboard didn't know both keys were being pressed at once, and would only send the first input. So I couldn't move when I had a button held down. So I needed to pull out all of my connections and start over.

I started out with hooks made from paperclips, but ended up soldering it in the end, as I thought it might be more robust. If I ever redo it, I'll try drilling wiring holes in the circuit board, and solder the wires through, instead of soldering it directly on. I'll also use some kind of quick release system or something so I don't waste so much heat shrink tubing. Too many of the contacts either came off when I was resoldering, or  got  pulled off by the weight of the harness (or my impatience).






I did make quick release end bits for the switch ends of the wires, so I could rewire the switches if I needed to. They worked really well, though I used a lot of heatshrink tubing to make them neat and tidy.

I'm not sure what I would do for twinsticks, but I could have it so the second stick uses the same keys as the four buttons, and have the buttons/extra stick each on their own removable baseplate.

Or I could make another cabinet, for twinstick shooters :P



Tuesday, November 5, 2013

Emulator choice and sample Advancemenu configuration file


Emulators

My emulator choices were constrained by a couple of things. Firstly, I had downloaded a heap of ROMs (from a disk put out in 1998!) so they needed to work with them. Secondly, there aren't that many emulators for Linux (especially for NeoGeo!). 

I was considering getting Space Ace and Dragon's Lair, old school laser disc games, but I haven't added them yet. I have the ROM files, but not the video files. It could be fun creating a video disc game of my own ( there are editors out there, I don't think it would be hard) but i lack the time and inclination at the moment.-Daphne is the emulator for those games. Here is how to get it to work with Advancemenu

For my other ROMs, there are other emulators which I could have used, especially for the NES, which has quite a variety, but as I said before, these are the ones which worked with my roms. 

So I have: 
Gens for Sega Megadrive (aka Genesis)
Osmose for Sega Master System
MAME for arcade machines
fceux for NES games
Gngeo for Neo Geo games

Frontends
I'm using this in a cabinet, with a heap of roms and emulators all mixed together, so I need a frontend to launch the different games, and keep everything organised. I've opted for Advancemenu, though there are loads of other frontends (a couple of lists are here and here) which are up to the task. Advancemenu can display the games how I want (a list on the left, screenshot on the right), and works with all of the emulators I want to use. Effectively, you could use advancemenu as a launcher for just about anything - movies, music, whatever - not just games.

Configuration files

Advancemenu (download my config here, includes comments)

My Advance menuconfig has the following features:
*Multiple emulators, with one emulator per screen.
*Custom keys mapped to page through ROM lists (one emulator per page).
*A 'utility' section, for shutdowns, restarts and verifying mame roms.
*Preview screenshots of games.
*8bit tunes as background music for the menu.

The music directory and mame roms directories are on a usb stick, which gets loaded when the operating system starts up.  I used ls-by-uuid to get the uuid of the usb stick, and added the following line to my /etc/fstab to load it where I wanted each time:

 UUID=dac3b911-d2e7-462d-b0cf-d19aa4d1fa48 /Roms/MAME/ fat32  auto  0       0
Utility directory
This has 3 scripts, one to shutdown the computer, one to restart the computer, and one to verify the mame roms. To do the shutdown and restarts, I had to add the user running Advancemenu to /etc/shutdown.allow.

Some configuration tips
You can add BIOS files to emulators, so they can run more games, for example adding the Naomi BIOS to MAME allows you to play Naomi based games. I put them in a seperate BIOS folder, and add that to the ROM search path in the emulator config file. That way the emulator can read the file, but Advancemenu doesn't add the BIOS files to its menu.  
All of the emulators I've used allow for multiple paths to the files.