Mercurial > sdl-ios-xcode
diff src/joystick/windows/SDL_dxjoystick.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 | b530ef003506 |
line wrap: on
line diff
--- a/src/joystick/windows/SDL_dxjoystick.c Mon Jan 24 17:47:18 2011 -0800 +++ b/src/joystick/windows/SDL_dxjoystick.c Mon Jan 24 21:20:30 2011 -0800 @@ -63,6 +63,7 @@ LPDIRECTINPUT * ppDI, LPUNKNOWN punkOuter); static DIDEVICEINSTANCE SYS_Joystick[MAX_JOYSTICKS]; /* array to hold joystick ID values */ +static char *SYS_JoystickNames[MAX_JOYSTICKS]; static int SYS_NumJoysticks; static HINSTANCE DInputDLL = NULL; @@ -326,6 +327,7 @@ { SDL_memcpy(&SYS_Joystick[SYS_NumJoysticks], pdidInstance, sizeof(DIDEVICEINSTANCE)); + SYS_JoystickNames[SYS_NumJoysticks] = WIN_StringToUTF8(pdidInstance->tszProductName); SYS_NumJoysticks++; if (SYS_NumJoysticks >= MAX_JOYSTICKS) @@ -338,8 +340,7 @@ const char * SDL_SYS_JoystickName(int index) { - /***-> test for invalid index ? */ - return (SYS_Joystick[index].tszProductName); + return SYS_JoystickNames[index]; } /* Function to open a joystick for use. @@ -793,6 +794,15 @@ void SDL_SYS_JoystickQuit(void) { + int i; + + for (i = 0; i < SDL_arraysize(SYS_JoystickNames); ++i) { + if (SYS_JoystickNames[i]) { + SDL_free(SYS_JoystickNames[i]); + SYS_JoystickNames[i] = NULL; + } + } + IDirectInput_Release(dinput); dinput = NULL; }