# HG changeset patch # User Edgar Simo # Date 1215710171 0 # Node ID 030fc4375e636cb46b5629b5f7983563a41a863e # Parent 840e1b6325c097d1cf88db1391864d27c5c2da99 Added SDL_HapticNumEffectsPlaying(). diff -r 840e1b6325c0 -r 030fc4375e63 include/SDL_haptic.h --- a/include/SDL_haptic.h Thu Jul 10 16:42:43 2008 +0000 +++ b/include/SDL_haptic.h Thu Jul 10 17:16:11 2008 +0000 @@ -740,11 +740,26 @@ * \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) * * \brief Gets the haptic devices supported features in bitwise matter. diff -r 840e1b6325c0 -r 030fc4375e63 src/haptic/SDL_haptic.c --- a/src/haptic/SDL_haptic.c Thu Jul 10 16:42:43 2008 +0000 +++ b/src/haptic/SDL_haptic.c Thu Jul 10 17:16:11 2008 +0000 @@ -356,6 +356,21 @@ 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. */ diff -r 840e1b6325c0 -r 030fc4375e63 src/haptic/SDL_syshaptic.h --- a/src/haptic/SDL_syshaptic.h Thu Jul 10 16:42:43 2008 +0000 +++ b/src/haptic/SDL_syshaptic.h Thu Jul 10 17:16:11 2008 +0000 @@ -47,6 +47,7 @@ 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 */ diff -r 840e1b6325c0 -r 030fc4375e63 src/haptic/linux/SDL_syshaptic.c --- a/src/haptic/linux/SDL_syshaptic.c Thu Jul 10 16:42:43 2008 +0000 +++ b/src/haptic/linux/SDL_syshaptic.c Thu Jul 10 17:16:11 2008 +0000 @@ -260,6 +260,7 @@ 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) {