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

Gamepad issues #297

Open
univrsal opened this issue Dec 5, 2022 · 59 comments
Open

Gamepad issues #297

univrsal opened this issue Dec 5, 2022 · 59 comments

Comments

@univrsal
Copy link
Owner

univrsal commented Dec 5, 2022

I've just finished some tests with SDL2, and it seems like I could replace the gamepad library with it. Before I do that, it would be good to have some people test SDL2 with their game pads to see if the mappings are working. SDL2 is used in a lot of games so I assume there shouldn't be any issues. I've attached the SDL2 gamepad test.

sdl2.gamepadtest.zip
image
Holding shift will show the back of the controller with additional buttons.

I'll also close all gamepad related issues and we'll just use this issue to collect information regarding gamepads.

SDL2 tests so far

Previous gamepad issues:
#294

  • LT + RT should be representable with buttons (Not an issue with mappings, but rather something I'd need to change in input overlay)
  • There should be an option for a "capture" or "share" button alongside the "guide" button since newer controllers also have this button. Not super important, but, might as well be a thing. (I assume SDL2 has this)

#286, #253
Should be fixed when using SDL2
#260
Should work with SDL2, if not I won't spend any additional time on this for now
#208
Apparently a crash with the gamepad library, should be fixed when using SDL2.
#195, #191
Mapping/ D-Pad issue should be fixed with SDL2
#183
SDL2 should support xbox one gamepads just fine
#175
More mapping issues once again SDL2 should handle them correctly
#241
Another dpad issue
#116
General issue with gamepad being detected
#213
Razer Rajiu not being detected, apparently that is a controller, so sdl will most likely handle it just fine.
#196 DirectInput implementation seemed to have caused stalls (probably waiting for a mutex)

Semi related issues:
#285 The incorrect position of the analog sticks is an issue with the library using different value ranges for linux and windows
#199 The binding tab will be removed as sdl2 should take care of correct bindings

@Arbel-arad
Copy link

seems to work fine for me, even with everything else connected

@univrsal
Copy link
Owner Author

univrsal commented Dec 6, 2022

seems to work fine for me, even with everything else connected

Thanks for testing, since your issue was a crash we'll have to see if the problem was really fixed once I switch the plugin to sdl

@clarfonthey
Copy link

clarfonthey commented Dec 7, 2022

I don't think that testing via WINE would be a fair test of how the native Linux SDL performs, but SDL2 stuff works perfectly on my system and I think porting to SDL2 would probably fix all my issues.

Would be happy to help test anything or provide some code changes as well depending on what's needed.

FWIW, since Nintendo Switch controller support is relatively new on Linux, a lot of things don't properly support it (mapping the buttons wrong under the assumption it's just an Xbox controller), although SDL2 actually does support it correctly.

@univrsal
Copy link
Owner Author

univrsal commented Dec 7, 2022

I don't think that testing via WINE would be a fair test of how the native Linux SDL performs, but SDL2 stuff works perfectly on my system and I think porting to SDL2 would probably fix all my issues.

Would be happy to help test anything or provide some code changes as well depending on what's needed.

FWIW, since Nintendo Switch controller support is relatively new on Linux, a lot of things don't properly support it (mapping the buttons wrong under the assumption it's just an Xbox controller), although SDL2 actually does support it correctly.

You can compile the program yourself if you want, it's just https://github.com/univrsal/SDL/blob/main/test/testgamecontroller.c which is part of the sdl2 tests

@HereInPlainSight
Copy link
Contributor

You can compile the program yourself if you want, it's just https://github.com/univrsal/SDL/blob/main/test/testgamecontroller.c which is part of the sdl2 tests

Tested in Linux with a PS3, PS4, and PS5 controller, seems to work fine on all.

@sanyer
Copy link

sanyer commented Dec 8, 2022

I can test it for Xbox and Xbox Elite controllers later today or tomorrow.
Additionally, I will also submit new preset/design for the Xbox controller.

@univrsal
Copy link
Owner Author

univrsal commented Dec 8, 2022

You can compile the program yourself if you want, it's just https://github.com/univrsal/SDL/blob/main/test/testgamecontroller.c which is part of the sdl2 tests

Tested in Linux with a PS3, PS4, and PS5 controller, seems to work fine on all.

The ps4 and ps4 controller have a touch pad, right? Did sdl2 detect any input when you used them? (There probably won't be any visualization since the display uses an xbox gamepad, but maybe the console window shows something). Also did the button with the playstation logo work?

I can test it for Xbox and Xbox Elite controllers later today or tomorrow. Additionally, I will also submit new preset/design for the Xbox controller.

Can you also test if the guide button and the additional buttons work?

@sanyer
Copy link

sanyer commented Dec 8, 2022

Can you also test if the guide button and the additional buttons work?

Sure, will do.

@sanyer
Copy link

sanyer commented Dec 8, 2022

All buttons (including Guide) work. And I don't have controller with Share button, so couldn't test that.
Sticks register direction correctly, but stick coordinates are all over the place, or at least it is hard to get consistent numbers, but perhaps it is just the internal thing as overlay always shows correct direction.

@univrsal
Copy link
Owner Author

univrsal commented Dec 8, 2022

All buttons (including Guide) work. And I don't have controller with Share button, so couldn't test that. Sticks register direction correctly, but stick coordinates are all over the place, or at least it is hard to get consistent numbers, but perhaps it is just the internal thing as overlay always shows correct direction.

Thanks for testing. I assume there's a way to convert the axis values if the interface shows the movements correctly.

@HereInPlainSight
Copy link
Contributor

HereInPlainSight commented Dec 8, 2022

The ps4 and ps4 controller have a touch pad, right? Did sdl2 detect any input when you used them? (There probably won't be any visualization since the display uses an xbox gamepad, but maybe the console window shows something).

Yes, as you said, no visual indicator. (I had to filter out the gyro \ accelerometer lines via ./testgamecontroller 2>&1 | grep -v "gyro\|accelerometer", for any other Linux user looking to pull out useful output.) This was as quick a straight press on the touchpad on a PS5 controller as possible. Note that only the first line and the 'button touchpad release' had to do with me pressing down, the rest is all 'We see a finger!' output. It's very spammy.

INFO: Controller 5 button touchpad pressed
INFO: Controller 5 touchpad 0 finger 0 moved to 0.85, 0.48, 1.00
INFO: Controller 5 touchpad 0 finger 0 moved to 0.85, 0.48, 1.00
INFO: Controller 5 touchpad 0 finger 0 moved to 0.85, 0.47, 1.00
INFO: Controller 5 touchpad 0 finger 0 moved to 0.85, 0.47, 1.00
INFO: Controller 5 touchpad 0 finger 0 moved to 0.85, 0.47, 1.00
INFO: Controller 5 touchpad 0 finger 0 moved to 0.85, 0.47, 1.00
INFO: Controller 5 touchpad 0 finger 0 moved to 0.85, 0.47, 1.00
INFO: Controller 5 touchpad 0 finger 0 moved to 0.85, 0.47, 1.00
INFO: Controller 5 touchpad 0 finger 0 moved to 0.85, 0.47, 1.00
INFO: Controller 5 touchpad 0 finger 0 moved to 0.85, 0.47, 1.00
INFO: Controller 5 button touchpad released
INFO: Controller 5 touchpad 0 finger 0 moved to 0.85, 0.47, 1.00
INFO: Controller 5 touchpad 0 finger 0 moved to 0.85, 0.47, 1.00
INFO: Controller 5 touchpad 0 finger 0 moved to 0.85, 0.47, 1.00
INFO: Controller 5 touchpad 0 finger 0 moved to 0.85, 0.48, 1.00
INFO: Controller 5 touchpad 0 finger 0 moved to 0.85, 0.48, 1.00
INFO: Controller 5 touchpad 0 finger 0 moved to 0.85, 0.48, 1.00
INFO: Controller 5 touchpad 0 finger 0 moved to 0.85, 0.48, 1.00
INFO: Controller 5 touchpad 0 finger 0 moved to 0.85, 0.49, 1.00
INFO: Controller 5 touchpad 0 finger 0 moved to 0.85, 0.49, 1.00
INFO: Controller 5 touchpad 0 finger 0 moved to 0.85, 0.49, 1.00
INFO: Controller 5 touchpad 0 finger 0 moved to 0.85, 0.50, 1.00
INFO: Controller 5 touchpad 0 finger 0 moved to 0.85, 0.50, 1.00
INFO: Controller 5 touchpad 0 finger 0 released at 0.85, 0.50, 0.00

Also did the button with the playstation logo work?

Yes. It showed as the giant center button in the picture (output indicated the 'guide' button), and the microphone mute button was reflected in the button just under that (the 'misc1' button).


Unrelated to the rest, since people were talking about switch controllers, I found an off-brand pro version I had in the house, and it works as expected. Y and X are swapped visually, but report correctly, the same as B and A, since Nintendo and Microsoft seem to have reversed positioning on those compared to each other.

Edit: I forgot the switch controller had buttons on the back / bottom. These do not seem to report anything at all when pressed.

@univrsal
Copy link
Owner Author

univrsal commented Dec 8, 2022

The ps4 and ps4 controller have a touch pad, right? Did sdl2 detect any input when you used them? (There probably won't be any visualization since the display uses an xbox gamepad, but maybe the console window shows something).

Yes, as you said, no visual indicator. (I had to filter out the gyro \ accelerometer lines via ./testgamecontroller 2>&1 | grep -v "gyro\|accelerometer", for any other Linux user looking to pull out useful output.) This was as quick a straight press on the touchpad on a PS5 controller as possible. Note that only the first line and the 'button touchpad release' had to do with me pressing down, the rest is all 'We see a finger!' output. It's very spammy.

INFO: Controller 5 button touchpad pressed
INFO: Controller 5 touchpad 0 finger 0 moved to 0.85, 0.48, 1.00
INFO: Controller 5 touchpad 0 finger 0 moved to 0.85, 0.48, 1.00
INFO: Controller 5 touchpad 0 finger 0 moved to 0.85, 0.47, 1.00
INFO: Controller 5 touchpad 0 finger 0 moved to 0.85, 0.47, 1.00
INFO: Controller 5 touchpad 0 finger 0 moved to 0.85, 0.47, 1.00
INFO: Controller 5 touchpad 0 finger 0 moved to 0.85, 0.47, 1.00
INFO: Controller 5 touchpad 0 finger 0 moved to 0.85, 0.47, 1.00
INFO: Controller 5 touchpad 0 finger 0 moved to 0.85, 0.47, 1.00
INFO: Controller 5 touchpad 0 finger 0 moved to 0.85, 0.47, 1.00
INFO: Controller 5 touchpad 0 finger 0 moved to 0.85, 0.47, 1.00
INFO: Controller 5 button touchpad released
INFO: Controller 5 touchpad 0 finger 0 moved to 0.85, 0.47, 1.00
INFO: Controller 5 touchpad 0 finger 0 moved to 0.85, 0.47, 1.00
INFO: Controller 5 touchpad 0 finger 0 moved to 0.85, 0.47, 1.00
INFO: Controller 5 touchpad 0 finger 0 moved to 0.85, 0.48, 1.00
INFO: Controller 5 touchpad 0 finger 0 moved to 0.85, 0.48, 1.00
INFO: Controller 5 touchpad 0 finger 0 moved to 0.85, 0.48, 1.00
INFO: Controller 5 touchpad 0 finger 0 moved to 0.85, 0.48, 1.00
INFO: Controller 5 touchpad 0 finger 0 moved to 0.85, 0.49, 1.00
INFO: Controller 5 touchpad 0 finger 0 moved to 0.85, 0.49, 1.00
INFO: Controller 5 touchpad 0 finger 0 moved to 0.85, 0.49, 1.00
INFO: Controller 5 touchpad 0 finger 0 moved to 0.85, 0.50, 1.00
INFO: Controller 5 touchpad 0 finger 0 moved to 0.85, 0.50, 1.00
INFO: Controller 5 touchpad 0 finger 0 released at 0.85, 0.50, 0.00

Also did the button with the playstation logo work?

Yes. It showed as the giant center button in the picture (output indicated the 'guide' button), and the microphone mute button was reflected in the button just under that (the 'misc1' button).

Thanks for the feedback. I assume that the movement is limited to values between 0 and 1. So I guess input overlay could visualize and forward that via the websocket server. The swapped X/Y are a bit annoying, but the preset for the switch can just switch (hah) them, alternatively it seems like there is an option to change this in sdl

Unrelated to the rest, since people were talking about switch controllers, I found an off-brand pro version I had in the house, and it works as expected. Y and X are swapped visually, but report correctly, the same as B and A, since Nintendo and Microsoft seem to have reversed positioning on those compared to each other.

Edit: I forgot the switch controller had buttons on the back / bottom. These do not seem to report anything at all when pressed.

Are those extra buttons also on a normal switch pro controller? If not it's probably an issue with SDL assuming that it is a switch pro controller

@HereInPlainSight
Copy link
Contributor

HereInPlainSight commented Dec 9, 2022

I assume that the movement is limited to values between 0 and 1.

Correct. Touchpad values on the PS5 touchpad seem to be 0.00 through 1.00 on the X and Y axis, with a Z value that seems to always be '1.00' when the touchpad's being touched, and '0.00' as the very last value as the touch pad is released. (You can see that in my output above.) No indication that I can see that the Z value is ever anything other than a binary value besides it being shown as having a decimal point. 0.00 0.00 is the top-left coordinates, 1.00 1.00 is the bottom-right. I can test the PS4 controller if you want, but I suspect it's the exact same given everything else is.

Also, while it only lists 'finger 0' above, it looks like the touchpad can register two fingers (0 and 1) at the same time.

Are those extra buttons also on a normal switch pro controller?

I don't see anything that looks similar on the pictures of a real switch pro controller, so I guess not. I have no idea what they're for, but since it's an off-brand and doesn't exist on the official pro controller and they're not registering in SDL, I doubt it's worth caring about.

@univrsal
Copy link
Owner Author

univrsal commented Dec 9, 2022

Correct. Touchpad values on the PS5 touchpad seem to be 0.00 through 1.00 on the X and Y axis, with a Z value that seems to always be '1.00' when the touchpad's being touched, and '0.00' as the very last value as the touch pad is released. (You can see that in my output above.) No indication that I can see that the Z value is ever anything other than a binary value besides it being shown as having a decimal point. 0.00 0.00 is the top-left coordinates, 1.00 1.00 is the bottom-right. I can test the PS4 controller if you want, but I suspect it's the exact same given everything else is.

The code references the third value as pressure so maybe it could technically be in between 0 and 1 just not with playstation controllers.

@ngeTaco
Copy link

ngeTaco commented Dec 20, 2022

I assume that the movement is limited to values between 0 and 1.

Correct. Touchpad values on the PS5 touchpad seem to be 0.00 through 1.00 on the X and Y axis, with a Z value that seems to always be '1.00' when the touchpad's being touched, and '0.00' as the very last value as the touch pad is released. (You can see that in my output above.) No indication that I can see that the Z value is ever anything other than a binary value besides it being shown as having a decimal point. 0.00 0.00 is the top-left coordinates, 1.00 1.00 is the bottom-right. I can test the PS4 controller if you want, but I suspect it's the exact same given everything else is.

Also, while it only lists 'finger 0' above, it looks like the touchpad can register two fingers (0 and 1) at the same time.

Are those extra buttons also on a normal switch pro controller?

I don't see anything that looks similar on the pictures of a real switch pro controller, so I guess not. I have no idea what they're for, but since it's an off-brand and doesn't exist on the official pro controller and they're not registering in SDL, I doubt it's worth caring about.

Those buttons probably have to be assigned to mimick another face or shoulder button, which is non-standard for the base model of controlers for microsoft, sony, and nintendo, so no need to worry. I would assume that if theyre assigned, SDL2 would show the mimicked button being activated and not those back buttons, but not something I think would be a deal breaker for people.

@patlefort
Copy link

Strange that the buttons are swapped, I assume they're fine in the gamepad test program (linked in the issue description)?

Indeed it is working, Y is Y and X is X.

@clarfonthey
Copy link

yeah It's something with simd headers clashing with sdl2, debug builds don't have that issue for some reason

I'm glad that you know the reason for this, because I honestly thought it was just some weird quirk of my system and didn't want to mention it. When you say "debug builds," how are you building it differently? (as in, is there a way for me to modify it so I can build a debug build, and maybe I can help figure out the issue this way)

@univrsal
Copy link
Owner Author

univrsal commented Mar 9, 2023

yeah It's something with simd headers clashing with sdl2, debug builds don't have that issue for some reason

I'm glad that you know the reason for this, because I honestly thought it was just some weird quirk of my system and didn't want to mention it. When you say "debug builds," how are you building it differently? (as in, is there a way for me to modify it so I can build a debug build, and maybe I can help figure out the issue this way)

Just the normal cmake debug target, i.e. cmake -S <path to git repo> -DCMAKE_BUILD_TYPE=Debug

You can also do what I did for the CI builds and tamper with the headers that cause the issue, but I wouldn't recommend that:
https://github.com/univrsal/input-overlay/blob/master/.github/scripts/.build.zsh#L182-L183

@clarfonthey
Copy link

Yeah, I wouldn't want to actually mess with library headers; that sounds like a lost cause.

I will try and see what's different in the debug build, though; my guess is that there might be some extra include flags that conflict, but we'll see. Not sure if I'll get to this over the weekend or not, but I'll share what I find if I find anything.

@patlefort
Copy link

On Arch, makepkg will default to x86-64 arch which result in the wall of errors with intrinsics. Adding -msse4.1 work around the problem.

@univrsal
Copy link
Owner Author

univrsal commented Mar 9, 2023

Where did you add that?

@patlefort
Copy link

It's a compile flag for GCC. For makepkg, you'd have to add it into /etc/makepkg.conf in the CFLAGS and CXXFLAGS. Alternatively I think it's better to change -march=x86-64 to -march=native so it can take full advantage of your hardware.

@univrsal
Copy link
Owner Author

univrsal commented Mar 9, 2023

So I guess set(CMAKE_CXX_FLAGS "-march=native") should do the trick

@patlefort
Copy link

patlefort commented Mar 9, 2023

I see what's going on: OBS is defining things that are defined in standard intrinsincs headers because they aren't included yet and compiler flags indicate that they aren't available. And then SDL include the file <immintrin.h> which include all intrinsics headers regardless of flags. I think what OBS is doing is wrong but to fix it, including SDL before obs headers should work.

@univrsal
Copy link
Owner Author

Strange that the buttons are swapped, I assume they're fine in the gamepad test program (linked in the issue description)?

Indeed it is working, Y is Y and X is X.

I figured it out. Since the scroll wheel and right mouse button are switched on linux I switched keycodes 2 and 3. That should only happen for mouse button elements, but I did it for all elements so the gamepad codes 2 and 3 where also switched. Should be fixed with 4cb687f

@patlefort
Copy link

So I guess set(CMAKE_CXX_FLAGS "-march=native") should do the trick

You shouldn't force it in your source. For a packager, it would cause issues as binaries packages are expected to target an architecture which isn't always to one of the machine compiling. Ideally it should have the widest compatibility by default. Also it won't work for msvc.

@univrsal
Copy link
Owner Author

Well windows never had the issue to begin with. I'll just leave it the way it is for now.

@GameKyuubi
Copy link

Went from dpad not working to everything not working now. New issue?

@univrsal
Copy link
Owner Author

univrsal commented Mar 14, 2023

nah just post the full log here, ideally while running obs with --verbose

@GameKyuubi
Copy link

GameKyuubi commented Mar 14, 2023

obs.log

@univrsal
Copy link
Owner Author

Try the a6d212f commit. Ideally with only one gamepad connected first. I already heard that multiple seem to cause issues.

@GameKyuubi
Copy link

I only have one connected, not sure why it's detecting two. jstest only shows one.

@univrsal
Copy link
Owner Author

Might be that it first thinks it's an xbox 360 gamepad and then identifies it as an xbox one gamepad. I'll try and see if I can find another gamepad so I can reproduce the bug

@AlexEndris
Copy link

AlexEndris commented Mar 26, 2023

I don't know if my issue is in anyway related to this. I'm using a GuliKit gamepad over Bluetooth. It's recognized as an XBox One controller but the only inputs that are shown are the left trigger and right trigger. None of the others light up or move. Is there anything I can provide you in terms of logs? Should I create another issue for this?

Edit: Maybe as a side-note: With your SDL2 implementation, everything is recognised as it should be.

@RowanSkie
Copy link

DS4 controllers doesn't seem to have full recognition by the overlay. Only ones that work are the d-pad, the joysticks, and the triggers. The rest don't show, even when clicked.

@DrakePHOSE
Copy link

DrakePHOSE commented Apr 21, 2023

Just came from #302 , finally got around to trying this.

Not sure if you are still accepting gamepad related issue threads so I'll drop something here and let me know if I should continue it in a thread.

Checked that this detects my controller inputs, and it does.

Then I saw there was an update to input-overlay so I updated.
Installed and hit my controller button and OBS crashed.
It crashed every time a controller input was detected.
It also seems like it wouldn't detect my controller until I unplugged it, then plugged it back in.
Once I did, then hit any button, crash.

Did some looking around, and my config file had the old codes for controller inputs.
So I updated it with the new codes from the config site, and it worked.
Then I plugged my controller in and out, hit my button, and it crashed.

That's where I am now. It crashes if input something with the controller after the controller is disconnected then reconnected.
This might be ok for some people but I'm emulating a controller thru ReWASD thru keyboard keys. I'm having it disconnect when I alt tab from the game, and reconnect when I tab back in. All so my keyboard buttons are free when I'm not in game.
I did confirm all this behaviour with a normal controller, so I'm sure it's not ReWASD.

OBS 29.0.2. input-overlay 5.0.3

@univrsal
Copy link
Owner Author

provide the crash log and the full obs studio log

@DrakePHOSE
Copy link

@univrsal
Copy link
Owner Author

Can you download the plugin build at the bottom of this page, install it and see if it fixes the crash?

@DrakePHOSE
Copy link

That would be under "Artifacts" --- input-overlay-windows-x64-85da14516
Correct?

If so, that does fix the crashes but now it doesn't detect the controller inputs most of the time.
And I'm struggling to see the pattern.
At first I thought it only worked when the controller was plugged in when OBS launched. But then I tried that again and it's not detecting it.
The only thing I think (?) I can confirm is that when it works or doesn't work, it will do so for the rest of the OBS session.
If it works, then I can disconnect and reconnect the controller and everything is fine.
You want logs?

@iznaut
Copy link

iznaut commented Sep 7, 2023

I had an older version of this that worked great (possibly pre-5.0) but I wiped the OBS and had to redownload - now it's super busted.

I tried the latest release, as well as the most recent Actions build, but I only see my sticks and triggers working (no buttons will light up)

@Nicolas-GE
Copy link

i just got V5.0.5 and i don't see any inputs from my Gulikit KK3
the program linked in #297 can see my controller's inputs correctly but i don't see any inputs on the pro controller overlay of that version's preset .zip file
if i swap it from Bluetooth mode to USB mode(wireless dongle that emulates a 360 controller) it doesn't work either

@0ak0
Copy link

0ak0 commented Jun 17, 2024

i just got V5.0.5 and i don't see any inputs from my Gulikit KK3 the program linked in #297 can see my controller's inputs correctly but i don't see any inputs on the pro controller overlay of that version's preset .zip file if i swap it from Bluetooth mode to USB mode(wireless dongle that emulates a 360 controller) it doesn't work either

I can also confirm my pro controller does not work with the default preset (switch or default gamepad).

When I first added the input overlay source, my joysticks seemed to be in non default positions. Restarting OBS put them back in the center, but still no input is being shown on the overlay.

The controller test program (sdl2.gamepadtest.zip) seems to read the inputs fine

18/6/24 - Update
Bluetooth seems to work fine (was charging controller yesterday), but not over usb.

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