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

PS3 controller multiple axis with same usage reports wrong value #15

Open
sonik-br opened this issue May 26, 2022 · 19 comments
Open

PS3 controller multiple axis with same usage reports wrong value #15

sonik-br opened this issue May 26, 2022 · 19 comments
Labels

Comments

@sonik-br
Copy link

Hi.
I'm interfacing with a game controller and it have two "Slider" axis.
The report is correct on windows (joy.cpl)
In the HID Demo one of the sliders report is duplicate on the other. The second one don't generate any report.

The descriptor: (I added the "DataIndex" property on the list).
image

And the event log.
image

Here it's possible to see that the Sliders both are sharing the same values.

I try to debug but could not find the problem. Looks like it ignores the DataIndex if the axis is duplicate?

If you can at least point me in the right direction so I can try to fix.

Thanks.

@Slion
Copy link
Owner

Slion commented May 28, 2022

Been a while since I had a look at that code but if I had to take a guess it probably does a look-up for the Slider and take the first one it finds, not expecting you can have multiple of them. It could be tricky to fix too. Can you not reassign one of the Sliders to another axis somehow? Do you mind me asking what kind of device is that?

@sonik-br
Copy link
Author

I'm interfacing with some gamepads and gamepad adapters.
This one is not an adapter, but an Playstation 3 controller directly connected to windows using the driver provided by Sony (maker of the device).
It's not really required to fix for this device but would be good to have it working for others.
I understand if it's something hard to track down and not worth to fix.

@Slion
Copy link
Owner

Slion commented Jun 13, 2022

I'm just now starting to understand that issue. I don't have a PS3 controller but I do have a PS4 controller so I guess I'll try to reproduce it with that one. Thanks again for taking the time to report it.

The thing is I don't think I'm myself using that DataIndex to fetch the values. It's done in HidEvent.GetUsageValues using HidP_GetUsageValue. I wonder if that could be a Windows bug. Need to take a closer look though.

I can't reproduce the issue with the PS4 controller cause it does not have multiple axis with the same usage…

@Slion Slion changed the title Duplicate axis PS3 controller multiple axis with same usage report wrong value Jun 14, 2022
@Slion Slion changed the title PS3 controller multiple axis with same usage report wrong value PS3 controller multiple axis with same usage reports wrong value Jun 14, 2022
@Slion
Copy link
Owner

Slion commented Jun 14, 2022

I have the means to test that here apparently by configuring my Virpil joystick. However when I try to configure it with multiple axes having the same name it gives out a warning message:
image

Just saying it looks like this is something to be avoided in general.

@Slion
Copy link
Owner

Slion commented Jun 14, 2022

It does work in the control panel, it's showing two sliders, both are working nicely.
image

@Slion
Copy link
Owner

Slion commented Jun 14, 2022

And I can reproduce the issue in HID Demo. I'll try to debug that later today.

@Slion
Copy link
Owner

Slion commented Jun 14, 2022

The issue it seems is indeed due to HidP_GetUsageValue. It looks like they even describe the problem in the docs remarks section.

Basically to support that we should use HidP_GetUsageValueArray instead off HidP_GetUsageValue.

@Slion Slion added the bug label Jun 14, 2022
@Slion
Copy link
Owner

Slion commented Jun 14, 2022

We should switch to Microsoft.Windows.CsWin32 to gain access to HidP_GetUsageValueArray

@Slion
Copy link
Owner

Slion commented Jun 14, 2022

Except that our ReportCount is not above one so that array function might not be what we need here. I'm still missing a piece of the puzzle.

I'm guessing I still need to experiment with HidP_GetUsageValueArray to see if I can get it to work somehow.

@sonik-br
Copy link
Author

Nice! Thanks for taking a shot at it.

The PS3 controller have some unique features... It's buttons are "pressure sensitive"!
So the driver them as button bits and also as sliders. That's why it does have a bunch of sliders.

@Slion
Copy link
Owner

Slion commented Jun 14, 2022

As feared using HidP_GetUsageValueArray does not work it returns HIDP_STATUS_NOT_VALUE_ARRAY. More investigation is needed to work that one out. I'll put on the ice for now however.

@Slion Slion closed this as completed in 8264655 Jun 14, 2022
@Slion Slion reopened this Jun 14, 2022
@Slion
Copy link
Owner

Slion commented Jun 14, 2022

UCR can pick up both Slider axes properly through SharpDX DirectInput. However this is done through DirectInput which is a higher level API so it won't help us here.

@Slion
Copy link
Owner

Slion commented Jun 19, 2022

@sonik-br Could you build and run the latest HID Demo? I'm just curious to see what kind of friendly name your PS3 controller is now reporting. Hopefully I did not break anything.

@Slion
Copy link
Owner

Slion commented Jun 19, 2022

I could try to use API Monitor see how Joy.cpl gets the axis value. Though I reckon it's using the DirectInput API rather than the HID API.

@sonik-br
Copy link
Author

Tested it with the current code from repo.
Working the same way with the PS3 controller. Sliders are sharing the same value.

I can try to see how UCR work and use SharpDX.

BTW got it "working" with IntergatedCircuits/HidSharp
Sliders works independently but it does have another problem. It's not handling signed/unsigned values correctly :(

@Slion
Copy link
Owner

Slion commented Jun 19, 2022

In the HID Demo, is it still displaying VID_054C as the name of the device?

@sonik-br
Copy link
Author

It changed...

On windows panel:
image

And on HID Demo:
image

@Slion
Copy link
Owner

Slion commented Jun 19, 2022

Thanks, still the wrong one though. Interesting that the control panel get it correct.

@sonik-br
Copy link
Author

Control Panel gets the info from windows register I think.
I've seen this happen with arduino based devices. On a clean windows install if you connect an customized arduino, windows will cache it's "name".
Then later if you connect an default arduino, it will still show the cached name and not what is being reported by the new device.
This off course when using devices with same VID/PID.

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

No branches or pull requests

2 participants