Date: Wed, 25 Feb 2004 06:41:17 -0500
From: "Ryan C. Gordon" Subject: Re: MacOS X bugs... This isn't an ideal patch (trying to open a joystick that has previously been unplugged will report success, but it'll just never give any input, etc), but it handles the worst case of deadlock in the event subsystem. --HG-- extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40859
This commit is contained in:
parent
46397620bd
commit
005ace8382
1 changed files with 40 additions and 1 deletions
|
@ -92,6 +92,9 @@ struct joystick_hwdata
|
||||||
recElement* firstButton;
|
recElement* firstButton;
|
||||||
recElement* firstHat;
|
recElement* firstHat;
|
||||||
|
|
||||||
|
int removed;
|
||||||
|
int uncentered;
|
||||||
|
|
||||||
struct joystick_hwdata* pNext; // next device
|
struct joystick_hwdata* pNext; // next device
|
||||||
};
|
};
|
||||||
typedef struct joystick_hwdata recDevice;
|
typedef struct joystick_hwdata recDevice;
|
||||||
|
@ -161,6 +164,19 @@ SInt32 HIDScaledCalibratedValue (recDevice *pDevice, recElement *pElement, long
|
||||||
return ((value - pElement->minReport) * deviceScale / readScale) + min;
|
return ((value - pElement->minReport) * deviceScale / readScale) + min;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void HIDRemovalCallback(void * target,
|
||||||
|
IOReturn result,
|
||||||
|
void * refcon,
|
||||||
|
void * sender)
|
||||||
|
{
|
||||||
|
recDevice *device = (recDevice *) refcon;
|
||||||
|
device->removed = 1;
|
||||||
|
device->uncentered = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Create and open an interface to device, required prior to extracting values or building queues.
|
/* Create and open an interface to device, required prior to extracting values or building queues.
|
||||||
* Note: appliction now owns the device and must close and release it prior to exiting
|
* Note: appliction now owns the device and must close and release it prior to exiting
|
||||||
*/
|
*/
|
||||||
|
@ -193,6 +209,9 @@ IOReturn HIDCreateOpenDeviceInterface (io_object_t hidDevice, recDevice *pDevice
|
||||||
result = (*(pDevice->interface))->open (pDevice->interface, 0);
|
result = (*(pDevice->interface))->open (pDevice->interface, 0);
|
||||||
if (kIOReturnSuccess != result)
|
if (kIOReturnSuccess != result)
|
||||||
HIDReportErrorNum ("Failed to open pDevice->interface via open.", result);
|
HIDReportErrorNum ("Failed to open pDevice->interface via open.", result);
|
||||||
|
else
|
||||||
|
(*(pDevice->interface))->setRemovalCallback (pDevice->interface, HIDRemovalCallback, pDevice, pDevice);
|
||||||
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -723,6 +742,26 @@ void SDL_SYS_JoystickUpdate(SDL_Joystick *joystick)
|
||||||
SInt32 value;
|
SInt32 value;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
if (device->removed) /* device was unplugged; ignore it. */
|
||||||
|
{
|
||||||
|
if (device->uncentered)
|
||||||
|
{
|
||||||
|
device->uncentered = 0;
|
||||||
|
|
||||||
|
/* Tell the app that everything is centered/unpressed... */
|
||||||
|
for (i = 0; i < device->axes; i++)
|
||||||
|
SDL_PrivateJoystickAxis(joystick, i, 0);
|
||||||
|
|
||||||
|
for (i = 0; i < device->buttons; i++)
|
||||||
|
SDL_PrivateJoystickButton(joystick, i, 0);
|
||||||
|
|
||||||
|
for (i = 0; i < device->hats; i++)
|
||||||
|
SDL_PrivateJoystickHat(joystick, i, SDL_HAT_CENTERED);
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
element = device->firstAxis;
|
element = device->firstAxis;
|
||||||
i = 0;
|
i = 0;
|
||||||
while (element)
|
while (element)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue