Haptic: Add some missing haptic types to test, and fix wrong array-sizes. Thanks, Elias! Fixes Bugzilla #2686. (along with the last several commits.)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
diff --git a/test/testhaptic.c b/test/testhaptic.c
index 92fcec5..2efd214 100644
--- a/test/testhaptic.c
+++ b/test/testhaptic.c
@@ -45,8 +45,8 @@ main(int argc, char **argv)
int i;
char *name;
int index;
- SDL_HapticEffect efx[5];
- int id[5];
+ SDL_HapticEffect efx[9];
+ int id[9];
int nefx;
unsigned int supported;
@@ -149,6 +149,7 @@ main(int argc, char **argv)
}
nefx++;
}
+
/* Now the classical constant effect. */
if (supported & SDL_HAPTIC_CONSTANT) {
SDL_Log(" effect %d: Constant Force\n", nefx);
@@ -166,6 +167,7 @@ main(int argc, char **argv)
}
nefx++;
}
+
/* The cute spring effect. */
if (supported & SDL_HAPTIC_SPRING) {
SDL_Log(" effect %d: Condition Spring\n", nefx);
@@ -185,6 +187,24 @@ main(int argc, char **argv)
}
nefx++;
}
+ /* The interesting damper effect. */
+ if (supported & SDL_HAPTIC_DAMPER) {
+ SDL_Log(" effect %d: Condition Damper\n", nefx);
+ efx[nefx].type = SDL_HAPTIC_DAMPER;
+ efx[nefx].condition.length = 5000;
+ for (i = 0; i < SDL_HapticNumAxes(haptic); i++) {
+ efx[nefx].condition.right_sat[i] = 0xFFFF;
+ efx[nefx].condition.left_sat[i] = 0xFFFF;
+ efx[nefx].condition.right_coeff[i] = 0x2000;
+ efx[nefx].condition.left_coeff[i] = 0x2000;
+ }
+ id[nefx] = SDL_HapticNewEffect(haptic, &efx[nefx]);
+ if (id[nefx] < 0) {
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "UPLOADING EFFECT ERROR: %s\n", SDL_GetError());
+ abort_execution();
+ }
+ nefx++;
+ }
/* The pretty awesome inertia effect. */
if (supported & SDL_HAPTIC_INERTIA) {
SDL_Log(" effect %d: Condition Inertia\n", nefx);
@@ -204,6 +224,44 @@ main(int argc, char **argv)
}
nefx++;
}
+ /* The hot friction effect. */
+ if (supported & SDL_HAPTIC_FRICTION) {
+ SDL_Log(" effect %d: Condition Friction\n", nefx);
+ efx[nefx].type = SDL_HAPTIC_FRICTION;
+ efx[nefx].condition.length = 5000;
+ for (i = 0; i < SDL_HapticNumAxes(haptic); i++) {
+ efx[nefx].condition.right_sat[i] = 0xFFFF;
+ efx[nefx].condition.left_sat[i] = 0xFFFF;
+ efx[nefx].condition.right_coeff[i] = 0x2000;
+ efx[nefx].condition.left_coeff[i] = 0x2000;
+ }
+ id[nefx] = SDL_HapticNewEffect(haptic, &efx[nefx]);
+ if (id[nefx] < 0) {
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "UPLOADING EFFECT ERROR: %s\n", SDL_GetError());
+ abort_execution();
+ }
+ nefx++;
+ }
+
+ /* Now we'll try a ramp effect */
+ if (supported & SDL_HAPTIC_RAMP) {
+ SDL_Log(" effect %d: Ramp\n", nefx);
+ efx[nefx].type = SDL_HAPTIC_RAMP;
+ efx[nefx].ramp.direction.type = SDL_HAPTIC_CARTESIAN;
+ efx[nefx].ramp.direction.dir[0] = 1; /* Force comes from */
+ efx[nefx].ramp.direction.dir[1] = -1; /* the north-east. */
+ efx[nefx].ramp.length = 5000;
+ efx[nefx].ramp.start = 0x4000;
+ efx[nefx].ramp.end = -0x4000;
+ efx[nefx].ramp.attack_length = 1000;
+ efx[nefx].ramp.fade_length = 1000;
+ id[nefx] = SDL_HapticNewEffect(haptic, &efx[nefx]);
+ if (id[nefx] < 0) {
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "UPLOADING EFFECT ERROR: %s\n", SDL_GetError());
+ abort_execution();
+ }
+ nefx++;
+ }
/* Finally we'll try a left/right effect. */
if (supported & SDL_HAPTIC_LEFTRIGHT) {