changeset 2486:24dd8b8669fa gsoc2008_force_feedback

Added SDL_HAPTIC_CUSTOM (not supported on linux). Exposed SDL_HapticEffectSupported().
author Edgar Simo <bobbens@gmail.com>
date Tue, 01 Jul 2008 16:19:54 +0000
parents 67978eea6d10
children 4c8e25ef2d97
files include/SDL_haptic.h src/haptic/SDL_haptic.c src/haptic/linux/SDL_syshaptic.c
diffstat 3 files changed, 21 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/include/SDL_haptic.h	Tue Jul 01 14:31:04 2008 +0000
+++ b/include/SDL_haptic.h	Tue Jul 01 16:19:54 2008 +0000
@@ -53,15 +53,21 @@
 #define SDL_HAPTIC_FRICTION   (1<<4)
 #define SDL_HAPTIC_DAMPER     (1<<5)
 #define SDL_HAPTIC_INERTIA    (1<<6)
-#define SDL_HAPTIC_GAIN       (1<<7)
-#define SDL_HAPTIC_AUTOCENTER (1<<8)
+#define SDL_HAPTIC_CUSTOM     (1<<7)
+#define SDL_HAPTIC_GAIN       (1<<8)
+#define SDL_HAPTIC_AUTOCENTER (1<<9)
 
+
+/*
+ * Different waveforms a SDL_HAPTIC_PERIODIC effect can have.
+ */
 typedef enum SDL_waveform {
    SDL_WAVEFORM_SINE,
    SDL_WAVEFORM_SQUARE,
    SDL_WAVEFORM_TRIANGLE,
    SDL_WAVEFORM_SAWTOOTHUP,
-   SDL_WAVEFORM_SAWTOOTHDOWN
+   SDL_WAVEFORM_SAWTOOTHDOWN,
+   SDL_WAVEFORM_CUSTOM
 } SDL_waveform;
 
 
@@ -153,7 +159,6 @@
    Sint16 left_coeff; /* How fast to increase the force towards the left */
    Uint16 deadband; /* Size of the dead zone */
    Sint16 center; /* Position of the dead zone */
-
 } SDL_HapticCondition;
 typedef struct SDL_HapticRamp {
    /* Header */
@@ -177,7 +182,6 @@
    Uint16 attack_level;
    Uint16 fade_length;
    Uint16 fade_level;
-
 } SDL_HapticRamp;
 
 typedef union SDL_HapticEffect {
@@ -231,6 +235,14 @@
 extern DECLSPEC unsigned int SDL_HapticQueryEffects(SDL_Haptic * haptic);
 
 /*
+ * Checks to see if effect is supported by haptic.
+ *
+ * Returns SDL_TRUE if effect is supported, SDL_FALSE if it isn't and -1
+ * on error.
+ */
+extern DECLSPEC int SDL_HapticEffectSupported(SDL_Haptic * haptic, SDL_HapticEffect * effect);
+
+/*
  * Creates a new haptic effect on the device.
  *
  * Returns the id of the effect on success, -1 on failure.
--- a/src/haptic/SDL_haptic.c	Tue Jul 01 14:31:04 2008 +0000
+++ b/src/haptic/SDL_haptic.c	Tue Jul 01 16:19:54 2008 +0000
@@ -228,6 +228,9 @@
    return haptic->supported;
 }
 
+/*
+ * Checks to see if the device can support the effect.
+ */
 int
 SDL_HapticEffectSupported(SDL_Haptic * haptic, SDL_HapticEffect * effect)
 {
--- a/src/haptic/linux/SDL_syshaptic.c	Tue Jul 01 14:31:04 2008 +0000
+++ b/src/haptic/linux/SDL_syshaptic.c	Tue Jul 01 16:19:54 2008 +0000
@@ -94,6 +94,7 @@
    EV_TEST(FF_FRICTION,   SDL_HAPTIC_FRICTION);
    EV_TEST(FF_DAMPER,     SDL_HAPTIC_DAMPER);
    EV_TEST(FF_INERTIA,    SDL_HAPTIC_INERTIA);
+   EV_TEST(FF_CUSTOM,     SDL_HAPTIC_CUSTOM);
    EV_TEST(FF_GAIN,       SDL_HAPTIC_GAIN);
    EV_TEST(FF_AUTOCENTER, SDL_HAPTIC_AUTOCENTER);