Last active
September 7, 2019 19:56
-
-
Save jdinalt/d9977cd1d7106487736ef0b43f0a427d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff -Naur SDL2-2.0.10/src/haptic/DSDL_Log.h SDL2-2.0.10.x/src/haptic/DSDL_Log.h | |
--- SDL2-2.0.10/src/haptic/DSDL_Log.h 1969-12-31 16:00:00.000000000 -0800 | |
+++ SDL2-2.0.10.x/src/haptic/DSDL_Log.h 2019-09-04 10:06:57.000000000 -0700 | |
@@ -0,0 +1,62 @@ | |
+#ifndef DSDL_LOG_H | |
+#define DSDL_LOG_H | |
+ | |
+#include <stdarg.h> | |
+ | |
+#define DSDL_LOG_ENABLED 1 | |
+#define DSDL_LOG_ENABLE_BACKTRACE 0 | |
+#define DSDL_LOG_MAX_BACKTRACE 6 | |
+ | |
+#define DSDL_LOG_PATH "/tmp/sdl.log" | |
+ | |
+/* | |
+ * All log operations are wrapped in macros. This serves two functions: | |
+ * | |
+ * 1. It makes it very quick and easy to convert the log calls into no-ops. | |
+ * 2. This allows us to transparently include function and line information. | |
+ */ | |
+#if DSDL_LOG_ENABLED | |
+ | |
+#define DSDL_LOG(...) \ | |
+ DSDL_Log__log(__func__, __LINE__, __VA_ARGS__) | |
+ | |
+#if DSDL_LOG_ENABLE_BACKTRACE | |
+#define DSDL_BACKTRACE(...) \ | |
+ DSDL_Log__logBacktrace(__func__, __LINE__, 2, DSDL_LOG_MAX_BACKTRACE, __VA_ARGS__) | |
+#else | |
+#define DSDL_BACKTRACE(...) \ | |
+ DSDL_LOG(__VA_ARGS__) | |
+#endif | |
+ | |
+#define DSDL_TRACE() \ | |
+do { \ | |
+ DSDL_Log__printHeader(__func__, __LINE__); \ | |
+ DSDL_Log__print("\n"); \ | |
+} while(0) | |
+ | |
+#else | |
+ | |
+#define DSDL_LOG(...) (void)0 | |
+#define DSDL_BACKTRACE(...) (void)0 | |
+#define DSDL_TRACE() (void)0 | |
+ | |
+#endif /* DSDL_LOG_ENABLED */ | |
+ | |
+/* Must be called before log functions will print anything */ | |
+void DSDL__init(void); | |
+ | |
+/* Raw log operations */ | |
+int DSDL_Log__print(char const *format, ...) | |
+__attribute__ ((format (printf, 1, 2))); | |
+int DSDL_Log__vaPrint(const char * format, va_list ap); | |
+int DSDL_Log__printHeader(const char *func, int line); | |
+int DSDL_Log__printBacktrace(int skip, int max); | |
+ | |
+/* These are just wrappers for the above */ | |
+int DSDL_Log__log(const char *func, int line, const char *format, ...) | |
+__attribute__ ((format (printf, 3, 4))); | |
+int DSDL_Log__logBacktrace(const char *func, int line, int skip, int max, | |
+ const char *format, ...) | |
+__attribute__ ((format (printf, 5, 6))); | |
+ | |
+#endif /* DSDL_LOG_H */ | |
diff -Naur SDL2-2.0.10/src/haptic/linux/SDL_syshaptic.c SDL2-2.0.10.x/src/haptic/linux/SDL_syshaptic.c | |
--- SDL2-2.0.10/src/haptic/linux/SDL_syshaptic.c 2019-07-24 21:32:36.000000000 -0700 | |
+++ SDL2-2.0.10.x/src/haptic/linux/SDL_syshaptic.c 2019-09-04 10:06:12.000000000 -0700 | |
@@ -90,6 +90,53 @@ | |
(((1UL << ((nr) & 31)) & (((const unsigned int *) addr)[(nr) >> 5])) != 0) | |
#define EV_TEST(ev,f) \ | |
if (test_bit((ev), features)) ret |= (f); | |
+ | |
+/* DSDL Sys Defs */ | |
+#include "../DSDL_Log.h" | |
+ | |
+static const char *DSDL_FFName(int type) { | |
+ switch(type) { | |
+ case FF_RUMBLE: | |
+ return "FF_RUMBLE"; | |
+ case FF_CONSTANT: | |
+ return "FF_CONSTANT"; | |
+ case FF_PERIODIC: | |
+ return "FF_PERIODIC"; | |
+ default: | |
+ return "FF_OTHER"; | |
+ } | |
+} | |
+ | |
+static void DSDL_FFPrefix(struct ff_effect *e) | |
+{ | |
+ DSDL_Log__print("type=0x%x %s, id=%d, dir=%u, len=%u, del=%u", | |
+ (int)e->type, | |
+ DSDL_FFName(e->type), | |
+ (int)e->id, | |
+ (unsigned)e->direction, | |
+ (unsigned)e->replay.length, | |
+ (unsigned)e->replay.delay); | |
+} | |
+ | |
+static void DSDL_DumpEffect(struct ff_effect *e) { | |
+ DSDL_FFPrefix(e); | |
+ | |
+ switch (e->type) { | |
+ case FF_CONSTANT: | |
+ DSDL_Log__print("str=%d, alen%u, alev=%u, flen=%u, flev=%u\n", | |
+ (int)e->u.constant.level, | |
+ (unsigned)e->u.constant.envelope.attack_length, | |
+ (unsigned)e->u.constant.envelope.attack_level, | |
+ (unsigned)e->u.constant.envelope.fade_length, | |
+ (unsigned)e->u.constant.envelope.fade_level); | |
+ break; | |
+ default: | |
+ DSDL_Log__print("\n"); | |
+ break; | |
+ }; | |
+} | |
+/* End DSDL Sys Defs */ | |
+ | |
/* | |
* Test whether a device has haptic properties. | |
* Returns available properties or 0 if there are none. | |
@@ -186,6 +233,7 @@ | |
SDL_UDEV_Scan(); | |
#endif /* SDL_USE_LIBUDEV */ | |
+ | |
return numhaptics; | |
} | |
@@ -389,6 +437,7 @@ | |
close(fd); | |
} | |
+ DSDL_LOG("name=%s\n", name); | |
return name; | |
} | |
@@ -399,6 +448,7 @@ | |
static int | |
SDL_SYS_HapticOpenFromFD(SDL_Haptic * haptic, int fd) | |
{ | |
+ DSDL_TRACE(); | |
/* Allocate the hwdata */ | |
haptic->hwdata = (struct haptic_hwdata *) | |
SDL_malloc(sizeof(*haptic->hwdata)); | |
@@ -454,6 +504,9 @@ | |
SDL_hapticlist_item *item; | |
item = HapticByDevIndex(haptic->index); | |
+ | |
+ DSDL_LOG("Open %s\n", item->fname); | |
+ | |
/* Open the character device */ | |
fd = open(item->fname, O_RDWR, 0); | |
if (fd < 0) { | |
@@ -542,6 +595,8 @@ | |
int ret; | |
SDL_hapticlist_item *item; | |
+ DSDL_TRACE(); | |
+ | |
/* Find the joystick in the haptic list. */ | |
for (item = SDL_hapticlist; item; item = item->next) { | |
if (SDL_strcmp(item->fname, joystick->hwdata->fname) == 0) { | |
@@ -922,7 +977,6 @@ | |
return 0; | |
} | |
- | |
/* | |
* Creates a new haptic effect. | |
*/ | |
@@ -932,6 +986,8 @@ | |
{ | |
struct ff_effect *linux_effect; | |
+ DSDL_TRACE(); | |
+ | |
/* Allocate the hardware effect */ | |
effect->hweffect = (struct haptic_hweffect *) | |
SDL_malloc(sizeof(struct haptic_hweffect)); | |
@@ -942,17 +998,29 @@ | |
/* Prepare the ff_effect */ | |
linux_effect = &effect->hweffect->effect; | |
if (SDL_SYS_ToFFEffect(linux_effect, base) != 0) { | |
+ DSDL_BACKTRACE("SDL_SYS_ToFFEffect failed\n"); | |
goto new_effect_err; | |
} | |
linux_effect->id = -1; /* Have the kernel give it an id */ | |
- | |
+ | |
/* Upload the effect */ | |
if (ioctl(haptic->hwdata->fd, EVIOCSFF, linux_effect) < 0) { | |
+ int err = errno; | |
+ char const * err_str = strerror(err); | |
+ | |
+ DSDL_BACKTRACE("New failed %s\n", err_str); | |
SDL_SetError("Haptic: Error uploading effect to the device: %s", | |
- strerror(errno)); | |
+ err_str); | |
goto new_effect_err; | |
} | |
+ /* | |
+ * Dump the effect after we call into the kernel, as the kernel assigns the | |
+ * effect index. | |
+ */ | |
+ DSDL_LOG("New haptic=%p, effect=%p, ", haptic, effect); | |
+ DSDL_DumpEffect(linux_effect); | |
+ | |
return 0; | |
new_effect_err: | |
@@ -961,7 +1029,6 @@ | |
return -1; | |
} | |
- | |
/* | |
* Updates an effect. | |
* | |
@@ -974,6 +1041,7 @@ | |
SDL_HapticEffect * data) | |
{ | |
struct ff_effect linux_effect; | |
+ int retry_count = 0; | |
/* Create the new effect */ | |
if (SDL_SYS_ToFFEffect(&linux_effect, data) != 0) { | |
@@ -981,10 +1049,44 @@ | |
} | |
linux_effect.id = effect->hweffect->effect.id; | |
+ DSDL_LOG("Update, haptic=%p, effect=%p, ", haptic, effect); | |
+ DSDL_DumpEffect(&linux_effect); | |
+ | |
+retry: | |
/* See if it can be uploaded. */ | |
if (ioctl(haptic->hwdata->fd, EVIOCSFF, &linux_effect) < 0) { | |
- return SDL_SetError("Haptic: Error updating the effect: %s", | |
- strerror(errno)); | |
+ int err = errno; | |
+ char const * err_str = strerror(err); | |
+ | |
+ DSDL_BACKTRACE("Update failed %s\n", err_str); | |
+ | |
+ /* | |
+ * For some strange and inexplicable reason, the kernel driver appears | |
+ * to "forget" about our effect for... "reasons." | |
+ * | |
+ * The only difference between creating a "new" effect and "updating" an | |
+ * effect, in the kernel API, is the use of the effect id of "-1" to | |
+ * request a new id. | |
+ * | |
+ * If we get EINVAL, try to reinitialize the effect by setting the index | |
+ * back to -1, but don't retry more than once. EINVAL is pretty vague | |
+ * and there could be other causes. | |
+ */ | |
+ if ((err == EINVAL) && (retry_count++ == 0)) { | |
+ DSDL_LOG("Retry as id -1\n"); | |
+ linux_effect.id = -1; | |
+ goto retry; | |
+ } | |
+ return SDL_SetError("Haptic: Error updating the effect: %s", err_str); | |
+ } | |
+ | |
+ /* | |
+ * If this is non-zero, we have reinitialized the effect and we need to | |
+ * update the local copy of the index with whatever the kernel has assigned. | |
+ */ | |
+ if (retry_count) { | |
+ DSDL_LOG("retry success, new id = %d\n", linux_effect.id); | |
+ effect->hweffect->effect.id = linux_effect.id; | |
} | |
/* Copy the new effect into memory. */ | |
@@ -1010,8 +1112,13 @@ | |
/* We don't actually have infinity here, so we just do INT_MAX which is pretty damn close. */ | |
run.value = (iterations > INT_MAX) ? INT_MAX : iterations; | |
+ DSDL_LOG("Run: id=%d, itr=%d\n", (int)run.code, (int)run.value); | |
if (write(haptic->hwdata->fd, (const void *) &run, sizeof(run)) < 0) { | |
- return SDL_SetError("Haptic: Unable to run the effect: %s", strerror(errno)); | |
+ int err = errno; | |
+ char const * err_str = strerror(err); | |
+ | |
+ DSDL_BACKTRACE("Run failed %s\n", err_str); | |
+ return SDL_SetError("Haptic: Unable to run the effect: %s", err_str); | |
} | |
return 0; | |
@@ -1030,7 +1137,10 @@ | |
stop.code = effect->hweffect->effect.id; | |
stop.value = 0; | |
+ DSDL_LOG("Stop: %d\n", (int)stop.code); | |
+ | |
if (write(haptic->hwdata->fd, (const void *) &stop, sizeof(stop)) < 0) { | |
+ DSDL_BACKTRACE("Stop failed!\n"); | |
return SDL_SetError("Haptic: Unable to stop the effect: %s", | |
strerror(errno)); | |
} | |
@@ -1045,9 +1155,13 @@ | |
void | |
SDL_SYS_HapticDestroyEffect(SDL_Haptic * haptic, struct haptic_effect *effect) | |
{ | |
+ DSDL_LOG("Destroy: %d\n", (int)effect->hweffect->effect.id); | |
if (ioctl(haptic->hwdata->fd, EVIOCRMFF, effect->hweffect->effect.id) < 0) { | |
+ int rc = errno; | |
+ | |
+ DSDL_BACKTRACE("Destory failed! %d %s\n", rc, strerror(rc)); | |
SDL_SetError("Haptic: Error removing the effect from the device: %s", | |
- strerror(errno)); | |
+ strerror(rc)); | |
} | |
SDL_free(effect->hweffect); | |
effect->hweffect = NULL; | |
@@ -1061,6 +1175,7 @@ | |
SDL_SYS_HapticGetEffectStatus(SDL_Haptic * haptic, | |
struct haptic_effect *effect) | |
{ | |
+ DSDL_LOG("Get status %d\n", (int)effect->hweffect->effect.id); | |
#if 0 /* Not supported atm. */ | |
struct input_event ie; | |
@@ -1087,11 +1202,13 @@ | |
{ | |
struct input_event ie; | |
+ DSDL_LOG("Set gain %d\n", (int)gain); | |
ie.type = EV_FF; | |
ie.code = FF_GAIN; | |
ie.value = (0xFFFFUL * gain) / 100; | |
if (write(haptic->hwdata->fd, &ie, sizeof(ie)) < 0) { | |
+ DSDL_BACKTRACE("Set gain failed!\n"); | |
return SDL_SetError("Haptic: Error setting gain: %s", strerror(errno)); | |
} | |
@@ -1107,11 +1224,16 @@ | |
{ | |
struct input_event ie; | |
+ | |
ie.type = EV_FF; | |
ie.code = FF_AUTOCENTER; | |
ie.value = (0xFFFFUL * autocenter) / 100; | |
+ DSDL_LOG("Set autocenter %d, %d\n", (int)autocenter, (int)ie.value); | |
+ | |
if (write(haptic->hwdata->fd, &ie, sizeof(ie)) < 0) { | |
+ DSDL_BACKTRACE("Set autocenter failed!\n"); | |
+ | |
return SDL_SetError("Haptic: Error setting autocenter: %s", strerror(errno)); | |
} | |
@@ -1147,6 +1269,8 @@ | |
{ | |
int i, ret; | |
+ DSDL_TRACE(); | |
+ | |
/* Linux does not support this natively so we have to loop. */ | |
for (i = 0; i < haptic->neffects; i++) { | |
if (haptic->effects[i].hweffect != NULL) { | |
diff -Naur SDL2-2.0.10/src/haptic/SDL_haptic.c SDL2-2.0.10.x/src/haptic/SDL_haptic.c | |
--- SDL2-2.0.10/src/haptic/SDL_haptic.c 2019-07-24 21:32:36.000000000 -0700 | |
+++ SDL2-2.0.10.x/src/haptic/SDL_haptic.c 2019-09-04 09:53:09.000000000 -0700 | |
@@ -32,6 +32,173 @@ | |
static SDL_Haptic *SDL_haptics = NULL; | |
#endif | |
+/* DSDL_Log */ | |
+#include "DSDL_Log.h" | |
+#include <stdint.h> | |
+#include <unistd.h> | |
+#include <stdio.h> | |
+#include <inttypes.h> | |
+#include <time.h> | |
+#include <execinfo.h> | |
+ | |
+ | |
+struct DSDL_Log_ { | |
+ FILE *file; | |
+ uint64_t start_time; | |
+}; | |
+ | |
+struct DSDL_Log_ DSDL_Log__static; | |
+ | |
+static uint64_t DSDL__useconds(void) | |
+{ | |
+ struct timespec now; | |
+ | |
+ if (clock_gettime(CLOCK_MONOTONIC_RAW, &now) == 0) { | |
+ return ((uint64_t)now.tv_nsec / 1000UL) + | |
+ ((uint64_t)now.tv_sec * 1000UL * 1000UL); | |
+ } | |
+ | |
+ return 0; | |
+} | |
+ | |
+void | |
+DSDL__init(void) | |
+{ | |
+ static const char *pathname = DSDL_LOG_PATH; | |
+ | |
+ if (DSDL_Log__static.file != NULL) { | |
+ return; | |
+ } | |
+ | |
+ DSDL_Log__static.start_time = DSDL__useconds(); | |
+ DSDL_Log__static.file = fopen(pathname, "a"); | |
+ DSDL_LOG("Log initialized\n"); | |
+} | |
+ | |
+ | |
+int | |
+DSDL_Log__vaPrint(const char * format, va_list ap) | |
+{ | |
+ int count = 0; | |
+ | |
+ if (DSDL_Log__static.file == NULL) { | |
+ return 0; | |
+ } | |
+ | |
+ count += vfprintf(DSDL_Log__static.file, format, ap); | |
+ | |
+ return count; | |
+} | |
+ | |
+int | |
+DSDL_Log__print(char const *format, ...) | |
+{ | |
+ va_list ap; | |
+ int count; | |
+ | |
+ va_start (ap, format); | |
+ count = DSDL_Log__vaPrint(format, ap); | |
+ va_end (ap); | |
+ | |
+ return count; | |
+} | |
+ | |
+int | |
+DSDL_Log__printHeader(const char *func, int line) | |
+{ | |
+ int count = 0; | |
+ uint64_t ts; | |
+ pid_t pid; | |
+ | |
+ ts = DSDL__useconds() - DSDL_Log__static.start_time; | |
+ pid = getpid(); | |
+ count += DSDL_Log__print("%d %" PRIu64 " %s:%d: ", (int)pid, ts, func, line); | |
+ | |
+ return count; | |
+} | |
+ | |
+int | |
+DSDL_Log__printBacktrace(int skip, int max) | |
+{ | |
+ static const int kMaxTrace = 32; | |
+ | |
+ void *trace_buf[kMaxTrace]; | |
+ char **symbols; | |
+ size_t trace_size; | |
+ int size; | |
+ char **symbol; | |
+ char **end; | |
+ int count = 0; | |
+ | |
+ | |
+ size = kMaxTrace - skip; | |
+ size = max > size ? size : max; | |
+ | |
+ if (size <= 0) { | |
+ return 0; | |
+ } | |
+ trace_size = backtrace(trace_buf, size); | |
+ if (trace_size == 0) { | |
+ return 0; | |
+ } | |
+ size = trace_size - skip; | |
+ | |
+ symbols = backtrace_symbols(trace_buf + skip, size); | |
+ if (symbols == NULL) { | |
+ return 0; | |
+ } | |
+ | |
+ for (symbol = symbols, end = symbol + size; symbol != end; ++symbol) { | |
+ count += DSDL_Log__print(" %s\n", *symbol); | |
+ } | |
+ free(symbols); | |
+ return count; | |
+} | |
+ | |
+int | |
+DSDL_Log__log(const char *func, int line, const char *format, ...) | |
+{ | |
+ va_list ap; | |
+ int count = 0; | |
+ | |
+ if (!DSDL_Log__static.file) { | |
+ return 0; | |
+ } | |
+ count = DSDL_Log__printHeader(func, line); | |
+ | |
+ va_start(ap, format); | |
+ count += DSDL_Log__vaPrint(format, ap); | |
+ va_end(ap); | |
+ fflush(DSDL_Log__static.file); | |
+ | |
+ return count; | |
+} | |
+ | |
+int | |
+DSDL_Log__logBacktrace(const char *func, int line, int skip, int max, | |
+ const char *format, ...) | |
+{ | |
+ va_list ap; | |
+ int count = 0; | |
+ | |
+ if (!DSDL_Log__static.file) { | |
+ return 0; | |
+ } | |
+ count = DSDL_Log__printHeader(func, line); | |
+ | |
+ va_start(ap, format); | |
+ count += DSDL_Log__vaPrint(format, ap); | |
+ va_end(ap); | |
+ | |
+ count += DSDL_Log__printBacktrace(skip, max); | |
+ fflush(DSDL_Log__static.file); | |
+ | |
+ return count; | |
+} | |
+ | |
+ | |
+/* End DSDL_Log */ | |
+ | |
/* | |
* Initializes the Haptic devices. | |
*/ | |
@@ -40,6 +207,10 @@ | |
{ | |
int status; | |
+#if DSDL_LOG_ENABLED | |
+ DSDL__init(); | |
+#endif | |
+ | |
status = SDL_SYS_HapticInit(); | |
if (status >= 0) { | |
status = 0; | |
@@ -156,6 +327,8 @@ | |
haptic->next = SDL_haptics; | |
SDL_haptics = haptic; | |
+ DSDL_LOG("Opened device %d=%p\n", device_index, haptic); | |
+ | |
/* Disable autocenter and set gain to max. */ | |
if (haptic->supported & SDL_HAPTIC_GAIN) | |
SDL_HapticSetGain(haptic, 100); | |
@@ -275,6 +448,8 @@ | |
SDL_Haptic *haptic; | |
SDL_Haptic *hapticlist; | |
+ DSDL_TRACE(); | |
+ | |
/* Make sure there is room. */ | |
if (SDL_NumHaptics() <= 0) { | |
SDL_SetError("Haptic: There are %d haptic devices available", | |
@@ -342,6 +517,8 @@ | |
SDL_Haptic *hapticlist; | |
SDL_Haptic *hapticlistprev; | |
+ DSDL_TRACE(); | |
+ | |
/* Must be valid */ | |
if (!ValidHaptic(haptic)) { | |
return; | |
@@ -393,6 +570,7 @@ | |
void | |
SDL_HapticQuit(void) | |
{ | |
+ DSDL_TRACE(); | |
while (SDL_haptics) { | |
SDL_HapticClose(SDL_haptics); | |
} | |
@@ -406,6 +584,7 @@ | |
int | |
SDL_HapticNumEffects(SDL_Haptic * haptic) | |
{ | |
+ DSDL_TRACE(); | |
if (!ValidHaptic(haptic)) { | |
return -1; | |
} | |
@@ -420,6 +599,7 @@ | |
int | |
SDL_HapticNumEffectsPlaying(SDL_Haptic * haptic) | |
{ | |
+ DSDL_TRACE(); | |
if (!ValidHaptic(haptic)) { | |
return -1; | |
} | |
@@ -434,10 +614,12 @@ | |
unsigned int | |
SDL_HapticQuery(SDL_Haptic * haptic) | |
{ | |
+ DSDL_TRACE(); | |
if (!ValidHaptic(haptic)) { | |
return 0; /* same as if no effects were supported */ | |
} | |
+ DSDL_LOG("Supported=0x%lx\n", (long)haptic->supported); | |
return haptic->supported; | |
} | |
@@ -448,6 +630,7 @@ | |
int | |
SDL_HapticNumAxes(SDL_Haptic * haptic) | |
{ | |
+ DSDL_TRACE(); | |
if (!ValidHaptic(haptic)) { | |
return -1; | |
} | |
@@ -483,8 +666,17 @@ | |
return -1; | |
} | |
+ if (effect == NULL) { | |
+ DSDL_BACKTRACE("NULL effect pointer\n"); | |
+ SDL_SetError("Haptic: NULL effect."); | |
+ | |
+ return -1; | |
+ } | |
+ | |
/* Check to see if effect is supported */ | |
if (SDL_HapticEffectSupported(haptic, effect) == SDL_FALSE) { | |
+ DSDL_BACKTRACE("Request for unsupported effect 0x%lx & 0x%lx == 0\n", | |
+ (unsigned long)haptic->supported, (unsigned long)effect->type); | |
return SDL_SetError("Haptic: Effect not supported by haptic device."); | |
} | |
@@ -495,15 +687,18 @@ | |
/* Now let the backend create the real effect */ | |
if (SDL_SYS_HapticNewEffect(haptic, &haptic->effects[i], effect) | |
!= 0) { | |
+ DSDL_BACKTRACE("Backend failed to create effect\n"); | |
return -1; /* Backend failed to create effect */ | |
} | |
SDL_memcpy(&haptic->effects[i].effect, effect, | |
sizeof(SDL_HapticEffect)); | |
+ DSDL_LOG("effect index=%d\n", i); | |
return i; | |
} | |
} | |
+ DSDL_BACKTRACE("Haptic: Device has no free space left.\n"); | |
return SDL_SetError("Haptic: Device has no free space left."); | |
} | |
@@ -533,6 +728,7 @@ | |
/* Can't change type dynamically. */ | |
if (data->type != haptic->effects[effect].effect.type) { | |
+ DSDL_BACKTRACE("Updating effect type is illegal\n"); | |
return SDL_SetError("Haptic: Updating effect type is illegal."); | |
} | |
@@ -555,6 +751,7 @@ | |
SDL_HapticRunEffect(SDL_Haptic * haptic, int effect, Uint32 iterations) | |
{ | |
if (!ValidHaptic(haptic) || !ValidEffect(haptic, effect)) { | |
+ DSDL_BACKTRACE("Invalid effect %d\n", effect); | |
return -1; | |
} | |
@@ -573,7 +770,9 @@ | |
int | |
SDL_HapticStopEffect(SDL_Haptic * haptic, int effect) | |
{ | |
+ DSDL_TRACE(); | |
if (!ValidHaptic(haptic) || !ValidEffect(haptic, effect)) { | |
+ DSDL_BACKTRACE("Invalid effect %d\n", effect); | |
return -1; | |
} | |
@@ -591,6 +790,7 @@ | |
void | |
SDL_HapticDestroyEffect(SDL_Haptic * haptic, int effect) | |
{ | |
+ DSDL_TRACE(); | |
if (!ValidHaptic(haptic) || !ValidEffect(haptic, effect)) { | |
return; | |
} | |
@@ -609,6 +809,7 @@ | |
int | |
SDL_HapticGetEffectStatus(SDL_Haptic * haptic, int effect) | |
{ | |
+ DSDL_TRACE(); | |
if (!ValidHaptic(haptic) || !ValidEffect(haptic, effect)) { | |
return -1; | |
} | |
@@ -629,15 +830,19 @@ | |
const char *env; | |
int real_gain, max_gain; | |
+ DSDL_LOG("Set gain=%d\n", gain); | |
+ | |
if (!ValidHaptic(haptic)) { | |
return -1; | |
} | |
if ((haptic->supported & SDL_HAPTIC_GAIN) == 0) { | |
+ DSDL_BACKTRACE("Device does not support setting gain\n"); | |
return SDL_SetError("Haptic: Device does not support setting gain."); | |
} | |
if ((gain < 0) || (gain > 100)) { | |
+ DSDL_BACKTRACE("Gain must be between 0 and 100\n"); | |
return SDL_SetError("Haptic: Gain must be between 0 and 100."); | |
} | |
@@ -671,6 +876,8 @@ | |
int | |
SDL_HapticSetAutocenter(SDL_Haptic * haptic, int autocenter) | |
{ | |
+ DSDL_LOG("autocenter=%d\n", autocenter); | |
+ | |
if (!ValidHaptic(haptic)) { | |
return -1; | |
} | |
@@ -696,6 +903,7 @@ | |
int | |
SDL_HapticPause(SDL_Haptic * haptic) | |
{ | |
+ DSDL_TRACE(); | |
if (!ValidHaptic(haptic)) { | |
return -1; | |
} | |
@@ -713,6 +921,7 @@ | |
int | |
SDL_HapticUnpause(SDL_Haptic * haptic) | |
{ | |
+ DSDL_TRACE(); | |
if (!ValidHaptic(haptic)) { | |
return -1; | |
} | |
@@ -730,6 +939,7 @@ | |
int | |
SDL_HapticStopAll(SDL_Haptic * haptic) | |
{ | |
+ DSDL_TRACE(); | |
if (!ValidHaptic(haptic)) { | |
return -1; | |
} | |
@@ -743,6 +953,7 @@ | |
int | |
SDL_HapticRumbleSupported(SDL_Haptic * haptic) | |
{ | |
+ DSDL_TRACE(); | |
if (!ValidHaptic(haptic)) { | |
return -1; | |
} | |
@@ -759,6 +970,7 @@ | |
{ | |
SDL_HapticEffect *efx = &haptic->rumble_effect; | |
+ DSDL_TRACE(); | |
if (!ValidHaptic(haptic)) { | |
return -1; | |
} | |
@@ -802,6 +1014,7 @@ | |
SDL_HapticEffect *efx; | |
Sint16 magnitude; | |
+ DSDL_TRACE(); | |
if (!ValidHaptic(haptic)) { | |
return -1; | |
} | |
@@ -842,6 +1055,7 @@ | |
int | |
SDL_HapticRumbleStop(SDL_Haptic * haptic) | |
{ | |
+ DSDL_TRACE(); | |
if (!ValidHaptic(haptic)) { | |
return -1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment