Added SDL_HAPTIC_CUSTOM (not supported on linux). gsoc2008_force_feedback
authorEdgar Simo <bobbens@gmail.com>
Tue, 01 Jul 2008 16:19:54 +0000
branchgsoc2008_force_feedback
changeset 248624dd8b8669fa
parent 2485 67978eea6d10
child 2487 4c8e25ef2d97
Added SDL_HAPTIC_CUSTOM (not supported on linux).
Exposed SDL_HapticEffectSupported().
include/SDL_haptic.h
src/haptic/SDL_haptic.c
src/haptic/linux/SDL_syshaptic.c
     1.1 --- a/include/SDL_haptic.h	Tue Jul 01 14:31:04 2008 +0000
     1.2 +++ b/include/SDL_haptic.h	Tue Jul 01 16:19:54 2008 +0000
     1.3 @@ -53,15 +53,21 @@
     1.4  #define SDL_HAPTIC_FRICTION   (1<<4)
     1.5  #define SDL_HAPTIC_DAMPER     (1<<5)
     1.6  #define SDL_HAPTIC_INERTIA    (1<<6)
     1.7 -#define SDL_HAPTIC_GAIN       (1<<7)
     1.8 -#define SDL_HAPTIC_AUTOCENTER (1<<8)
     1.9 +#define SDL_HAPTIC_CUSTOM     (1<<7)
    1.10 +#define SDL_HAPTIC_GAIN       (1<<8)
    1.11 +#define SDL_HAPTIC_AUTOCENTER (1<<9)
    1.12  
    1.13 +
    1.14 +/*
    1.15 + * Different waveforms a SDL_HAPTIC_PERIODIC effect can have.
    1.16 + */
    1.17  typedef enum SDL_waveform {
    1.18     SDL_WAVEFORM_SINE,
    1.19     SDL_WAVEFORM_SQUARE,
    1.20     SDL_WAVEFORM_TRIANGLE,
    1.21     SDL_WAVEFORM_SAWTOOTHUP,
    1.22 -   SDL_WAVEFORM_SAWTOOTHDOWN
    1.23 +   SDL_WAVEFORM_SAWTOOTHDOWN,
    1.24 +   SDL_WAVEFORM_CUSTOM
    1.25  } SDL_waveform;
    1.26  
    1.27  
    1.28 @@ -153,7 +159,6 @@
    1.29     Sint16 left_coeff; /* How fast to increase the force towards the left */
    1.30     Uint16 deadband; /* Size of the dead zone */
    1.31     Sint16 center; /* Position of the dead zone */
    1.32 -
    1.33  } SDL_HapticCondition;
    1.34  typedef struct SDL_HapticRamp {
    1.35     /* Header */
    1.36 @@ -177,7 +182,6 @@
    1.37     Uint16 attack_level;
    1.38     Uint16 fade_length;
    1.39     Uint16 fade_level;
    1.40 -
    1.41  } SDL_HapticRamp;
    1.42  
    1.43  typedef union SDL_HapticEffect {
    1.44 @@ -231,6 +235,14 @@
    1.45  extern DECLSPEC unsigned int SDL_HapticQueryEffects(SDL_Haptic * haptic);
    1.46  
    1.47  /*
    1.48 + * Checks to see if effect is supported by haptic.
    1.49 + *
    1.50 + * Returns SDL_TRUE if effect is supported, SDL_FALSE if it isn't and -1
    1.51 + * on error.
    1.52 + */
    1.53 +extern DECLSPEC int SDL_HapticEffectSupported(SDL_Haptic * haptic, SDL_HapticEffect * effect);
    1.54 +
    1.55 +/*
    1.56   * Creates a new haptic effect on the device.
    1.57   *
    1.58   * Returns the id of the effect on success, -1 on failure.
     2.1 --- a/src/haptic/SDL_haptic.c	Tue Jul 01 14:31:04 2008 +0000
     2.2 +++ b/src/haptic/SDL_haptic.c	Tue Jul 01 16:19:54 2008 +0000
     2.3 @@ -228,6 +228,9 @@
     2.4     return haptic->supported;
     2.5  }
     2.6  
     2.7 +/*
     2.8 + * Checks to see if the device can support the effect.
     2.9 + */
    2.10  int
    2.11  SDL_HapticEffectSupported(SDL_Haptic * haptic, SDL_HapticEffect * effect)
    2.12  {
     3.1 --- a/src/haptic/linux/SDL_syshaptic.c	Tue Jul 01 14:31:04 2008 +0000
     3.2 +++ b/src/haptic/linux/SDL_syshaptic.c	Tue Jul 01 16:19:54 2008 +0000
     3.3 @@ -94,6 +94,7 @@
     3.4     EV_TEST(FF_FRICTION,   SDL_HAPTIC_FRICTION);
     3.5     EV_TEST(FF_DAMPER,     SDL_HAPTIC_DAMPER);
     3.6     EV_TEST(FF_INERTIA,    SDL_HAPTIC_INERTIA);
     3.7 +   EV_TEST(FF_CUSTOM,     SDL_HAPTIC_CUSTOM);
     3.8     EV_TEST(FF_GAIN,       SDL_HAPTIC_GAIN);
     3.9     EV_TEST(FF_AUTOCENTER, SDL_HAPTIC_AUTOCENTER);
    3.10