Skip to content

Commit

Permalink
Only allocate a joystick instance ID once we know it's a joystick.
Browse files Browse the repository at this point in the history
This fixes compatibility with code that assumes 0 based joystick instance IDs.
  • Loading branch information
slouken committed Oct 7, 2013
1 parent 11c45c4 commit cca0942
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/joystick/darwin/SDL_sysjoystick.c
Expand Up @@ -589,7 +589,6 @@ HIDBuildDevice(io_object_t hidDevice)
if (kIOReturnSuccess == result) {
HIDGetDeviceInfo(hidDevice, hidProperties, pDevice); /* hidDevice used to find parents in registry tree */
HIDGetCollectionElements(hidProperties, pDevice);
pDevice->instance_id = ++s_joystick_instance_id;
} else {
DisposePtr((Ptr) pDevice);
pDevice = NULL;
Expand Down Expand Up @@ -678,6 +677,9 @@ AddDeviceHelper( io_object_t ioHIDDeviceObject )
return 0;
}

/* Allocate an instance ID for this device */
device->instance_id = ++s_joystick_instance_id;

/* We have to do some storage of the io_service_t for
* SDL_HapticOpenFromJoystick */
if (FFIsForceFeedback(ioHIDDeviceObject) == FF_OK) {
Expand Down

0 comments on commit cca0942

Please sign in to comment.