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

Add support for the PS5 DualSense controller #5257

Merged
merged 9 commits into from
Oct 30, 2023

Conversation

maxolasersquad
Copy link
Contributor

This adds support for the PS5 DualSense controller.

@maxolasersquad maxolasersquad requested a review from a team as a code owner April 7, 2023 18:41
@ThadHouse
Copy link
Member

Does this add any functionality or changed button mappings compared to the PS4Controller class? If not I’d probably rather just rename PS4Controller to PSController

@maxolasersquad
Copy link
Contributor Author

Yes, if you look at the two structs, the mapping is different.

PS5:

  struct Button {
    static constexpr int kSquare = 3;
    static constexpr int kCross = 1;
    static constexpr int kCircle = 2;
    static constexpr int kTriangle = 4;
    static constexpr int kL1 = 5;
    static constexpr int kR1 = 6;
    static constexpr int kL2 = 7;
    static constexpr int kR2 = 8;
    static constexpr int kCreate = 9;
    static constexpr int kOptions = 10;
    static constexpr int kL3 = 12;
    static constexpr int kR3 = 13;
    static constexpr int kPS = 11;
    static constexpr int kTouchpad = 14;
  };

  struct Axis {
    static constexpr int kLeftX = 0;
    static constexpr int kLeftY = 1;
    static constexpr int kRightX = 3;
    static constexpr int kRightY = 4;
    static constexpr int kL2 = 2;
    static constexpr int kR2 = 5;
  };

PS4:

  struct Button {
    static constexpr int kSquare = 1;
    static constexpr int kCross = 2;
    static constexpr int kCircle = 3;
    static constexpr int kTriangle = 4;
    static constexpr int kL1 = 5;
    static constexpr int kR1 = 6;
    static constexpr int kL2 = 7;
    static constexpr int kR2 = 8;
    static constexpr int kShare = 9;
    static constexpr int kOptions = 10;
    static constexpr int kL3 = 11;
    static constexpr int kR3 = 12;
    static constexpr int kPS = 13;
    static constexpr int kTouchpad = 14;
  };

  struct Axis {
    static constexpr int kLeftX = 0;
    static constexpr int kLeftY = 1;
    static constexpr int kRightX = 2;
    static constexpr int kRightY = 5;
    static constexpr int kL2 = 3;
    static constexpr int kR2 = 4;
  };

@maxolasersquad
Copy link
Contributor Author

maxolasersquad commented Apr 7, 2023

There's another trivial change. The share button is now called create on the DualSense.

@Starlight220
Copy link
Member

Are there more changes planned here, or is this ready for review?

@maxolasersquad
Copy link
Contributor Author

Are there more changes planned here, or is this ready for review?

Yes

@rzblue
Copy link
Member

rzblue commented Jun 25, 2023

Yes....to what?

@auscompgeek
Copy link
Member

This does still need a Java implementation.

@maxolasersquad
Copy link
Contributor Author

Yes....to what?

Sorry. Ready for review.

@rzblue
Copy link
Member

rzblue commented Jun 25, 2023

This should also add a CommandPS5Controller

@maxolasersquad
Copy link
Contributor Author

This should also add a CommandPS5Controller

I have added the CommandPS5Controller, Java classes, tests, etc. I believe I have added everything. Let me know if something appears to be missing.

@calcmogul
Copy link
Member

/format

calcmogul
calcmogul previously approved these changes Oct 18, 2023
@Starlight220
Copy link
Member

@PeterJohnson the resource ID needs to be confirmed with NI, right?
To prevent issues like we had this year with the PS4 resource ID.

@PeterJohnson
Copy link
Member

Correct, and PS4 needs to be changed as well (but that should be a separate PR).

@PeterJohnson PeterJohnson merged commit 9536a31 into wpilibsuite:main Oct 30, 2023
24 checks passed
@ThadHouse
Copy link
Member

ThadHouse commented Dec 15, 2023

@maxolasersquad Were you using an official stock PS5 controller for this? The mappings I'm seeing are wrong, and on my controller actually map what the PS4 controller does.

Also, were you testing with a DS, or with simulation?

@maxolasersquad
Copy link
Contributor Author

@maxolasersquad Were you using an official stock PS5 controller for this? The mappings I'm seeing are wrong, and on my controller actually map what the PS4 controller does.

Also, were you testing with a DS, or with simulation?

I was using a PlayStation DualSense. We just got a new laptop, and last weekend got it all setup to test our non-competition bot, but we were testing with the XBox input (we have an XBox and PS5 controller). With the upcoming holidays, it may be a couple weeks before I can test again, but will make sure to do that.

@ThadHouse
Copy link
Member

Testing with the XBox input makes it sound like you were using simulation. The xbox checkbox should only be used for xbox controllers, and not for non xbox controllers. And for mappings, the ones we need are with the official DS. We don't guarantee simulation matches the official DS, especially on non windows platforms.

@maxolasersquad
Copy link
Contributor Author

Testing with the XBox input makes it sound like you were using simulation. The xbox checkbox should only be used for xbox controllers, and not for non xbox controllers. And for mappings, the ones we need are with the official DS. We don't guarantee simulation matches the official DS, especially on non windows platforms.

What I meant was that we were testing our new laptop on our non-competition bot with the XBox mapping, meaning we were not using the PS5 controller and mappings. I will test with the PS5 controller and mappings the next time we meetup again.

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

Successfully merging this pull request may close these issues.

7 participants