Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Warn about using button triggers.
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbens committed Jul 30, 2008
1 parent 5f41e79 commit 0974e84
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 7 deletions.
4 changes: 4 additions & 0 deletions include/SDL_haptic.h
Expand Up @@ -645,6 +645,10 @@ typedef struct SDL_HapticCustom {
* Additionally, the SDL_HAPTIC_RAMP effect does not support a duration of
* SDL_HAPTIC_INFINITY.
*
* Button triggers may not be supported on all devices, it is advised to not
* use them if possible. Buttons start at index 1 instead of index 0 like
* they joystick.
*
* Common parts:
* \code
* // Replay - All effects have this
Expand Down
31 changes: 24 additions & 7 deletions src/haptic/darwin/SDL_syshaptic.c
Expand Up @@ -309,8 +309,8 @@ GetSupportedFeatures(FFDeviceObjectReference device,
FF_TEST(FFCAP_ET_CUSTOMFORCE, SDL_HAPTIC_CUSTOM);

/* Check if supports gain. */
ret = FFDeviceGetForceFeedbackProperty(device, FFPROP_FFGAIN,
&val, sizeof(val));
ret = FFDeviceGetForceFeedbackProperty( device, FFPROP_FFGAIN,
&val, sizeof(val));
if (ret == FF_OK) supported |= SDL_HAPTIC_GAIN;
else if (ret != FFERR_UNSUPPORTED) {
SDL_SetError("Haptic: Unable to get if device supports gain: %s.",
Expand Down Expand Up @@ -513,6 +513,23 @@ SDL_SYS_HapticQuit(void)
}


/*
* Converts an SDL trigger button to an FFEFFECT trigger button.
*/
static DWORD
FFGetTriggerButton( Uint16 button )
{
DWORD dwTriggerButton;

dwTriggerButton = FFEB_NOTRIGGER;

if (hap_constant->button != 0)
dwTriggerButton = FFJOFS_BUTTON(hap_constant->button);

return dwTriggerButton;
}


/*
* Sets the direction.
*/
Expand Down Expand Up @@ -634,7 +651,7 @@ SDL_SYS_ToFFEFFECT( SDL_Haptic * haptic, FFEFFECT * dest, SDL_HapticEffect * src

/* Generics */
dest->dwDuration = hap_constant->length * 1000; /* In microseconds. */
dest->dwTriggerButton = FFJOFS_BUTTON(hap_constant->button);
dest->dwTriggerButton = FFGetTriggerButton(hap_constant->button);
dest->dwTriggerRepeatInterval = hap_constant->interval;
dest->dwStartDelay = hap_constant->delay * 1000; /* In microseconds. */

Expand Down Expand Up @@ -674,7 +691,7 @@ SDL_SYS_ToFFEFFECT( SDL_Haptic * haptic, FFEFFECT * dest, SDL_HapticEffect * src

/* Generics */
dest->dwDuration = hap_periodic->length * 1000; /* In microseconds. */
dest->dwTriggerButton = FFJOFS_BUTTON(hap_periodic->button);
dest->dwTriggerButton = FFGetTriggerButton(hap_periodic->button);
dest->dwTriggerRepeatInterval = hap_periodic->interval;
dest->dwStartDelay = hap_periodic->delay * 1000; /* In microseconds. */

Expand Down Expand Up @@ -717,7 +734,7 @@ SDL_SYS_ToFFEFFECT( SDL_Haptic * haptic, FFEFFECT * dest, SDL_HapticEffect * src

/* Generics */
dest->dwDuration = hap_condition->length * 1000; /* In microseconds. */
dest->dwTriggerButton = FFJOFS_BUTTON(hap_condition->button);
dest->dwTriggerButton = FFGetTriggerButton(hap_condition->button);
dest->dwTriggerRepeatInterval = hap_condition->interval;
dest->dwStartDelay = hap_condition->delay * 1000; /* In microseconds. */

Expand Down Expand Up @@ -753,7 +770,7 @@ SDL_SYS_ToFFEFFECT( SDL_Haptic * haptic, FFEFFECT * dest, SDL_HapticEffect * src

/* Generics */
dest->dwDuration = hap_ramp->length * 1000; /* In microseconds. */
dest->dwTriggerButton = FFJOFS_BUTTON(hap_ramp->button);
dest->dwTriggerButton = FFGetTriggerButton(hap_ramp->button);
dest->dwTriggerRepeatInterval = hap_ramp->interval;
dest->dwStartDelay = hap_ramp->delay * 1000; /* In microseconds. */

Expand Down Expand Up @@ -792,7 +809,7 @@ SDL_SYS_ToFFEFFECT( SDL_Haptic * haptic, FFEFFECT * dest, SDL_HapticEffect * src

/* Generics */
dest->dwDuration = hap_custom->length * 1000; /* In microseconds. */
dest->dwTriggerButton = FFJOFS_BUTTON(hap_custom->button);
dest->dwTriggerButton = FFGetTriggerButton(hap_custom->button);
dest->dwTriggerRepeatInterval = hap_custom->interval;
dest->dwStartDelay = hap_custom->delay * 1000; /* In microseconds. */

Expand Down

0 comments on commit 0974e84

Please sign in to comment.