Homepage Forums RetroPie Project Everything else related to the RetroPie Project Analog support for PSX controllers via GPIO

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #90633
    Borgar
    Participant

    My setup: A Raspberry Pi 2 using one (or two) Sony Dual-Shock PSX (PS1/PS2) controllers linked up via GPIO, running on RetroPie 2.6.

    The gamecon_gpio_rpi module is loaded like this:

    gamecon_gpio_rpi map=0,0,0,0,7,7 psx-delay=10

    Everything is working smooth except for this one last thing that’s driving me absolutly insane: Left analog stick refuses to cooperate!

    I’m pretty sure all my settings are fine, as dpad and buttons all work perfectly and by running Ape Escape I can confirm that the right analog stick works as expected. But not the left one. :(

    Running jstest reports this:

    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, ?, ?).

    All axis look and work fine when testing them in jstest. But I think that axis 5 and 6 reported as hats may be the problem (or some part of it).

    If I run retroarch-joyconfig it wants to assign these axis as buttons. With something like this:

    input_l_x_plus_btn = h0right

    Same thing happens in retroarch input config menus: Hat axis are assigned as buttons.

    This does indeed work to some degree. But the fine-movement noise from the stick causes button presses all over the place. I’ve tried running jscal to try to correct for this but to no effect.

    Setting input_l_x_plus_axis to h0right does nothing, as does setting it to axis numbers 5 and 6.

    I’ve tried switching controllers to other versions (using other SCPH numbers) but this changes nothing.

    So I’m pretty much out of ideas at this point expect. Can anyone please point me in the right direction?

    #90651
    justinbeaird
    Participant

    What emulators you using? it seams many of them don’t support analog joysticks. Mame and pfba are the only ones that do out of the box. Psx you have to enable in the emulator GUI. Their is a way to fake it with dpad as analog

    #90652
    Borgar
    Participant

    To clarify: All emulators that I have running are working fine. For SNES/NES/GB/Megadrive I only need, and want, the d-pad. I am only interested in analog support for the PSX, which I think is pcsx-rearmed retroarch core. It’s whatever 2.6 uses by default and is most certainly a retroarch core.

    Analog is already enabled. As I said above; the right analog stick does work! The left one is the only thing missing.

    #90653
    justinbeaird
    Participant

    [quote=90652]To clarify: All emulators that I have running are working fine. For SNES/NES/GB/Megadrive I only need, and want, the d-pad. I am only interested in analog support for the PSX, which I think is pcsx-rearmed retroarch core. It’s whatever 2.6 uses by default and is most certainly a retroarch core.

    Analog is already enabled. As I said above; the right analog stick does work! The left one is the only thing missing.
    [/quote]

    try this

    /opt/retropie/configs/all/retroarch-core-options.cfg

    change

    pcsx_rearmed_pad1type = “standerd”
    to
    pcsx_rearmed_pad1type = “analog”
    

    there is a hotkey to do this in the psx emulator menu that you can setup
    some games will tell you controller not supported until you change it back to standard. ans some the opposite. thats why the menu hotkey is useful

    #90654
    Borgar
    Participant

    It is already set that way. Which is why analog works for the right stick.

    #90657
    justinbeaird
    Participant

    [quote=90654]It is already set that way. Which is why analog works for the right stick.[/quote]
    OK sorry I am fairly new and am using Xbox wireless controller and thought the above would help since i t was the only way I could get joysticks working in ape escape the character in that game would only look up and down before I changed that.
    And I couldn’t get the menu is psx to come uup

    #90658
    Borgar
    Participant

    Yeah, this problem is something very specific to this particular controller. Possibly in the driver. But thanks anyway.

    #90694
    kevinfol
    Participant

    I’m having the same issue as Borgar. Both analogs work perfectly in jstest, and the right analog works fine in emulators, but the left analog is non-responsive. I too am using psx controllers with marqs gamecon_gpio_rpi driver.

    #90700
    Borgar
    Participant

    I have this figured out. Now let me see if I can explain how I have set this up.

    First of all, the gamecon_gpio_rpi controller maps axis as follows: X/Y, RX/RY, HAT0X/HAT0Y confirmed by source code. This is simply the way joystick-axis are set up on Linux (again, confirmed by source). The d-pad buttons on the Playstation controller are emitted as a “fake” axis X/Y, and I’m guessing this is pretty standard so most games will detect the pad first.

    Linux treats all hats as axis by default so this is why jstest looks fine. But as far as I can see, the RetroArch udev driver treats all hats as buttons only. So that means these things are never going to work together.

    The workaround: Use the linuxraw driver instead!

    Here’s how I’ve set this up on my machine:

    Because I like different button-mappings for different emulators I created a basic file that simulates the SNES layout:

    input_device = "PSX controller"
    input_driver = "udev"
    input_a_btn = "1"
    input_b_btn = "2"
    input_x_btn = "0"
    input_y_btn = "3"
    input_select_btn = "8"
    input_start_btn = "9"
    input_up_axis = "-1"
    input_down_axis = "+1"
    input_left_axis = "-0"
    input_right_axis = "+0"
    input_l_btn = "6"
    input_r_btn = "7"
    input_l2_btn = "4"
    input_r2_btn = "5"
    input_enable_hotkey_btn = "8"
    input_exit_emulator_btn = "9"

    Along with some alternate-layout versions which are the same except for this bit:

    input_a_btn = "2"
    input_b_btn = "3"
    input_x_btn = "0"
    input_y_btn = "1"

    And so on… These are each put into separate directories like this:

    ~/joyconf/snes/PSXcontroller.cfg
    ~/joyconf/nes/PSXcontroller.cfg
    ...

    Then I modified /opt/retropie/configs/all/retroarch.cfg to use these (defaulting to SNES for no special reason):

    # use input auto-detection
    input_autodetect_enable = true
    
    # use SNES layout by default
    joypad_autoconfig_dir = /home/pi/joyconf/snes/
    
    # set controllers as joypads by default
    input_libretro_device_p1 = 1
    input_libretro_device_p2 = 1
    
    # ensure correct order
    input_player1_joypad_index = 0
    input_player2_joypad_index = 1

    In all other ways my retroarch.cfg file is the same as the original (some of these settings are unchanged but I include them because they are important).

    Then, for every system I want a different layout, I alter its specific config. So:

    /opt/retropie/configs/nes/retroarch.cfg

    … includes:

    joypad_autoconfig_dir = /home/pi/joyconf/nes/

    And then the PSX:

    Ensure that /opt/retropie/configs/all/retroarch-core-options.cfg has these settings:

    pcsx_rearmed_pad1type = "analog"
    pcsx_rearmed_pad2type = "analog"

    I recommend starting with calibrating the analog sticks using:

    # jcal -c /dev/input/js0

    And if you have a second controller:

    # jcal -c /dev/input/js1

    I don’t know if this is vital but it will avoid fine analog stick movements triggering button selections in the next step.

    Secondly, detect button config for each controller (most likely you can just use mine below):

    # /opt/retropie/emulators/retroarch/retroarch-joyconfig -j 0 -p 1 -d linuxraw

    And for the second one:

    # /opt/retropie/emulators/retroarch/retroarch-joyconfig -j 0 -p 1 -d linuxraw

    Save the output.

    Lastly, edit /opt/retropie/configs/psx/retroarch.cfg.

    Here, I prevent the auto-detection, which seemed to be causing retroarch to shift to the udev driver:

    # set controllers as joypads+analog
    input_libretro_device_p1 = 5
    input_libretro_device_p2 = 5
    
    # don't auto-detect
    input_autodetect_enable = false
    
    # use raw driver
    input_joypad_driver = linuxraw

    This then gets followed by the previously generated output from retroarch-joyconfig, and whatever extra hotkeys you might want.

    I have not gone through this for the N64, but I expect that to be something along similar lines (using linuxraw).

    I should mention that I had some problems that seem to have been caused by removing quotation marks. Using retroarch-joyconfig output as-is worked perfectly.

    So here is my full /opt/retropie/configs/psx/retroarch.cfg:

    # All settings made here will override the global settings for the current emulator core
    
    rewind_enable = false
    
    input_libretro_device_p1 = 5
    input_libretro_device_p2 = 5
    
    input_autodetect_enable = false
    input_joypad_driver = linuxraw
    
    input_player1_joypad_index = "0"
    input_player1_b_btn = "2"
    input_player1_y_btn = "3"
    input_player1_select_btn = "8"
    input_player1_start_btn = "9"
    input_player1_up_axis = "-1"
    input_player1_down_axis = "+1"
    input_player1_left_axis = "-0"
    input_player1_right_axis = "+0"
    input_player1_a_btn = "1"
    input_player1_x_btn = "0"
    input_player1_l_btn = "6"
    input_player1_r_btn = "7"
    input_player1_l2_btn = "4"
    input_player1_r2_btn = "5"
    input_player1_l3_btn = "11"
    input_player1_r3_btn = "10"
    input_player1_l_x_plus_axis = "+4"
    input_player1_l_x_minus_axis = "-4"
    input_player1_l_y_plus_axis = "+5"
    input_player1_l_y_minus_axis = "-5"
    input_player1_r_x_plus_axis = "+2"
    input_player1_r_x_minus_axis = "-2"
    input_player1_r_y_plus_axis = "+3"
    input_player1_r_y_minus_axis = "-3"
    
    input_player2_joypad_index = "1"
    input_player2_b_btn = "2"
    input_player2_y_btn = "3"
    input_player2_select_btn = "8"
    input_player2_start_btn = "9"
    input_player2_up_axis = "-1"
    input_player2_down_axis = "+1"
    input_player2_left_axis = "-0"
    input_player2_right_axis = "+0"
    input_player2_a_btn = "1"
    input_player2_x_btn = "0"
    input_player2_l_btn = "6"
    input_player2_r_btn = "7"
    input_player2_l2_btn = "4"
    input_player2_r2_btn = "5"
    input_player2_l3_btn = "11"
    input_player2_r3_btn = "10"
    input_player2_l_x_plus_axis = "+4"
    input_player2_l_x_minus_axis = "-4"
    input_player2_l_y_plus_axis = "+5"
    input_player2_l_y_minus_axis = "-5"
    input_player2_r_x_plus_axis = "+2"
    input_player2_r_x_minus_axis = "-2"
    input_player2_r_y_plus_axis = "+3"
    input_player2_r_y_minus_axis = "-3"
    
    input_enable_hotkey_btn = "8"
    input_exit_emulator_btn = "9"

    Done! Ape Escape is now playable.

    #111478
    Soullous
    Participant

    [quote=90700]I have not gone through this for the N64, but I expect that to be something along similar lines (using linuxraw).[/quote]

    Thanks for this! I was able to get the analog sticks working on PS1 games by more or less following your guide.

    I have a few questions, though.

    1. Have you figured out how to get them working in N64, MAME, etc.?
    2. Can we use the linuxraw driver everywhere? I’m not exactly sure where it’s loading the driver for the controller.
    3. Some PS1 games only support digital controllers, while some only support analog. Have you found a way to set the controllers to digital or analog on a per-game basis?
Viewing 10 posts - 1 through 10 (of 10 total)
  • The forum ‘Everything else related to the RetroPie Project’ is closed to new topics and replies.