Fixed Mac OS X build

This commit is contained in:
Sam Lantinga 2018-08-15 19:53:24 -07:00
parent ec74c318b9
commit dfbd7f65a9
1 changed files with 24 additions and 19 deletions

View File

@ -171,10 +171,11 @@ static LRESULT CALLBACK ControllerWndProc(HWND hwnd, UINT message, WPARAM wParam
#if defined(__MACOSX__)
static void CallbackIOServiceFUNC(void *context, io_iterator_t portIterator)
static void CallbackIOServiceFunc(void *context, io_iterator_t portIterator)
{
/* Must drain the iterator, or we won't receive new notifications */
while ((io_object_t entry = IOIteratorNext(portIterator)) != NULL) {
io_object_t entry;
while ((entry = IOIteratorNext(portIterator)) != 0) {
IOObjectRelease(entry);
*(SDL_bool*)context = SDL_TRUE;
}
@ -225,9 +226,10 @@ HIDAPI_InitializeDiscovery()
/* Note: IOServiceAddMatchingNotification consumes the reference to matchingDict */
io_iterator_t portIterator = 0;
io_object_t entry;
if (IOServiceAddMatchingNotification(SDL_HIDAPI_discovery.m_notificationPort, kIOMatchedNotification, matchingDict, CallbackIOServiceFunc, &SDL_HIDAPI_discovery.m_bHaveDevicesChanged, &portIterator) == 0) {
/* Must drain the existing iterator, or we won't receive new notifications */
while (io_object_t entry = IOIteratorNext(portIterator)) {
while ((entry = IOIteratorNext(portIterator)) != 0) {
IOObjectRelease(entry);
}
} else {
@ -240,9 +242,10 @@ HIDAPI_InitializeDiscovery()
/* Note: IOServiceAddMatchingNotification consumes the reference to matchingDict */
io_iterator_t portIterator = 0;
io_object_t entry;
if (IOServiceAddMatchingNotification(SDL_HIDAPI_discovery.m_notificationPort, kIOMatchedNotification, matchingDict, CallbackIOServiceFunc, &SDL_HIDAPI_discovery.m_bHaveDevicesChanged, &portIterator) == 0) {
/* Must drain the existing iterator, or we won't receive new notifications */
while (io_object_t entry = IOIteratorNext(portIterator)) {
while ((entry = IOIteratorNext(portIterator)) != 0) {
IOObjectRelease(entry);
}
} else {
@ -803,6 +806,8 @@ HIDAPI_JoystickQuit(void)
{
int i;
HIDAPI_ShutdownDiscovery();
while (SDL_HIDAPI_devices) {
HIDAPI_DelDevice(SDL_HIDAPI_devices, SDL_FALSE);
}