diff src/haptic/SDL_haptic.c @ 2478:4fd783e0f34b gsoc2008_force_feedback

Added query functions for haptic devices.
author Edgar Simo <bobbens@gmail.com>
date Mon, 30 Jun 2008 17:28:34 +0000
parents 97f75ea43a93
children b9eb2cfe16cd
line wrap: on
line diff
--- a/src/haptic/SDL_haptic.c	Mon Jun 30 16:48:16 2008 +0000
+++ b/src/haptic/SDL_haptic.c	Mon Jun 30 17:28:34 2008 +0000
@@ -197,6 +197,43 @@
    }
 }
 
+/*
+ * Returns the number of effects a haptic device has.
+ */
+int
+SDL_HapticNumEffects(SDL_Haptic * haptic)
+{
+   if (!ValidHaptic(&haptic)) {
+      return -1;
+   }
+
+   return haptic->neffects;
+}
+
+/*
+ * Returns supported effects by the device.
+ */
+unsigned int
+SDL_HapticQueryEffects(SDL_Haptic * haptic)
+{
+   if (!ValidHaptic(&haptic)) {
+      return -1;
+   }
+
+   return haptic->supported;
+}
+
+int
+SDL_HapticEffectSupported(SDL_Haptic * haptic, SDL_HapticEffect * effect)
+{
+   if (!ValidHaptic(&haptic)) {
+      return -1;
+   }
+
+   if ((haptic->supported & effect->type) != 0)
+      return SDL_TRUE;
+   return SDL_FALSE;
+}
 
 /*
  * Creates a new haptic effect.