SDL_HapticClose and SDL_HapticDestroyEffect returns int

This commit is contained in:
Sylvain 2023-02-09 10:00:31 +01:00
parent 2530d1b3df
commit 26d7381179
No known key found for this signature in database
GPG key ID: 5F87E02E5BC0939E
3 changed files with 22 additions and 13 deletions

View file

@ -337,8 +337,8 @@ typedef struct SDL_Haptic SDL_Haptic;
#define SDL_HAPTIC_SPHERICAL 2
/**
* \brief Use this value to play an effect on the steering wheel axis. This
* provides better compatibility across platforms and devices as SDL will guess
* \brief Use this value to play an effect on the steering wheel axis. This
* provides better compatibility across platforms and devices as SDL will guess
* the correct axis.
* \sa SDL_HapticDirection
*/
@ -970,12 +970,14 @@ extern DECLSPEC SDL_Haptic *SDLCALL SDL_HapticOpenFromJoystick(SDL_Joystick *
* Close a haptic device previously opened with SDL_HapticOpen().
*
* \param haptic the SDL_Haptic device to close
* \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_HapticOpen
*/
extern DECLSPEC void SDLCALL SDL_HapticClose(SDL_Haptic * haptic);
extern DECLSPEC int SDLCALL SDL_HapticClose(SDL_Haptic * haptic);
/**
* Get the number of effects a haptic device can store.
@ -1154,12 +1156,14 @@ extern DECLSPEC int SDLCALL SDL_HapticStopEffect(SDL_Haptic * haptic,
*
* \param haptic the SDL_Haptic device to destroy the effect on
* \param effect the ID of the haptic effect to destroy
* \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_HapticNewEffect
*/
extern DECLSPEC void SDLCALL SDL_HapticDestroyEffect(SDL_Haptic * haptic,
extern DECLSPEC int SDLCALL SDL_HapticDestroyEffect(SDL_Haptic * haptic,
int effect);
/**

View file

@ -460,8 +460,8 @@ SDL_DYNAPI_PROC(const char*,SDL_GetWindowTitle,(SDL_Window *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_GetWindowWMInfo,(SDL_Window *a, SDL_SysWMinfo *b, Uint32 c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_YUV_CONVERSION_MODE,SDL_GetYUVConversionMode,(void),(),return)
SDL_DYNAPI_PROC(SDL_YUV_CONVERSION_MODE,SDL_GetYUVConversionModeForResolution,(int a, int b),(a,b),return)
SDL_DYNAPI_PROC(void,SDL_HapticClose,(SDL_Haptic *a),(a),)
SDL_DYNAPI_PROC(void,SDL_HapticDestroyEffect,(SDL_Haptic *a, int b),(a,b),)
SDL_DYNAPI_PROC(int,SDL_HapticClose,(SDL_Haptic *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_HapticDestroyEffect,(SDL_Haptic *a, int b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_HapticEffectSupported,(SDL_Haptic *a, SDL_HapticEffect *b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_HapticGetEffectStatus,(SDL_Haptic *a, int b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_HapticIndex,(SDL_Haptic *a),(a),return)

View file

@ -330,7 +330,7 @@ SDL_HapticOpenFromJoystick(SDL_Joystick *joystick)
/*
* Closes a SDL_Haptic device.
*/
void SDL_HapticClose(SDL_Haptic *haptic)
int SDL_HapticClose(SDL_Haptic *haptic)
{
int i;
SDL_Haptic *hapticlist;
@ -338,12 +338,12 @@ void SDL_HapticClose(SDL_Haptic *haptic)
/* Must be valid */
if (!ValidHaptic(haptic)) {
return;
return SDL_InvalidParamError("haptic");
}
/* Check if it's still in use */
if (--haptic->ref_count > 0) {
return;
return 0; /* nothing to do */
}
/* Close it, properly removing effects if needed */
@ -374,6 +374,7 @@ void SDL_HapticClose(SDL_Haptic *haptic)
/* Free */
SDL_free(haptic);
return 0;
}
/*
@ -562,18 +563,22 @@ int SDL_HapticStopEffect(SDL_Haptic *haptic, int effect)
/*
* Gets rid of a haptic effect.
*/
void SDL_HapticDestroyEffect(SDL_Haptic *haptic, int effect)
int SDL_HapticDestroyEffect(SDL_Haptic *haptic, int effect)
{
if (!ValidHaptic(haptic) || !ValidEffect(haptic, effect)) {
return;
if (!ValidHaptic(haptic)) {
return SDL_InvalidParamError("haptic");
}
if (!ValidEffect(haptic, effect)) {
return SDL_InvalidParamError("effect");
}
/* Not allocated */
if (haptic->effects[effect].hweffect == NULL) {
return;
return 0; /* nothing to do */
}
SDL_SYS_HapticDestroyEffect(haptic, &haptic->effects[effect]);
return 0;
}
/*