snes9x-rpi controls broken? Retroflag Gpi
-
I've tried for many days now to get the controls to work for snes9x-rpi. I know it's an abandoned and forgotten core but my interest in it is to get it working for the pi zero and Retroflag-Gpi case. Here's my issue: Keyboard keys are very broken, the only key's that will respond are the two global ones (Escape and Backspace) and the number keys that disable layers (1,2,3,4...) None of the player control keyboard keys work at all. They are defined in the source code as d,s,a,w,e,f,space,lctrl,right,left,up,down (None of these work). I've poured over the source code (making sure to look at the retropie branch) for many days now and many hours, and I just can't understand why that is. I have also tried to make the joystick controls work. j[JB_A] = 0;j[JB_B] = 1;j[JB_X] = 2;j[JB_Y] = 3;j[JB_L] = 4;j[JB_R] = 5;j[JB_START] = 6;j[JB_SELECT] = 7;j[JB_ACCEL] = 8;j[JB_QUIT] = 9; and what is strange about these, is they do somewhat work, but they are not correct for the xpad joystick of the Gpi case. Weirder still, the joystick controls of the emulator do not seem to be matching up with these from the source. And what is confusing me the absolute most about all of this, is that if I fork the code, and change these keys and joystick buttons in the code, and compile it. My changes do not have any effect in the compiled binary. I am at a total loss as to how that could be possible? I truly would love to have any advice or help with this. I am modifying the github link inside the snes9x.sh file in the scriptmodules/emulators folder, pointing it to my git, and making sure the changes I am doing are in the "retropie" branch. And that is what I see when I tell retropie-setup to install/update from source. I can even go into /build/snes9x and nano the files I changed, and see that it has in-fact pulled down my changes. And yet, the compiled binary acts as though I have changed nothing when it comes to the controls. I feel like I am going crazy with this, going in circles, and not getting anywhere. Please help.
-
@SinisterSpatula A log from the installation from source would help - maybe the scriptmodule fails to install (i.e. copy the resulting binary to the install location).
I don't have a GPI case, are the controls detected as a keyboard or as a gamepad ? -
@mitu I can provide the build log if it's helpful, it does succeed to build, and does move the built files into the /emulators/snes9x folder, so it appears to be building just fine. The Gpi controls are xpad (xbox360) style. But I've also tried a bluetooth keyboard with it as well. When I had problems with the joystick inputs, I also tried using xboxdrv to send keyboard keys to the emulator instead. It behaved the same way as the bluetooth keyboard (escape, backspace, and number keys will work, but not any of the player movement or buttons).
-
@SinisterSpatula I see - so maybe the joystick code needs to be modified:
JOYSTICK BUTTONS:
Same deal here, at the moment you need to edit a header file and recompile
to redefine the joystick buttons. The defaults are not likely to make
sense for you unless you have a digital Thrustmaster Firestorm 12-button
controller. :)To find out which joystick buttons and axes are which, do:
$ sudo apt-get install joystick
Then:
$ jstest /dev/js0
Test and write down. Edit unix/joydef.h and then recompile. Future versions
will make this stuff not require a recompile.EDIT: did you try using
lr-snes9x2002
as an alternative ? -
@mitu Yes, I did that. A = 0, B = 1, X = 2, Y = 3, LB = 4, RB = 5, Select is 6, Start is 7, Axis6(left/right), Axis7(up/down) [These are the results of jstest for the Gpi case]. Those are the values I tried to change in the code. I found three different places to change them:
snes9x-rpi/unix/input/inputConfig.cpp snes9x-rpi/unix/input/joystick.cpp snes9x-rpi/unix/unix.cpp
Maybe there is a fourth place I have not found, but I kind of doubt it, I've been looking painstakingly hard.
edit: yes, it still suffers from significant slowdown, where this old core performs like a beauty on the zero. I'm really trying to bring this guy back from the dead. :)
-
Looking at the code, it looks like it uses the SDL2 joystick subsystem to detect the gamepads. What do you have in your run log file -
/dev/shm/runcommand.log
? -
Parameters: Executing: SDL1_VIDEODRIVER=dispmanx /opt/retropie/emulators/snes9x/snes9x "/home/pi/RetroPie/roms/snes/Earthworm Jim (USA).sfc" Rate: 44100, Buffer size: 1024, 16-bit: yes, Stereo: yes, Encoded: no Could not find joystick mapping forMicrosoft X-Box 360 pad, use default No ROM file header found. "EARTHWORM JIM" [checksum ok] HiROM, 32Mbits, Type: ROM only, Mode: 21, TV: NTSC, S-RAM: 0Kb, ROMId: AEJE Company: 4G
-
@SinisterSpatula OK, so the gamepad is detected correctly, but I'm not sure why the mapping doesn't work - maybe it's just using the name but gamepad has different key codes.
I started a ROM - with a SNES style USB controller - and it played fine (minus the emulator exit, which is not mappable), without any re-configuration. I also got the same type of messages in the log, but despite the 'default' mapping being used, it worked fine.
EDIT: Can you try with
sdl2-jstest
(from here) to see how your controller is detected ? -
@mitu That's very interesting! We're the select and start buttons working? For me, the start button does nothing, and the A/B/X/Y were in the wrong order.
-
@SinisterSpatula Yes, buttons looked fine - though I didn't make use of L/R much.
-
@mitu said in snes9x-rpi controls broken?:
sdl2-jstest
Sorry, Iinux is not really my strong suit. I was able to clone the git, and run the cmake, but I couldn't seem to do "make" or "make isntall". Not sure what arguments I'm supposed to add to them. Edit: actually the cmake fails, saying the gamecontrollerdb.txt is a symlink that is "dangling" I assume not there.
-
@SinisterSpatula Must have changed since I last installed it. You can try with this version, which doesn't need additional files.
-
@mitu It tells me unable to open Joystick 1. Uhg. It's probably something unique to the Gpi-case I'm thinking, if you tested it with a usb controller and it worked for you. I'll see if I can try using a usb controller also, with a different pi, and see if I'm able to compile a version and change button mapping around. I'm also curious to try a usb keyboard with it on a different pi and see what happens. Maybe others here that have a Gpi case are also looking into this, and we can help each other to get it working. I appreciate your help greatly.
-
@SinisterSpatula If you haven't tried
lr-snes9x2002
, I suggest you try to see how it performs.xboxdrv
may also be a solution for re-mapping the gamepad without any re-compilation - useful for a drop-in configuration. -
@mitu Yeah, that's what I'm really puzzled about. I've gotten extremely savvy with xboxdrv and I've used it with many of these older cores now. When I tried using it with this one, it just refused to receive or process any of the key events I sent it, except for two, escape (quit) and backspace (speed up the cpu). And when I connected a bluetooth keyboard and it did the same thing, that's what made me think it must be the core itself. My fork of snes9x-rpi for Gpi is here: https://github.com/SinisterSpatula/snes9x-rpi
-
I feel like I'm SOOO Close to this now. I was able to modify the code for the joystick detection skipping over Js0 (the retroflag xpad joystick) and get snes9x to grab Js1 instead (xboxdrv joystick). You would think that would be all it takes right? Wrong. So there is some weirdness happening even with that. The button assignments seem to change practically at random. They are one way for one launch, and then they shift around on the next launch. So I'm pretty much abandoning Joystick buttons and going for keyboard input. I know exactly the area of the code I need to change but still working out the best way to change it. It reads like "first we get all the joystick players, and then we get keyboard players". So I think because it was finding joysticks, the keyboard keys became player 2 (which is why none of the movement keyboard keys affected player 1). So if I find away for it to take NO joysticks, the keys should become player 1. That is my current goal.
-
@SinisterSpatula Since it uses SDL, just disable the joystick sub-system initialisation - https://wiki.libsdl.org/SDL_InitSubSystem - and see if that leaves you with just the keyboard controls.
-
@SinisterSpatula Hi. I use
xboxdrv
on my 4 player arcade machine where it is really handy, but I'm just wondering what you consider is or will be the benefit of usingxboxdrv
andsnes9x-rpi
on the GPI. I received the GPI a couple of days ago and am using one of the standard snes libretro emulators - I'm not sure which because I'm not at home at present. The libretro emulator, though, seems pretty good to me. -
@spud11 The default SNES emulator on the pi zero is lr-snes9x2002 - It runs okay, but has some pretty choppy sound and some slowdown on some of the more demanding titles (at least in my experience). Snes9x-rpi runs extremely smooth on the Retroflag GPi Case. If @SinisterSpatula can get the controls working I'd love to switch emulators.
-
@pomme Thanks. That explains it well.
Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.
Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.