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

Commit

Permalink
Some correctness, especially on axes.
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbens committed Aug 5, 2008
1 parent 186e75f commit b34c0b2
Showing 1 changed file with 7 additions and 20 deletions.
27 changes: 7 additions & 20 deletions src/haptic/win32/SDL_syshaptic.c
Expand Up @@ -66,6 +66,7 @@ static struct
struct haptic_hwdata
{
LPDIRECTINPUTDEVICE2 device;
DWORD axes[3];
/* DIDEVCAPS capabilities; */
};

Expand Down Expand Up @@ -233,6 +234,7 @@ DI_DeviceObjectCallback(LPCDIDEVICEOBJECTINSTANCE dev, LPVOID pvRef)

if ((dev->dwType & DIDFT_AXIS) && (dev->dwFlags & DIDOI_FFACTUATOR)) {

haptic->hwdata->axes[haptic->naxes] = dev->dwOfs;
haptic->naxes++;

/* Currently using the artificial limit of 3 axes. */
Expand Down Expand Up @@ -345,7 +347,6 @@ SDL_SYS_HapticOpenFromInstance(SDL_Haptic * haptic, DIDEVICEINSTANCE instance)
goto acquire_err;
}


/* Enabling actuators. */
ret = IDirectInputDevice2_SendForceFeedbackCommand( haptic->hwdata->device,
DISFFC_SETACTUATORSON );
Expand Down Expand Up @@ -374,36 +375,22 @@ SDL_SYS_HapticOpenFromInstance(SDL_Haptic * haptic, DIDEVICEINSTANCE instance)
dipdw.dwData = 10000;
ret = IDirectInputDevice2_SetProperty( haptic->hwdata->device,
DIPROP_FFGAIN, &dipdw.diph );
if (FAILED(ret)) {
if (ret != DIERR_UNSUPPORTED) {
DI_SetError("Checking gain",ret);
goto acquire_err;
}
}
else { /* Gain is supported. */
if (!FAILED(ret)) { /* Gain is supported. */
haptic->supported |= SDL_HAPTIC_GAIN;
}
dipdw.diph.dwObj = 0;
dipdw.diph.dwHow = DIPH_DEVICE;
dipdw.dwData = DIPROPAUTOCENTER_OFF;
ret = IDirectInputDevice2_SetProperty( haptic->hwdata->device,
DIPROP_AUTOCENTER, &dipdw.diph );
if (FAILED(ret)) {
if (ret != DIERR_UNSUPPORTED) {
DI_SetError("Checking autocenter",ret);
goto acquire_err;
}
}
else { /* Autocenter is supported. */
if (!FAILED(ret)) { /* Autocenter is supported. */
haptic->supported |= SDL_HAPTIC_AUTOCENTER;
}


/* Check maximum effects. */
haptic->neffects = 128; /* TODO actually figure this out. */
haptic->nplaying = 128;


/* Prepare effects memory. */
haptic->effects = (struct haptic_effect *)
SDL_malloc(sizeof(struct haptic_effect) * haptic->neffects);
Expand Down Expand Up @@ -634,12 +621,12 @@ SDL_SYS_ToDIEFFECT( SDL_Haptic * haptic, DIEFFECT * dest, SDL_HapticEffect * src
SDL_OutOfMemory();
return -1;
}
axes[0] = DIJOFS_X; /* Always at least one axis. */
axes[0] = haptic->hwdata->axes[0]; /* Always at least one axis. */
if (dest->cAxes > 1) {
axes[1] = DIJOFS_Y;
axes[1] = haptic->hwdata->axes[1];
}
if (dest->cAxes > 2) {
axes[2] = DIJOFS_Z;
axes[2] = haptic->hwdata->axes[2];
}
dest->rgdwAxes = axes;
}
Expand Down

0 comments on commit b34c0b2

Please sign in to comment.