Skip to content

Commit

Permalink
Add Sixaxis init for Monterey
Browse files Browse the repository at this point in the history
  • Loading branch information
nastys authored and Megamouse committed May 23, 2023
1 parent 9c712bb commit 8b43a97
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
8 changes: 8 additions & 0 deletions hidapi/hidapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,14 @@ extern "C" {
*/
int HID_API_EXPORT HID_API_CALL hid_write_control(hid_device *device, const unsigned char *data, size_t length);

#ifdef __APPLE__
/** RPCS3 EDIT: Initializes a USB Sixaxis/DualShock 3 controller,
* which requires report_id to be separate from the data packet.
* Required on macOS Monterey.
*/
int HID_API_EXPORT hid_init_sixaxis_usb(hid_device *dev);
#endif

#ifdef __cplusplus
}
#endif
Expand Down
13 changes: 13 additions & 0 deletions mac/hid.c
Original file line number Diff line number Diff line change
Expand Up @@ -1555,3 +1555,16 @@ HID_API_EXPORT const wchar_t * HID_API_CALL hid_error(hid_device *dev)
return L"Success";
return last_global_error_str;
}

int HID_API_EXPORT hid_init_sixaxis_usb(hid_device *dev)
{
const char data[] = { 0x42, 0x0C, 0x00, 0x00 };
size_t length = sizeof(data);
const unsigned char report_id = 0xF4;

if (IOHIDDeviceSetReport(dev->device_handle, kIOHIDReportTypeFeature, report_id, data, length) == kIOReturnSuccess) {
return length;
}

return -1;
}

0 comments on commit 8b43a97

Please sign in to comment.