Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Added SDL_HapticNumEffectsPlaying().
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbens committed Jul 10, 2008
1 parent ace23db commit 7753d4c
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 0 deletions.
15 changes: 15 additions & 0 deletions include/SDL_haptic.h
Expand Up @@ -740,10 +740,25 @@ extern DECLSPEC void SDL_HapticClose(SDL_Haptic * haptic);
* \return The number of effects the haptic device can store or
* -1 on error.
*
* \sa SDL_HapticNumEffectsPlaying
* \sa SDL_HapticQuery
*/
extern DECLSPEC int SDL_HapticNumEffects(SDL_Haptic * haptic);

/**
* \fn int SDL_HapticNumEffectsPlaying(SDL_Haptic * haptic)
*
* \brief Returns the number of effects a haptic device can play at the same time.
*
* \param haptic The haptic device to query maximum playing effect.s
* \return The number of effects the haptic device can play at the same time
* or -1 on error.
*
* \sa SDL_HapticNumEffects
* \sa SDL_HapticQuery
*/
extern DECLSPEC int SDL_HapticNumEffectsPlaying(SDL_Haptic * haptic);

/**
* \fn unsigned int SDL_HapticQuery(SDL_Haptic * haptic)
*
Expand Down
15 changes: 15 additions & 0 deletions src/haptic/SDL_haptic.c
Expand Up @@ -356,6 +356,21 @@ SDL_HapticNumEffects(SDL_Haptic * haptic)
return haptic->neffects;
}


/*
* Returns the number of effects a haptic device can play.
*/
int
SDL_HapticNumEffectsPlaying(SDL_Haptic * haptic)
{
if (!ValidHaptic(&haptic)) {
return -1;
}

return haptic->nplaying;
}


/*
* Returns supported effects by the device.
*/
Expand Down
1 change: 1 addition & 0 deletions src/haptic/SDL_syshaptic.h
Expand Up @@ -47,6 +47,7 @@ struct _SDL_Haptic

struct haptic_effect *effects; /* Allocated effects */
int neffects; /* Maximum amount of effects */
int nplaying; /* Maximum amount of effects to play at the same time */
unsigned int supported; /* Supported effects */

struct haptic_hwdata *hwdata; /* Driver dependent */
Expand Down
1 change: 1 addition & 0 deletions src/haptic/linux/SDL_syshaptic.c
Expand Up @@ -260,6 +260,7 @@ SDL_SYS_HapticOpenFromFD(SDL_Haptic * haptic, int fd)
SDL_SetError("Haptic: Unable to query device memory: %s", strerror(errno));
goto open_err;
}
haptic->nplaying = haptic->neffects; /* Linux makes no distinction. */
haptic->effects = (struct haptic_effect *)
SDL_malloc(sizeof(struct haptic_effect) * haptic->neffects);
if (haptic->effects == NULL) {
Expand Down

0 comments on commit 7753d4c

Please sign in to comment.