How to exit GNGEO from gamepad - no keyboard


7 posts
by fg1998 » Tue Apr 30, 2013 5:26 pm
Hi everyone

Some days ago a user from this forum post a question about how to exit the NeoGeo Emulator 'gngeo' from the gamepad, because he didn´t have a keyboard on his Pi .. Just a gamepad

It´s exactly the way I use my Pi for gaming - ho keyboard. And I not use gngeo anymore because there is no way to exit the emulator from the gamepad (or I cannot find a way to do this, if someone know how please explains will be good !!).

So to avoid this behavior I make some modifications on Gngeo source code to allow exit from gamepad/joystick buttons. First of all, you will need to find a empty button to attach this feature, and of course cannot be one used for movements, coin, start, etc ... I use a Snes USB style gamepad (easy to find in some Chinese sites) and the START button, numbered as 9 is the available button.

To discover the number of a empty button just run gngeo with joystick support (--joystick) and press the F4 key on the keyboard, then press the button you wish to exit the emulator. GNGEO will show the code number for that key.

Once you have this code in hands, you will need to make a modification on gngeo source. In the folder you have had untar the source, find the file src/emu.c (in my case its ~/gngeo-0.7/src/emu.c). So edit the file with your editor and change the follow

Code: Select all
            case SDL_JOYBUTTONDOWN:
                joy_button[event.jbutton.which][event.jbutton.button] = 1;

                if (show_keysym) {
                    sprintf(ksym_code, "%d", event.jbutton.button);
                    draw_message(ksym_code);
                }
#ifdef GP2X



to this code

Code: Select all
            case SDL_JOYBUTTONDOWN:
                joy_button[event.jbutton.which][event.jbutton.button] = 1;
                sprintf(ksym_code, "%d", event.jbutton.button);

                if(strcmp(ksym_code, "9") == 0)
                {
                    neo_emu_done = 1;
                    break;
                }
                if (show_keysym) {
                    draw_message(ksym_code);
                }
#ifdef GP2X


where the number '9' in the line if(strcmp(ksym_code, "9") == 0) is the correct code for your exit gamepad button. In my case, this is the 'start' button on the gamepad and it´s not used by gngeo for another function.

Notice that you will find that piece of code in the neighborhood of line 750 on the file emu.c

After all, save the file and type 'make' in the root of gngeo source (usually ~/gngeo-0.7) and then sudo make install.

Run gngeo with your favorite game (something like gngeo ~/ emuladores/neogeo/rom/mslug.zip --joystick --scale=2) and press the assigned key and you will see the emulator exits and returns to bash.

Hope this can help

Regards
fg1998
Posts: 6
Joined: Tue Apr 30, 2013 3:12 pm
Location: Brazil
by smshiera » Tue Apr 30, 2013 11:51 pm
thanks,I think i will need this .
ask 2 questions about gngeo:
1.how to define a hotkey? e.g. I want set "u" as a+b+c+d
2.how to set Select in aes-system
Posts: 37
Joined: Fri Feb 22, 2013 6:59 am
by Cia91 » Thu May 02, 2013 9:28 am
Nice tips!

In my case F4 doesn't work, so i will try to use joy2key for use the R2 button like a "keyboard ESC".
Download GamePi OS: www.raspberrygaming.tk
User avatar
Posts: 89
Joined: Tue Jan 29, 2013 3:01 pm
Location: Pavia (italy)
by fg1998 » Thu May 02, 2013 5:07 pm
Cia91 wrote:Nice tips!

In my case F4 doesn't work, so i will try to use joy2key for use the R2 button like a "keyboard ESC".


Hi Cia91.

A mapping between Joystick/keyboard can work too, plz post the results when you get it. Some years ago I used a keyboard as a joystick (in a real arcade cabinet) but I had a lot of 'ghost-keys' in this solution. Sometimes when I pressed 'Ctrl' and in the same time 'A', for example, mame understand I´ve been pressed CTRL-A, and it´s not 'CTRL' even 'A', and, of course, I lost a lot of lifes playing Metal Slug this way. (maybe... I´m a bad player as well :oops: ), so I´m trying to avoid keyboard solutions.

But .. why F4 does not show the Key/Gamepad codes for you ? What version of gnGeo are you using ?

Cheers
Posts: 6
Joined: Tue Apr 30, 2013 3:12 pm
Location: Brazil
by Cia91 » Fri May 03, 2013 9:53 am
Hi i think it the 0.7. When i press F4 it show me the FPS...

However ghosting occur with keyboard, but not with joypad. I will recognize the button pressed like a keyboard, but the hardware if from a joy, so no ghosting.
Download GamePi OS: www.raspberrygaming.tk
User avatar
Posts: 89
Joined: Tue Jan 29, 2013 3:01 pm
Location: Pavia (italy)
by derus » Thu Aug 29, 2013 9:32 pm
I am using RetroPie with gngeo-pi-0.85. By pressing Esc or a button on the joypad you can access the emulator-menu and exit the emulator from there. But is there a way to setup a sinlge button (or two) to exit directly and go back to emulationstation like in the other emulators?
Posts: 13
Joined: Wed Aug 21, 2013 1:12 pm
by fg1998 » Thu Sep 26, 2013 8:07 pm
derus wrote:I am using RetroPie with gngeo-pi-0.85. By pressing Esc or a button on the joypad you can access the emulator-menu and exit the emulator from there. But is there a way to setup a sinlge button (or two) to exit directly and go back to emulationstation like in the other emulators?



Sorry, but i´m´out of information about retropie. Did you try the sugestion show on this post ?
Posts: 6
Joined: Tue Apr 30, 2013 3:12 pm
Location: Brazil