Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Controllers changing GPIO joystick device ID on restart #17219

Open
Funwayguy opened this issue Nov 28, 2024 · 3 comments
Open

Controllers changing GPIO joystick device ID on restart #17219

Funwayguy opened this issue Nov 28, 2024 · 3 comments

Comments

@Funwayguy
Copy link

Description

Controllers shifting joystick device indexes but not port mappings on restart leading to non-functional controls on both devices.

Expected behavior

GPIO joystick keeps it's configured device/port mapping from joystick.conf. Control mappings remember what device type they were configured for even if their index or port changes such that they stay functional during player drop in/out or restart, without having to rely on auto-configure which could overwrite said mappings.

Actual behavior

The mk_arcade_joystick_rpi is set to map=1 in joystick.conf which, during normal operation, puts the joystick in index 1 port 1 and the controller in index 2 port 2 as intended when a new one is connected. However, on a restart one of several things can happen:

  • Devices switch indexes on opposite ports leaving both inputs with inoperable mappings
  • Devices switch indexes on opposite ports and the inputs work in menus (using default mappings only) but not in any cores

Thinking this might be an Xbox thing or 3rd party controller issue, I tried with a PS4 controller and had the same issues. Connecting all three devices simultaneously then restarting results in even weirder behaviour:

  • Xbox controller seizes index 1
  • PS4 controller is pushed from index 1 to 2
  • Joystick is pushed to index 3
  • PS4 mouse controls are still bound to index 1 despite being Xbox controlled now
  • Button mappings are still bound to their respective ports but unable to function correctly

Then disconnecting the PS4 controller but leaving the Xbox controller and restarting...

  • Xbox keeps index 1 but switches to port 2
  • Joystick switches to index 2 but jumps to port 1
  • Mouse controls reverted to default

Interesting thing to note is that this happens each restart of the RetroArch application without rebooting the Pi itself or changing input device connectivity between restarts. If I leave the flipped indexes, it restarts fine as if that's the preferred order but only if I keep the same controller(s) connected every restart. This would be fine if the devices rebind to their original ports or carries the control mappings over but that never appears to be the case. Auto configure is disabled as it auto-fills the joystick mapping with non-existent or duplicate controls that cannot be removed otherwise.

This may be related, but the turbo button binding is permanently stuck as 'B' for all controllers despite what the config is set to during all this, even if the rest of the controls are seemingly inoperable. There also may be some relation to issue #17113

Going to take another deeper look at this soon with logging enabled to hopefully make sense of this behaviour.

Steps to reproduce the bug

  1. Start RetroArch with only the joystick connected to device index 1 port 1
  2. Connect controller and verify it has connected to device index 2 port 2
  3. Disable auto-config and save mappings for both devices in their respective ports
  4. Restart RetroArch without rebooting the system or disconnecting either device
  5. Check that the device indexes has shifted to incorrect ports and mappings
  6. Start a core and note the controls are no longer functional

Extra: B Turbo button mapping cannot be remapped or disabled during all this for some unknown reason. May be a separate issue.

Bisect Results

This is occurring on a fresh install of Lakka on a RPi 4B+ using mk_arcade_joystick_rpi for the GPIO joystick.

Version/Commit

Environment information

  • Hardware:
    • Raspberry Pi 4B+ (4GB)
    • Gulikit KK3 Max
    • PS4 Controller
    • GPIO Joystick (8 buttons, 1 stick)
  • OS: Lakka 5.0 (RetroArch 1.17.0)
@zoltanvb
Copy link
Contributor

Is this with linuxraw joypad driver? Can you get a RetroArch log for some of these error scenarios?

Auto configure is disabled as it auto-fills the joystick mapping with non-existent or duplicate controls that cannot be removed otherwise.

That should not happen, linuxraw driver should recognize vendor/product IDs correctly. But, if there is a clash, removing the offending config files should help with that. Without autoconfig, some of the possible solutions (like the device reservation function) will not work. In any case, there were improvements after 1.17.0, so a newer Lakka nightly build may also help if there is one available.

@Funwayguy
Copy link
Author

Currently using the udev driver for controllers. Managed to get GPIO controller to at least flip back to port 1 after a controller disconnect. Seems the GPIO profile generated with the vendor_id and product_id identical to an xbox controller. Still shifts to port 2 with improper mappings and generates xbox-like controller defaults despite what the joypad profile states.

Logs don't appear to show anything out of the ordinary besides the port allocations.
(Keyboard plugged in for when the controls fails. Autoconf enabled)

[INFO] RetroArch 1.17.0 (Git ad8975c)
[INFO] === Build =======================================
[INFO] Capabilities: ASIMD 
[INFO] Version: 1.17.0
[INFO] Git: ad8975c
[INFO] Built: Apr 17 2024
[INFO] =================================================
[INFO] [Input]: Found input driver: "udev".
[INFO] [Environ]: SET_PIXEL_FORMAT: RGB565.
[INFO] [Core]: Version of libretro API: 1, Compiled against API: 1
[INFO] [Core]: Geometry: 320x240, Aspect: 1.333, FPS: 60.00, Sample rate: 48000.00 Hz.
[INFO] [Audio]: Set audio input rate to: 48000.00 Hz.
[INFO] [Video]: Set video size to: fullscreen.
[INFO] [Video]: Starting threaded video driver..
[INFO] [Vulkan]: Vulkan dynamic library loaded.
[INFO] [Vulkan]: Found vulkan context: "khr_display".
[INFO] [Vulkan]: Detecting screen resolution: 0x0.
[INFO] [Vulkan]: Found GPU at index 0: "V3D 4.2.14".
[INFO] [Vulkan]: Using GPU index 0.
[INFO] [Vulkan]: Found GPU at index 0: "V3D 4.2.14".
[INFO] [Vulkan]: Using GPU index 0.
[INFO] [Vulkan]: Using semaphores for WSI acquire.
[INFO] [Vulkan]: Using GPU: "V3D 4.2.14".
[INFO] [Vulkan]: Queue family 0 supports 1 sub-queues.
[INFO] [Vulkan]: Got 3 swapchain images.
[INFO] [Vulkan]: Using resolution 1920x1080.
[INFO] [Vulkan]: Using RGB565 format.
[INFO] [Vulkan]: Loading stock shader.
[INFO] [Video]: Graphics driver did not initialize an input driver. Attempting to pick a suitable driver.
[DEBUG] [udev] Adding devices of type 0 -> "ID_INPUT_KEY"
[DEBUG] [udev] Adding device (t0) "/sys/devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb1/1-1/1-1.4/1-1.4:1.0/0003:046D:C31D.0001/input/input0"
[DEBUG] [udev] Adding device (t0) "/sys/devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb1/1-1/1-1.4/1-1.4:1.0/0003:046D:C31D.0001/input/input0/event0"
[DEBUG] [udev] Adding device (t0) "/sys/devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb1/1-1/1-1.4/1-1.4:1.1/0003:046D:C31D.0002/input/input1"
[DEBUG] [udev] Adding device (t0) "/sys/devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb1/1-1/1-1.4/1-1.4:1.1/0003:046D:C31D.0002/input/input1/event1"
[DEBUG] [udev] Adding device (t0) "/sys/devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb1/1-1/1-1.4/1-1.4:1.1/0003:046D:C31D.0002/input/input2"
[DEBUG] [udev] Adding device (t0) "/sys/devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb1/1-1/1-1.4/1-1.4:1.1/0003:046D:C31D.0002/input/input2/event2"
[DEBUG] [udev] Adding device (t0) "/sys/devices/virtual/input/input3"
[DEBUG] [udev] Adding device (t0) "/sys/devices/virtual/input/input3/event3"
[DEBUG] [udev] Adding devices of type 1 -> "ID_INPUT_MOUSE"
[DEBUG] [udev] Adding devices of type 2 -> "ID_INPUT_TOUCHPAD"
[WARN] [udev]: Full-screen pointer won't be available.
[INFO] [udev]: Keyboard #0: "Logitech USB Keyboard" (/dev/input/event0).
[INFO] [udev]: Keyboard #1: "Logitech USB Keyboard Consumer Control" (/dev/input/event1).
[INFO] [udev]: Keyboard #2: "Logitech USB Keyboard System Control" (/dev/input/event2).
[INFO] [udev]: Keyboard #3: "cec-mini-kb" (/dev/input/event3).
[INFO] [udev]: Pad #0 (/dev/input/event5) supports force feedback.
[INFO] [udev]: Pad #0 (/dev/input/event5) supports 16 force feedback effects.
[INFO] [Autoconf]: Xbox 360 Controller configured in port 1.
[INFO] [udev]: Pad #1 (/dev/input/event4) supports 0 force feedback effects.
[INFO] [Autoconf]: GPIO Controller 1 configured in port 2.
[INFO] [Joypad]: Found joypad driver: "udev".
[INFO] [Video]: Found display server: "null".
[WARN] [udev]: Mouse grab/ungrab feature unavailable.
[INFO] [ALSA] Using ALSA version 1.2.8
[DEBUG] [ALSA]: Requesting device "default" for PLAYBACK stream
[INFO] [ALSA]: Using FLOAT_LE sample format for PLAYBACK device "default"
[INFO] [ALSA]: Period: 4 periods per buffer (768 frames, 6144 bytes)
[INFO] [ALSA]: Buffer size: 3072 frames (24576 bytes)
[INFO] [ALSA]: Can pause: no.
[INFO] [ALSA]: Initialized PLAYBACK device "default"
[INFO] [Audio]: Started synchronous audio driver.
[DEBUG] [ALSA] [playback thread 0x7f8bfff100]: Beginning playback worker thread
[INFO] [ALSA] Using ALSA version 1.2.8
[INFO] [Microphone]: Initialized microphone driver.
[INFO] [Display]: Found display driver: "vulkan".
[ERROR] [MIDI]: snd_seq_open failed with error -2.
[ERROR] [MIDI]: Initialization failed.
[INFO] [Playlist]: Loading history file: "/storage/.config/retroarch/content_history.lpl".
[INFO] [Playlist]: Loading history file: "/storage/.config/retroarch/content_music_history.lpl".
[INFO] [Playlist]: Loading history file: "/storage/.config/retroarch/content_video_history.lpl".
[INFO] [Playlist]: Loading history file: "/storage/.config/retroarch/content_image_history.lpl".
[INFO] [Playlist]: Loading favorites file: "/storage/.config/retroarch/content_favorites.lpl".
[INFO] [Vulkan]: QueuePresent failed, destroying swapchain.
[INFO] [Vulkan]: Got 3 swapchain images.

Sometimes GPIO connects even later.

[INFO] RetroArch 1.17.0 (Git ad8975c)
[INFO] === Build =======================================
[INFO] Capabilities: ASIMD 
[INFO] Version: 1.17.0
[INFO] Git: ad8975c
[INFO] Built: Apr 17 2024
[INFO] =================================================
[INFO] [Input]: Found input driver: "udev".
[INFO] [Environ]: SET_PIXEL_FORMAT: RGB565.
[INFO] [Core]: Version of libretro API: 1, Compiled against API: 1
[INFO] [Core]: Geometry: 320x240, Aspect: 1.333, FPS: 60.00, Sample rate: 48000.00 Hz.
[INFO] [Audio]: Set audio input rate to: 48000.00 Hz.
[INFO] [Video]: Set video size to: fullscreen.
[INFO] [Video]: Starting threaded video driver..
[INFO] [Vulkan]: Vulkan dynamic library loaded.
[INFO] [Vulkan]: Found vulkan context: "khr_display".
[INFO] [Vulkan]: Detecting screen resolution: 0x0.
[INFO] [Vulkan]: Found GPU at index 0: "V3D 4.2.14".
[INFO] [Vulkan]: Using GPU index 0.
[INFO] [Vulkan]: Found GPU at index 0: "V3D 4.2.14".
[INFO] [Vulkan]: Using GPU index 0.
[INFO] [Vulkan]: Using semaphores for WSI acquire.
[INFO] [Vulkan]: Using GPU: "V3D 4.2.14".
[INFO] [Vulkan]: Queue family 0 supports 1 sub-queues.
[INFO] [Vulkan]: Got 3 swapchain images.
[INFO] [Vulkan]: Using resolution 1920x1080.
[INFO] [Vulkan]: Using RGB565 format.
[INFO] [Vulkan]: Loading stock shader.
[INFO] [Video]: Graphics driver did not initialize an input driver. Attempting to pick a suitable driver.
[DEBUG] [udev] Adding devices of type 0 -> "ID_INPUT_KEY"
[DEBUG] [udev] Adding device (t0) "/sys/devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb1/1-1/1-1.4/1-1.4:1.0/0003:046D:C31D.0001/input/input0"
[DEBUG] [udev] Adding device (t0) "/sys/devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb1/1-1/1-1.4/1-1.4:1.0/0003:046D:C31D.0001/input/input0/event0"
[DEBUG] [udev] Adding device (t0) "/sys/devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb1/1-1/1-1.4/1-1.4:1.1/0003:046D:C31D.0002/input/input1"
[DEBUG] [udev] Adding device (t0) "/sys/devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb1/1-1/1-1.4/1-1.4:1.1/0003:046D:C31D.0002/input/input1/event1"
[DEBUG] [udev] Adding device (t0) "/sys/devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb1/1-1/1-1.4/1-1.4:1.1/0003:046D:C31D.0002/input/input2"
[DEBUG] [udev] Adding device (t0) "/sys/devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb1/1-1/1-1.4/1-1.4:1.1/0003:046D:C31D.0002/input/input2/event2"
[DEBUG] [udev] Adding device (t0) "/sys/devices/virtual/input/input3"
[DEBUG] [udev] Adding device (t0) "/sys/devices/virtual/input/input3/event3"
[DEBUG] [udev] Adding devices of type 1 -> "ID_INPUT_MOUSE"
[DEBUG] [udev] Adding devices of type 2 -> "ID_INPUT_TOUCHPAD"
[WARN] [udev]: Full-screen pointer won't be available.
[INFO] [udev]: Keyboard #0: "Logitech USB Keyboard" (/dev/input/event0).
[INFO] [udev]: Keyboard #1: "Logitech USB Keyboard Consumer Control" (/dev/input/event1).
[INFO] [udev]: Keyboard #2: "Logitech USB Keyboard System Control" (/dev/input/event2).
[INFO] [udev]: Keyboard #3: "cec-mini-kb" (/dev/input/event3).
[INFO] [udev]: Pad #0 (/dev/input/event5) supports force feedback.
[INFO] [udev]: Pad #0 (/dev/input/event5) supports 16 force feedback effects.
[INFO] [udev]: Pad #1 (/dev/input/event4) supports 0 force feedback effects.
[INFO] [Autoconf]: Xbox 360 Controller configured in port 1.
[INFO] [Joypad]: Found joypad driver: "udev".
[INFO] [Video]: Found display server: "null".
[WARN] [udev]: Mouse grab/ungrab feature unavailable.
[INFO] [ALSA] Using ALSA version 1.2.8
[DEBUG] [ALSA]: Requesting device "default" for PLAYBACK stream
[INFO] [ALSA]: Using FLOAT_LE sample format for PLAYBACK device "default"
[INFO] [ALSA]: Period: 4 periods per buffer (768 frames, 6144 bytes)
[INFO] [ALSA]: Buffer size: 3072 frames (24576 bytes)
[INFO] [ALSA]: Can pause: no.
[INFO] [ALSA]: Initialized PLAYBACK device "default"
[INFO] [Audio]: Started synchronous audio driver.
[DEBUG] [ALSA] [playback thread 0x7f877ef100]: Beginning playback worker thread
[INFO] [ALSA] Using ALSA version 1.2.8
[INFO] [Microphone]: Initialized microphone driver.
[INFO] [Autoconf]: GPIO Controller 1 configured in port 2.
[INFO] [Display]: Found display driver: "vulkan".
[ERROR] [MIDI]: snd_seq_open failed with error -2.
[ERROR] [MIDI]: Initialization failed.
[INFO] [Playlist]: Loading history file: "/storage/.config/retroarch/content_history.lpl".
[INFO] [Playlist]: Loading history file: "/storage/.config/retroarch/content_music_history.lpl".
[INFO] [Playlist]: Loading history file: "/storage/.config/retroarch/content_video_history.lpl".
[INFO] [Playlist]: Loading history file: "/storage/.config/retroarch/content_image_history.lpl".
[INFO] [Playlist]: Loading favorites file: "/storage/.config/retroarch/content_favorites.lpl".
[INFO] [Vulkan]: QueuePresent failed, destroying swapchain.
[INFO] [Vulkan]: Got 3 swapchain images.

The jstest report is correct besides an extra detected button.

Joystick (GPIO Controller 1) has 2 axes and 9 buttons. Driver version is 2.1.0.
Testing ... (interrupt to exit)
Axes:  0:     0  1:     0 Buttons:  0:off  1:off  2:off  3:off  4:off  5:off  6:off  7:off  8:off 

Contents of GPIO Controller 1.conf file:

input_driver = "udev"
input_device = "GPIO Controller 1"
input_vendor_id = "1"
input_product_id = "1"
input_b_btn = "0"
input_y_btn = "3"
input_select_btn = "7"
input_start_btn = "6"
input_a_btn = "1"
input_x_btn = "2"
input_l_btn = "4"
input_r_btn = "5"
input_l_x_plus_axis = "+0"
input_l_x_minus_axis = "-0"
input_l_y_plus_axis = "+1"
input_l_y_minus_axis = "-1"
input_l2_btn = "4"
input_r2_btn = "5"
input_up_axis = "-1"
input_down_axis = "+1"
input_left_axis = "-0"
input_right_axis = "+0"

Possibly related console error but not included in the log:

  • xpad 1-1.1:1.0: xpad_try_sending_next_out_packet - usb_submit_urb failed with result -19

Will experiment with the nightly builds and linuxraw driver to see if there are any improvements.

@zoltanvb
Copy link
Contributor

zoltanvb commented Dec 7, 2024

No faulty working can be seen from the logs. Even though the module seems to provide primarily those inputs that are read by the linuxraw driver, the udev driver can also see it, even with vid/pid 1/1 which is intentional according to source. The order of the devices is primarily controlled by the OS, but recent RA builds provide a way to override (#16647 ).

If the GPIO profile was set up originally when both controllers were plugged in, it may have had the wrong vid/pid, that was a long standing fault that was also recently fixed (#17156). The autoconfig file pasted above looks correct, but there may be another one saved that has the GPIO layout and the XBox vid/pid, which can cause problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants