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

Re: Multi-console gamepad driver for GPIO

Tue Dec 01, 2015 5:30 pm

Soullous wrote:I've got two PSX controller ports wired to the Raspberry Pi (v2), using the gamecon_gpio driver, they seem to be working, OK for the most part, except for a few issues. I have two original Sony PS2 DualShock controllers, and one original Sony PS1 DualShock controller.
SCPH-1200 and SCPH-10010, right? It's a bit strange to get reports of these symptoms as I've tested at least 3 different PS1/PS2 controllers and none of those had any issues.
Soullous wrote:1) The left analog stick does not register on any of them in EmulationStation, although they register in jstest. I've seen mentions of several other people with the same issue, but have yet to see a solution.
That's probably due to axis mapping since d-pad is always mapped as the first axis (could otherwise cause issues when controller is in digital mode), and analog sticks are mapped as second and third axis. There should be an option in EmulationStation to define which axis is used for input in the UI.
Soullous wrote:2) The Start and Select buttons do not register on the PS1 controller. This is unfortunate, since I'm doing a PS1 case mod, and would like to use original PS1 controllers.
That might be a timing issue as Start&Select are the first buttons read after issuing the read command. Did you try different psx_delay values when loading the driver?
Soullous wrote:3) I'm not sure if it's an issue or not, but jstest shows constant movement when in analog mode. I'm assuming because the analog sticks are not properly calibrated.
What's the magnitude of the movement out of the range (-32768...32767)? It's possible to set deadzone etc. via jscal, but the calibration applies only to applications which use "joystick"-interface instead of "evdev".
Soullous wrote:4) Certain PS1 games don't seem to be registering the controller correctly, using lr-pcsx-rearmed. For instance, on Crash Bandicoot, I can't get past the title screen. No buttons seem to register here. On Oddworld: Abe's Odysee, I can navigate the title screen just fine, but once the game starts, it says "Unsupported Controller in Port 1".
Perhaps they won't work with controllers configured in analog mode. You should try changing controller type in pcsx config.

Soullous
Posts: 16
Joined: Sat Nov 28, 2015 10:49 pm

Re: Multi-console gamepad driver for GPIO

Tue Dec 01, 2015 9:31 pm

Thanks for the reply. Responses below:
marqs wrote:
Soullous wrote:I've got two PSX controller ports wired to the Raspberry Pi (v2), using the gamecon_gpio driver, they seem to be working, OK for the most part, except for a few issues. I have two original Sony PS2 DualShock controllers, and one original Sony PS1 DualShock controller.
SCPH-1200 and SCPH-10010, right? It's a bit strange to get reports of these symptoms as I've tested at least 3 different PS1/PS2 controllers and none of those had any issues.
Yes, those are the ones.
marqs wrote:
Soullous wrote:1) The left analog stick does not register on any of them in EmulationStation, although they register in jstest. I've seen mentions of several other people with the same issue, but have yet to see a solution.
That's probably due to axis mapping since d-pad is always mapped as the first axis (could otherwise cause issues when controller is in digital mode), and analog sticks are mapped as second and third axis. There should be an option in EmulationStation to define which axis is used for input in the UI.
It's not just that I can't use the analog stick for navigation in the EmulationStation UI. That wouldn't be that big of a deal. But when I go to configure my contollers through EmulationStation's GUI, it doesn't register any input at all on the left analog stick, so I can't configure any of the emulators to use the left analog stick, either. Perhaps I just have to find the configuration files that EmulationStation creates and edit them manually?
marqs wrote:
Soullous wrote:2) The Start and Select buttons do not register on the PS1 controller. This is unfortunate, since I'm doing a PS1 case mod, and would like to use original PS1 controllers.
That might be a timing issue as Start&Select are the first buttons read after issuing the read command. Did you try different psx_delay values when loading the driver?
I was using the default setting, but changed it to psx_delay=25, then psx_delay=50, and it behaves the same. Here's the entry in /etc/modules. I rebooted after making a change.
gamecon_gpio_rpi map=0,0,0,0,7,7 psx_delay=50
marqs wrote:
Soullous wrote:3) I'm not sure if it's an issue or not, but jstest shows constant movement when in analog mode. I'm assuming because the analog sticks are not properly calibrated.
What's the magnitude of the movement out of the range (-32768...32767)? It's possible to set deadzone etc. via jscal, but the calibration applies only to applications which use "joystick"-interface instead of "evdev".
It's showing the full range -32767...32767 for each axis. I haven't looked into setting deadzones yet, and not really sure what applications it would affect. I may look into it more later... need to get the joysticks actually working before I worry too much about calibrating them, though.
marqs wrote:
Soullous wrote:4) Certain PS1 games don't seem to be registering the controller correctly, using lr-pcsx-rearmed. For instance, on Crash Bandicoot, I can't get past the title screen. No buttons seem to register here. On Oddworld: Abe's Odysee, I can navigate the title screen just fine, but once the game starts, it says "Unsupported Controller in Port 1".
Perhaps they won't work with controllers configured in analog mode. You should try changing controller type in pcsx config.
That's probably it! I know these games didn't use the analog sticks. I'll look into setting up separate configurations for them. So, it sounds like turning off the analog button has no effect on the driver, right? It will always read as an analog controller by default?

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

Re: Multi-console gamepad driver for GPIO

Wed Dec 02, 2015 6:13 pm

Soullous wrote:It's not just that I can't use the analog stick for navigation in the EmulationStation UI. That wouldn't be that big of a deal. But when I go to configure my contollers through EmulationStation's GUI, it doesn't register any input at all on the left analog stick, so I can't configure any of the emulators to use the left analog stick, either. Perhaps I just have to find the configuration files that EmulationStation creates and edit them manually?
The axes corresponding to left stick are named as hat axes (ABS_HAT0X, ABS_HAT0Y), so it perhaps it causes some applications to treat those as digital axes. Modifying the config files manually should do the job.
Soullous wrote:It's showing the full range -32767...32767 for each axis. I haven't looked into setting deadzones yet, and not really sure what applications it would affect. I may look into it more later... need to get the joysticks actually working before I worry too much about calibrating them, though.
The erroneous movement is also that high? There's something really wrong if a centered joystick reports values over 10% of the full range.
Soullous wrote:That's probably it! I know these games didn't use the analog sticks. I'll look into setting up separate configurations for them. So, it sounds like turning off the analog button has no effect on the driver, right? It will always read as an analog controller by default?
Turning analog mode off should make second and third axis disappear from the driver output, but it won't change the pad type which emulator reports to the game.

Soullous
Posts: 16
Joined: Sat Nov 28, 2015 10:49 pm

Re: Multi-console gamepad driver for GPIO

Wed Dec 02, 2015 6:59 pm

marqs wrote:
Soullous wrote:It's not just that I can't use the analog stick for navigation in the EmulationStation UI. That wouldn't be that big of a deal. But when I go to configure my contollers through EmulationStation's GUI, it doesn't register any input at all on the left analog stick, so I can't configure any of the emulators to use the left analog stick, either. Perhaps I just have to find the configuration files that EmulationStation creates and edit them manually?
The axes corresponding to left stick are named as hat axes (ABS_HAT0X, ABS_HAT0Y), so it perhaps it causes some applications to treat those as digital axes. Modifying the config files manually should do the job.
Thanks. I was able to get the analog sticks working in PS1 games by more or less following this post.
http://blog.petrockblock.com/forums/top ... post-90700

I switched to the linuxraw driver and manually configured the inputs for PS1. I still need to figure out how to configure MAME and N64. It's kind of unfortunate, since all of these should be configured automatically by RetroPie, but it's unable to see the left analog stick during the configuration process.
marqs wrote:
Soullous wrote:It's showing the full range -32767...32767 for each axis. I haven't looked into setting deadzones yet, and not really sure what applications it would affect. I may look into it more later... need to get the joysticks actually working before I worry too much about calibrating them, though.
The erroneous movement is also that high? There's something really wrong if a centered joystick reports values over 10% of the full range.
No, sorry. I thought you were asking me to check the full range. The maximum values reported by jstest for the axes at rest look something like this:

2: -1366
3: -2185
4: -2185
5: -820

I'm not really sure if this is causing any issues in-game yet, because I still have to get the analog sticks working with MAME and N64 and have only tested 1 PSX game that uses them so far. I did notice that it makes it very difficult to configure the joysticks using the RetroPie GUI, since the constant movement of the right analog stick at rest (it can't see the left one) makes it think that you are pressing buttons when you are not, so it keeps wanting to map random buttons to the right stick.
marqs wrote:
Soullous wrote:That's probably it! I know these games didn't use the analog sticks. I'll look into setting up separate configurations for them. So, it sounds like turning off the analog button has no effect on the driver, right? It will always read as an analog controller by default?
Turning analog mode off should make second and third axis disappear from the driver output, but it won't change the pad type which emulator reports to the game.
Thanks. That makes sense. I'm able to get the PSX games working in either analog or digital mode now. Now to figure out how to set analog or digital on a per-game basis. Adding the relevant lines to the RetroArch per-game config files doesn't seem to have any effect.

Soullous
Posts: 16
Joined: Sat Nov 28, 2015 10:49 pm

Re: Multi-console gamepad driver for GPIO

Wed Dec 09, 2015 7:08 am

marqs,

Thanks for the help on this... and for all the hard work that went into creating this driver! However, after several hours of messing around with this, I am still unable to get the left analog stick on the PSX controller to work on anything other than lr-pcsx-rearmed, and that is by telling it to use the linuxraw driver rather than udev or sdl. I'm trying to set it up for mupen64plus, mame4all, etc. which do not use RetroArch, and none of these are able to see the left analog stick, and neither is the gamepad configuration screen in EmulationStation.

For MAME, I opened the configuration menu with Tab, and ran through the input configurations. It was able to read the button presses and map all of the buttons, except for the left analog stick, for which it gets no reading. The configuration seems to be stored in a binary format, so the only way to configure the joysticks that I can see, is through the GUI. And since the GUI is unable to read them, that means this will never work for MAME. :(

On mupen64plus, I don't believe there is any graphical configuration, but I updated InputAutoConfig.ini and added a [PSX controller] section. I tried to configure both axis 4/5 and hat 0/1 for the X and Y axis, but neither seems to work, although the rest of the mapping seems to be OK. Also interesting to note, this file has built-in configurations for dozens of other joysticks, and none of them are using hat axes for X and Y. There are several other controllers using hat axes, but they are mostly all map to the D-Pad, with a handful using them for the right stick. Admittedly, I'm not familiar with any of this stuff, but the fact that the D-Pad and analog sticks of the PSX controller are configured differently than any other type of controller has me wondering if maybe the driver shouldn't be reporting these axes differently.

For reference, here is my InputAutoConfig.ini entry for the PSX controller:

Code: Select all

[PSX controller]
plugged = True
plugin = 2
mouse = False
AnalogDeadzone = 4096,4096
AnalogPeak = 32768,32768
DPad R = axis(0+)
DPad L = axis(0-)
DPad D = axis(1+)
DPad U = axis(1-)
Start = button(9)
Z Trig = button(5)
B Button = button(2)
A Button = button(1)
C Button R = axis(2+)
C Button L = axis(2-)
C Button D = axis(3+)
C Button U = axis(3-)
R Trig = button(7)
L Trig = button(6)
Mempak switch = 
Rumblepak switch = 
X Axis = hat(0-,0+)
Y Axis = hat(1-,1+)
Notice how the X Axis and Y Axis are configured differently than the other buttons, with a single line for X and Y. I'm not even sure if hat(0-,0+) is the correct format to use here, since no other controller uses hat for X and Y. Here is the built-in configuration for an X-Box 360 controller:

Code: Select all

; X-box controllers and compatible clones
[Microsoft X-Box pad v1 (US)]
[Microsoft X-Box pad v2 (US)]
[Microsoft X-Box pad (Japan)]
[Microsoft Xbox Controller S]
[Thrustmaster, Inc. Controller]
[Logitech Xbox Cordless Controller]
[Logitech Compact Controller for Xbox]
[Mad Catz Controller (unverified)]
[InterAct 'PowerPad Pro' X-Box pad (Germany)]
[Mad Catz Control Pad]
[Mad Catz LumiCON]
[Mad Catz Control Pad Pro]
[Mad Catz MicroCON]
[Mad Catz Lynx Wireless Controller]
[Zeroplus Xbox Controller]
[Pelican Eclipse PL-2023]
[Zeroplus Xbox Controller]
[Radica Gamester Controller]
[Radica Games Jtech Controller]
[Logic3 Freebird wireless Controller]
[Eclipse wireless Controller]
[Edge wireless Controller]
[SmartJoy Frag Xpad/PS2 adaptor]
[Joytech Advanced Controller]
[BigBen XBMiniPad Controller]
[Joytech Wireless Advanced Controller]
[Chinese-made Xbox Controller]
[Generic X-Box pad]
plugged = True
plugin = 2
mouse = False
AnalogDeadzone = 4096,4096
AnalogPeak = 32768,32768
DPad R = hat(0 Right)
DPad L = hat(0 Left)
DPad D = hat(0 Down)
DPad U = hat(0 Up)
Start = button(7)
Z Trig = axis(2+)
B Button = button(2)
A Button = button(0)
C Button R = axis(3+)
C Button L = axis(3-) button(3)
C Button D = axis(4+) button(1)
C Button U = axis(4-)
R Trig = button(5) axis(5+)
L Trig = button(4)
Mempak switch = button(9)
Rumblepak switch = button(10)
X Axis = axis(0-,0+)
Y Axis = axis(1-,1+)
Any ideas?
Thanks!

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

Re: Multi-console gamepad driver for GPIO

Wed Dec 09, 2015 11:02 pm

Mapping the left analog stick to hat axis has its roots in the original gamecon driver for parport. I can only guess that the purpose was to always map d-pad to first axis (ABX_X, ABS_Y) regardless whether controller was in analog mode or not - which worked ok 15 years ago or so when the driver was written as applications back then probably treated all axis the same way.

I can modify the mappings in the driver so that d-pad will be hat0/hat1 and analog sticks are x/y and rx/ry axis. I'll test this on the next weekend and update the packages.

Soullous
Posts: 16
Joined: Sat Nov 28, 2015 10:49 pm

Re: Multi-console gamepad driver for GPIO

Wed Dec 09, 2015 11:53 pm

That would be awesome! Thanks for looking into it. I tried to dig into the code myself, but have no idea what's going on in there. :D

muelli
Posts: 56
Joined: Sat Jul 21, 2012 12:16 pm

Re: Multi-console gamepad driver for GPIO

Thu Dec 10, 2015 4:21 pm

Is there already a header package for 4.1.14+ ?
I tried to download the rpi kernel myself und preparte it, the modules build OK, but when I try to

modprobe db9_gpio_rpi

I get
root@raspberrypi:~/db9# modprobe db9_gpio_rpi map=1,1

Message from syslogd@raspberrypi at Dec 10 17:14:19 ...
kernel:[ 3021.275852] Internal error: Oops: 5 [#1] PREEMPT ARM

Message from syslogd@raspberrypi at Dec 10 17:14:19 ...
kernel:[ 3021.318143] Process modprobe (pid: 20379, stack limit = 0xdc6b4188)

Message from syslogd@raspberrypi at Dec 10 17:14:19 ...
kernel:[ 3021.321077] Stack: (0xdc6b5e90 to 0xdc6b6000)

Message from syslogd@raspberrypi at Dec 10 17:14:19 ...
kernel:[ 3021.323983] 5e80: bf15a6d0 00007fff c008a094 ffffffff

Message from syslogd@raspberrypi at Dec 10 17:14:19 ...
kernel:[ 3021.326982] 5ea0: e04a0000 00000002 bf15a6d0 00000000 bf15a6d0 bf15a844 bf15a678 bf15a834

Message from syslogd@raspberrypi at Dec 10 17:14:19 ...
kernel:[ 3021.330026] 5ec0: b6ee0000 dc6b4000 00002db8 00004090 00000000 00000000 00000000 00000000

Message from syslogd@raspberrypi at Dec 10 17:14:19 ...
kernel:[ 3021.333101] 5ee0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
Segmentation fault

Which does not look good :(

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

Re: Multi-console gamepad driver for GPIO

Thu Dec 10, 2015 4:51 pm

muelli wrote:Is there already a header package for 4.1.14+ ?
I tried to download the rpi kernel myself und preparte it, the modules build OK, but when I try to
I triggered the build manually (header packages are automatically built every night so there may be a small delay after new fw release) and 4.1.14+ header package is now available. Hopefully that fixes your issue.

muelli
Posts: 56
Joined: Sat Jul 21, 2012 12:16 pm

Re: Multi-console gamepad driver for GPIO

Thu Dec 10, 2015 6:01 pm

Thanks, it worked :)

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

Re: Multi-console gamepad driver for GPIO

Mon Dec 14, 2015 12:16 am

Soullous wrote:That would be awesome! Thanks for looking into it. I tried to dig into the code myself, but have no idea what's going on in there. :D
I swapped axis types and made a few other improvements (better reliability, less cpu cycles) to psx driver. You can download new version here, and install it as follows:

Code: Select all

dpkg -i gamecon-gpio-rpi-dkms_1.1_all.deb
Hopefully that fixes your axis issue and unresponsive select button.

Soullous
Posts: 16
Joined: Sat Nov 28, 2015 10:49 pm

Re: Multi-console gamepad driver for GPIO

Mon Dec 14, 2015 5:07 am

Thanks. I updated to 1.1. I'm not sure exactly what changed, but the buttons on all of my controllers (PS1 and PS2) seem to have a mind of their own now. They all seem to be registering randomly, as soon as the controllers are plugged in, and actually pressing the buttons seems to have no effect. I did try changing the psx_delay from 10 to 25, and then to 50, with no effect.

Here is some output from jstest with the controller plugged in and analog mode turned off on the controller, with no buttons being pressed physically. Notice how several buttons constantly register as on (the buttons which are registering do change from time to time), and the axes all appear to have some extreme values when they are centered.

Code: Select all

pi@retropie ~ $ jstest /dev/input/js0
Driver version is 2.1.0.
Joystick (PSX controller) has 6 axes (X, Y, Rx, Ry, Hat0X, Hat0Y)
and 12 buttons (BtnX, BtnY, BtnTL, BtnTR, BtnTR2, BtnSelect, BtnStart, BtnMode, BtnThumbL, BtnThumbR, ?, ?).
Testing ... (interrupt to exit)
Axes:  0: 12287  1:-32767  2:-16111  3:  9284  4:     0  5:     0 Buttons:  0:on   1:on   2:off  3:off  4:on   5:on   6:off  7:off  8:on   9:on  10:on  11:on

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

Re: Multi-console gamepad driver for GPIO

Mon Dec 14, 2015 9:45 pm

Soullous wrote:Thanks. I updated to 1.1. I'm not sure exactly what changed, but the buttons on all of my controllers (PS1 and PS2) seem to have a mind of their own now. They all seem to be registering randomly, as soon as the controllers are plugged in, and actually pressing the buttons seems to have no effect. I did try changing the psx_delay from 10 to 25, and then to 50, with no effect.
I modified the new version so that tweaking psx_delay is no more needed (and has no effect). I made a new test today, using RPi v2 (used RPi1 originally) and testing different pins. I think I found the reason why some people are having problems with PSX controllers: the internal pull-up resistors are not sufficient for reliable operation. The solution is to use gpio pins P1-03 or P1-05 for the data line (1.8kohm onboard pull-up). If more than 2 controllers needs to be plugged or if those pins are used for something else, an external pull-up resistor (anything between 1.8k-4.7k should be fine) must be added per each additional data pin (GPIO4 / GPIO7) and 3.3V.

Tested 2 different controllers with driver version 1.1 using that setup, and everything worked reliably. Analog sticks registered slight random movement at rest though, but that might be a controller "feature" and can be filtered out with suitable deadzone settings.

chrisis
Posts: 1
Joined: Wed Dec 23, 2015 12:35 pm

Re: Multi-console gamepad driver for GPIO

Wed Dec 23, 2015 12:58 pm

I have modofied the latest latest version (1.1) of the gamecon driver to make it compatible with the NES Four Score. With the modifications I've made it is possible to use the NES Four Score to add two extra NES gamepads (player 3 and 4) without having to use any extra GPIOs. It is also possible to hot swap between a NES gamepad and a NES Four Score.

Would it be possible for you (Marqs) to add my modifications to an upcoming release of your gamecon driver? There might be others out there, besides me, who would like to have this feature.

I'm also planning to add SNES Multitap support some time in the future, when I have more time for coding.

Soullous
Posts: 16
Joined: Sat Nov 28, 2015 10:49 pm

Re: Multi-console gamepad driver for GPIO

Wed Dec 23, 2015 8:41 pm

marqs wrote:The solution is to use gpio pins P1-03 or P1-05 for the data line (1.8kohm onboard pull-up). If more than 2 controllers needs to be plugged or if those pins are used for something else, an external pull-up resistor (anything between 1.8k-4.7k should be fine) must be added per each additional data pin (GPIO4 / GPIO7) and 3.3V.
Sorry I haven't replied back sooner. I was waiting until I had time to open it up and switch the pins, but P1-03 and P1-05 are the pins that I have always been using (I believe). My pins look like the image on the RetroPie Wiki, except I'm using a Pi 2, so I have more pins, and power and ground are coming from the PS1 power supply rather than the Pi. In the 1.0 build this worked fine with psx_delay=10 (with the exception of the left analog stick not working, of course), but in 1.1, all of my controllers are unusable. I have 2 PS2 DualShocks, 1 PS1 DualShock, and 2 Generic PS2 wireless controllers. The wireless controllers will randomly register button presses, as long as the dongle is plugged in, even if the controllers themselves are turned off and not sending a signal.

In the image below I'm using the pins labeled PAD1, PAD2, PSX_CMD, PSX_SEL, and PSX_CLK.
3.3V, 7.4?V, and GND are coming from the PS1 power supply.
Image

The line in /etc/modules which loads the driver is:

Code: Select all

gamecon_gpio_rpi map=0,0,0,0,7,7
Am I doing something wrong? Any other ideas?

Thanks.

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

Re: Multi-console gamepad driver for GPIO

Wed Dec 23, 2015 9:23 pm

Soullous wrote:My pins look like the image on the RetroPie Wiki, except I'm using a Pi 2, so I have more pins, and power and ground are coming from the PS1 power supply rather than the Pi. In the 1.0 build this worked fine with psx_delay=10 (with the exception of the left analog stick not working, of course), but in 1.1, all of my controllers are unusable.

In the image below I'm using the pins labeled PAD1, PAD2, PSX_CMD, PSX_SEL, and PSX_CLK.
3.3V, 7.4?V, and GND are coming from the PS1 power supply.
I think you should at least wire grounds (PSX & RPi) together if you haven't already done so. Besides that, I don't have any ideas what could cause your issues. Overclocking could somewhat affect timing but not so much that it should make any difference here.

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

Re: Multi-console gamepad driver for GPIO

Wed Dec 23, 2015 9:28 pm

chrisis wrote:I have modofied the latest latest version (1.1) of the gamecon driver to make it compatible with the NES Four Score. With the modifications I've made it is possible to use the NES Four Score to add two extra NES gamepads (player 3 and 4) without having to use any extra GPIOs. It is also possible to hot swap between a NES gamepad and a NES Four Score.

Would it be possible for you (Marqs) to add my modifications to an upcoming release of your gamecon driver? There might be others out there, besides me, who would like to have this feature.

I'm also planning to add SNES Multitap support some time in the future, when I have more time for coding.
Sure, that's great! Just PM me with the details where to fetch your patch and I'll add it to next release.

Soullous
Posts: 16
Joined: Sat Nov 28, 2015 10:49 pm

Re: Multi-console gamepad driver for GPIO

Thu Dec 24, 2015 12:46 am

marqs wrote:I think you should at least wire grounds (PSX & RPi) together if you haven't already done so. Besides that, I don't have any ideas what could cause your issues.
OK, now I'm getting somewhere. I ran a jumper cable between the grounds and the random button presses is now gone. I figured ground was ground, so it didn't matter which ground it was hooked up to. Apparently not!

However, something still seems to be wrong. I've also tried hooking the power and ground directly up to the RPi, and the behavior is the same. According to jstest, everything seems to be working, and the D-Pad is now mapped to Axis 4/5 and the left analog stick is on Axis 0/1. I'm able to navigate EmulationStation using my previous configuration, except the left analog stick is now used for navigation instead of the D-Pad. However, if I try to re-configure my joystick now through EmulationStation (Start > Configure Inputs), EmulationStation freezes up as soon as it starts looking for keypresses. It also freezes up if I try to map the D-Pad in the RetroArch GUI. I've tried modifying es_input.cfg just to try to get navigation working in EmulationStation, but I can't figure out what the mappings are supposed to be. They don't seem to match what SDL/EmulationStation are expecting based on Aloshi's comment here.

Code: Select all

#define SDL_HAT_UP              0x01
#define SDL_HAT_RIGHT           0x02
#define SDL_HAT_DOWN            0x04
#define SDL_HAT_LEFT            0x08
I tried commenting out all of the up/down/right sections from es_input.cfg, and just played with left, trying to determine which buttons mapped to which buttons map to which HAT values. It looks like the left button maps to HAT 0 Value 2, and down maps to HAT 0 Value 4. The rest of them I can't figure out. But the worst part is, when I do happen to get a button mapped, once I restart emulationstation and press it, it never stops registering the button press! If I press the left button in emulation station, it just starts scrolling left through all of the menus, until eventually emulationstation freezes up and becomes unresponsive, even with the keyboard.

Again, everything except the left analog stick works fine in version 1.0, but I am now unable to use the D pad or configure my controllers through the GUI in version 1.1

Here is my PSX Controller section of es_input.cfg:

Code: Select all

  <inputConfig type="joystick" deviceName="PSX controller">
    <input name="start" type="button" id="9" value="1"/>
    <input name="select" type="button" id="8" value="1"/>
    <input name="pagedown" type="button" id="5" value="1"/>
    <input name="pageup" type="button" id="4" value="1"/>
    <input name="a" type="button" id="2" value="1"/>
    <input name="b" type="button" id="1" value="1"/>

    <!-- <input name="up" type="hat" id="0" value="1"/> -->
    <!-- <input name="down" type="hat" id="0" value="4"/> -->
    <!-- <input name="right" type="hat" id="0" value="2"/> -->
    <input name="left" type="hat" id="0" value="2"/>
  </inputConfig>

Schnell
Posts: 19
Joined: Sat Jun 21, 2014 4:02 am

Re: Multi-console gamepad driver for GPIO

Sun Dec 27, 2015 9:42 pm

Hello,

I've spent the last couples hours trying to get this to work. It's all installed and everything is set up, to the point where I need to run modprobe. I have a Raspberry Pi 2 and I have no idea where to wire the N64 wires to. The first 6 pins on the left and right side are covered up so I have to use whats left. If anyone can help me or tell me what pins I can use, it'd be greatly appreciated. If I need to put up any more info or pictures I can.

Edit
Right now I have the data plugged into the botton left GPIO port, SCLK/GPIO21. The power comes from the 3.3v pin, #17. And the ground is the ground next to the 3.3v I just mentioned.

Thanks,
Schnell

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

Re: Multi-console gamepad driver for GPIO

Sun Dec 27, 2015 9:55 pm

If you have only a single controller, you can plug it to GPIO7 and load the driver with:

Code: Select all

modprobe --first-time gamecon_gpio_rpi map=0,0,0,6
Schnell wrote:Hello,

I've spent the last couples hours trying to get this to work. It's all installed and everything is set up, to the point where I need to run modprobe. I have a Raspberry Pi 2 and I have no idea where to wire the N64 wires to. The first 6 pins on the left and right side are covered up so I have to use whats left. If anyone can help me or tell me what pins I can use, it'd be greatly appreciated. If I need to put up any more info or pictures I can.

Edit
Right now I have the data plugged into the botton left GPIO port, SCLK/GPIO21. The power comes from the 3.3v pin, #17. And the ground is the ground next to the 3.3v I just mentioned.

Thanks,
Schnell

Schnell
Posts: 19
Joined: Sat Jun 21, 2014 4:02 am

Re: Multi-console gamepad driver for GPIO

Sun Dec 27, 2015 10:04 pm

marqs wrote:If you have only a single controller, you can plug it to GPIO7 and load the driver with:

Code: Select all

modprobe --first-time gamecon_gpio_rpi map=0,0,0,6
That worked perfectly! What is the underlying logic behind that? I was trying things like map=6,7. As in Pad6 for n64 and 7 for GPIO7. I'd like to set up one more controller and I don't want to keep having to have people feed me the code, lol. Thanks again for your help.

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

Re: Multi-console gamepad driver for GPIO

Sun Dec 27, 2015 10:10 pm

Soullous wrote:However, something still seems to be wrong. I've also tried hooking the power and ground directly up to the RPi, and the behavior is the same. According to jstest, everything seems to be working, and the D-Pad is now mapped to Axis 4/5 and the left analog stick is on Axis 0/1. I'm able to navigate EmulationStation using my previous configuration, except the left analog stick is now used for navigation instead of the D-Pad. However, if I try to re-configure my joystick now through EmulationStation (Start > Configure Inputs), EmulationStation freezes up as soon as it starts looking for keypresses. It also freezes up if I try to map the D-Pad in the RetroArch GUI.
I checked this today with more time. While everything was looking fine with jstest, I managed to reproduce your issues with other test apps (e.g. sdl-jstest, retroarch-joyconfig). I also checked the signals with oscilloscope and found out that udelay() implementation may generate far too short delay, which causes some uncertainty. There was also a bug in the hat axis setup code which causes SDL to de-center the hat. I fixed these and also tweaked deadzone in the driver so it should be no more necessary to tweak it in userspace. Now everything seems to be working great but I still continue testing for a short while before making a new version available.

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

Re: Multi-console gamepad driver for GPIO

Sun Dec 27, 2015 10:14 pm

Schnell wrote:That worked perfectly! What is the underlying logic behind that? I was trying things like map=6,7. As in Pad6 for n64 and 7 for GPIO7. I'd like to set up one more controller and I don't want to keep having to have people feed me the code, lol. Thanks again for your help.
It is explained here and in the driver README (/usr/share/doc/gamecon_gpio_rpi/README.gz).

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

Re: Multi-console gamepad driver for GPIO

Mon Dec 28, 2015 11:00 am

marqs wrote:I checked this today with more time. While everything was looking fine with jstest, I managed to reproduce your issues with other test apps (e.g. sdl-jstest, retroarch-joyconfig). I also checked the signals with oscilloscope and found out that udelay() implementation may generate far too short delay, which causes some uncertainty. There was also a bug in the hat axis setup code which causes SDL to de-center the hat. I fixed these and also tweaked deadzone in the driver so it should be no more necessary to tweak it in userspace. Now everything seems to be working great but I still continue testing for a short while before making a new version available.
Version 1.2 is now available with both PSX pad fixes and NES fourscore support. If there's no issues this time, I will soon update RetroPie-script to use that version.

Soullous
Posts: 16
Joined: Sat Nov 28, 2015 10:49 pm

Re: Multi-console gamepad driver for GPIO

Mon Dec 28, 2015 6:13 pm

marqs wrote:Version 1.2 is now available with both PSX pad fixes and NES fourscore support. If there's no issues this time, I will soon update RetroPie-script to use that version.
OK. I updated to 1.2, and it now appears to be working! :D Thanks!

I did have issues when I first installed it (still couldn't configure the controllers through EmulationStation). But then I purged the package and reinstalled it, manually configured es_input.cfg, and then configured the controllers through RetroArch GUI, and it worked fine. I then went back into EmulationStation's configuration screen, and it worked fine this time as well. So, I'm not sure what the issue was the first time, but now it appears to be working and all is good so far. I don't have a lot of time right now, to test/play, but so far so good.

Thanks again for all the work you did on this!

Return to “Gaming”

Who is online

Users browsing this forum: No registered users and 13 guests