diff src/haptic/SDL_haptic.c @ 2512:ef147ee4896c gsoc2008_force_feedback

Improved some ioctl handling. Implemented SDL_MouseIsHaptic and SDL_HapticOpenFromMouse. More code comments.
author Edgar Simo <bobbens@gmail.com>
date Thu, 10 Jul 2008 08:38:08 +0000
parents 8ef1d0f4d0c1
children 55fd9103a330
line wrap: on
line diff
--- a/src/haptic/SDL_haptic.c	Wed Jul 09 18:29:11 2008 +0000
+++ b/src/haptic/SDL_haptic.c	Thu Jul 10 08:38:08 2008 +0000
@@ -25,7 +25,7 @@
 #include "../joystick/SDL_joystick_c.h" /* For SDL_PrivateJoystickValid */
 
 
-static Uint8 SDL_numhaptics = 0;
+Uint8 SDL_numhaptics = 0;
 SDL_Haptic **SDL_haptics = NULL;
 static SDL_Haptic *default_haptic = NULL;
 
@@ -188,6 +188,37 @@
 
 
 /*
+ * Returns SDL_TRUE if mouse is haptic, SDL_FALSE if it isn't.
+ */
+int
+SDL_MouseIsHaptic(void)
+{
+   if (SDL_SYS_HapticMouse() < 0)
+      return SDL_FALSE;
+   return SDL_TRUE;
+}
+
+
+/*
+ * Returns the haptic device if mouse is haptic or NULL elsewise.
+ */
+SDL_Haptic *
+SDL_HapticOpenFromMouse(void)
+{
+   int device_index;
+
+   device_index = SDL_SYS_HapticMouse();
+
+   if (device_index < 0) {
+      SDL_SetError("Mouse isn't a haptic device.");
+      return NULL;
+   }
+
+   return SDL_HapticOpen(device_index);
+}
+
+
+/*
  * Returns SDL_TRUE if joystick has haptic features.
  */
 int