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 · 46 comments
Closed

Support for pressure-sensitive face buttons #5148

eVenent opened this issue Dec 29, 2021 · 46 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

@SAMGARTNER
Copy link

SAMGARTNER commented Nov 4, 2024

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

Hello, did you used SDL 2 or SDL3? I'm still getting only 6 Axes with SDL 2.30.3
screenshot

@AntTheAlchemist
Copy link
Contributor

@SAMGARTNER I believe the button pressure data comes through as unmapped axis, so you won't see them being counted as an axis. It's a shame, but pressure axis mapping won't be added.

@slouken
Copy link
Collaborator

slouken commented Nov 5, 2024

The issue here is that the HIDAPI driver isn't being used for some reason. That's usually a permissions issue on the hidraw device.

@SAMGARTNER
Copy link

@SAMGARTNER I believe the button pressure data comes through as unmapped axis, so you won't see them being counted as an axis. It's a shame, but pressure axis mapping won't be added.

🙏 in Slouken's comment he showed he got the 16 axes although he used sdl2-jstest and I used Grumbel's jstest-sdl (https://github.com/Grumbel/sdl-jstest) with a few changes that I made to show the version and the variable. What's not clear for me is whether he used SDL3 or SDL2

@SAMGARTNER
Copy link

SAMGARTNER commented Nov 5, 2024

The issue here is that the HIDAPI driver isn't being used for some reason. That's usually a permissions issue on the hidraw device.

Thank you very much for chiming in, I'm not very GNUL savvy, any advice?, I need a big road sign.

UPDATE:

Ok I just notice this on the official docs, I thought it was also included on the last SDL2

"Syntax

#define SDL_HINT_JOYSTICK_HIDAPI_PS3 "SDL_JOYSTICK_HIDAPI_PS3"
Remarks
...

This hint is available since SDL 3.1.3."

@vaccinemedia
Copy link

After installing the latest 3.x version of SDL on Raspberry Pi OS I'm getting:

grahambrown@pi5:~ $ DL_JOYSTICK_HIDAPI_PS3=1 sdl2-jstest --list
Found 1 joystick(s)

Joystick Name:     'Sony PLAYSTATION(R)3 Controller'
Joystick GUID:     0300afd34c0500006802000011810000
Joystick Number:    0
Number of Axes:     6
Number of Buttons: 17
Number of Hats:     0
Number of Balls:    0
GameControllerConfig:
  Name:    'PS3 Controller'
  Mapping: '0300afd34c0500006802000011810000,PS3 Controller,a:b0,b:b1,back:b8,dpdown:b14,dpleft:b15,dpright:b16,dpup:b13,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b2,platform:Linux,'

It would be awesome to have full support for analogue / pressure sensitive buttons. I came here because I have been testing GTA Vice City on the Pi 5 and this was the first thing I noticed being missing. I don't know if this is an issue with the port, or if this is a system wide issue so I thought I'd chime in here ;)

@mirh
Copy link

mirh commented Dec 22, 2024

  1. it's SDL_JOYSTICK_HIDAPI_PS3
  2. I don't think testing windows games is exactly the best idea
  3. let alone gta? even with GInput I'm really skpetical that's supposed to support SDL

@vaccinemedia
Copy link

vaccinemedia commented Dec 22, 2024

it's SDL_JOYSTICK_HIDAPI_PS3

Good catch - I was copying / pasting from earlier replies on this issue but must not have copied the whole line. I'll have another try when I'm back with the Pi in a couple of days.

The version of GTA Vice City is the native linux one installed by PiKISS. I've asked the PiKISS maintainer if it's possible to have pressure sensitive buttons in Vice City.

Running jstest-gtk shows the DS3 pad ok and the main axes work but the buttons are showing as buttons and not axes. I read somewhere that before Sony removed the pressure sensitive button feature from the kernel that people used to see lots of axes in jstest-gtk and it caused some confusion. Should the buttons be showing as axes in jstest-gtk or does the application need to use SDL? Apologies for my lack of knowledge and for any silly questions!

@SAMGARTNER
Copy link

SAMGARTNER commented Dec 22, 2024

After installing the latest 3.x version of SDL on Raspberry Pi OS I'm getting:

grahambrown@pi5:~ $ DL_JOYSTICK_HIDAPI_PS3=1 sdl2-jstest --list
Found 1 joystick(s)

Joystick Name:     'Sony PLAYSTATION(R)3 Controller'
Joystick GUID:     0300afd34c0500006802000011810000
Joystick Number:    0
Number of Axes:     6
Number of Buttons: 17
Number of Hats:     0
Number of Balls:    0
GameControllerConfig:
  Name:    'PS3 Controller'
  Mapping: '0300afd34c0500006802000011810000,PS3 Controller,a:b0,b:b1,back:b8,dpdown:b14,dpleft:b15,dpright:b16,dpup:b13,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b2,platform:Linux,'

It would be awesome to have full support for analogue / pressure sensitive buttons. I came here because I have been testing GTA Vice City on the Pi 5 and this was the first thing I noticed being missing. I don't know if this is an issue with the port, or if this is a system wide issue so I thought I'd chime in here ;)

It's not as simple as installing SDL3, on Windows you don't need SDL for that, you have to use a driver such as dshidmini and the GInput mod that works specifically for Windows (to support analog buttons), on Linux and other platforms there is not GInput equivalent. The only two available paths are either to develop an SDL3 compatible GInput equivalent or for Lutris and Proton (steam) to provide full Xinput compatibility layer. The good news is that both PCSX2 and RPCX3 are both moving to SDL3 thanks to it's analog button support, so there is already open source code for that.

PD: also keep in mind that SDL2-JTEST might have been compiled with SDL2 I have been checking a different fork and it has no support for SDL3

@mirh
Copy link

mirh commented Dec 23, 2024

I'm fairly sure that HIDAPI should work even through wine. The problem if any is that the format that is linux native isn't the one used by the windows drivers (because the DS3 descriptors are broken and everywhere need to be overridden to get anything).
Something that could probably be handled (if any standard existed at all for two dozens analog axes), but regardless that's not even what GInput uses.
GInput which in turn definitively doesn't come with reVC, and that even in the best scenario still couldn't work with an ARM build.

@SAMGARTNER
Copy link

SAMGARTNER commented Dec 23, 2024

I think if I'm not mistaken that @nefarius 🙇‍♂️created a custom XInput.dll to bridge Ginput and DSHidMini so maybe there is a third path for this.

Maybe this is not the right place to ask this but, what would be the approximate bounty for a freelancer to implement this feature?

@vaccinemedia
Copy link

vaccinemedia commented Dec 23, 2024

Of course! Apologies for any confusion here. My I totally forgot about the 'GinputVC.asi' and 'GinputVC.ini' files that are needed (see here for more info https://gtaforums.com/topic/562765-ginput/) for force feedback buttons to become active on the Windows version of Vice City.

Just for clarification I'm using a Pi5 running Raspberry Pi OS and have installed PiKISS which has a native port of the Vice City (and GTA 3 too) engine where you copy the Windows game files over to it to run the game. I forgot about the required hack / mod files as it's about 4 years since I got it working on Windows 10 and assumed it "just worked" last time and that the tricky part I had was getting the joypad to work on Windows in general with pressure sensitive buttons.

When I saw that the buttons were acting in a digital manner though I installed jstest-gtk and saw 6 axes and all the buttons were showing as buttons. So I began searching for a solution. I found this post here: https://www.reddit.com/r/linux_gaming/comments/zq5byy/is_there_support_for_the_duel_shock_2_3_analog/

Which links to here: https://codeberg.org/fabiscafe/game-devices-udev - but when this didn't work I stumbled upon this issue. The issue I'm having it system wide i.e. I was expecting to see all the axes present in jstest-gtk. I'm away from my pi for the next day but is all that I need to do is run "SDL_JOYSTICK_HIDAPI_PS3=1" from the command line before running jstest-gtk ?

As for GTA Vice City I'll add to my issue here: jmcerrejon/PiKISS#228

@nefarius
Copy link

I think if I'm not mistaken that @nefarius 🙇‍♂️created a custom XInput.dll to bridge Ginput and DSHidMini so maybe there is a third path for this.

Works perfectly well https://docs.nefarius.at/projects/DsHidMini/v2/SCP-XInput-Bridge/

@SAMGARTNER
Copy link

Just for clarification I'm using a Pi5 running Raspberry Pi OS and have installed PiKISS which has a native port of the Vice City (and GTA 3 too) engine where you copy the Windows game files over to it to run the game.
As for GTA Vice City I'll add to my issue here: jmcerrejon/PiKISS#228

How did they manage to port the engine to PiKISS? I mean I know there are reverse engineering efforts but I didn't know they were complete

@vaccinemedia
Copy link

I'm assuming it's from here: https://github.com/halpz/re3 - on the PiKISS install scripts though it's downloading a pre-built binary but the folder names in the script make it look like it's from here.

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