jpd002 / Play-

Play! - PlayStation2 Emulator
http://purei.org
Other
2.04k stars 248 forks source link

Analog controller settings not working properly #1131

Open micaelis72 opened 2 years ago

micaelis72 commented 2 years ago

Quick summary

The possible values for analog controllers are not correctly taken, turning the use of analog controllers unreliable

System Details

Describe the ambient being used to run Play! Information needed:

Issue Details

It seems the evdev setup doesn't allow values as uint, but only close to uint8, what clips the possible positions and turning the controller unusable with the analog sticks. I'm using a DualSense controller, but I can try to use a DualShock 3, if necessary as base for testing (Isolate if it's a DualSense issue or not)

Screenshots/Videos

play-controller-settings

This is how is configured now, after I've tried to set my controller. As you can see, the values for Analog AXIS are little off of what they should be:

Using jstest, I've got this: Axes: 0:-32767 1: -4387 2:-32767 3: 516 4: -259 5:-32767 6: 0 7: 0 Buttons: 0:off 1:off 2:off 3:off 4:off 5:off 6:off 7:off 8:off 9:off 10:off 11:off 12:off Axes: 0: 32767 1: 5934 2:-32767 3: 516 4: -259 5:-32767 6: 0 7: 0 Buttons: 0:off 1:off 2:off 3:off 4:off 5:off 6:off 7:off 8:off 9:off 10:off 11:off 12:off

I moved the left analog controller to the extremes of the X axis, left and right. Doesn't match with I got in Play!

I can be mistaken, but seems odd the values I've got in the Controller settings on Play! Please let me know in what I could help more. I'm searching in the code what could be wrong, but I have little experience with C/C++ code and I need more time to familiarize myself specifically with the Play!'s code!

Best,

-- Micaelis

Dragon20C commented 2 years ago

Hello, This is technically a duplicate post from my previous posts from the past few years(https://github.com/jpd002/Play-/issues/890), but its a good post on updating this issue. as I can tell its only a linux issue and the buttons now work correctly, used too register wrong buttons, but analog buttons like the triggers and sticks 99% of the time register wrong values. not sure how I could help as I dont know much about how linux does its controller input.

jpd002 commented 2 years ago

Humm, one strange thing I can see from your screenshot is that the analog axis binding types are simulatedaxisbinding, which is used to simulate an axis with two keys (like arrow keys on the keyboard). When configuring axis inputs, if you move your analog stick, it should normally pick up simplebinding. This is on Windows, but it should be the same idea for Linux:

image

I've pushed a branch that prints key info when configuring an axis: https://github.com/jpd002/Play-/tree/linux_analog_debug. Should help in figuring out where's the issue.

Dragon20C commented 2 years ago

@jpd002 Im not expert on the building process, I just built the whole branch but im not sure how to start the emulator, I see a folder named "installer_unix" and see a play.desktop icon but it errors out.

jpd002 commented 2 years ago

@Dragon20C There should be an executable in the directory you've ran CMake in. Like inside Source\ui_qt or something like that. You can also use the AppImage from the GitHub actions: https://github.com/jpd002/Play-/actions/runs/1312607957

Dragon20C commented 2 years ago

@jpd002 sorry I took so long to get back to you, Okay I have made two quick videos showing 1, the values of input from the left stick going horizontal, and the second video showing the thumb sticks acting incorrectly, if I had to guess it feels like there isnt any dead zone though I am not an expert, I should also mention the triggers did not produce any input at all held down or anything.

Video of input values: https://www.youtube.com/watch?v=8QRBz2n3lNI

Video of the left thumb stick acting incorrectly: https://www.youtube.com/watch?v=8mhTdCreOs4

jpd002 commented 2 years ago

Thanks for that!

So, from what I can see, I think the values from the axis are not in the proper range for the config dialog. I pushed another commit that should convert the range properly. Lemme know if that works any better!

Dragon20C commented 2 years ago

@jpd002 Hello again!, I just tested the new branch called "fix build" and im not 100% sure but at least configuring is a bit better but the issues still exist, I have tried moving the left thumb stick left and right in a horizontal motion and it produces these unique values, here is another video : https://www.youtube.com/watch?v=nNP7f3APZqI from the video it might be hard to tell but there where a few seconds where I didnt move the stick and it still registered some values and the values seem to be close to each other making precise stick movements to be harder.

jpd002 commented 2 years ago

Thanks again for testing!

Oops, I made a mistake with the range conversion formulae. I fixed that in the new commit in that branch, hopefully, that should do the trick!

Dragon20C commented 2 years ago

@jpd002 Hello! the recent build has fixed the configuration of the thumb sticks, so I can say its safe to push at least those changes to main, but I still experiencing the issue where the thumb stick is moving on its own, now its hard to tell if its the code or something else like the game, I decided to test two different games to see if it did the same results and one game produced the stick issue while the other game didnt, here is a video: https://www.youtube.com/watch?v=OM1FZ0PVrS8 and the last issue that the controller config has is the triggers dont produce any input. but I think I can say the thumb sticks at least configuring the controller issue is all gone, and I think it can be pushed to main!

jpd002 commented 2 years ago

Nice! Glad that helped!

In that video, are you moving the controller at all? We can see the values change in the console, just wondering if they move on their own or if you're doing something to make them change? Normally, if are not touching the analog stick, the values displayed on the console should stay around 127 (+/- 10).

Another thing to try would be to bind the dpad buttons to keyboard keys, just to rule the pov hat buttons out in case they are messing up things.

About the triggers, they might be axis buttons on your controller and for now, I don't think the emulator can handle binding axis on simple buttons atm. It's something that I could add in there (shouldn't be too hard to do).

Dragon20C commented 2 years ago

@jpd002, I wrote a lot about the thumb-stick until I changed the dpads to keyboard inputs and you are correct, removing the dpad inputs off the controller fixed this issue, why does this happen? I am surprised that is the issue, well you did code the whole thing haha so you know everything in and out.

and to answer your question, the values only change when I move the thumb sticks, and also the values are sticking around the 127 mark, but without touching the sticks the game moves downwards by its self, though I dont know how the game reads the controller values but when I hit the 45ish value the movement changes from going down automatically to going up while I hold it up, just thought to let you know if that becomes useful!

jpd002 commented 2 years ago

Ok, interesting. I pushed another commit that prints the values for the switch hat. Should help figure out what's wrong with it.

Dragon20C commented 2 years ago

@jpd002 your gonna find this funny, the issue might not be the dpad or maybe it is, watch this video : https://www.youtube.com/watch?v=Nekgi4AB3wg

but I will explain what I did first. okay firstly I set up the dpad to my controller, and then I went to load a game, I firstly used the thumbsticks no issues, and then I used the D-pad no issues (confused face) and then I go back into the controller config and BANG it starts doing the issue, so yea I found this very funny but at least its been narrowed down real quick!

Zer0xFF commented 2 years ago

do you have different profiles saved?

if you do, i guess what might be happening*, is that once you open the config, the list of profiles is loaded, then "default" is selected, force reloading the profile, thus resetting controller states, and i assume neurtal hate state is not 0, thus it starts moving.

Dragon20C commented 2 years ago

No profiles exist, bone stock default

jpd002 commented 2 years ago

I think @Zer0xFF's hypothesis is right, but I've added more prints in a new commit just to confirm it. Could you please test it out?

Thanks a bunch!

Dragon20C commented 2 years ago

Hello all, I wasnt really sure what to test on this bit, so I kinda just did the same things I did before, in the terminal I already pressed some values before the video started and half way through the video I pressed the D-pad just to let you know what does values going through the terminal was, it seems to print pressed when I start a game, and prints the resetBindingValues every time I open the controller config menu, here is the video: https://www.youtube.com/watch?v=acz7u5Rz5Kg and no profiles were created.

I looked through the commit and I saw some print statements that never printed while I was testing and configuring, this could be normal but I dont know.

jpd002 commented 2 years ago

So, it was as @Zer0xFF said. I pushed another commit that should fix the issue.

Dragon20C commented 2 years ago

@jpd002 that fixed it, no problems that I could see from the initial tests I did, I think its safe to push to main! I can finally use my controller on linux!

the last thing is implementing the triggers, but that can be left for when ever!

jpd002 commented 2 years ago

Awesome! I've cleaned up the changes and added them to a new https://github.com/jpd002/Play-/tree/gamepad_fixes branch. Could you test it out just to be sure I didn't mess anything up? If everything's good, I'll merge to master and close #890.

I dunno if @micaelis72's original issue is the same, but if it's still broken and you have the chance to test the linux_analog_debug branch, we can try to work it out.

Dragon20C commented 2 years ago

Hello, just tested it, I played a few games to see if any issues popped up and no issues!, though I got to say I haven't tested other operating systems, could be one of those situations where it works fine on Linux but windows doesn't like it.

jpd002 commented 2 years ago

Thanks for testing! Merged! Should be fine on Windows and macOS.

micaelis72 commented 2 years ago

Hi @jpd002!

I've got the latest release to test. Those fixes are present on it? If you want, I can do other tests. I had to be away from my computer a couple of days, but I can do any test wanted anytime.

I'm happy to see the improvements on Play!

micaelis72 commented 2 years ago

I've tested right now and the behavior is the same.

To examplify:

I have a DualSense controller. The controller settings, to assign a position on Linux expects something pressed. But DualSense, DualShock 4 and maybe previous ones have in the analog controllers the L3 or R3, that are expressed by pressing the analog controllers as buttons.

In the end, I can't properly register the X Left, X Right, Y Left or Y Right. Pressing it is registering L3 or R3 instead of the Axis X and Y of the analog controllers.

All of this makes sense to you? I'm not a native English speaker, so writing some concepts in English for me occasionaly is harder.

Best,

jpd002 commented 2 years ago

Hey there!

Yup, it makes sense. Did you test the linux_analog_debug branch? This branch has some output in the console, I would be curious to see what is output when you move the right or left analog stick.

Thanks!

Quackdoc commented 4 months ago

Seems like this is still an issue. DS3 and DS5 neither get picked up