hrydgard / ppsspp

A PSP emulator for Android, Windows, Mac and Linux, written in C++. Want to contribute? Join us on Discord at https://discord.gg/5NJB6dD or just send pull requests / issues. For discussion use the forums at forums.ppsspp.org.
https://www.ppsspp.org
Other
11.19k stars 2.17k forks source link

Controller not working under Linux with SDL2 (and an incomplete and nasty hack to fix it) #9825

Closed marty1885 closed 5 years ago

marty1885 commented 7 years ago

Hello, I found that PPSSPP with SDL under Liunx don't response to my DS4 controller no matter what. Have anyone encounter this? After digging into the source. I found that the events in SDLJoystick.cpp never happens and the controller seems not to be initialized in SDL. And I have come up with an incomplete and nasty hack to fix this. (link)(Good enough for playing Project DIVA) Which requires a controller to be connected to the PC when PPSSPP is launched. Is my patch going at the right direction? What should I improve so I could contribute this for PPSSPP?

OS: Arch Linux Kernel: 4.11 AMD64 Compiler: GCC 7.1.1 Controller: DualShock4 Gen2 Interface: USB

unknownbrackets commented 7 years ago

This might be related the the "game controller db" not having your controller in it. I think there's another issue for this, and specifically there was some discussion that things not found in the db should fall back to some sane handling - which apparently is not currently happening.

-[Unknown]

marty1885 commented 7 years ago

I'll have a look into that. I have also found that the DPad on DS4 are handles as hats under SDL. Which PPSSPP currently does not support. How much discussion and code will be required to add a new input type? (I haven't look into PPSSPP's core yet. I have only looking at the SDL part.) Also, the problem of DS4 not working seems to start after I upgraded my kernel from 4.9 to 4.10 a while ago. Maybe the kernel changes how it handles DS4?

hrydgard commented 7 years ago

You could just handle hat directions as digital buttons, and inject them the same way, I think. Will just have to define a few new keycodes for them. They should probably not be analog axes.

logos88 commented 7 years ago

@marty1885 kernel 4.10 included support for DS4 v.2 which didn't have until then (only v1) https://wiki.gentoo.org/wiki/Sony_DualShock#cite_note-ds4v2-support-3

marty1885 commented 7 years ago

@logos88 I know. But It just works. maybe some patches are added in my kernel. Or it might be some non-mainline driver I have been testing and I accidentally installed them.

wodencafe commented 7 years ago

Hi guys, I have this same issue. (With Kernel 4.10.0.21, SDL2, Qt)

Using an official PS3 controller works. But controller support does not work with a "Generic" version of the PS3 controller from Amazon. This "Generic" PS3-Like controller works for almost all of the other emulators and applications I've tried, such as dolphin-emu and desmume.

It even works with PPSSPP on Wine, but that leads to other issues with running PPSSPP under Wine.

As a developer, is there any way I can assist with getting this Generic Controller Support resolved @hrydgard @marty1885 ?

marty1885 commented 7 years ago

@unknownbrackets how is the gamecontrollerdb.txt formatted? I found Sony DualShock 4 under the Linux tab. My assumption is that the first collum is the GUID and the one in it is for DS4 Gen 1? I have tried to replace the GUID of DS4 Gen1 with the GUID of my DS4 Gen2. But it doesn't work.

@wodencafe In theory, you could dump your controller's GUID and modify gamecontrollerdb.txt appropriately to make PPSSPP support your controller. However, I think making a sane default behavior for all controllers will be a better solution for all of us. And I'm currently working on that. Are you interested in doing so?

wodencafe commented 7 years ago

@marty1885 Thanks for the info! Since you are working on the default behavior, I'll probably just look at this gamecontrollerdb.txt file and see if I can add my controller there. If I can be of any assistance with the changes you are working on, please let me know and I will definitely contribute.

carlsmith commented 7 years ago

Same issue on macOS Sierra.

unknownbrackets commented 7 years ago

Sorry, I don't know the format. I assumed there was some SDL tool to manage it, or something. I think it's related to this:

https://github.com/gabomdq/SDL_GameControllerDB

-[Unknown]

marty1885 commented 7 years ago

@carlsmith What controller are you using? If you are using a DS4 Gen 2. I have it working trough USB now. And I'm trying to get BT to work on my laptop so I can test DS4 trough BT. Hopefully I can finish the test and open a PR for adding DS4 Gen2 soon.

carlsmith commented 7 years ago

It's just a cheap, generic DualShock clone (USB).

hexacera commented 7 years ago

@marty1885 I have been encountering the exact same problem, and experimented around for a while (even opened another issue #9872) before I discovered this thread.

I have found out another workaround that could solve the problem even easier. Go to this link, find the line that you need (in my case Sony Dualshock V2 for OS X) and put it into your gamecontrollerdb.txt, and it works. I might be creating a pull request for this when I have time.

@unknownbrackets thanks for pointing out that game controller DB repo, do you think it's a good idea to just use the updated version (or add it as a submodule or something)?

unknownbrackets commented 7 years ago

I'm not against a submodule. I'm not sure if there's some benefit to keeping it separate, unless it needs to be in a specific directory.

-[Unknown]

hexacera commented 7 years ago

@unknownbrackets Wrote a script and found out that changing to the submodule would result in the support for 5 controller disappearing (but adding a ton of new supported ones)

hrydgard commented 7 years ago

@VVVFO you should contribute the 5 missing ones to https://github.com/gabomdq/SDL_GameControllerDB , send them a pull request or something. Then we can switch to that.

hexacera commented 7 years ago

I will try that, but judging from the number of pull request there are having, it's likely that this will take a long while. I think I should create a pull request for PPSSPP just in case anyone tries it before the migration, but only to find their controller does not work.

On Aug 1, 2017, at 17:38, Henrik Rydgård notifications@github.com wrote:

@VVVFO you should contribute the 5 missing ones to https://github.com/gabomdq/SDL_GameControllerDB , send them a pull request or something. Then we can switch to that.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

binaryronin commented 7 years ago

@VVVFO Your fix kind of worked. For some reason my controller's ID wasn't in that linked database. I instead installed the controllermap program and generated a mapping for my DualShock 4 V2 (Bluetooth) and then placed this into the gamecontrollerdb.txt on my system.

Thanks for pointing me in the right direction!

hrydgard commented 7 years ago

@binaryronin can you paste your mapping line here se we can add it?

binaryronin commented 7 years ago

@hrydgard Sure, no problem!

050000004c050000cc09000000810000,Wireless Controller,platform:Linux,x:b3,a:b0,b:b1,y:b2,back:b8,guide:b10,start:b9,dpleft:h0.8,dpdown:h0.0,dpdown:h0.4,dpright:h0.0,dpright:h0.2,dpup:h0.0,dpup:h0.1,leftshoulder:h0.0,leftshoulder:b4,lefttrigger:a2,rightshoulder:b6,rightshoulder:b5,righttrigger:a5,leftstick:b7,leftstick:b11,rightstick:b12,leftx:a0,lefty:a1,rightx:a3,righty:a4,
logos88 commented 7 years ago

I have needed to use controllermap to make my DS4 work too. This is my mapping: 030000004c050000cc09000011810000,Sony Interactive Entertainment Wireless Controller,platform:Linux,x:b3,a:b0,b:b1,y:b2,back:b8,guide:b10,start:b9,dpleft:h0.8,dpdown:h0.0,dpdown:h0.4,dpright:h0.0,dpright:h0.2,dpup:h0.0,dpup:h0.1,leftshoulder:h0.0,leftshoulder:b4,lefttrigger:a2,rightshoulder:b6,rightshoulder:b5,righttrigger:a5,leftstick:b7,leftstick:b11,rightstick:b12,leftx:a0,lefty:a1,rightx:a3,righty:a4,

(Edited)

unknownbrackets commented 6 years ago

Is this improved with #9997? Though, maybe we still need to pull in mappings from other projects.

-[Unknown]

carlsmith commented 6 years ago

Any news on support for 8bitdo controllers? The new SNES one has triggers, shoulder buttons, analogue sticks etc. and should ship in time for Christmas.

8bitdo have a solid reputation for build quality and compatibility, even pushing firmware updates to their pads when new consoles are released. They support most platforms, including mobile, and are becoming very popular with people who run emulators and stuff. Official support for 8bitdo controllers in PPSSPP would be awesome.

I'm nothing to do with the company. I just have two control pads that don't work with PPSSPP, and would be gutted if my new one didn't work as well.

hrydgard commented 6 years ago

They should work if you add the appropriate controllermap lines to gamecontrollerdb.txt, at least.

Also I think we do autogenerate lines now for unknown controllers, have you tried to use them in recent builds?

carlsmith commented 6 years ago

Thanks for taking the time to reply.

I preordered the SF30 Pro for Dec 10th, and the other two pads are not by 8bitdo. One's from the Ouya, so it will probably never work. The other pad is a generic, fake PlayStation pad, so I'll test that with a more recent build.

I wasn't blaming PPSSPP for my pads not working. They're both crap pads. It would just be gutting if the new pad didn't work too, as being able to play PPSSPP properly was a motivation for getting it.

To be clear, PPSSPP is working on Mac, with good controller support, but only through OpenEmu. OpenEmu doesn't let users change emulator settings, so you have to run everything at 480 x 272. Given that it's written for OS X, and my 2013 MacBook Air 13 can run most games in PPSSPP at 1440 x 900 with anti-aliasing, without even running the fan, using PPSSPP through OpenEmu is pointless (unless you have a really old machine).

It a shame we can't just reuse OpenEmu's controller support.

unknownbrackets commented 5 years ago

Are the controllers still not working?

-[Unknown]

marty1885 commented 5 years ago

@unknownbrackets DS4v2 is orking on Linux now. Not sure of other people's devices in this issue.

unknownbrackets commented 5 years ago

Thanks for the feedback. Since no one else has said anything on this issue in a year, I'm going to assume it's working better. I know several people have contributed additional gamecontrollerdb mappings as well.

If anyone isn't seeing it working, please feel free to reply to this issue with details about your controller. If possible, it'd be great for you to try the SDL game controller db app and submit the additional line it creates to fix the issue for everyone.

-[Unknown]