-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Qt: Native DualShock 3 support in Windows using official Sony driver #9138
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for submitting a contribution to PCSX2
As this is your first pull request, please be aware of the contributing guidelines.
Additionally, as per recent changes in GitHub Actions, your pull request will need to be approved by a maintainer before GitHub Actions can run against it. You can find more information about this change here.
Please be patient until this happens. In the meantime if you'd like to confirm the builds are passing, you have the option of opening a PR on your own fork, just make sure your fork's master branch is up to date!
Bit of a shame this can't be added to SDL instead, to avoid duplication. AFAIK DS3 with pressure is supported under SDL on Linux. |
Is it a bug in sdl? |
I assume the standard Linux DS3 driver supports rumble but not pressure? Any reason rumble cant be added to SDL's HIDAPI driver? Seems very odd. |
I believe there is a limitation with the official Sony driver where you can't initialize HID Reports and this is why SDL do not have HID support for DualShock 3. See libsdl-org/SDL@1fc7f68 |
I'm sorry, what are we even talking about here? So.. uhm, whatever you are eventually using in your "vanilla SDL" scenario seems just directinput or xinput. |
Nobody is saying it's out of the box, there is an official Sony driver for DS3. https://www.pcgamingwiki.com/wiki/Controller:DualShock_3#Wired_connection_-_official_drivers |
Yes, I know.. I probably wrote a part of that page..
It's just not clear what OP is thinking here. All this premised, good that the old wx code was ported here.. but as stenzek noted it would be even nicer if this could be addressed upstream. |
The point I was making is that if you use a DS3 controller with Qt PCSX and select SDL input, you don't get rumble support. With my PR, which uses Windows HID API, if you have the Sony sixaxis.sys driver installed then rumble is supported. Edited to make it clearer. |
Yes, but it just wasn't clear what kind of driver you were using with SDL. So.. if nobody is adding this to SDL, I suppose this PR is the second best thing. |
Great job David! I was waiting for this since Qt has become official PCSX2 version. Finally I will be able to leave old wxWidgets build. I'm using official Sony's driver with RPCS3, DS4Windows and reWASD, so changing driver to unofficial one was not comfortable for me. This one I will be able to use with official DS3, virtual DS3 by reWASD and with adapter DS2 to DS3 and make my pressure-sensitive controllers work again with the newest version of PCSX2. I hoped that SDL will add this feature, but they skipped Windows version, so official driver is the most comfortable way to play with this controller. Thank you very much! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CMakeLists also needs to be updated.
std::array<bool, 17> physicalButtonState = {}; | ||
std::array<bool, 17> lastPhysicalButtonState = {}; | ||
|
||
//If we wever want to support pressure sensitive buttons |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems a bit silly to go to all the effort of adding a DS3-specific backend but not support pressure-sensitive buttons? Since that would be the main reason for using a DS3.
May as well just use DInput in that case.
|
||
bool active = false; | ||
|
||
u8 SmallMotorOn = 0; // 0 or 1 (off/on) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent variable naming. Try to use snake_case
for all fields/local variables.
static constexpr u16 DS3_VID = 0x054c; // Sony Corp. | ||
static constexpr u16 DS3_PID = 0x0268; // PlayStation 3 Controller | ||
|
||
static constexpr const char* DualShock3AxisNames[] = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All of these declarations should be in the .cpp file, not the .h.
|
||
namespace WindowsHIDUtility | ||
{ | ||
std::vector<HidDeviceInfo> FindHids(u16 vid, u16 pid) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code isn't used anywhere else, and is probably unlikely to be, so it's best to make it local to the DS3 input source, rather than adding additional files.
if (GetLastError() != ERROR_INSUFFICIENT_BUFFER || !size) | ||
continue; | ||
|
||
SP_DEVICE_INTERFACE_DETAIL_DATA_W* devInterfaceDetails = (SP_DEVICE_INTERFACE_DETAIL_DATA_W*)malloc(size); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use a unique_ptr
, not C malloc/free. You're leaking memory with the continues otherwise.
{ | ||
HIDD_ATTRIBUTES attributes; | ||
attributes.Size = sizeof(attributes); | ||
if (HidD_GetAttributes(hfile, &attributes)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better to use continue here rather than a staircase of ifs.
{ | ||
std::vector<HidDeviceInfo> FindHids(u16 vid, u16 pid) | ||
{ | ||
std::vector<HidDeviceInfo> foundDevs; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See variable naming note above.
|
||
public: | ||
bool Activate(); | ||
void Deactivate(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A destructor is better than an explicit "Deactivate()" call.
As I noted in the review above, this doesn't seem to actually report pressure sensitivity, so I'm questioning what the point is in its current state. |
As noted above, adding rumble is already a pretty important addition. And if you are still going to have a subpar experience, than at this point you could as well just recommend dshidmini isn't it? |
Thanks for the feedback. I'll look into implementing pressure-sensitive buttons. |
Sorry to bump this up, but I've been recently catching some new DS3 controllers to test this out in the future but, are you managing to finish the PR? |
With all that I don't understand if it's possible to have the sensitive buttons with pcsx2 qt and a dualshock 3 without the wxWidgets driver or dshidmini? |
It is not possible to have DS3 working at all, without the ~official sony driver or any of the nefarius/SCP ones. EDIT: on the other hand, I wonder how much this makes sense now that SDL merged the hidapi support for windows? |
Without driver it works but is recognized as virtual DS3. So the only solution remains dshidmini? The problem is that the software has not been updated for more than 3 years. I installed the DS3 driver and pcsx2 recognizes the official controller but still no pressure sensitive button. I managed to have sensitive pressures but with the old version of pcsx2 with wxwidget which no longer exists on qt. |
Without driver I think the controller should still be "recognized", but nonetheless no input is possible. Then, it's true that dshidmini has seen its last official release 3 years ago, but it's not dead. It's just that is has been entirely rewritten in the time since (and I believe a new beta should be released quite soon-ish). |
How to do ? because before I went through dshidmini + setting pcsx2 with wxwidget but it no longer exists with pcsx2 qt. |
@Julinkk please stop spamming the pr with comments , if you need help join the discord or forum |
Closing due to the stale state (> 1 year). Feel free to let us know when you've continued working on it and we can open it. |
For the records, whenever SDL 3(?) is released/integrated, the code should already be trivially compatible. |
Description of Changes
Adds native DualShock 3 support in Windows to Qt PCSX2 using official Sony driver. An advantage this PR has over SDL is that rumble is supported.
I have created a new
InputSource
for DualShock 3 analogous to SDL/DirectInput/XInput.I have implemented Automatic Mapping for convenience.
Credit to @rewasdadmin for implementing DualShock 3 native support in the old wxWidgets PCSX2 which I ported (#7099).
Rationale behind Changes
DualShock 3 rumble support is not provided by SDL.
Suggested Testing Steps
Test with multiple DualShock 3 controllers on a range of games. I have tested with the two DualShock 3 controllers I have and all seems well.