mirror of
https://github.com/felis/USB_Host_Shield_2.0.git
synced 2024-03-22 11:31:26 +01:00
Merge pull request #281 from felis/PS4Slim
Fixed bug for PS4 Slim controller via USB
This commit is contained in:
commit
343ae2c1d1
2 changed files with 9 additions and 11 deletions
9
PS4USB.h
9
PS4USB.h
|
@ -23,6 +23,7 @@
|
||||||
|
|
||||||
#define PS4_VID 0x054C // Sony Corporation
|
#define PS4_VID 0x054C // Sony Corporation
|
||||||
#define PS4_PID 0x05C4 // PS4 Controller
|
#define PS4_PID 0x05C4 // PS4 Controller
|
||||||
|
#define PS4_PID_SLIM 0x09CC // PS4 Slim Controller
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class implements support for the PS4 controller via USB.
|
* This class implements support for the PS4 controller via USB.
|
||||||
|
@ -44,7 +45,7 @@ public:
|
||||||
* @return Returns true if it is connected.
|
* @return Returns true if it is connected.
|
||||||
*/
|
*/
|
||||||
bool connected() {
|
bool connected() {
|
||||||
return HIDUniversal::isReady() && HIDUniversal::VID == PS4_VID && HIDUniversal::PID == PS4_PID;
|
return HIDUniversal::isReady() && HIDUniversal::VID == PS4_VID && (HIDUniversal::PID == PS4_PID || HIDUniversal::PID == PS4_PID_SLIM);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -65,7 +66,7 @@ protected:
|
||||||
* @param buf Pointer to the data buffer.
|
* @param buf Pointer to the data buffer.
|
||||||
*/
|
*/
|
||||||
virtual void ParseHIDData(USBHID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf) {
|
virtual void ParseHIDData(USBHID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf) {
|
||||||
if (HIDUniversal::VID == PS4_VID && HIDUniversal::PID == PS4_PID)
|
if (HIDUniversal::VID == PS4_VID && (HIDUniversal::PID == PS4_PID || HIDUniversal::PID == PS4_PID_SLIM))
|
||||||
PS4Parser::Parse(len, buf);
|
PS4Parser::Parse(len, buf);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -75,7 +76,7 @@ protected:
|
||||||
* This is useful for instance if you want to set the LEDs in a specific way.
|
* This is useful for instance if you want to set the LEDs in a specific way.
|
||||||
*/
|
*/
|
||||||
virtual uint8_t OnInitSuccessful() {
|
virtual uint8_t OnInitSuccessful() {
|
||||||
if (HIDUniversal::VID == PS4_VID && HIDUniversal::PID == PS4_PID) {
|
if (HIDUniversal::VID == PS4_VID && (HIDUniversal::PID == PS4_PID || HIDUniversal::PID == PS4_PID_SLIM)) {
|
||||||
PS4Parser::Reset();
|
PS4Parser::Reset();
|
||||||
if (pFuncOnInit)
|
if (pFuncOnInit)
|
||||||
pFuncOnInit(); // Call the user function
|
pFuncOnInit(); // Call the user function
|
||||||
|
@ -120,7 +121,7 @@ protected:
|
||||||
* @return Returns true if the device's VID and PID matches this driver.
|
* @return Returns true if the device's VID and PID matches this driver.
|
||||||
*/
|
*/
|
||||||
virtual bool VIDPIDOK(uint16_t vid, uint16_t pid) {
|
virtual bool VIDPIDOK(uint16_t vid, uint16_t pid) {
|
||||||
return (vid == PS4_VID && pid == PS4_PID);
|
return (vid == PS4_VID && (pid == PS4_PID || HIDUniversal::PID == PS4_PID_SLIM));
|
||||||
};
|
};
|
||||||
/**@}*/
|
/**@}*/
|
||||||
|
|
||||||
|
|
|
@ -119,16 +119,13 @@ bool ConfigDescParser<CLASS_ID, SUBCLASS_ID, PROTOCOL_ID, MASK>::ParseDescriptor
|
||||||
switch(dscrType) {
|
switch(dscrType) {
|
||||||
case USB_DESCRIPTOR_INTERFACE:
|
case USB_DESCRIPTOR_INTERFACE:
|
||||||
isGoodInterface = false;
|
isGoodInterface = false;
|
||||||
|
break;
|
||||||
case USB_DESCRIPTOR_CONFIGURATION:
|
case USB_DESCRIPTOR_CONFIGURATION:
|
||||||
theBuffer.valueSize = sizeof (USB_CONFIGURATION_DESCRIPTOR) - 2;
|
|
||||||
break;
|
|
||||||
case USB_DESCRIPTOR_ENDPOINT:
|
case USB_DESCRIPTOR_ENDPOINT:
|
||||||
theBuffer.valueSize = sizeof (USB_ENDPOINT_DESCRIPTOR) - 2;
|
|
||||||
break;
|
|
||||||
case HID_DESCRIPTOR_HID:
|
case HID_DESCRIPTOR_HID:
|
||||||
theBuffer.valueSize = dscrLen - 2;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
theBuffer.valueSize = dscrLen - 2;
|
||||||
valParser.Initialize(&theBuffer);
|
valParser.Initialize(&theBuffer);
|
||||||
stateParseDescr = 4;
|
stateParseDescr = 4;
|
||||||
case 4:
|
case 4:
|
||||||
|
|
Loading…
Reference in a new issue