mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-10-06 18:06:26 +00:00
Fixed bug 4910 - Missing joystick-driver type check in haptic
meyraud705 On Linux and MacOS, some haptic system functions access joystick->hw_data without checking the driver type.
This commit is contained in:
@@ -599,6 +599,9 @@ SDL_SYS_HapticMouse(void)
|
||||
int
|
||||
SDL_SYS_JoystickIsHaptic(SDL_Joystick * joystick)
|
||||
{
|
||||
if (joystick->driver != &SDL_DARWIN_JoystickDriver) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
if (joystick->hwdata->ffservice != 0) {
|
||||
return SDL_TRUE;
|
||||
}
|
||||
@@ -612,6 +615,9 @@ SDL_SYS_JoystickIsHaptic(SDL_Joystick * joystick)
|
||||
int
|
||||
SDL_SYS_JoystickSameHaptic(SDL_Haptic * haptic, SDL_Joystick * joystick)
|
||||
{
|
||||
if (joystick->driver != &SDL_DARWIN_JoystickDriver) {
|
||||
return 0;
|
||||
}
|
||||
if (IOObjectIsEqualTo((io_object_t) ((size_t)haptic->hwdata->device),
|
||||
joystick->hwdata->ffservice)) {
|
||||
return 1;
|
||||
@@ -628,7 +634,10 @@ SDL_SYS_HapticOpenFromJoystick(SDL_Haptic * haptic, SDL_Joystick * joystick)
|
||||
{
|
||||
int device_index = 0;
|
||||
SDL_hapticlist_item *item;
|
||||
|
||||
|
||||
if (joystick->driver != &SDL_DARWIN_JoystickDriver) {
|
||||
return -1;
|
||||
}
|
||||
for (item = SDL_hapticlist; item; item = item->next) {
|
||||
if (IOObjectIsEqualTo((io_object_t) item->dev,
|
||||
joystick->hwdata->ffservice)) {
|
||||
|
Reference in New Issue
Block a user