Replaced SDL_HAPTIC_SQUARE with SDL_HAPTIC_LEFTRIGHT.

We needed a bit, so we're hoping no one needs this effect, especially when
it's fairly close to SDL_HAPTIC_SINE, we hope.

SDL_HAPTIC_LEFTRIGHT maps to XInput's functionality, so this removes the SINE
code for the XInput driver to keep things clean.

This also makes the simplified Rumble API use SDL_HAPTIC_LEFTRIGHT if
SDL_HAPTIC_SINE isn't available, to keep XInput working.

When we break the ABI, and can extend the supported capabilities field from
a Uint16, we'll add SDL_HAPTIC_SQUARE back in.

This patch is based on work by Ethan Lee.
This commit is contained in:
Ryan C. Gordon 2013-08-10 13:38:09 -04:00
parent 24097af6ac
commit c35c4a6f18
6 changed files with 146 additions and 62 deletions

View file

@ -213,6 +213,22 @@ main(int argc, char **argv)
nefx++;
}
/* First we'll try a SINE effect. */
if (supported & SDL_HAPTIC_LEFTRIGHT) {
printf(" effect %d: Left/Right\n", nefx);
efx[nefx].type = SDL_HAPTIC_LEFTRIGHT;
efx[nefx].leftright.length = 5000;
efx[nefx].leftright.large_magnitude = 0x3000;
efx[nefx].leftright.small_magnitude = 0xFFFF;
id[nefx] = SDL_HapticNewEffect(haptic, &efx[nefx]);
if (id[nefx] < 0) {
printf("UPLOADING EFFECT ERROR: %s\n", SDL_GetError());
abort_execution();
}
nefx++;
}
printf
("\nNow playing effects for 5 seconds each with 1 second delay between\n");
for (i = 0; i < nefx; i++) {
@ -260,8 +276,9 @@ HapticPrintSupported(SDL_Haptic * haptic)
printf(" constant\n");
if (supported & SDL_HAPTIC_SINE)
printf(" sine\n");
if (supported & SDL_HAPTIC_SQUARE)
printf(" square\n");
/* !!! FIXME: put this back when we have more bits in 2.1 */
/*if (supported & SDL_HAPTIC_SQUARE)
printf(" square\n");*/
if (supported & SDL_HAPTIC_TRIANGLE)
printf(" triangle\n");
if (supported & SDL_HAPTIC_SAWTOOTHUP)
@ -280,6 +297,8 @@ HapticPrintSupported(SDL_Haptic * haptic)
printf(" intertia\n");
if (supported & SDL_HAPTIC_CUSTOM)
printf(" custom\n");
if (supported & SDL_HAPTIC_LEFTRIGHT)
printf(" left/right\n");
printf(" Supported capabilities:\n");
if (supported & SDL_HAPTIC_GAIN)
printf(" gain\n");