Tuesday, February 14, 2017

Simple Emulator Frontend for Raspberry Pi

I was annoyed by how complex the Raspberry Pi emulator frontends are, and I was looking for an excuse to write my first Python program.  So, here it is, a barebone curses-based frontend for launching emulators.  But really it could also be used to launch anything, like videos, ebooks, etc.

All the customization happens at the top of the code.  The extensions, directories, and launch commands will need corresponding entries for each emulator to be included.


# GUI keys
exit_key = 27 # ESC key
up_key = curses.KEY_UP
down_key = curses.KEY_DOWN
left_key = curses.KEY_LEFT
right_key = curses.KEY_RIGHT
launch_key = ord("j")
a_key = ord("x")
b_key = ord("z")

# rom file extensions
file_ext = [".gb", ".gbc", ".nes", ".smc"]

# rom directories
romdir = ["/home/pi/roms/gb",
"/home/pi/roms/gbc",
"/home/pi/roms/nes",
"/home/pi/roms/snes"]

# emulator launch commands
emulator = ["/home/pi/emu/./gambatte_sdl -i j g x z up down left right -s 8",
"/home/pi/emu/./gambatte_sdl -i j g x z up down left right -s 8",
"mednafen",
"mednafen"]