From eeda5697ce5f7e5d8101fc2c4e77f55e3c3e6b3c Mon Sep 17 00:00:00 2001 From: Edgar Simo Date: Tue, 1 Jul 2008 16:19:54 +0000 Subject: [PATCH] Added SDL_HAPTIC_CUSTOM (not supported on linux). Exposed SDL_HapticEffectSupported(). --- include/SDL_haptic.h | 22 +++++++++++++++++----- src/haptic/SDL_haptic.c | 3 +++ src/haptic/linux/SDL_syshaptic.c | 1 + 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/include/SDL_haptic.h b/include/SDL_haptic.h index 4a13c82af..bcd922863 100644 --- a/include/SDL_haptic.h +++ b/include/SDL_haptic.h @@ -53,15 +53,21 @@ typedef struct _SDL_Haptic SDL_Haptic; #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 @@ typedef struct SDL_HapticCondition { 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 @@ typedef struct SDL_HapticRamp { Uint16 attack_level; Uint16 fade_length; Uint16 fade_level; - } SDL_HapticRamp; typedef union SDL_HapticEffect { @@ -230,6 +234,14 @@ extern DECLSPEC int SDL_HapticNumEffects(SDL_Haptic * haptic); */ 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. * diff --git a/src/haptic/SDL_haptic.c b/src/haptic/SDL_haptic.c index 7d846d4f9..cbe6ad644 100644 --- a/src/haptic/SDL_haptic.c +++ b/src/haptic/SDL_haptic.c @@ -228,6 +228,9 @@ SDL_HapticQueryEffects(SDL_Haptic * haptic) return haptic->supported; } +/* + * Checks to see if the device can support the effect. + */ int SDL_HapticEffectSupported(SDL_Haptic * haptic, SDL_HapticEffect * effect) { diff --git a/src/haptic/linux/SDL_syshaptic.c b/src/haptic/linux/SDL_syshaptic.c index 33d2961ca..fb255226e 100644 --- a/src/haptic/linux/SDL_syshaptic.c +++ b/src/haptic/linux/SDL_syshaptic.c @@ -94,6 +94,7 @@ EV_IsHaptic(int fd) 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);