SDL_OpenHapticFromJoystick() returns a valid haptic object
This commit is contained in:
parent
c4550d906a
commit
1c0e2b7f97
1 changed files with 3 additions and 0 deletions
|
@ -131,6 +131,7 @@ SDL_Haptic *SDL_OpenHaptic(SDL_HapticID instance_id)
|
||||||
haptic->instance_id = instance_id;
|
haptic->instance_id = instance_id;
|
||||||
haptic->rumble_id = -1;
|
haptic->rumble_id = -1;
|
||||||
if (!SDL_SYS_HapticOpen(haptic)) {
|
if (!SDL_SYS_HapticOpen(haptic)) {
|
||||||
|
SDL_SetObjectValid(haptic, SDL_OBJECT_TYPE_HAPTIC, false);
|
||||||
SDL_free(haptic);
|
SDL_free(haptic);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -268,9 +269,11 @@ SDL_Haptic *SDL_OpenHapticFromJoystick(SDL_Joystick *joystick)
|
||||||
/* Initialize the haptic device
|
/* Initialize the haptic device
|
||||||
* This function should fill in the instance ID and name.
|
* This function should fill in the instance ID and name.
|
||||||
*/
|
*/
|
||||||
|
SDL_SetObjectValid(haptic, SDL_OBJECT_TYPE_HAPTIC, true);
|
||||||
haptic->rumble_id = -1;
|
haptic->rumble_id = -1;
|
||||||
if (!SDL_SYS_HapticOpenFromJoystick(haptic, joystick)) {
|
if (!SDL_SYS_HapticOpenFromJoystick(haptic, joystick)) {
|
||||||
SDL_SetError("Haptic: SDL_SYS_HapticOpenFromJoystick failed.");
|
SDL_SetError("Haptic: SDL_SYS_HapticOpenFromJoystick failed.");
|
||||||
|
SDL_SetObjectValid(haptic, SDL_OBJECT_TYPE_HAPTIC, false);
|
||||||
SDL_free(haptic);
|
SDL_free(haptic);
|
||||||
SDL_UnlockJoysticks();
|
SDL_UnlockJoysticks();
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue