petrockblog
Posts: 269
Joined: Wed Jul 04, 2012 6:12 am
Location: Germany
Contact: Website

Re: Multi-console gamepad driver for GPIO

Sat Oct 06, 2012 4:53 pm

marqs wrote:
Anyway, it would be a good idea not to load the driver during the RetroPie-installation (as it is fixed to snes pad -config), but instead pop a dialog which mentions the readme under /usr/share/doc and let the user do rest. Of course there could be a separate option for enabling the 2-player snes pad config, but it shouldn't be done as default.
Thank you for this suggestion! I will change this accordingly in the RetroPie script.
fun stuff for technics enthusiasts: www.petrockblock.com

marqs
Posts: 198
Joined: Sat Jun 09, 2012 11:34 am

Re: Multi-console gamepad driver for GPIO

Sat Oct 06, 2012 5:31 pm

fotastisch wrote:So it seems that somehow my pi doesn't want me to connect controllers via the GPIOs. I'd be happy if someone had an idea how to make it work, preferable for the gamecon-driver, since I already soldered my connector to use the GPIOs 1 and 4. ;)
Could it be that you have rev.2 board, which has a bit different GPIO pinout? That would explain why the first pad doesn't work, though it shouldn't cause any freezes.

After removing the lines from /etc/modules and reboot, try loading the gamecon with the following command:

Code: Select all

# modprobe gamecon_gpio_rpi map=0,0,1
This sets the pad connected to GPIO4 (not changed in the board rev.) as the first controller.

Then try to see if that pad works:

Code: Select all

# jstest /dev/input/js0
I'll add support for rev.2 pi in the next version among other things, but if that's the problem you have, I can provide you a patch.

fotastisch
Posts: 33
Joined: Tue Aug 07, 2012 4:37 pm

Re: Multi-console gamepad driver for GPIO

Sat Oct 06, 2012 7:48 pm

Hey again!

Looks as if I had a minor mix-up earlier with marqs and petrockblog. Sorry for that! ;)

But anyway. Since I tried SNESDev-RPi, I have a problem accessing the SNES games. So I'm removing and reinstalling RetroPie right now to start with a fresh installation.
After adjusting to the GPIOs I am using, my keyboard got still set to capital letters after starting SNESDev and I also noticed that my shift-key stopped working.

Btw, I'm running the newest Raspbian on a rev.2 board. So you're right about the GPIOs, marqs (this time I'm not mixing things up, I hope :) ).

So, if I'm not mistaken, the default GPIOs for the Gamecon-driver are 1 and 4 on the revision 1 board, which would be P1-05 and P1-07. Since I've used the same pins on a revision 2 board, it's now GPIO 3 instead of 1, but shouldn't that be all right?!
I'll check if the second controller is working with gamecon as soon as possible.

Thanks for your help!

fotastisch
Posts: 33
Joined: Tue Aug 07, 2012 4:37 pm

Re: Multi-console gamepad driver for GPIO

Sat Oct 06, 2012 9:21 pm

marqs wrote:

Code: Select all

# jstest /dev/input/js0
Somehow it doesn't work, jstest doesn't give me any input on the controller. But that could actually be a result of my great soldering skills ;)
Nevertheless, trying to start emulationstation, I receive this "dialog" again (that's a real screenshot, isn't it ;) )
Image
While it says, I could press any key to skip, the only working key I've found so far is F4 to shut it down. :D

marqs
Posts: 198
Joined: Sat Jun 09, 2012 11:34 am

Re: Multi-console gamepad driver for GPIO

Sat Oct 06, 2012 9:49 pm

fotastisch wrote:So, if I'm not mistaken, the default GPIOs for the Gamecon-driver are 1 and 4 on the revision 1 board, which would be P1-05 and P1-07. Since I've used the same pins on a revision 2 board, it's now GPIO 3 instead of 1, but shouldn't that be all right?!
You can select from a list of pre-defined GPIOs (0,1,4,7) when you load the module. The configuration which RetroPie-setup does (to /etc/modules), sets it to use GPIO1 & 4 as you mentioned. Check this page and README for more details how to select the pins.
fotastisch wrote:Somehow it doesn't work, jstest doesn't give me any input on the controller. But that could actually be a result of my great soldering skills ;)
Nevertheless, trying to start emulationstation, I receive this "dialog" again (that's a real screenshot, isn't it ;) )
Image
While it says, I could press any key to skip, the only working key I've found so far is F4 to shut it down.
If jstest doesn't show any input, then there's no point going further. Starting Emulationstation gets you that dialog as it detects a joystick, but it cannot get any keypresses.

I'd verify the connections next. Do you have an official or 3rd-party SNES pad? It's probably not related, but I recall reading back in the SNES days that Nintendo made a few different versions of the controllers, so that US pads wouldn't work with PAL SNESes and perhaps vice-versa. I have only tested with US controllers, but I'm fairly sure all versions should work.

fotastisch
Posts: 33
Joined: Tue Aug 07, 2012 4:37 pm

Re: Multi-console gamepad driver for GPIO

Sun Oct 07, 2012 10:46 am

marqs wrote:Starting Emulationstation gets you that dialog as it detects a joystick, but it cannot get any keypresses.
Yes, i see. After not receiving any input from the controllers I actually was trying to skip that dialog by pressing some keyboard keys, but the Pi only reacts to F4 so far.
marqs wrote:I'd verify the connections next. Do you have an official or 3rd-party SNES pad?
I'll see about the connections tomorrow and keep you posted ;) I'm using a 3rd-party controller by EAXUS. So far, I didn't have a chance to verify if they work with a "real" SNES, but I'll try to do so.

fotastisch
Posts: 33
Joined: Tue Aug 07, 2012 4:37 pm

Re: Multi-console gamepad driver for GPIO

Mon Oct 08, 2012 7:01 pm

Hey there!

I checked my not so well soldered adapter today and it seemed to be all right. The resistance was about 0.3 mOhm, so imho that should be all right. And all pins were connected as shown here:
http://petrockblog.wordpress.com/2012/0 ... up-script/

Thanks for the advice about the wiki. Since I wasn't satisfied with the looks of my adapter and it wasn't working anyway, I'm about to build a new one. Do you think there would be a problem choosing the pad 1 and pad 2 pins as shown in the wiki on a revision 2 board?

Thanks!

fotastisch
Posts: 33
Joined: Tue Aug 07, 2012 4:37 pm

Re: Multi-console gamepad driver for GPIO

Tue Oct 09, 2012 12:19 pm

Hey again!

Somehow my Pi wants to keep me from playing ;)
Now I receive the message that the Gamecon driver could not be installed, when I try to enable it.
I think, FATAL here in the messages is not really a good sign, or am I wrong?
Unpacking replacement gamecon-gpio-rpi-dkms ...
Setting up gamecon-gpio-rpi-dkms (0.5) ...
Loading new gamecon_gpio_rpi-0.5 DKMS files...
First Installation: checking all kernels...
It is likely that 3.2.27+ belongs to a chroot's host
Building for architecture armv6l
Module build for the currently running kernel was skipped since the
kernel source for this kernel does not seem to be installed.
FATAL: Module gamecon_gpio_rpi not found.
Added gamecon_gpio_rpi map=0,1,1,0 to file /etc/modules
Thanks for your help!

marqs
Posts: 198
Joined: Sat Jun 09, 2012 11:34 am

Re: Multi-console gamepad driver for GPIO

Tue Oct 09, 2012 4:07 pm

fotastisch wrote:Thanks for the advice about the wiki. Since I wasn't satisfied with the looks of my adapter and it wasn't working anyway, I'm about to build a new one. Do you think there would be a problem choosing the pad 1 and pad 2 pins as shown in the wiki on a revision 2 board?
You can use those pins, but then you need new version of the driver as their respective GPIOs have changed between the board revisions.
fotastisch wrote:Somehow my Pi wants to keep me from playing ;)
Now I receive the message that the Gamecon driver could not be installed, when I try to enable it.
I think, FATAL here in the messages is not really a good sign, or am I wrong?
That's probably due to the shady cleanup routine of the kernel headers, which I had to use as kernel was missing a few Makefiles when I generated the headers .deb. You don't have to reinstall gamecon once you have installed it using RetroPie (currently the menu option "Enable..." installs and enables the driver, and doing that after it has been installed causes problems with the headers). You can just use modprobe to load the driver, or remove the headers manually if you want to start from scratch (dpkg -r linux-headers-3.2.27+).

I'll update the headers package tonight, and also look at updating the actual driver.

petrockblog
Posts: 269
Joined: Wed Jul 04, 2012 6:12 am
Location: Germany
Contact: Website

Re: Multi-console gamepad driver for GPIO

Thu Oct 11, 2012 5:58 am

Thank you for your update for the RetroPie routines for the gamecon driver!

With respect to revision 2 of thr RPi, do you see any difficulties in keeping the same physical pins used by the gamecon driver on the revision 1 board? This would allow for the same peace of GPIO adapter hardware for both boards ...
fun stuff for technics enthusiasts: www.petrockblock.com

marqs
Posts: 198
Joined: Sat Jun 09, 2012 11:34 am

Re: Multi-console gamepad driver for GPIO

Fri Oct 12, 2012 8:13 am

petrockblog wrote:Thank you for your update for the RetroPie routines for the gamecon driver!

With respect to revision 2 of thr RPi, do you see any difficulties in keeping the same physical pins used by the gamecon driver on the revision 1 board? This would allow for the same peace of GPIO adapter hardware for both boards ...
Thanks for merging the installer patch, that should fix the installation issues some people are having.

It's possible to use the same physical pins, you'll just need to use a different map with modprobe and swap the controller ID:s in retroarch.cfg (as GPIO4 gets mapped to player1, and GPIO3 to player2). I can add an input dialog to RetroPie asking which board revision is in use (or read it somehow if possible) when I have the next gamecon version ready. That way the process gets automated.

petrockblog
Posts: 269
Joined: Wed Jul 04, 2012 6:12 am
Location: Germany
Contact: Website

Re: Multi-console gamepad driver for GPIO

Fri Oct 12, 2012 8:17 am

petrockblog wrote: This would allow for the same peace of GPIO adapter hardware for both boards ...
Uups, I had to laugh when I found this typo ...
fun stuff for technics enthusiasts: www.petrockblock.com

petrockblog
Posts: 269
Joined: Wed Jul 04, 2012 6:12 am
Location: Germany
Contact: Website

Re: Multi-console gamepad driver for GPIO

Fri Oct 12, 2012 8:27 am

marqs wrote:It's possible to use the same physical pins, you'll just need to use a different map with modprobe and swap the controller ID:s in retroarch.cfg (as GPIO4 gets mapped to player1, and GPIO3 to player2). I can add an input dialog to RetroPie asking which board revision is in use (or read it somehow if possible) when I have the next gamecon version ready. That way the process gets automated.
Yeah, that would be great!

I just had a quick look into how to automatically determine the RPi revision and found >>this<< thread.

By looking at the Python >>RPi.GPIO library<<, I found some C code that determines the board revision:

Code: Select all

char *get_cpuinfo_revision(char *revision)
{
   FILE *fp;
   char buffer[1024];
   char hardware[1024];
   int  rpi_found = 0;

   if ((fp = fopen("/proc/cpuinfo", "r")) == NULL)
      return 0;

   while(!feof(fp)) {
      fgets(buffer, sizeof(buffer) , fp);
      sscanf(buffer, "Hardware	: %s", hardware);
      if (strcmp(hardware, "BCM2708") == 0)
         rpi_found = 1;
      sscanf(buffer, "Revision	: %s", revision);
   }
   fclose(fp);

   if (!rpi_found)
      revision = NULL;
   return revision;
}

int get_rpi_revision(void)
{
   char revision[1024] = {'\0'};
   
   if (get_cpuinfo_revision(revision) == NULL)
      return -1;
      
   if ((strcmp(revision, "0002") == 0) ||
       (strcmp(revision, "1000002") == 0 ) ||
       (strcmp(revision, "0003") == 0) ||
       (strcmp(revision, "1000003") == 0 ))
      return 1;
   else // assume rev 2 (0004 0005 0006 1000004 1000005 1000006)
      return 2;
}
According to this the revision can be determined by parsing the output of /proc/cpuinfo, which could also be done with bash.
fun stuff for technics enthusiasts: www.petrockblock.com

marqs
Posts: 198
Joined: Sat Jun 09, 2012 11:34 am

Re: Multi-console gamepad driver for GPIO

Thu Oct 18, 2012 8:49 pm

Gamecon is now updated to version 0.9, which can be installed with RetroPie script.

The most important updates are:

1. Support for rev. 2 board gpio pins.
2. Improved robustness for N64 / GC pad reading.
3. Improved performance with PSX pads by reducing the default access delay. The access delay can now also be specified when loading the module.

More information can be found on the wikipage and README.

Segway
Posts: 5
Joined: Sun Sep 23, 2012 2:39 pm

Re: Multi-console gamepad driver for GPIO

Wed Oct 24, 2012 1:21 am

If anyone else is having a hard time with player2_input controls using the gpio driver on the NES emulator, I found that recompiling the NES emulator using the setup script did the trick. Hope that saves someone a night's worth of time troubleshooting.

marqs
Posts: 198
Joined: Sat Jun 09, 2012 11:34 am

Re: Multi-console gamepad driver for GPIO

Wed Oct 24, 2012 9:57 pm

Yeah, I also noticed the problem some time ago but though it would have been fixed by now. It seems that it was fixed a month ago in libretro, but perhaps that's not yet included in RetroPie binaries.

Petrockblog: could you check the version of fceu/libretro in the RetroPie binary, and recompile it if necessary to include the fix? Thanks!

Segway
Posts: 5
Joined: Sun Sep 23, 2012 2:39 pm

Re: Multi-console gamepad driver for GPIO

Wed Oct 24, 2012 10:05 pm

It might already have been fixed. My setup was from September 23 and probably used the binary install. I actually just decided to update the whole image and have been impressed with the various new features bundled in with RetroPie.

jlongstreet
Posts: 31
Joined: Wed Sep 05, 2012 2:59 am

Re: Multi-console gamepad driver for GPIO

Wed Oct 24, 2012 10:11 pm

marqs wrote:Yeah, I also noticed the problem some time ago but though it would have been fixed by now. It seems that it was fixed a month ago in libretro, but perhaps that's not yet included in RetroPie binaries.

Petrockblog: could you check the version of fceu/libretro in the RetroPie binary, and recompile it if necessary to include the fix? Thanks!
If you do a source installation in the RetroPie-Setup script, it'll grab latest from git for all the cores, retroarch, emulationstation, etc.

nubie
Posts: 4
Joined: Wed Nov 07, 2012 7:01 am

Re: Multi-console gamepad driver for GPIO

Thu Nov 08, 2012 9:27 am

I'll be looking into this on my own, but how hard would it be to add 'atari' support, AKA just single GPIO per button, or possibly matrixed buttons?

I am trying to put the Pi in a Gameboy and wanted to avoid any unnecessary components. If there are 8 GPIO pins and 8 buttons on the Gameboy, it should be technically feasible.

I am ignorant of the Raspberry's GPIO, but can they be configured to read as a single byte?

Thanks, my only experience with this is mucking about in the code for an Atmega8 OVR USB to PSX, I added 4 bytes to the read length, increased the button mapping and modified the HID descriptor to enable the D-pad when in analog mode as more buttons instead of being ignored.

Assuming the emulator(s) can use keyboard keys would I be better off trying to adapt this code? http://git.kernel.org/?p=linux/kernel/g ... .c;hb=HEAD

Edit: forgot to add THANKS!! I can't live without my PSX pads and having them on the Pi without the need for a USB converter is a great feeling.

marqs
Posts: 198
Joined: Sat Jun 09, 2012 11:34 am

Re: Multi-console gamepad driver for GPIO

Thu Nov 08, 2012 9:27 pm

nubie wrote:I'll be looking into this on my own, but how hard would it be to add 'atari' support, AKA just single GPIO per button, or possibly matrixed buttons?
That should be quite easy, but I'd implement that kind of scheme in a separate driver (you could take a look at db9.c).
nubie wrote:I am ignorant of the Raspberry's GPIO, but can they be configured to read as a single byte?
One GPIO level register is 32bits, and you can read that at once. You could read just a byte, but the way the pins are distributed makes it unfeasible as you wouldn't be able to read status of 8 physically connected pins.
nubie wrote:Assuming the emulator(s) can use keyboard keys would I be better off trying to adapt this code? http://git.kernel.org/?p=linux/kernel/g ... .c;hb=HEAD
That looks unnecessary complex for this purpose, so I'd adapt db9.c instead.

bleketas
Posts: 8
Joined: Thu Dec 06, 2012 11:01 am

Re: Multi-console gamepad driver for GPIO

Thu Dec 06, 2012 11:04 am

Hi, i'm trying to connect psx pads to my rpi, so far so good, jstest shows input, and even in emulationstation i can move from emulator to emulator, or browse games, but when i start game, nothing happens, game doesn't respond to any button. Any ideas what could be wrong?

bleketas
Posts: 8
Joined: Thu Dec 06, 2012 11:01 am

Re: Multi-console gamepad driver for GPIO

Fri Dec 07, 2012 9:05 am

This evening something vent a bit different. I'm not sure what i have done, but now controller works in the game as well, but games started to lag very much. It's unplayable at all. Any ideas?

marqs
Posts: 198
Joined: Sat Jun 09, 2012 11:34 am

Re: Multi-console gamepad driver for GPIO

Fri Dec 07, 2012 8:00 pm

PSX controller reads cause some overhead, which can be a problem if the emulator is maxing the CPU already without it. If the emu is vsynced and cannot keep with 60fps, the fps is dropped to half. I noticed this with pocketsnes when I tested the PSX driver with stock speeds. Overclocking helped a lot in my case, and I had no issues after some increase in cpu&memory speeds (e.g. 1GHz core / 500MHz sdram). I've attached my OC settings below - you can try them with your own responsibility.

A second thing worth trying is lowering PSX controller access delay (see README) from the default 10us. Not all controllers work reliably with lower delays, though.

Code: Select all

#overclock options
initial_turbo=30
force_turbo=1
arm_freq=1000
core_freq=400
sdram_freq=500
over_voltage=4
over_voltage_sdram=2

atvdude01
Posts: 23
Joined: Wed Oct 03, 2012 8:01 pm

Re: Multi-console gamepad driver for GPIO

Sat Dec 08, 2012 12:09 pm

Well i tried this driver with a gamestop ps2 controller and it didnt work... anyone ever try it with a game stop one? my sony brand ps2 controllers broke so all i have is gamestop brand ones. its the basic gamestop brand nothing fancy about them.

marqs
Posts: 198
Joined: Sat Jun 09, 2012 11:34 am

Re: Multi-console gamepad driver for GPIO

Sat Dec 08, 2012 1:24 pm

atvdude01 wrote:Well i tried this driver with a gamestop ps2 controller and it didnt work... anyone ever try it with a game stop one?
I've tried GameStop-branded Mad Catz Control Pad Pro, which worked OK. You could try to raise the access delay, although it has a negative impact on performance. The original driver code had 25us as the default btw.

Return to “Gaming”

Who is online

Users browsing this forum: No registered users and 21 guests