Retrogame Vulcan Nerve Pinch

General project help for Adafruit customers

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
amp1276
 
Posts: 6
Joined: Wed Aug 13, 2014 2:38 pm

Retrogame Vulcan Nerve Pinch

Post by amp1276 »

I am in the process of playing with my Pi to make a multicade. I am using Retropie and Retrogame to map my keys to the RPIO. I have everything working and mapped appropriately but I can not get the nerve pinch to work. I did change the selection from 6 and 7 to 9 and 10 but I can't seem to get it to be recognized at all. What am I missing?

User avatar
tdicola
 
Posts: 1074
Joined: Thu Oct 17, 2013 9:11 pm

Re: Retrogame Vulcan Nerve Pinch

Post by tdicola »

Can you post the source code for retrogame that you've modified? That should help clarify how things are configured.

Also just to rule out a few simple things, do each of the individual buttons you're using work as expected on their own? When you hold them all down for the vulcan nerve pinch are you holding it for a few seconds?

User avatar
amp1276
 
Posts: 6
Joined: Wed Aug 13, 2014 2:38 pm

Re: Retrogame Vulcan Nerve Pinch

Post by amp1276 »

Yes! All the buttons I have assigned work as they are supposed to and I have held the buttons a sufficient amount of time. Here is the section of code I have modified.

Code: Select all

// START HERE ------------------------------------------------------------
// This table remaps GPIO inputs to keyboard values.  In this initial
// implementation there's a 1:1 relationship (can't attach multiple keys
// to a button) and the list is fixed in code; there is no configuration
// file.  Buttons physically connect between GPIO pins and ground.  There
// are only a few GND pins on the GPIO header, so a breakout board is
// often needed.  If you require just a couple extra ground connections
// and have unused GPIO pins, set the corresponding key value to GND to
// create a spare ground point.

#define GND -1
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_SPACE        }, // Fire/jump/primary
	{ 22,      KEY_A        }, // Bomb/secondary
	{ 23,      KEY_5        }, // Credit
	{ 18,      KEY_1        }  // 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_A        }, // Fire/jump/primary
	{  7,      KEY_B        },  // Bomb/secondary
	{  2,	   KEY_C        }, // Third fire button
	{  3,	   KEY_5	}, //Credit
	{  4,	   KEY_1	}, //Start 1P
	{ 27,	   KEY_2        },  //Start 2P
	{ 22, 	   KEY_ESC	}  //Escape
	// For credit/start/etc., use USB keyboard or add more buttons.
#endif
};
#define IOLEN (sizeof(io) / sizeof(io[0])) // io[] table size

// A "Vulcan nerve pinch" (holding down a specific button combination
// for a few seconds) issues an 'esc' keypress to MAME (which brings up
// an exit menu or quits the current game).  The button combo is
// configured with a bitmask corresponding to elements in the above io[]
// array.  The default value here uses elements 6 and 7 (credit and start
// in the Cupcade pinout).  If you change this, make certain it's a combo
// that's not likely to occur during actual gameplay (i.e. avoid using
// joystick directions or hold-for-rapid-fire buttons).
// Also key auto-repeat times are set here.  This is for navigating the
// game menu using the 'gamera' utility; MAME disregards key repeat
// events (as it should).
const unsigned long vulcanMask = (1L << 9) | (1L << 10);
const int           vulcanKey  = KEY_ESC, // Keycode to send
                    vulcanTime = 1500,    // Pinch time in milliseconds
                    repTime1   = 500,     // Key hold time to begin repeat
                    repTime2   = 100;     // Time between key repetitions


User avatar
tdicola
 
Posts: 1074
Joined: Thu Oct 17, 2013 9:11 pm

Re: Retrogame Vulcan Nerve Pinch

Post by tdicola »

Thanks for sharing the code, for a value of 9 and 10 it looks like that would be grabbing buttons on GPIO 27 and 22 which send the keys 2 and escape. Those are the buttons you're pressing to see if the nerve pinch works right?

One thing that might be odd is having button 22 send the key escape in addition to being part of the vulcan nerve pinch that also sends escape. If you press button 22 alone does it send an escape? I have a suspicion that because one of the keys is setup to send escape it might be sending a lot of escape events and conflicting with the nerve pinch sending escape. Have you tried it with button 22 mapped to a key other than escape?

User avatar
amp1276
 
Posts: 6
Joined: Wed Aug 13, 2014 2:38 pm

Re: Retrogame Vulcan Nerve Pinch

Post by amp1276 »

I ended up scrapping RetroPie all together since it had some other buggy issues going on too. I started from scratch and did Mame4All with PiMenu and everything's working good. Thanks for the response, I appreciate it!!

User avatar
braydendevito
 
Posts: 1
Joined: Sun Aug 17, 2014 1:38 pm

Re: Retrogame Vulcan Nerve Pinch

Post by braydendevito »

Hello,

Thanks for all the support you guy provide on the forum.

Your solution to his problem helped me figure out a little more about the vulcan nerve pinch.

now.... here is the big question.

How would I go about setting multiple nerve pinches for different button combinations.

I cant figure it out quite yet.
Thank you so much!

PS. Check out my project on Hackaday- you might like it! :]
https://hackaday.io/project/2090-Raspbe ... age-Arcade
i'd be willing to help anyone out with support for a similar project as well!
thanks guys.

User avatar
pburgess
 
Posts: 4161
Joined: Sun Oct 26, 2008 2:29 am

Re: Retrogame Vulcan Nerve Pinch

Post by pburgess »

In retrogame.c, around line 136:

Code: Select all

const unsigned long vulcanMask = (1L << 6) | (1L << 7);
The 6 & 7 are array indices in the io[] array above this. In theory you could add some more here; maybe they're called vulcanMask1, vulcanMask2, vulcanMask3, etc.
You might then have a corresponding vulcanKey1, vulcanKey2, etc. to represent the keycodes sent. Only need the one vulcanTime though; that doesn't change.
Also, if adding key numbers like that, make a separate global, non-const, let's call it vulcanKey with no number, i.e.:

Code: Select all

int vulcanKey;
Currently, around line 464, there's:

Code: Select all

                        if((bitMask & vulcanMask) == vulcanMask)
                                timeout = vulcanTime;
This could be expanded to:

Code: Select all

                        if((bitMask & vulcanMask1) == vulcanMask1) {
                                vulcanKey = vulcanKey1;
                                timeout = vulcanTime;
                        } else if((bitMask & vulcanMask2) == vulcanMask2) {
                                vulcanKey = vulcanKey2;
                                timeout = vulcanTime;
                        } // ...and so forth for each Vulcan combo
Shouldn't need to change the Vulcan timeout code then.

Can't say for certain that'll work right out of the box, but hopefully sets you in the right direction.

mandream
 
Posts: 1
Joined: Fri Jan 02, 2015 8:47 pm

Re: Retrogame Vulcan Nerve Pinch

Post by mandream »

Looks like the above suggestion applies to the prior version of retrogame before it was based on the config file and support was added for the IO extender.

Any tips on adding support for multiple Vulcan keys in the current source? Ideally it would allow you to specify "unlimited" combinations in the config file, but honestly I'd be happy with having 3 (instead of 1). I'd also be ok with suggestions on how to hard code these as opposed to making them config based.

Mike

Locked
Please be positive and constructive with your questions and comments.

Return to “General Project help”