From ecf1b62882c1b6ca1da445fa94ee8dae42cf5961 Mon Sep 17 00:00:00 2001 From: nastys <@a.a> Date: Sun, 23 Jan 2022 13:52:21 +0100 Subject: [PATCH] Add Sixaxis init for Monterey --- hidapi/hidapi.h | 8 ++++++++ mac/hid.c | 13 +++++++++++++ 2 files changed, 21 insertions(+) diff --git a/hidapi/hidapi.h b/hidapi/hidapi.h index 9074f35..0231ba1 100644 --- a/hidapi/hidapi.h +++ b/hidapi/hidapi.h @@ -600,6 +600,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 diff --git a/mac/hid.c b/mac/hid.c index 2391742..18c2b2d 100644 --- a/mac/hid.c +++ b/mac/hid.c @@ -1448,3 +1448,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; +}