batocera-linux / batocera.linux

batocera.linux
https://batocera.org
Other
2.02k stars 516 forks source link

v37 Controller not working in PPSSPP - Controllername has comma which seems to work as delimiter #8568

Open sfels opened 1 year ago

sfels commented 1 year ago

Hi, I have tried the PSP Emulator. With my Xbox 360 Controller everything is fine. Then I tried it with two other controllers. Both did not work - but only in the PSP Emulator.

The following Lines are copied from es_input.cfg Working in PPSSPP: xbox 360 Controller <inputConfig type="joystick" deviceName="Microsoft X-Box 360 pad" deviceGUID="030081b85e0400008e02000014010000">

not Working in PPSSPP: Hori Fighting Commander OCTA for PlayStation®5 <inputConfig type="joystick" deviceName="HORI CO.,LTD. HORI Fighting Commander OCTA" deviceGUID="0300adf80d0f00006201000001110000"> Retro-Bit Tribute64 2.4 GHz Wireless Controller <inputConfig type="joystick" deviceName="SWITCH CO.,LTD. Retro-bit Controller" deviceGUID="03001a64632500007505000011010000">

As far as I have understood the /usr/lib/python3.11/site-packages/configgen/controllersConfig.py generates the /userdata/system/configs/ppsspp/gamecontrollerdb.txt more or less from the values in es_input.cfg

I don't list everything what I have tried so far. I only write the workaround I have found. Here is an example of a generated gamecontrollerdb.txt 0300adf80d0f00006201000001110000,HORI CO.,LTD. HORI Fighting Commander OCTA,platform:Linux,b:b2,a:b1,dpdown:h0.4,leftx:a0,lefty:a1,lefttrigger:b11,leftstick:b5,dpleft:h0.8,rightshoulder:b4,leftshoulder:b10,righttrigger:b6,rightstick:b7,dpright:h0.2,back:b8,start:b9,dpup:h0.1,y:b3,x:b0,guide:b12,

The real name has a comma which seems to make the file unuseable.

I changed in the controllersConfig.py this

    config.append(controller.guid)
    config.append(controller.realName)
    config.append("platform:Linux")

to this:

    config.append(controller.guid)
    config.append(controller.guid)
    config.append("platform:Linux")

and everything works as expected so far. Here is the generated gamecontrollerdb file: 03001a64632500007505000011010000,03001a64632500007505000011010000,platform:Linux,b:b3,a:b2,dpdown:h0.4,leftx:a0,lefty:a1,lefttrigger:b6,leftstick:b11,dpleft:h0.8,rightshoulder:b5,leftshoulder:b4,righttrigger:b7,rightstick:b10,dpright:h0.2,back:b8,start:b9,dpup:h0.1,y:b0,x:b1,guide:b12,

I have not invested much testing time after finding this. But I hope that this helps to solve this issue in the future. For me it looks like the comma in the Controllernames is the Problem.

Edit: 2023-04-13: This is another Workaround which also seems to work:

    config.append(controller.guid)
    config.append(controller.realName.replace(",", "."))
    config.append("platform:Linux")

03001a64632500007505000011010000,SWITCH CO..LTD. Retro-bit Controller,platform:Linux,b:b3,a:b2,dpdown:h0.4,leftx:a0,lefty:a1,lefttrigger:b6,leftstick:b11,dpleft:h0.8,rightshoulder:b5,leftshoulder:b4,righttrigger:b7,rightstick:b10,dpright:h0.2,back:b8,start:b9,dpup:h0.1,y:b0,x:b1,guide:b12,

after changing the python script i made it permanent with "batocera-save-overlay" https://wiki.batocera.org/modify_the_system_while_it_s_running

nadenislamarre commented 1 year ago

i guess that there is an escape char for the , no ?

dmanlfc commented 1 year ago

great issue post @sfels Can you try this v37 test build, I think I fixed it a different way - https://drive.google.com/drive/folders/1_bqmR7CoZ78i7DolYt5b-RRqB5c-LPyN?usp=share_link

Note: It's important you remove the gamecontrollerdb.txt file in system/configs/ppsspp

sfels commented 1 year ago

Thank you for your support and also thank you for that praise. I really was a bit nervous opening such an issue post with having only two or three weeks of experience in batocera.

but now to topic: I downloaded batocera-x86_64-37-20230413.img.gz and made a bootable usb device. In the usb live version the problem is not solved. I looked at some logs. They show that the gamecontrollerdb.txt is not there - so no need to delete it. The Xbox controller works out of the box. The Hori does as before and does not work in PPSSPP. What I never mentioned in libretro: PPSSPP the controller Hori controller works.

I added the logs and hope that they are helpful and extracted the controller part from these logs to the code boxes in this post. I try the manual-upgrade version later. I don't know if that could make a difference.

es_launch_stdout.log extracts:

the xbox 360 controller log part

loading control pad mappings from /userdata/system/configs/ppsspp/gamecontrollerdb.txt: gamecontrollerdb.txt missing
SUCCESS!
found control pad: Microsoft X-Box 360 pad, loading mapping: SUCCESS, mapping is:
030081b85e0400008e02000014010000,Microsoft X-Box 360 pad,platform:Linux,b:b1,a:b0,dpdown:h0.4,leftx:a0,lefty:a1,rightx:a3,righty:a4,lefttrigger:a2,leftstick:b9,dpleft:h0.8,rightshoulder:b5,leftshoulder:b4,righttrigger:a5,rightstick:b10,dpright:h0.2,back:b6,start:b7,dpup:h0.1,y:b3,x:b2,guide:b8,crc:b881,
pad 1 has been assigned to control pad: Microsoft X-Box 360 pad
found control pad: Microsoft X-Box 360 pad, loading mapping: SUCCESS, mapping is:
030081b85e0400008e02000014010000,Microsoft X-Box 360 pad,platform:Linux,b:b1,a:b0,dpdown:h0.4,leftx:a0,lefty:a1,rightx:a3,righty:a4,lefttrigger:a2,leftstick:b9,dpleft:h0.8,rightshoulder:b5,leftshoulder:b4,righttrigger:a5,rightstick:b10,dpright:h0.2,back:b6,start:b7,dpup:h0.1,y:b3,x:b2,guide:b8,crc:b881,

hori controller log part

loading control pad mappings from /userdata/system/configs/ppsspp/gamecontrollerdb.txt: gamecontrollerdb.txt missing
SUCCESS!
found control pad: HORI CO., loading mapping: SUCCESS, mapping is:
0300adf80d0f00006201000001110000,HORI CO.,LTD. HORI Fighting Commander OCTA,platform:Linux,b:b2,a:b1,dpdown:h0.4,leftx:a0,lefty:a1,lefttrigger:b11,leftstick:b5,dpleft:h0.8,rightshoulder:b4,leftshoulder:b10,righttrigger:b6,rightstick:b7,dpright:h0.2,back:b8,start:b9,dpup:h0.1,y:b3,x:b0,guide:b12,crc:f8ad,
pad 1 has been assigned to control pad: HORI CO.
found control pad: HORI CO., loading mapping: SUCCESS, mapping is:
0300adf80d0f00006201000001110000,HORI CO.,LTD. HORI Fighting Commander OCTA,platform:Linux,b:b2,a:b1,dpdown:h0.4,leftx:a0,lefty:a1,lefttrigger:b11,leftstick:b5,dpleft:h0.8,rightshoulder:b4,leftshoulder:b10,righttrigger:b6,rightstick:b7,dpright:h0.2,back:b8,start:b9,dpup:h0.1,y:b3,x:b0,guide:b12,crc:f8ad,
Leaving main

es_launch_stdout_XBOX360.log es_launch_stdout_hori.log

dmanlfc commented 1 year ago

Interesting... My Nintendo switch controller works which has a , in the pad real name also. Same logs, pad 1 gets assigned... Can you reconfigure the Hori controller & post the ES last input CFG file (located /system/configs/emulation station )? Then retry ppsspp.

sfels commented 1 year ago

Okay, what I have done now:

I also tried other things after that with no success. For me it seems that the "gamecontrollerdb.txt" has no use anymore. Is that right? Should the ini-files in /userdata/system/configs/ppsspp/PSP/SYSTEM be different with different controllers(Xbox vs Hori)? ppsspp.ini and controls.ini are the same with xbox and with hori controller. The xbox does it's job well.

If the ppssppControllers.py ist still responsible for mapping - I don't understand enough to try more things on my own.

es_last_input_hori.txt

dmanlfc commented 1 year ago

thanks @sfels i think i have a working solution for you - can you ping me on Discord?

dmanlfc commented 1 year ago

Alternatively use this PPSSPP binary from here - https://drive.google.com/drive/folders/1eVyae7ww5YcKT82kAWdLV--eCvaib_G6?usp=sharing

And replace the one in your /usr/bin folder. See if that works.

sfels commented 1 year ago

it still does not work after replacing the binary.

After that first try I made a factory Reset like this:

cd /etc/init.d
S31emulationstation stop
mv /userdata/system /userdata/system.old
reboot

after that I configured the hori, copied the PPSSPP binary again and started the PSP Game. No input is accepted. I quit with ALT+F4 on keyboard

In the Log the name is not shotened anymore and has full length: pad 1 has been assigned to control pad: HORI CO.,LTD. HORI Fighting Commander OCTA

but it still not works

es_last_input.txt es_launch_stdout.log

I dont't have discord. If I need it I think I can get it.

dmanlfc commented 1 year ago

updated file on share, ignore the larger size

sfels commented 1 year ago

I tryed this new binary after renaming it to PPSSPP and it to does the same. Hori Controller does not work. I copied the file to my /usr/bin/ folder and did not reboot the system -> I know that after a reboot the file is replaced with the original one.

Edit: I startet PPSSPP with both controller connected: 1 xbox 2:Hori -> When I go to the configuration menu with the xbox controller I can change the Mapping to the hori but it also does not work. The pad2 changes to pad1, but all values behind that keep their settings (if it is by design in this case because of abstraction - I don't know). Trying to change the controller back to the xbox does not work. I don't know if that would be the case with other controllers. After restarting the game it's resetted and works as before. I don't know if there is a conjunction to the other problem or not.

es_last_input.txt es_launch_stdout_hori.log es_launch_stdout_xbox.log

dmanlfc commented 1 year ago

@sfels can you try standalone ppsspp with that controller on another linux distribution?

sfels commented 1 year ago

I Installed ubuntu on my testing device: ubuntu-22.10-desktop-amd64.iso followed this steps: https://flatpak.org/setup/Ubuntu Installed PPSSPP via: https://flathub.org/apps/details/org.ppsspp.PPSSPP copied an PSP iso on the linux pc

In general the controller works. I can not use every button on the hori - some buttons are not mapable (like circle). But I can map other buttons instead and play the game with that controller.

rsn8887 commented 1 year ago

The problem is most definitely the comma. SDL2 looks for comma when parsing the controller name:

https://github.com/libsdl-org/SDL/blob/0b9d8e679a26ee98bb055efd244c703b7dda8727/src/joystick/SDL_gamecontroller.c#L1175

And there are many other places where explicit comma checks are done in SDL2 gamecontroller string parsing, they can be found by searching the contents of SDL_gamecontroller.c for occurrences of ','. Depending on the string and where the comma appears, things will easily go wrong.

The original poster has also empirically verified that the comma is the problem, because replacing the comma with a full stop fixed the issue.

I don't have an easy fix though. I made an issue upstream.

adhiy1204 commented 1 year ago

How to get es_systems.cfg

cracklejoy commented 3 months ago

I modified /usr/lib/python3.11/site-packages/configgen/controllersConfig.py with the mentioned

config.append(controller.realName.replace(",", "."))

This solved my issue of my ps2 controller not responding to inputs using my ps2 to usb adapter with pcsx2.

My controller.realName also contained a comma like the original poster.

Further parsing needs to happen wherever it may be. I also have adapters that have multiple spaces in the name too so enclosing the string within double quotes would be a wise idea along with further strict parsing of this value within gamecontrollerdb.txt.