PiGRRL - Raspberry Pi Gameboy - More buttons!(?)
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- d3rax
- Posts: 16
- Joined: Mon Aug 25, 2014 8:40 am
PiGRRL - Raspberry Pi Gameboy - More buttons!(?)
Really like the Pi Gameboy project, but I was wondering if its possible to connect more buttons? We now have A and B, but I would also like to add X and Y and maybe the to back buttons.
- Bel_Z_Bub
- Posts: 263
- Joined: Wed Jun 04, 2014 1:58 pm
Re: PiGRRL - Raspberry Pi Gameboy - More buttons!(?)
if you disable the serial port you can hook up pin 14 and 15 as well, then you can specify your new buttons in retrogame.c and what they should do. then recompile retrogame and gamera. you can map the new keys to mame funtions in advmame.rc.common. or the advmame.rc.(your screens orientation). You can find all the map names and function names when you type "man advmame" in the console.
its as easy as hooking one end of your button to ground, the other one to the pin. if you still want more buttons you will have to enable the p5 header.
to disable the serial port:
and change this:
into this:
then open:
and comment out this line (near the bottom of the file) so:
becomes:
reboot and your done.
its as easy as hooking one end of your button to ground, the other one to the pin. if you still want more buttons you will have to enable the p5 header.
to disable the serial port:
Code: Select all
sudo nano /boot/cmdline.txt
Code: Select all
dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait fbcon=map:10 fbcon=font:VGA8x8
Code: Select all
dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait fbcon=map:10 fbcon=font:VGA8x8
Code: Select all
sudo nano /etc/inittab
Code: Select all
T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100
Code: Select all
#T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100
- d3rax
- Posts: 16
- Joined: Mon Aug 25, 2014 8:40 am
Re: PiGRRL - Raspberry Pi Gameboy - More buttons!(?)
Thanks for your quick and detailed reply! Its clear for me how to disable the serial port, but I don't understand how to specifying the new buttons...kinda lost you at 'specify your new buttons in retrogame.c' and 'recompile retrogame and gamera'...
- Bel_Z_Bub
- Posts: 263
- Joined: Wed Jun 04, 2014 1:58 pm
Re: PiGRRL - Raspberry Pi Gameboy - More buttons!(?)
lets say you want to add a button to pause the game
hook up a button to GPIO14 (one of the pins you just freed by disabling the serial port), and the other end of the button to GND
backup your original file
then edit your file:
find this part (may be a bit different I used an old backup of mine I dont have the original by hand but it looks the same):
if you found it, add a comma after the last button specification in the CUPCADE part of the list and then the extra button part after that like so: make sure its a keycode thats not used for other stuff. I used KEY_P as thats also whats mapped to pause the when you use a keyboard but mainly you can use any keycode you want.
then save the file, and do to compile the code
wait till its done and doesnt ouput any errors, if completed you type
then do
and add this line (you can find these codes in the manual by typing "man advmame"):
save, close and reboot.
if all went well, you can now pause and unpause the game when you press the button
hook up a button to GPIO14 (one of the pins you just freed by disabling the serial port), and the other end of the button to GND
Code: Select all
sudo su
cd /usr/local/src/retrogame
Code: Select all
cp retrogame.c retrogame.c.1
Code: Select all
nano retrogame.c
Code: Select all
struct {
int pin;
int key;
} io[] = {
// Input Output (from /usr/include/linux/input.h)
#ifdef CUPCADE
// Use this table for the Cupcade project (w/PiTFT).
// To compile, type: make clean; make CFLAGS=-DCUPCADE
{ 2, KEY_LEFT }, // Joystick (4 pins)
{ 3, KEY_RIGHT },
{ 4, KEY_DOWN },
{ 17, KEY_UP },
{ 27, KEY_Z }, // Fire/jump/primary
{ 22, KEY_X }, // Bomb/secondary
{ 23, KEY_R }, // Credit
{ 18, KEY_Q } // Start 1P
// MAME must be configured with 'z' & 'x' as buttons 1 & 2 -
// this was required for the accompanying 'menu' utility to
// work (catching crtl/alt w/ncurses gets totally NASTY).
// Credit/start are likewise moved to 'r' & 'q,' reason being
// to play nicer with certain emulators not liking numbers.
// GPIO options are 'maxed out' with PiTFT + above table.
// If additional buttons are desired, will need to disable
// serial console and/or use P5 header. Or use keyboard.
#else
// Use this table for the basic retro gaming project:
{ 25, KEY_LEFT }, // Joystick (4 pins)
{ 9, KEY_RIGHT },
{ 10, KEY_UP },
{ 17, KEY_DOWN },
{ 23, KEY_LEFTCTRL }, // Fire/jump/primary
{ 7, KEY_LEFTALT } // Bomb/secondary
// For credit/start/etc., use USB keyboard or add more buttons.
#endif
};
Code: Select all
{ 2, KEY_LEFT }, // Joystick (4 pins)
{ 3, KEY_RIGHT },
{ 4, KEY_DOWN },
{ 17, KEY_UP },
{ 27, KEY_Z }, // Fire/jump/primary
{ 22, KEY_X }, // Bomb/secondary
{ 23, KEY_R }, // Credit
{ 18, KEY_Q }, // Start 1P // place a comma
{ 14, KEY_P } // this is your new pause button
Code: Select all
make clean; make CFLAGS=-DCUPCADE
Code: Select all
make install
Code: Select all
nano /boot/advmame.rc.common
Code: Select all
input_map[ui_pause] keyboard[0,p]
if all went well, you can now pause and unpause the game when you press the button
- Bel_Z_Bub
- Posts: 263
- Joined: Wed Jun 04, 2014 1:58 pm
Re: PiGRRL - Raspberry Pi Gameboy - More buttons!(?)
I just realized the pause function only works for the .rom games (that I use mostly) and nes games have a pause button by default (start) :D sorry about that lol. Let me find another example or tell what you like to use the buttons for so I'll adjust the example to it.
Please be positive and constructive with your questions and comments.