Added SDL_HapticNumEffectsPlaying(). gsoc2008_force_feedback
authorEdgar Simo <bobbens@gmail.com>
Thu, 10 Jul 2008 17:16:11 +0000
branchgsoc2008_force_feedback
changeset 2515 030fc4375e63
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
--- 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.
--- 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.
  */
--- 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 */
--- 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) {