Added SDL_HapticNumEffectsPlaying(). gsoc2008_force_feedback
authorEdgar Simo <bobbens@gmail.com>
Thu, 10 Jul 2008 17:16:11 +0000
branchgsoc2008_force_feedback
changeset 2515030fc4375e63
parent 2514 840e1b6325c0
child 2516 6da022b18314
Added SDL_HapticNumEffectsPlaying().
include/SDL_haptic.h
src/haptic/SDL_haptic.c
src/haptic/SDL_syshaptic.h
src/haptic/linux/SDL_syshaptic.c
     1.1 --- a/include/SDL_haptic.h	Thu Jul 10 16:42:43 2008 +0000
     1.2 +++ b/include/SDL_haptic.h	Thu Jul 10 17:16:11 2008 +0000
     1.3 @@ -740,11 +740,26 @@
     1.4   *    \return The number of effects the haptic device can store or
     1.5   *            -1 on error.
     1.6   *
     1.7 + * \sa SDL_HapticNumEffectsPlaying
     1.8   * \sa SDL_HapticQuery
     1.9   */
    1.10  extern DECLSPEC int SDL_HapticNumEffects(SDL_Haptic * haptic);
    1.11  
    1.12  /**
    1.13 + * \fn int SDL_HapticNumEffectsPlaying(SDL_Haptic * haptic)
    1.14 + *
    1.15 + * \brief Returns the number of effects a haptic device can play at the same time.
    1.16 + *
    1.17 + *    \param haptic The haptic device to query maximum playing effect.s
    1.18 + *    \return The number of effects the haptic device can play at the same time
    1.19 + *            or -1 on error.
    1.20 + *
    1.21 + * \sa SDL_HapticNumEffects
    1.22 + * \sa SDL_HapticQuery
    1.23 + */
    1.24 +extern DECLSPEC int SDL_HapticNumEffectsPlaying(SDL_Haptic * haptic);
    1.25 +
    1.26 +/**
    1.27   * \fn unsigned int SDL_HapticQuery(SDL_Haptic * haptic)
    1.28   *
    1.29   * \brief Gets the haptic devices supported features in bitwise matter.
     2.1 --- a/src/haptic/SDL_haptic.c	Thu Jul 10 16:42:43 2008 +0000
     2.2 +++ b/src/haptic/SDL_haptic.c	Thu Jul 10 17:16:11 2008 +0000
     2.3 @@ -356,6 +356,21 @@
     2.4     return haptic->neffects;
     2.5  }
     2.6  
     2.7 +
     2.8 +/*
     2.9 + * Returns the number of effects a haptic device can play.
    2.10 + */
    2.11 +int
    2.12 +SDL_HapticNumEffectsPlaying(SDL_Haptic * haptic)
    2.13 +{
    2.14 +   if (!ValidHaptic(&haptic)) {
    2.15 +      return -1;
    2.16 +   }
    2.17 +
    2.18 +   return haptic->nplaying;
    2.19 +}
    2.20 +
    2.21 +
    2.22  /*
    2.23   * Returns supported effects by the device.
    2.24   */
     3.1 --- a/src/haptic/SDL_syshaptic.h	Thu Jul 10 16:42:43 2008 +0000
     3.2 +++ b/src/haptic/SDL_syshaptic.h	Thu Jul 10 17:16:11 2008 +0000
     3.3 @@ -47,6 +47,7 @@
     3.4  
     3.5     struct haptic_effect *effects; /* Allocated effects */
     3.6     int neffects; /* Maximum amount of effects */
     3.7 +   int nplaying; /* Maximum amount of effects to play at the same time */
     3.8     unsigned int supported; /* Supported effects */
     3.9  
    3.10     struct haptic_hwdata *hwdata; /* Driver dependent */
     4.1 --- a/src/haptic/linux/SDL_syshaptic.c	Thu Jul 10 16:42:43 2008 +0000
     4.2 +++ b/src/haptic/linux/SDL_syshaptic.c	Thu Jul 10 17:16:11 2008 +0000
     4.3 @@ -260,6 +260,7 @@
     4.4        SDL_SetError("Haptic: Unable to query device memory: %s", strerror(errno));
     4.5        goto open_err;
     4.6     }
     4.7 +   haptic->nplaying = haptic->neffects; /* Linux makes no distinction. */
     4.8     haptic->effects = (struct haptic_effect *)
     4.9           SDL_malloc(sizeof(struct haptic_effect) * haptic->neffects);
    4.10     if (haptic->effects == NULL) {