Sam Lantinga 2024-01-18 06:55:36 -08:00
parent df4b855af5
commit cda2bffeee
8 changed files with 55 additions and 54 deletions

View File

@ -166,7 +166,7 @@ typedef struct SDL_Haptic SDL_Haptic;
* *
* \sa SDL_HapticCondition * \sa SDL_HapticCondition
*/ */
#define SDL_HAPTIC_CONSTANT (1u<<0) #define SDL_HAPTIC_CONSTANT (1u<<0)
/** /**
* Sine wave effect supported. * Sine wave effect supported.
@ -175,21 +175,16 @@ typedef struct SDL_Haptic SDL_Haptic;
* *
* \sa SDL_HapticPeriodic * \sa SDL_HapticPeriodic
*/ */
#define SDL_HAPTIC_SINE (1u<<1) #define SDL_HAPTIC_SINE (1u<<1)
/** /**
* Left/Right effect supported. * Square wave effect supported.
* *
* Haptic effect for direct control over high/low frequency motors. * Periodic haptic effect that simulates square waves.
* *
* \sa SDL_HapticLeftRight * \sa SDL_HapticPeriodic
* \warning this value was SDL_HAPTIC_SQUARE right before 2.0.0 shipped. Sorry,
* we ran out of bits, and this is important for XInput devices.
*/ */
#define SDL_HAPTIC_LEFTRIGHT (1u<<2) #define SDL_HAPTIC_SQUARE (1<<2)
/* !!! FIXME: put this back when we have more bits in 2.1 */
/* #define SDL_HAPTIC_SQUARE (1<<2) */
/** /**
* Triangle wave effect supported. * Triangle wave effect supported.
@ -198,7 +193,7 @@ typedef struct SDL_Haptic SDL_Haptic;
* *
* \sa SDL_HapticPeriodic * \sa SDL_HapticPeriodic
*/ */
#define SDL_HAPTIC_TRIANGLE (1u<<3) #define SDL_HAPTIC_TRIANGLE (1u<<3)
/** /**
* Sawtoothup wave effect supported. * Sawtoothup wave effect supported.
@ -207,7 +202,7 @@ typedef struct SDL_Haptic SDL_Haptic;
* *
* \sa SDL_HapticPeriodic * \sa SDL_HapticPeriodic
*/ */
#define SDL_HAPTIC_SAWTOOTHUP (1u<<4) #define SDL_HAPTIC_SAWTOOTHUP (1u<<4)
/** /**
* Sawtoothdown wave effect supported. * Sawtoothdown wave effect supported.
@ -225,7 +220,7 @@ typedef struct SDL_Haptic SDL_Haptic;
* *
* \sa SDL_HapticRamp * \sa SDL_HapticRamp
*/ */
#define SDL_HAPTIC_RAMP (1u<<6) #define SDL_HAPTIC_RAMP (1u<<6)
/** /**
* Spring effect supported - uses axes position. * Spring effect supported - uses axes position.
@ -235,7 +230,7 @@ typedef struct SDL_Haptic SDL_Haptic;
* *
* \sa SDL_HapticCondition * \sa SDL_HapticCondition
*/ */
#define SDL_HAPTIC_SPRING (1u<<7) #define SDL_HAPTIC_SPRING (1u<<7)
/** /**
* Damper effect supported - uses axes velocity. * Damper effect supported - uses axes velocity.
@ -245,7 +240,7 @@ typedef struct SDL_Haptic SDL_Haptic;
* *
* \sa SDL_HapticCondition * \sa SDL_HapticCondition
*/ */
#define SDL_HAPTIC_DAMPER (1u<<8) #define SDL_HAPTIC_DAMPER (1u<<8)
/** /**
* Inertia effect supported - uses axes acceleration. * Inertia effect supported - uses axes acceleration.
@ -255,7 +250,7 @@ typedef struct SDL_Haptic SDL_Haptic;
* *
* \sa SDL_HapticCondition * \sa SDL_HapticCondition
*/ */
#define SDL_HAPTIC_INERTIA (1u<<9) #define SDL_HAPTIC_INERTIA (1u<<9)
/** /**
* Friction effect supported - uses axes movement. * Friction effect supported - uses axes movement.
@ -265,14 +260,30 @@ typedef struct SDL_Haptic SDL_Haptic;
* *
* \sa SDL_HapticCondition * \sa SDL_HapticCondition
*/ */
#define SDL_HAPTIC_FRICTION (1u<<10) #define SDL_HAPTIC_FRICTION (1u<<10)
/**
* Left/Right effect supported.
*
* Haptic effect for direct control over high/low frequency motors.
*
* \sa SDL_HapticLeftRight
*/
#define SDL_HAPTIC_LEFTRIGHT (1u<<11)
/**
* Reserved for future use
*/
#define SDL_HAPTIC_RESERVED1 (1u<<12)
#define SDL_HAPTIC_RESERVED2 (1u<<13)
#define SDL_HAPTIC_RESERVED3 (1u<<14)
/** /**
* Custom effect is supported. * Custom effect is supported.
* *
* User defined custom haptic effect. * User defined custom haptic effect.
*/ */
#define SDL_HAPTIC_CUSTOM (1u<<11) #define SDL_HAPTIC_CUSTOM (1u<<15)
/* @} *//* Haptic effects */ /* @} *//* Haptic effects */
@ -285,7 +296,7 @@ typedef struct SDL_Haptic SDL_Haptic;
* *
* \sa SDL_SetHapticGain * \sa SDL_SetHapticGain
*/ */
#define SDL_HAPTIC_GAIN (1u<<12) #define SDL_HAPTIC_GAIN (1u<<16)
/** /**
* Device can set autocenter. * Device can set autocenter.
@ -294,7 +305,7 @@ typedef struct SDL_Haptic SDL_Haptic;
* *
* \sa SDL_SetHapticAutocenter * \sa SDL_SetHapticAutocenter
*/ */
#define SDL_HAPTIC_AUTOCENTER (1u<<13) #define SDL_HAPTIC_AUTOCENTER (1u<<17)
/** /**
* Device can be queried for effect status. * Device can be queried for effect status.
@ -303,7 +314,7 @@ typedef struct SDL_Haptic SDL_Haptic;
* *
* \sa SDL_GetHapticEffectStatus * \sa SDL_GetHapticEffectStatus
*/ */
#define SDL_HAPTIC_STATUS (1u<<14) #define SDL_HAPTIC_STATUS (1u<<18)
/** /**
* Device can be paused. * Device can be paused.
@ -313,7 +324,7 @@ typedef struct SDL_Haptic SDL_Haptic;
* \sa SDL_PauseHaptic * \sa SDL_PauseHaptic
* \sa SDL_ResumeHaptic * \sa SDL_ResumeHaptic
*/ */
#define SDL_HAPTIC_PAUSE (1u<<15) #define SDL_HAPTIC_PAUSE (1u<<19)
/** /**
@ -511,7 +522,7 @@ typedef struct SDL_HapticConstant
* *
* The struct handles the following effects: * The struct handles the following effects:
* - ::SDL_HAPTIC_SINE * - ::SDL_HAPTIC_SINE
* - ::SDL_HAPTIC_LEFTRIGHT * - ::SDL_HAPTIC_SQUARE
* - ::SDL_HAPTIC_TRIANGLE * - ::SDL_HAPTIC_TRIANGLE
* - ::SDL_HAPTIC_SAWTOOTHUP * - ::SDL_HAPTIC_SAWTOOTHUP
* - ::SDL_HAPTIC_SAWTOOTHDOWN * - ::SDL_HAPTIC_SAWTOOTHDOWN
@ -557,7 +568,7 @@ typedef struct SDL_HapticConstant
\endverbatim \endverbatim
* *
* \sa SDL_HAPTIC_SINE * \sa SDL_HAPTIC_SINE
* \sa SDL_HAPTIC_LEFTRIGHT * \sa SDL_HAPTIC_SQUARE
* \sa SDL_HAPTIC_TRIANGLE * \sa SDL_HAPTIC_TRIANGLE
* \sa SDL_HAPTIC_SAWTOOTHUP * \sa SDL_HAPTIC_SAWTOOTHUP
* \sa SDL_HAPTIC_SAWTOOTHDOWN * \sa SDL_HAPTIC_SAWTOOTHDOWN
@ -566,7 +577,7 @@ typedef struct SDL_HapticConstant
typedef struct SDL_HapticPeriodic typedef struct SDL_HapticPeriodic
{ {
/* Header */ /* Header */
Uint16 type; /**< ::SDL_HAPTIC_SINE, ::SDL_HAPTIC_LEFTRIGHT, Uint16 type; /**< ::SDL_HAPTIC_SINE, ::SDL_HAPTIC_SQUARE
::SDL_HAPTIC_TRIANGLE, ::SDL_HAPTIC_SAWTOOTHUP or ::SDL_HAPTIC_TRIANGLE, ::SDL_HAPTIC_SAWTOOTHUP or
::SDL_HAPTIC_SAWTOOTHDOWN */ ::SDL_HAPTIC_SAWTOOTHDOWN */
SDL_HapticDirection direction; /**< Direction of the effect. */ SDL_HapticDirection direction; /**< Direction of the effect. */
@ -1050,7 +1061,7 @@ extern DECLSPEC int SDLCALL SDL_GetMaxHapticEffectsPlaying(SDL_Haptic *haptic);
* \sa SDL_HapticEffectSupported * \sa SDL_HapticEffectSupported
* \sa SDL_GetMaxHapticEffects * \sa SDL_GetMaxHapticEffects
*/ */
extern DECLSPEC unsigned int SDLCALL SDL_GetHapticFeatures(SDL_Haptic *haptic); extern DECLSPEC Uint32 SDLCALL SDL_GetHapticFeatures(SDL_Haptic *haptic);
/** /**

View File

@ -447,7 +447,7 @@ SDL_DYNAPI_PROC(SDL_Haptic*,SDL_OpenHaptic,(SDL_HapticID a),(a),return)
SDL_DYNAPI_PROC(SDL_Haptic*,SDL_OpenHapticFromJoystick,(SDL_Joystick *a),(a),return) SDL_DYNAPI_PROC(SDL_Haptic*,SDL_OpenHapticFromJoystick,(SDL_Joystick *a),(a),return)
SDL_DYNAPI_PROC(SDL_Haptic*,SDL_OpenHapticFromMouse,(void),(),return) SDL_DYNAPI_PROC(SDL_Haptic*,SDL_OpenHapticFromMouse,(void),(),return)
SDL_DYNAPI_PROC(int,SDL_PauseHaptic,(SDL_Haptic *a),(a),return) SDL_DYNAPI_PROC(int,SDL_PauseHaptic,(SDL_Haptic *a),(a),return)
SDL_DYNAPI_PROC(unsigned int,SDL_GetHapticFeatures,(SDL_Haptic *a),(a),return) SDL_DYNAPI_PROC(Uint32,SDL_GetHapticFeatures,(SDL_Haptic *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_InitHapticRumble,(SDL_Haptic *a),(a),return) SDL_DYNAPI_PROC(int,SDL_InitHapticRumble,(SDL_Haptic *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_PlayHapticRumble,(SDL_Haptic *a, float b, Uint32 c),(a,b,c),return) SDL_DYNAPI_PROC(int,SDL_PlayHapticRumble,(SDL_Haptic *a, float b, Uint32 c),(a,b,c),return)
SDL_DYNAPI_PROC(int,SDL_StopHapticRumble,(SDL_Haptic *a),(a),return) SDL_DYNAPI_PROC(int,SDL_StopHapticRumble,(SDL_Haptic *a),(a),return)

View File

@ -366,7 +366,7 @@ int SDL_GetMaxHapticEffectsPlaying(SDL_Haptic *haptic)
return haptic->nplaying; return haptic->nplaying;
} }
unsigned int SDL_GetHapticFeatures(SDL_Haptic *haptic) Uint32 SDL_GetHapticFeatures(SDL_Haptic *haptic)
{ {
CHECK_HAPTIC_MAGIC(haptic, 0); CHECK_HAPTIC_MAGIC(haptic, 0);

View File

@ -48,7 +48,7 @@ struct SDL_Haptic
struct haptic_effect *effects; /* Allocated effects */ struct haptic_effect *effects; /* Allocated effects */
int neffects; /* Maximum amount of effects */ int neffects; /* Maximum amount of effects */
int nplaying; /* Maximum amount of effects to play at the same time */ int nplaying; /* Maximum amount of effects to play at the same time */
unsigned int supported; /* Supported effects */ Uint32 supported; /* Supported effects and features */
int naxes; /* Number of axes on the device. */ int naxes; /* Number of axes on the device. */
struct haptic_hwdata *hwdata; /* Driver dependent */ struct haptic_hwdata *hwdata; /* Driver dependent */

View File

@ -445,8 +445,7 @@ static unsigned int GetSupportedFeatures(SDL_Haptic *haptic)
/* Test for effects. */ /* Test for effects. */
FF_TEST(FFCAP_ET_CONSTANTFORCE, SDL_HAPTIC_CONSTANT); FF_TEST(FFCAP_ET_CONSTANTFORCE, SDL_HAPTIC_CONSTANT);
FF_TEST(FFCAP_ET_RAMPFORCE, SDL_HAPTIC_RAMP); FF_TEST(FFCAP_ET_RAMPFORCE, SDL_HAPTIC_RAMP);
/* !!! FIXME: put this back when we have more bits in 2.1 */ FF_TEST(FFCAP_ET_SQUARE, SDL_HAPTIC_SQUARE);
/* FF_TEST(FFCAP_ET_SQUARE, SDL_HAPTIC_SQUARE); */
FF_TEST(FFCAP_ET_SINE, SDL_HAPTIC_SINE); FF_TEST(FFCAP_ET_SINE, SDL_HAPTIC_SINE);
FF_TEST(FFCAP_ET_TRIANGLE, SDL_HAPTIC_TRIANGLE); FF_TEST(FFCAP_ET_TRIANGLE, SDL_HAPTIC_TRIANGLE);
FF_TEST(FFCAP_ET_SAWTOOTHUP, SDL_HAPTIC_SAWTOOTHUP); FF_TEST(FFCAP_ET_SAWTOOTHUP, SDL_HAPTIC_SAWTOOTHUP);
@ -862,8 +861,7 @@ static int SDL_SYS_ToFFEFFECT(SDL_Haptic *haptic, FFEFFECT *dest, SDL_HapticEffe
break; break;
case SDL_HAPTIC_SINE: case SDL_HAPTIC_SINE:
/* !!! FIXME: put this back when we have more bits in 2.1 */ case SDL_HAPTIC_SQUARE:
/* case SDL_HAPTIC_SQUARE: */
case SDL_HAPTIC_TRIANGLE: case SDL_HAPTIC_TRIANGLE:
case SDL_HAPTIC_SAWTOOTHUP: case SDL_HAPTIC_SAWTOOTHUP:
case SDL_HAPTIC_SAWTOOTHDOWN: case SDL_HAPTIC_SAWTOOTHDOWN:
@ -1077,9 +1075,8 @@ SDL_SYS_HapticEffectType(Uint16 type)
case SDL_HAPTIC_RAMP: case SDL_HAPTIC_RAMP:
return kFFEffectType_RampForce_ID; return kFFEffectType_RampForce_ID;
/* !!! FIXME: put this back when we have more bits in 2.1 */ case SDL_HAPTIC_SQUARE:
/* case SDL_HAPTIC_SQUARE: return kFFEffectType_Square_ID;
return kFFEffectType_Square_ID; */
case SDL_HAPTIC_SINE: case SDL_HAPTIC_SINE:
return kFFEffectType_Sine_ID; return kFFEffectType_Sine_ID;

View File

@ -100,8 +100,7 @@ static int EV_IsHaptic(int fd)
/* Convert supported features to SDL_HAPTIC platform-neutral features. */ /* Convert supported features to SDL_HAPTIC platform-neutral features. */
EV_TEST(FF_CONSTANT, SDL_HAPTIC_CONSTANT); EV_TEST(FF_CONSTANT, SDL_HAPTIC_CONSTANT);
EV_TEST(FF_SINE, SDL_HAPTIC_SINE); EV_TEST(FF_SINE, SDL_HAPTIC_SINE);
/* !!! FIXME: put this back when we have more bits in 2.1 */ EV_TEST(FF_SQUARE, SDL_HAPTIC_SQUARE);
/* EV_TEST(FF_SQUARE, SDL_HAPTIC_SQUARE); */
EV_TEST(FF_TRIANGLE, SDL_HAPTIC_TRIANGLE); EV_TEST(FF_TRIANGLE, SDL_HAPTIC_TRIANGLE);
EV_TEST(FF_SAW_UP, SDL_HAPTIC_SAWTOOTHUP); EV_TEST(FF_SAW_UP, SDL_HAPTIC_SAWTOOTHUP);
EV_TEST(FF_SAW_DOWN, SDL_HAPTIC_SAWTOOTHDOWN); EV_TEST(FF_SAW_DOWN, SDL_HAPTIC_SAWTOOTHDOWN);
@ -761,8 +760,7 @@ static int SDL_SYS_ToFFEffect(struct ff_effect *dest, SDL_HapticEffect *src)
break; break;
case SDL_HAPTIC_SINE: case SDL_HAPTIC_SINE:
/* !!! FIXME: put this back when we have more bits in 2.1 */ case SDL_HAPTIC_SQUARE:
/* case SDL_HAPTIC_SQUARE: */
case SDL_HAPTIC_TRIANGLE: case SDL_HAPTIC_TRIANGLE:
case SDL_HAPTIC_SAWTOOTHUP: case SDL_HAPTIC_SAWTOOTHUP:
case SDL_HAPTIC_SAWTOOTHDOWN: case SDL_HAPTIC_SAWTOOTHDOWN:
@ -785,9 +783,8 @@ static int SDL_SYS_ToFFEffect(struct ff_effect *dest, SDL_HapticEffect *src)
/* Periodic */ /* Periodic */
if (periodic->type == SDL_HAPTIC_SINE) { if (periodic->type == SDL_HAPTIC_SINE) {
dest->u.periodic.waveform = FF_SINE; dest->u.periodic.waveform = FF_SINE;
/* !!! FIXME: put this back when we have more bits in 2.1 */ } else if (periodic->type == SDL_HAPTIC_SQUARE) {
/* else if (periodic->type == SDL_HAPTIC_SQUARE) dest->u.periodic.waveform = FF_SQUARE;
dest->u.periodic.waveform = FF_SQUARE; */
} else if (periodic->type == SDL_HAPTIC_TRIANGLE) { } else if (periodic->type == SDL_HAPTIC_TRIANGLE) {
dest->u.periodic.waveform = FF_TRIANGLE; dest->u.periodic.waveform = FF_TRIANGLE;
} else if (periodic->type == SDL_HAPTIC_SAWTOOTHUP) { } else if (periodic->type == SDL_HAPTIC_SAWTOOTHUP) {

View File

@ -260,8 +260,7 @@ static BOOL CALLBACK DI_EffectCallback(LPCDIEFFECTINFO pei, LPVOID pv)
EFFECT_TEST(GUID_ConstantForce, SDL_HAPTIC_CONSTANT); EFFECT_TEST(GUID_ConstantForce, SDL_HAPTIC_CONSTANT);
EFFECT_TEST(GUID_CustomForce, SDL_HAPTIC_CUSTOM); EFFECT_TEST(GUID_CustomForce, SDL_HAPTIC_CUSTOM);
EFFECT_TEST(GUID_Sine, SDL_HAPTIC_SINE); EFFECT_TEST(GUID_Sine, SDL_HAPTIC_SINE);
/* !!! FIXME: put this back when we have more bits in 2.1 */ EFFECT_TEST(GUID_Square, SDL_HAPTIC_SQUARE);
/* EFFECT_TEST(GUID_Square, SDL_HAPTIC_SQUARE); */
EFFECT_TEST(GUID_Triangle, SDL_HAPTIC_TRIANGLE); EFFECT_TEST(GUID_Triangle, SDL_HAPTIC_TRIANGLE);
EFFECT_TEST(GUID_SawtoothUp, SDL_HAPTIC_SAWTOOTHUP); EFFECT_TEST(GUID_SawtoothUp, SDL_HAPTIC_SAWTOOTHUP);
EFFECT_TEST(GUID_SawtoothDown, SDL_HAPTIC_SAWTOOTHDOWN); EFFECT_TEST(GUID_SawtoothDown, SDL_HAPTIC_SAWTOOTHDOWN);
@ -678,8 +677,7 @@ static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest,
break; break;
case SDL_HAPTIC_SINE: case SDL_HAPTIC_SINE:
/* !!! FIXME: put this back when we have more bits in 2.1 */ case SDL_HAPTIC_SQUARE:
/* case SDL_HAPTIC_SQUARE: */
case SDL_HAPTIC_TRIANGLE: case SDL_HAPTIC_TRIANGLE:
case SDL_HAPTIC_SAWTOOTHUP: case SDL_HAPTIC_SAWTOOTHUP:
case SDL_HAPTIC_SAWTOOTHDOWN: case SDL_HAPTIC_SAWTOOTHDOWN:
@ -889,9 +887,8 @@ static REFGUID SDL_SYS_HapticEffectType(SDL_HapticEffect *effect)
case SDL_HAPTIC_RAMP: case SDL_HAPTIC_RAMP:
return &GUID_RampForce; return &GUID_RampForce;
/* !!! FIXME: put this back when we have more bits in 2.1 */ case SDL_HAPTIC_SQUARE:
/* case SDL_HAPTIC_SQUARE: return &GUID_Square;
return &GUID_Square; */
case SDL_HAPTIC_SINE: case SDL_HAPTIC_SINE:
return &GUID_Sine; return &GUID_Sine;

View File

@ -351,9 +351,8 @@ HapticPrintSupported(SDL_Haptic *ptr)
if (supported & SDL_HAPTIC_SINE) { if (supported & SDL_HAPTIC_SINE) {
SDL_Log(" sine\n"); SDL_Log(" sine\n");
} }
/* !!! FIXME: put this back when we have more bits in 2.1 */ if (supported & SDL_HAPTIC_SQUARE)
/* if (supported & SDL_HAPTIC_SQUARE) SDL_Log(" square\n");
SDL_Log(" square\n"); */
if (supported & SDL_HAPTIC_TRIANGLE) { if (supported & SDL_HAPTIC_TRIANGLE) {
SDL_Log(" triangle\n"); SDL_Log(" triangle\n");
} }