Added SDL_HapticOpened(). gsoc2008_force_feedback
authorEdgar Simo <bobbens@gmail.com>
Tue, 08 Jul 2008 19:35:10 +0000
branchgsoc2008_force_feedback
changeset 2506 ba8e99fe92c1
parent 2505 abfcba0f3bd1
child 2507 8ef1d0f4d0c1
Added SDL_HapticOpened().
include/SDL_haptic.h
src/haptic/SDL_haptic.c
--- a/include/SDL_haptic.h	Tue Jul 08 19:23:03 2008 +0000
+++ b/include/SDL_haptic.h	Tue Jul 08 19:35:10 2008 +0000
@@ -642,6 +642,18 @@
  */
 extern DECLSPEC SDL_Haptic * SDL_HapticOpen(int device_index);
 
+/**
+ * \fn int SDL_HapticOpened(int device_index)
+ *
+ * \brief Checks if the haptic device at index has been opened.
+ *
+ *    \param device_index Index to check to see if it has been opened.
+ *    \return 1 if it has been opened or 0 if it hasn't.
+ * 
+ * \sa SDL_HapticOpen
+ * \sa SDL_HapticIndex
+ */
+extern DECLSPEC int SDL_HapticOpened(int device_index);
 
 /**
  * \fn int SDL_HapticIndex(SDL_Haptic * haptic)
@@ -652,6 +664,7 @@
  *    \return The index of the haptic device or -1 on error.
  *
  * \sa SDL_HapticOpen
+ * \sa SDL_HapticOpened
  */
 extern DECLSPEC int SDL_HapticIndex(SDL_Haptic * haptic);
 
--- a/src/haptic/SDL_haptic.c	Tue Jul 08 19:23:03 2008 +0000
+++ b/src/haptic/SDL_haptic.c	Tue Jul 08 19:35:10 2008 +0000
@@ -149,6 +149,25 @@
 
 
 /*
+ * Returns 1 if the device has been opened.
+ */
+int
+SDL_HapticOpened(int device_index)
+{
+   int i, opened;
+
+   opened = 0;
+   for (i=0; SDL_haptics[i]; i++) {
+      if (SDL_haptics[i]->index == (Uint8) device_index) {
+         opened = 1;
+         break;
+      }
+   }
+   return opened;
+}
+
+
+/*
  * Returns the index to a haptic device.
  */
 int