Picade Controller PCB sending multiple SDL events

Hello all,

I’ve been trying to track down an issue for a while and can use some help. I’ve got a Picade Controller PCB (firmware v2.3) hooked up to a Raspberry Pi running RetroPie 4.5.1. I’ve been doing some testing with SDL2 and have found that when in Keyboard mode, the Picade PCB will output both a keyboard and gamepad event. When in gamepad mode, the Picade PCB will output both a gamepad and mouse event (and additionally send a double event for the first event).

Upon looking at the Picade firmware Arduino sketch, I’ve found that it seems to do something with the HID library. If I comment that library out, then Keyboard mode works as expected. Unfortunately, then the Gamepad mode doesn’t seem to work. I’m talking specifically about these lines in joystick.cpp:




Alternatively, if I comment out the Keyboard.press(key); and Keyboard.release(key); lines in Picade.ino, the Gamepad mode will send gamepad and mouse events, while keyboard mode will send no events.

I’ve read that the device automatically registers itself as a keyboard HID device and that the HID library is limited. Is there anyway for the device to register multiple HID devices and send events appropriately? Meaning, only send keyboard events for keyboard actions and gamepad events for gamepad actions?

Thank you very much.

  • George

I’ve done some more testing and I’m pretty confident now that this has nothing to do with the Picade, or the Arduino code, but is dependent on the version of SDL2 that is installed on the machine. I did a comparison between RetroPie vs. plain Raspbian and found that my installation of Raspbian did not have the issue with multiple hits. I also noticed that Raspbian showed the Picade as having 4 axis and 16 buttons, while RetroPie showed it as having 4 axis and 135 buttons.

After much digging I saw that the versions of SDL2 installed on either were different:

  • RetroPie: 2.0.8+1rpi
  • Raspbian: 2.0.5+dfsg1-2+rpt1

Attempting to update them via APT was of no use, as it stated that the latest version was installed in both places. They must be from different sources. So instead I just cross copied the library binaries (.so) files between the systems and switched the symlinks. On the RetroPie system, LibSDL failed to load. That’s not surprising as it’s a highly customized system. On the Raspbian system, I now see the errors where there were none before.

My next steps are to find out the source of RetroPie’s SDL and see if there is something that can be done to fix the issue. I’ll post my progress here for future consumption, in case others have a similar issue.

  • George

Found that RetroPie has its own installation manager for some items and that the most recent version of SDL available is now: 2.0.10+5rpi

I updated it with

sudo ./retropie_packages.sh sdl2 install_bin

But, I still see the same issue. Continuing to look.

Through building different versions of SDL2 on Raspbian, I’ve been able to eliminate the RetroPie fork from the list of possible culprits. In fact, the issue seems to arise somewhere between SDL2 release 2.0.5 and 2.0.6. Unfortunately, there 963 commits and 1,364 files to cover. It’s even a lot, focusing just on files that relate to events, keyboard, HID, gamepads, etc.

Still much to do, but on the right track.

Thank you for posting and leaving it posted as I am learning reading your posts. I wish I could help. I too have Picade issues. I started with 2 separate Retropi SD cards. One installs the drivers from, the stock script and works fine. The other kills the keyboard and no joystick ofcourse upon install . Hosed at that point locked up. Re-imaged numerous times to start over.

Looks like I’ve found a probable cause for the issues I’m seeing. In a commit on Nov 22, 2016, there were some changes in order to enhance compatibility with the XBox One S controller.

Note, I’ve been using GitHub for my investigation, and you can see the diff between commits on spurious’s unofficial SDL mirror. I’ve been using that because RetroPie’s version of SDL is a fork from that.

Anyway, it seems the changes increase the range of buttons on controllers, which had been reduced via a BTN_MISC define. This would also seem to be the reason why in previous commits of SDL2, the Picade would only show 16 buttons, while in later versions it shows 135 buttons.

Now to dig into how it might be fixable, and ensure compatibility with the entire range of Picade capabilities (as it’s a programmable controller and can send keyboard, gamepad, and evidently mouse events).

@Claudius2k, if one SD card is working and the other one doesn’t, I’d try a third SD card just in case. Or even try just a stock RetroPie install to make sure there is nothing wrong with that second SD card.

If you have multiple Raspberry Pi’s, Picades, or even power supplies, I’d start swapping components to see which one is causing the problem. If you have a good setup, first switch SD cards. If that is working, then switch Picades. Still working? Switch power supplies. It can be boring, but it’s supposed to be an exhaustive search of the possibilities.

Good luck!

Thanks that sounds like good basic diagnosis. I probably wasn’t perfectly clear about the card itself. The integrity of the card itself is fine. I have narrowed it down. I have two separate Retro pi configurations. The problem with one of them is unique to Picade. There is something the driver installation is remapping differently for the one which doesn’t work. Keyboard keys work before driver installation but key presses are wacky after and the joystick doesn’t register except stick up. I tried manually tricking it using keyboard keys to map the stick but no luck it is scewy. I thought of copying the config.txt file from the working one to the other but I don’t know what else would be unique. I am going to need to study the driver install shell and see what it is doing.That is difficult for me. Thx for replying.

Wow this is useful information. I am new to Picade and know nothing about the Keyboard / Joystick / Driver history. But I see there was an older method before the current one line script which performed installs. I sensed maybe you could run it in pieces or separate components (Stick, Sound, power button etc). Maybe some variation of the ‘old method’ would simplify my problem and work?

Seems that I’ve been successful at diagnosing and now fixing the issue. I patched the most recent SDL release with reverted code from Nov 22, 2016 and everything works as expected. Gamepad configuration sends only gamepad events, keyboard configuration sends only keyboard events. I even did a configuration with a mix of keyboard and gamepad buttons and each individual button works correctly! I went as far as to cross some wires together on my Picade PCB so a single button would trigger both a keyboard and gamepad button and that works correctly too. Very nice! I was concerned that I’d have to choose one or another, but it seems like I don’t!

Now my only concern is how to broach this with the SDL team. The original changes were put in place to enable compatibility with an XBox One controller. Hopefully there is a way to accommodate both.

@Claudius2k, do you have another post about your issue at “Picade Hat installation locking out keyboard” and is that the main issue you are describing? If so, I’ll respond to that post. Thanks!

Thank you very much. I found the /boot/retropie.cfg file and looked at the key mappings. They were not what I expected. I learned the file uses the keyword and BCM code to bind. So I found the Pi pinout for the Picade HAT X. I began editing the file and then I had questions. First question, I have been looking for an agreed upon button layout for the picade? Might as well get the buttons as standard as possible. And also Buttons 3 and 6 don’t seem to be mentioned anywhere. That seems unlikely given they are right on the key panel. So I am searching for how 3 and 6 should be mapped (some say L&R, is that the same LR as the stick?) and then I plan to save the configuration and test. Before remapping I was getting a message saying
Retrogame: Pin config failed. Try ‘sudo /home/pi/Retrogame/retrogame’ ?
Retrogame: Unloading config

Testing was unsuccessful. When setting up, I can map the keyboard and controls beautifully by editing the retrogame.cfg file. It does exactly what I expect BUT since I haven’t loaded the drivers, I have no sound and no power control. The minute I run the driver installation script, it kills everything on the gamepad. Oh sound works and the power switch but the game pad is completely dead and unrecognizable and the keys on the keyboard are pretty erratic too. I must bang on them a little to get control otherwise it just logs out and starts emulation station again. Is it possible to run portions of the driver script so that it doesn’t remap or alter my keysrokes?

That’s the post about the problem

I’ve submitted a bug report (bug 5058) to LibSDL.