mirror of
https://github.com/libretro/Play-.git
synced 2024-11-27 18:50:28 +00:00
Qt: OSX: refactoring to support many custom HID configs
This commit is contained in:
parent
434ad840b7
commit
152b61992b
@ -114,7 +114,7 @@ void CGamePadDeviceListener::InputValueCallbackStub(void* context, IOReturn resu
|
||||
(*device_info->OnInputEventCallBack)(device_info->device_id, usage, value, btn_type);
|
||||
}
|
||||
|
||||
void CGamePadDeviceListener::InputReportCallbackStub(void *context, IOReturn result, void *sender, IOHIDReportType type, uint32_t reportID, uint8_t *report, CFIndex reportLength)
|
||||
void CGamePadDeviceListener::InputReportCallbackStub_DS4(void *context, IOReturn result, void *sender, IOHIDReportType type, uint32_t reportID, uint8_t *report, CFIndex reportLength)
|
||||
{
|
||||
auto device_info = reinterpret_cast<DeviceInfo*>(context);
|
||||
int offset = report[0] == 1 ? 1 : 3;
|
||||
@ -219,16 +219,16 @@ void CGamePadDeviceListener::onDeviceMatched(void* context, IOReturn result, voi
|
||||
}
|
||||
}
|
||||
|
||||
//TODO ID devices that need custom handling
|
||||
DeviceInfo* device_info = static_cast<DeviceInfo*>(malloc(sizeof(struct DeviceInfo)));
|
||||
device_info->device_id = CGamePadUtils::GetDeviceID(device);
|
||||
device_info->OnInputEventCallBack = &GPDL->OnInputEventCallBack;
|
||||
device_info->m_filter = &GPDL->m_filter;
|
||||
if(true)
|
||||
auto InputReportCallbackStub = GPDL->GetCallback(GPDL, device);
|
||||
if(InputReportCallbackStub)
|
||||
{
|
||||
uint32_t max_input_report_size = CGamePadUtils::GetIntProperty(device, CFSTR(kIOHIDMaxInputReportSizeKey));
|
||||
uint8_t* report_buffer = static_cast<uint8_t*>(calloc(max_input_report_size, sizeof(uint8_t)));
|
||||
IOHIDDeviceRegisterInputReportCallback(device, report_buffer, max_input_report_size, GPDL->InputReportCallbackStub, device_info);
|
||||
IOHIDDeviceRegisterInputReportCallback(device, report_buffer, max_input_report_size, InputReportCallbackStub, device_info);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -236,6 +236,20 @@ void CGamePadDeviceListener::onDeviceMatched(void* context, IOReturn result, voi
|
||||
}
|
||||
}
|
||||
|
||||
IOHIDReportCallback CGamePadDeviceListener::GetCallback(CGamePadDeviceListener* GPDL, IOHIDDeviceRef device)
|
||||
{
|
||||
auto vid = CGamePadUtils::GetIntProperty(device, CFSTR(kIOHIDVendorIDKey));
|
||||
auto pid = CGamePadUtils::GetIntProperty(device, CFSTR(kIOHIDProductIDKey));
|
||||
if(vid == 0x54C)
|
||||
{
|
||||
if(pid == 0x9CC || pid == 0x5C4)
|
||||
{
|
||||
return GPDL->InputReportCallbackStub_DS4;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void CGamePadDeviceListener::InputDeviceListenerThread()
|
||||
{
|
||||
m_hidManager = IOHIDManagerCreate(kCFAllocatorDefault, 0);
|
||||
|
@ -87,5 +87,6 @@ private:
|
||||
CFMutableDictionaryRef CreateDeviceMatchingDictionary(uint32 usagePage, uint32 usage);
|
||||
void static InputValueCallbackStub(void* context, IOReturn result, void* sender, IOHIDValueRef valueRef);
|
||||
void static onDeviceMatched(void* context, IOReturn result, void* sender, IOHIDDeviceRef device);
|
||||
void static InputReportCallbackStub(void* context, IOReturn result, void* sender, IOHIDReportType type, uint32_t reportID, uint8_t* report, CFIndex reportLength);
|
||||
void static InputReportCallbackStub_DS4(void* context, IOReturn result, void* sender, IOHIDReportType type, uint32_t reportID, uint8_t* report, CFIndex reportLength);
|
||||
IOHIDReportCallback GetCallback(CGamePadDeviceListener* GPDL, IOHIDDeviceRef device);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user