Skip to content

Commit

Permalink
Add support for the PS5 Access Controller
Browse files Browse the repository at this point in the history
Tested on PS5 DualSense and Access controllers.

The change is the Access controller has a different PID.

felis#796
  • Loading branch information
esp32beans committed Dec 12, 2023
1 parent 59cc3d2 commit 433abf1
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions PS5USB.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

#define PS5_VID 0x054C // Sony Corporation
#define PS5_PID 0x0CE6 // PS5 Controller
#define PS5_PID_AC 0x0E5F // PS5 Access Controller

/**
* This class implements support for the PS5 controller via USB.
Expand All @@ -47,7 +48,7 @@ class PS5USB : public HIDUniversal, public PS5Parser {
* @return Returns true if it is connected.
*/
bool connected() {
return HIDUniversal::isReady() && HIDUniversal::VID == PS5_VID && HIDUniversal::PID == PS5_PID;
return HIDUniversal::isReady() && VIDPIDOK(HIDUniversal::VID, HIDUniversal::PID);
};

/**
Expand All @@ -68,7 +69,7 @@ class PS5USB : public HIDUniversal, public PS5Parser {
* @param buf Pointer to the data buffer.
*/
virtual void ParseHIDData(USBHID *hid __attribute__((unused)), bool is_rpt_id __attribute__((unused)), uint8_t len, uint8_t *buf) {
if (HIDUniversal::VID == PS5_VID && HIDUniversal::PID == PS5_PID)
if (VIDPIDOK(HIDUniversal::VID, HIDUniversal::PID))
PS5Parser::Parse(len, buf);
};

Expand All @@ -78,7 +79,7 @@ class PS5USB : public HIDUniversal, public PS5Parser {
* This is useful for instance if you want to set the LEDs in a specific way.
*/
virtual uint8_t OnInitSuccessful() {
if (HIDUniversal::VID == PS5_VID && HIDUniversal::PID == PS5_PID) {
if (VIDPIDOK(HIDUniversal::VID, HIDUniversal::PID)) {
PS5Parser::Reset();
if (pFuncOnInit)
pFuncOnInit(); // Call the user function
Expand Down Expand Up @@ -147,7 +148,7 @@ class PS5USB : public HIDUniversal, public PS5Parser {
* @return Returns true if the device's VID and PID matches this driver.
*/
virtual bool VIDPIDOK(uint16_t vid, uint16_t pid) {
return (vid == PS5_VID && pid == PS5_PID);
return (vid == PS5_VID && (pid == PS5_PID || pid == PS5_PID_AC));
};
/**@}*/

Expand Down

0 comments on commit 433abf1

Please sign in to comment.