diff src/haptic/windows/SDL_syshaptic.c @ 5092:327f181542f1

Include windows.h in a single point in the source, so we can be consistent about the definition of UNICODE and have core utility functions for Windows that all modules can share. I think this also fixes the bug relating to non-latin characters in filenames, since UNICODE wasn't defined in SDL_rwops.c
author Sam Lantinga <slouken@libsdl.org>
date Mon, 24 Jan 2011 21:20:30 -0800
parents e8916fe9cfc8
children
line wrap: on
line diff
--- a/src/haptic/windows/SDL_syshaptic.c	Mon Jan 24 17:47:18 2011 -0800
+++ b/src/haptic/windows/SDL_syshaptic.c	Mon Jan 24 21:20:30 2011 -0800
@@ -39,6 +39,7 @@
 static struct
 {
     DIDEVICEINSTANCE instance;
+    char *name;
     SDL_Haptic *haptic;
     DIDEVCAPS capabilities;
 } SDL_hapticlist[MAX_HAPTICS];
@@ -220,6 +221,9 @@
         return DIENUM_CONTINUE;
     }
 
+    /* Copy the name */
+    SDL_hapticlist[SDL_numhaptics].name = WIN_StringToUTF8(SDL_hapticlist[SDL_numhaptics].instance.tszProductName);
+
     /* Close up device and count it. */
     IDirectInputDevice_Release(device);
     SDL_numhaptics++;
@@ -238,7 +242,7 @@
 const char *
 SDL_SYS_HapticName(int index)
 {
-    return SDL_hapticlist[index].instance.tszProductName;
+    return SDL_hapticlist[index].name;
 }
 
 
@@ -630,6 +634,15 @@
 void
 SDL_SYS_HapticQuit(void)
 {
+    int i;
+
+    for (i = 0; i < SDL_arraysize(SDL_hapticlist); ++i) {
+        if (SDL_hapticlist[i].name) {
+            SDL_free(SDL_hapticlist[i].name);
+            SDL_hapticlist[i].name = NULL;
+        }
+    }
+
     IDirectInput_Release(dinput);
     dinput = NULL;
 }