Forum Replies Created

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • in reply to: Analog support for PSX controllers via GPIO #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.

    in reply to: Analog support for PSX controllers via GPIO #90658
    Borgar
    Participant

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

    in reply to: Analog support for PSX controllers via GPIO #90654
    Borgar
    Participant

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

    in reply to: Analog support for PSX controllers via GPIO #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.

Viewing 4 posts - 1 through 4 (of 4 total)