Mercurial > sdl-ios-xcode
comparison 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 |
comparison
equal
deleted
inserted
replaced
5091:79bd1e289005 | 5092:327f181542f1 |
---|---|
61 static LPDIRECTINPUT dinput = NULL; | 61 static LPDIRECTINPUT dinput = NULL; |
62 extern HRESULT(WINAPI * DInputCreate) (HINSTANCE hinst, DWORD dwVersion, | 62 extern HRESULT(WINAPI * DInputCreate) (HINSTANCE hinst, DWORD dwVersion, |
63 LPDIRECTINPUT * ppDI, | 63 LPDIRECTINPUT * ppDI, |
64 LPUNKNOWN punkOuter); | 64 LPUNKNOWN punkOuter); |
65 static DIDEVICEINSTANCE SYS_Joystick[MAX_JOYSTICKS]; /* array to hold joystick ID values */ | 65 static DIDEVICEINSTANCE SYS_Joystick[MAX_JOYSTICKS]; /* array to hold joystick ID values */ |
66 static char *SYS_JoystickNames[MAX_JOYSTICKS]; | |
66 static int SYS_NumJoysticks; | 67 static int SYS_NumJoysticks; |
67 static HINSTANCE DInputDLL = NULL; | 68 static HINSTANCE DInputDLL = NULL; |
68 | 69 |
69 | 70 |
70 /* local prototypes */ | 71 /* local prototypes */ |
324 static BOOL CALLBACK | 325 static BOOL CALLBACK |
325 EnumJoysticksCallback(const DIDEVICEINSTANCE * pdidInstance, VOID * pContext) | 326 EnumJoysticksCallback(const DIDEVICEINSTANCE * pdidInstance, VOID * pContext) |
326 { | 327 { |
327 SDL_memcpy(&SYS_Joystick[SYS_NumJoysticks], pdidInstance, | 328 SDL_memcpy(&SYS_Joystick[SYS_NumJoysticks], pdidInstance, |
328 sizeof(DIDEVICEINSTANCE)); | 329 sizeof(DIDEVICEINSTANCE)); |
330 SYS_JoystickNames[SYS_NumJoysticks] = WIN_StringToUTF8(pdidInstance->tszProductName); | |
329 SYS_NumJoysticks++; | 331 SYS_NumJoysticks++; |
330 | 332 |
331 if (SYS_NumJoysticks >= MAX_JOYSTICKS) | 333 if (SYS_NumJoysticks >= MAX_JOYSTICKS) |
332 return DIENUM_STOP; | 334 return DIENUM_STOP; |
333 | 335 |
336 | 338 |
337 /* Function to get the device-dependent name of a joystick */ | 339 /* Function to get the device-dependent name of a joystick */ |
338 const char * | 340 const char * |
339 SDL_SYS_JoystickName(int index) | 341 SDL_SYS_JoystickName(int index) |
340 { | 342 { |
341 /***-> test for invalid index ? */ | 343 return SYS_JoystickNames[index]; |
342 return (SYS_Joystick[index].tszProductName); | |
343 } | 344 } |
344 | 345 |
345 /* Function to open a joystick for use. | 346 /* Function to open a joystick for use. |
346 The joystick to open is specified by the index field of the joystick. | 347 The joystick to open is specified by the index field of the joystick. |
347 This should fill the nbuttons and naxes fields of the joystick structure. | 348 This should fill the nbuttons and naxes fields of the joystick structure. |
791 | 792 |
792 /* Function to perform any system-specific joystick related cleanup */ | 793 /* Function to perform any system-specific joystick related cleanup */ |
793 void | 794 void |
794 SDL_SYS_JoystickQuit(void) | 795 SDL_SYS_JoystickQuit(void) |
795 { | 796 { |
797 int i; | |
798 | |
799 for (i = 0; i < SDL_arraysize(SYS_JoystickNames); ++i) { | |
800 if (SYS_JoystickNames[i]) { | |
801 SDL_free(SYS_JoystickNames[i]); | |
802 SYS_JoystickNames[i] = NULL; | |
803 } | |
804 } | |
805 | |
796 IDirectInput_Release(dinput); | 806 IDirectInput_Release(dinput); |
797 dinput = NULL; | 807 dinput = NULL; |
798 } | 808 } |
799 | 809 |
800 #endif /* SDL_JOYSTICK_DINPUT */ | 810 #endif /* SDL_JOYSTICK_DINPUT */ |