Using errno for more verbosity in errors.
1.1 --- a/src/haptic/linux/SDL_syshaptic.c Thu Jul 03 09:58:27 2008 +0000
1.2 +++ b/src/haptic/linux/SDL_syshaptic.c Thu Jul 03 21:03:25 2008 +0000
1.3 @@ -37,6 +37,7 @@
1.4 #include <fcntl.h>
1.5 #include <linux/limits.h>
1.6 #include <string.h>
1.7 +#include <errno.h>
1.8
1.9
1.10 #define MAX_HAPTICS 32
1.11 @@ -88,7 +89,7 @@
1.12 ret = 0;
1.13
1.14 if (ioctl(fd, EVIOCGBIT(EV_FF, sizeof(unsigned long) * 4), features) < 0) {
1.15 - SDL_SetError("Unable to get device's haptic abilities.");
1.16 + SDL_SetError("Unable to get device's haptic abilities: %s", strerror(errno));
1.17 return -1;
1.18 }
1.19
1.20 @@ -212,7 +213,7 @@
1.21
1.22 /* Set the effects */
1.23 if (ioctl(fd, EVIOCGEFFECTS, &haptic->neffects) < 0) {
1.24 - SDL_SetError("Unable to query haptic device memory.");
1.25 + SDL_SetError("Unable to query haptic device memory: %s", strerror(errno));
1.26 goto open_err;
1.27 }
1.28 haptic->effects = (struct haptic_effect *)
1.29 @@ -249,7 +250,8 @@
1.30 /* Open the character device */
1.31 fd = open(SDL_hapticlist[haptic->index].fname, O_RDWR, 0);
1.32 if (fd < 0) {
1.33 - SDL_SetError("Unable to open %s\n", SDL_hapticlist[haptic->index]);
1.34 + SDL_SetError("Unable to open %s: %s",
1.35 + SDL_hapticlist[haptic->index], strerror(errno));
1.36 return -1;
1.37 }
1.38
1.39 @@ -477,7 +479,7 @@
1.40
1.41
1.42 default:
1.43 - SDL_SetError("Unknown haptic effect type.");
1.44 + SDL_SetError("Unknown haptic effect type");
1.45 return -1;
1.46 }
1.47
1.48 @@ -511,7 +513,7 @@
1.49
1.50 /* Upload the effect */
1.51 if (ioctl(haptic->hwdata->fd, EVIOCSFF, linux_effect) < 0) {
1.52 - SDL_SetError("Error uploading effect to the haptic device.");
1.53 + SDL_SetError("Error uploading effect to the haptic device: %s", strerror(errno));
1.54 goto new_effect_err;
1.55 }
1.56
1.57 @@ -543,7 +545,7 @@
1.58
1.59 /* See if it can be uploaded. */
1.60 if (ioctl(haptic->hwdata->fd, EVIOCSFF, &linux_effect) < 0) {
1.61 - SDL_SetError("Error updating the haptic effect.");
1.62 + SDL_SetError("Error updating the haptic effect: %s", strerror(errno));
1.63 return -1;
1.64 }
1.65
1.66 @@ -568,7 +570,7 @@
1.67 run.value = 1;
1.68
1.69 if (write(haptic->hwdata->fd, (const void*) &run, sizeof(run)) < 0) {
1.70 - SDL_SetError("Unable to run the haptic effect.");
1.71 + SDL_SetError("Unable to run the haptic effect: %s", strerror(errno));
1.72 return -1;
1.73 }
1.74
1.75 @@ -589,7 +591,7 @@
1.76 stop.value = 0;
1.77
1.78 if (write(haptic->hwdata->fd, (const void*) &stop, sizeof(stop)) < 0) {
1.79 - SDL_SetError("Unable to stop the haptic effect.");
1.80 + SDL_SetError("Unable to stop the haptic effect: %s", strerror(errno));
1.81 return -1;
1.82 }
1.83
1.84 @@ -604,7 +606,8 @@
1.85 SDL_SYS_HapticDestroyEffect(SDL_Haptic * haptic, struct haptic_effect * effect)
1.86 {
1.87 if (ioctl(haptic->hwdata->fd, EVIOCRMFF, effect->hweffect->effect.id) < 0) {
1.88 - SDL_SetError("Error removing the effect from the haptic device.");
1.89 + SDL_SetError("Error removing the effect from the haptic device: %s",
1.90 + strerror(errno));
1.91 }
1.92 SDL_free(effect->hweffect);
1.93 effect->hweffect = NULL;
1.94 @@ -649,7 +652,7 @@
1.95 ie.value = (0xFFFFUL * gain) / 100;
1.96
1.97 if (write(haptic->hwdata->fd, &ie, sizeof(ie)) < 0) {
1.98 - SDL_SetError("Error setting gain.");
1.99 + SDL_SetError("Error setting gain: %s", strerror(errno));
1.100 return -1;
1.101 }
1.102
1.103 @@ -670,7 +673,7 @@
1.104 ie.value = (0xFFFFUL * autocenter) / 100;
1.105
1.106 if (write(haptic->hwdata->fd, &ie, sizeof(ie)) < 0) {
1.107 - SDL_SetError("Error setting autocenter.");
1.108 + SDL_SetError("Error setting autocenter: %s", strerror(errno));
1.109 return -1;
1.110 }
1.111