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

Support for pressure-sensitive face buttons #5148

Closed
eVenent opened this issue Dec 29, 2021 · 31 comments
Closed

Support for pressure-sensitive face buttons #5148

eVenent opened this issue Dec 29, 2021 · 31 comments
Assignees
Milestone

Comments

@eVenent
Copy link

eVenent commented Dec 29, 2021

I have got forwarded here from my feature request for Xbox emulator to add pressure-sensitive face buttons for Xbox OG controller, DualShock 2 and DualShock 3. But it is even better, as direct feature in SDL can lead to creating good quality tools for these devices.

Actually we do not have now good quality drivers for Xbox and DualShock 2 controllers supporting unique feature which are pressure-sensitive buttons. DualShock 3 has this support in DsHidMini and reWASD application.

Xbox OG controller has 3 drivers on Windows:

  • XBCD allows to use assign 6 of 8 pressure sensitive buttons to 3 free axis.
  • Mayflash Tigergame allows only 2 of 8.
  • Xb2XInput none as translates signals to XInput which is not supporting pressure sensitive buttons.

DualShock 2 has drivers where Mayflash's supports only 2 from 12 pressure sensitive buttons and Bliss-Box's allows to remap only 4 of 12 pressure sensitive buttons. Not satisfying solution as rest works as digital buttons.

I would like to ask for implementation pressure-sensitive face buttons which later can be used as DirectInput axes for every pressure sensitive button. Support of pressure sensitive buttons should be preserved as they still can give a lot of fun. They will let enjoy applications like reWASD, PS2, PS3, Xbox emulators and even GInput mods for old GTA III, VC and SA where pressure-sensitive option is used already by DualShock's 3 DsHidMini drivers.

Pressure sensitive controllers:

  • DualShock 2: 8 × pressure-sensitive buttons: △, ○, ×, □, L1, R1, L2, R2 and 4 × pressure-sensitive directional buttons (d-pad): ↑, ↓, ←, →
  • DualShock 3: 6 × pressure-sensitive buttons: △, ○, ×, □, L1, R1 and 4 × pressure-sensitive directional buttons (d-pad): ↑, ↓, ←, → plus analog triggers (L2, R2)
  • Xbox OG Controller: 6 × pressure-sensitive buttons: 𝐀, 𝐁, 𝐗, 𝗬, ᴡʜɪᴛᴇ, ʙʟᴀᴄᴋ plus analog triggers (LT, RT)
@slouken
Copy link
Collaborator

slouken commented Dec 29, 2021

Feel free to propose an API and submit a PR.

@mirh
Copy link

mirh commented Aug 31, 2022

This didn't go pretty well in #5339...
But anyway, the current solutions don't seem revolutionary and they are pretty fairly lightweight too.
RPCS3/rpcs3#1034
PCSX2/pcsx2#5861
And I'm going to guess it's also in the interests of the project to support Wooting and Razer Huntsman/Tartarus products?

@lucasmr
Copy link

lucasmr commented Sep 11, 2022

For DS3, code landed on this commit

I'm not sure about Windows and Linux support. I want to test this on Linux, do I need anything special other than SDL_JOYSTICK_HIDAPI_PS3=1?

@Slider-Whistle
Copy link

@lucasmr You could try seeing if sdl2-jstest supports it? https://gitlab.com/sdl-jstest/sdl-jstest
If I'm interpreting it right, the comment on line 355 seems to imply that the buttons will just show up as axes, rather than adding any new, incompatible API.

@mirh
Copy link

mirh commented Sep 12, 2022

1fc7f68 seems pretty clear to me.
I guess that support could always come once people agree this new driver is good.

@lucasmr
Copy link

lucasmr commented Sep 12, 2022

@lucasmr You could try seeing if sdl2-jstest supports it? https://gitlab.com/sdl-jstest/sdl-jstest If I'm interpreting it right, the comment on line 355 seems to imply that the buttons will just show up as axes, rather than adding any new, incompatible API.

Tested with sdl2-jstest, no change. 6 axes and digital buttons.
Also tested on PCSX2, the emulator sees the device, can activate rumble, but cannot remap any buttons.
I'm with a genuine DS3 controller, /dev/hidraw has read/write permissions and I can see the gyroscope sending data with cat, but so far no luck. I think there's some code needed for this to work on Linux.

@mirh
Copy link

mirh commented Sep 12, 2022

Pcsx2 doesn't seem to have any kind of support for pressure sensitivity on linux (and they were in fact looking forward to SDL to handle the feature) PCSX2/pcsx2#4875

You should try rpcs3 if any RPCS3/rpcs3#5888 (comment)
(take note some extra tinkering may be needed)

@lucasmr
Copy link

lucasmr commented Sep 12, 2022

Pcsx2 doesn't seem to have any kind of support for pressure sensitivity on linux (and they were in fact looking forward to SDL to handle the feature) PCSX2/pcsx2#4875

You should try rpcs3 if any RPCS3/rpcs3#5888 (comment) (take note some extra tinkering may be needed)

Thanks. RPCS3 is accessing DS3 directly via HIDAPI. What I wanted to do was test the DS3 from SDL with the new pressure sensitive code, which also access it via HIDAPI.

@mirh
Copy link

mirh commented Sep 12, 2022

Yes, but I guess something as convoluted as reading RPCS3/rpcs3@839fe78, needs some kind of specific "thoughtfulness" on the side of normal programs (or if not any, even just an innocent assumption in the GUI could lead to whatever misleading).

And indeed this looks even more of the case if even a test app is not reporting it properly (despite the fact the "system side" is good if rpcs3 is working).

@slouken slouken self-assigned this Sep 12, 2022
@slouken slouken added this to the 2.26.0 milestone Sep 12, 2022
@slouken
Copy link
Collaborator

slouken commented Sep 12, 2022

This is working here:

root@streaming-laptop:/home/slouken/projects/sdl-jstest# SDL_JOYSTICK_HIDAPI_PS3=1 ./sdl2-jstest --list
error: failed to read gamecontrollerdb.txt: Invalid RWops
Found 1 joystick(s)

Joystick Name:     'PS3 Controller'
Joystick GUID:     0300afd34c0500006802000000016800
Joystick Number:    0
Number of Axes:    16
Number of Buttons: 15
Number of Hats:     0
Number of Balls:    0
GameControllerConfig:
  Name:    'PS3 Controller'
  Mapping: '0300afd34c0500006802000000016800,*,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,crc:d3af,platform:Linux'

Make sure you're running with the new version of SDL, not a system installed version.

@slouken
Copy link
Collaborator

slouken commented Sep 12, 2022

Note that the HIDAPI controller has '68' in the second to last byte. That's how you know the right driver is being used.

@lucasmr
Copy link

lucasmr commented Sep 12, 2022

Thanks @slouken, I forgot the environment variable when running sdl2-jstest. I can confirm all 16 axes work!

@slouken
Copy link
Collaborator

slouken commented Sep 12, 2022

Great, thanks!

@slouken slouken closed this as completed Sep 12, 2022
@mirh
Copy link

mirh commented Sep 12, 2022

Shouldn't this be left open to finalize the thing on other platforms?

@slouken
Copy link
Collaborator

slouken commented Sep 12, 2022

Well, it's not possible on Windows, and works well on macOS. Are there other platforms you're concerned about?

@mirh
Copy link

mirh commented Sep 12, 2022

It *is* possible in windows.
Just not by default (not that the PS3 or OG xbox controllers would otherwise work out of the box anyway, to be fair).
From the top of my head I can think of:

  • the half-assed way: the ludicrous DirectInput remapping of the old xbox drivers, or the GPJ mode of DsHidMini
  • hidapi¿ (unsure about the relationship between libusb, winusb and whatnot)
  • XInputGetExtended with the SCP XInput Bridge

@slouken
Copy link
Collaborator

slouken commented Dec 8, 2022

It is possible in windows. Just not by default (not that the PS3 or OG xbox controllers would otherwise work out of the box anyway, to be fair). From the top of my head I can think of:

  • the half-assed way: the ludicrous DirectInput remapping of the old xbox drivers, or the GPJ mode of DsHidMini
  • hidapi¿ (unsure about the relationship between libusb, winusb and whatnot)
  • XInputGetExtended with the SCP XInput Bridge

You need a driver to do this on Windows. The Windows HIDAPI interface won't allow the report that starts input because it's not in the report descriptor for the PS3 controller.

@mirh
Copy link

mirh commented Dec 8, 2022

Of course you need a driver, that's like what I said.. The question here is how (if) to interface with them in SDL.

@eVenent
Copy link
Author

eVenent commented Dec 8, 2022

Hmm... Currently only two drivers are used by Windows' majority. ReWASD App is quite good using official Sony's DualShock 3 driver under Windows to support pressure sensitivity. On beginning they were just letting to remap pressure sensitive buttons in their app, but in version 6.3.0 they released virtual DS3 controller to emulate pressure sensitive buttons on every controller. Additionally, to make it more useful, they've added official support for Sony's driver to PCSX2 with this commit. This driver is used with Sony Remote Play for Playstation 3, PS Plus Premium and emulator RPCS3. I'm not telling that this driver should be used, but some Windows applications are making very good use of it. Maybe in the future, reWASD will be able to use pressure-sensitive Steam Deck's touchpads to remap them into their virtual DS3 controller (where upper zone will activate triangle, left square, right circle and lower cross) and open support for pressure-sensitive touchpads in emus.

On other hand we have @Nefarius's projects where his driver DsHidMini works with GInput, PCSX2 and RPCS3 and maybe will work with new DS4Windows... This driver is preferred by community projects. What is interesting, this driver can be installed on reWASD's DS3 virtual controller too.

@mirh
Copy link

mirh commented Dec 9, 2022

The problem with sixaxis.sys is that I'm pretty sure SDL isn't going to ship/link/use libpad.dll, and so you'd have to interface directly with the absolutely undocumented driver (as if the base library wasn't already offensively mysterious)

Anyhow, regardless.. I guess like you could support even more than a single driver per controller. Though there should probably be a market and a reason for it.

@slouken
Copy link
Collaborator

slouken commented Dec 9, 2022

Feel free to submit a PR for Windows support using either of those drivers.

@mirh
Copy link

mirh commented Dec 11, 2022

My qualm was just addressing the status of this issue

@nefarius
Copy link

nefarius commented Dec 29, 2022

and maybe will work with new DS4Windows...

Already does for like over a year. All in my README and docs 😉

EDIT: oh you meant our fork, yeah, likewise, the bare basics already work 👍

@nefarius
Copy link

What is interesting, this driver can be installed on reWASD's DS3 virtual controller too.

If the virtual device behaves exactly like the hardware then that is working as expected 👍

@fir3-1ce
Copy link

fir3-1ce commented Apr 17, 2023

did they add this in yet?

and if so, has it been implemented on the flatpak?

@Hunter16g
Copy link

Is it expected that pressure sensitivity works only when the controller is connected via USB ? Whenever I connect it via bluetooth I only see 6 axis.

@mirh
Copy link

mirh commented Jun 8, 2023

My uneducated guess would be (if we are talking about hidapi on linux, right?) that's a bug, possibly in the kernel code that handles one of the interfaces. AFAIR ds3 had no capabilities difference between wireless and wired mode.

@Hunter16g
Copy link

Do you have any idea how I could find the issue ? I'm using SDL 2.26.5 provided by debian 12, and I'm using SDL_JOYSTICK_HIDAPI_PS3=1 ./sdl2-jstest --list
I see all 16 axis, but over bluetooth the GUID is different and only 6 axis show up.

@slouken
Copy link
Collaborator

slouken commented Jun 8, 2023

Bluetooth mode is fixed for SDL 3.0 in 32d015a

@mirh
Copy link

mirh commented Jul 3, 2023

It has came to my attention that on windows (with the "official" driver) you aren't just loosing analog buttons without HIDAPI.
Force feedback is also broken.

@mirh
Copy link

mirh commented May 27, 2024

Rejoice for #9144

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

8 participants