diff src/haptic/linux/SDL_syshaptic.c @ 2484:666472fd4cb0 gsoc2008_force_feedback

HapticSetGain checks to see if device supports it. Added HapticSetAutocenter().
author Edgar Simo <bobbens@gmail.com>
date Tue, 01 Jul 2008 14:21:09 +0000
parents 9d52368ebcf5
children 67978eea6d10
line wrap: on
line diff
--- a/src/haptic/linux/SDL_syshaptic.c	Tue Jul 01 14:09:53 2008 +0000
+++ b/src/haptic/linux/SDL_syshaptic.c	Tue Jul 01 14:21:09 2008 +0000
@@ -519,13 +519,36 @@
    ie.type = EV_FF;
    ie.code = FF_GAIN;
    ie.value = (0xFFFFUL * gain) / 100;
-   printf("%d\n",ie.value);
 
-   if (write(haptic->hwdata->fd, &ie, sizeof(ie)) == -1) {
+   if (write(haptic->hwdata->fd, &ie, sizeof(ie)) < 0) {
       SDL_SetError("Error setting gain.");
+      return -1;
    }
 
+   return 0;
 }
 
 
+/*
+ * Sets the autocentering.
+ */
+int
+SDL_SYS_HapticSetAutocenter(SDL_Haptic * haptic, int autocenter)
+{
+   struct input_event ie;
+
+   ie.type = EV_FF;
+   ie.code = FF_AUTOCENTER;
+   ie.value = (0xFFFFUL * autocenter) / 100;
+
+   if (write(haptic->hwdata->fd, &ie, sizeof(ie)) < 0) {
+      SDL_SetError("Error setting autocenter.");
+      return -1;
+   }
+
+   return 0;
+}
+
+
+
 #endif /* SDL_HAPTIC_LINUX */