Mercurial > sdl-ios-xcode
comparison src/joystick/win32/SDL_mmjoystick.c @ 938:fa2ce068b0b6
Hmm, this should work a little better. :)
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sat, 21 Aug 2004 03:55:12 +0000 |
parents | 1e6366bde299 |
children | cf6133247d34 |
comparison
equal
deleted
inserted
replaced
937:1e6366bde299 | 938:fa2ce068b0b6 |
---|---|
50 | 50 |
51 | 51 |
52 /* array to hold joystick ID values */ | 52 /* array to hold joystick ID values */ |
53 static UINT SYS_JoystickID[MAX_JOYSTICKS]; | 53 static UINT SYS_JoystickID[MAX_JOYSTICKS]; |
54 static JOYCAPS SYS_Joystick[MAX_JOYSTICKS]; | 54 static JOYCAPS SYS_Joystick[MAX_JOYSTICKS]; |
55 static char *SYS_JoystickNames[MAX_JOYSTICKS]; | 55 static char *SYS_JoystickName[MAX_JOYSTICKS]; |
56 | 56 |
57 /* The private structure used to keep track of a joystick */ | 57 /* The private structure used to keep track of a joystick */ |
58 struct joystick_hwdata | 58 struct joystick_hwdata |
59 { | 59 { |
60 /* joystick ID */ | 60 /* joystick ID */ |
70 | 70 |
71 /* Convert a win32 Multimedia API return code to a text message */ | 71 /* Convert a win32 Multimedia API return code to a text message */ |
72 static void SetMMerror(char *function, int code); | 72 static void SetMMerror(char *function, int code); |
73 | 73 |
74 | 74 |
75 static char *GetJoystickName(const char *szRegKey) | 75 static char *GetJoystickName(int index, const char *szRegKey) |
76 { | 76 { |
77 /* added 7/24/2004 by Eckhard Stolberg */ | 77 /* added 7/24/2004 by Eckhard Stolberg */ |
78 /* | 78 /* |
79 see if there is a joystick for the current | 79 see if there is a joystick for the current |
80 index (1-16) listed in the registry | 80 index (1-16) listed in the registry |
99 find the registry key name for the | 99 find the registry key name for the |
100 joystick's properties | 100 joystick's properties |
101 */ | 101 */ |
102 regsize = sizeof(regname); | 102 regsize = sizeof(regname); |
103 sprintf(regvalue, | 103 sprintf(regvalue, |
104 "Joystick%d%s", i+1, | 104 "Joystick%d%s", index+1, |
105 REGSTR_VAL_JOYOEMNAME); | 105 REGSTR_VAL_JOYOEMNAME); |
106 regresult = RegQueryValueExA(hKey, | 106 regresult = RegQueryValueExA(hKey, |
107 regvalue, 0, 0, (LPBYTE) ®name, | 107 regvalue, 0, 0, (LPBYTE) ®name, |
108 (LPDWORD) ®size); | 108 (LPDWORD) ®size); |
109 RegCloseKey(hKey); | 109 RegCloseKey(hKey); |
166 } | 166 } |
167 | 167 |
168 | 168 |
169 for ( i = 0; i < MAX_JOYSTICKS; i++ ) { | 169 for ( i = 0; i < MAX_JOYSTICKS; i++ ) { |
170 SYS_JoystickID[i] = JOYSTICKID1 + i; | 170 SYS_JoystickID[i] = JOYSTICKID1 + i; |
171 SYS_JoystickNames[i] = NULL; | 171 SYS_JoystickName[i] = NULL; |
172 } | 172 } |
173 | 173 |
174 | 174 |
175 for ( i = 0; (i < maxdevs); ++i ) { | 175 for ( i = 0; (i < maxdevs); ++i ) { |
176 | 176 |
183 if ( result == JOYERR_NOERROR ) { | 183 if ( result == JOYERR_NOERROR ) { |
184 result = joyGetDevCaps(SYS_JoystickID[i], &joycaps, sizeof(joycaps)); | 184 result = joyGetDevCaps(SYS_JoystickID[i], &joycaps, sizeof(joycaps)); |
185 if ( result == JOYERR_NOERROR ) { | 185 if ( result == JOYERR_NOERROR ) { |
186 SYS_JoystickID[numdevs] = SYS_JoystickID[i]; | 186 SYS_JoystickID[numdevs] = SYS_JoystickID[i]; |
187 SYS_Joystick[numdevs] = joycaps; | 187 SYS_Joystick[numdevs] = joycaps; |
188 SYS_JoystickName[numdevs] = GetJoystickName(joycaps.szRegKey); | 188 SYS_JoystickName[numdevs] = GetJoystickName(numdevs, joycaps.szRegKey); |
189 numdevs++; | 189 numdevs++; |
190 } | 190 } |
191 } | 191 } |
192 } | 192 } |
193 return(numdevs); | 193 return(numdevs); |
194 } | 194 } |
195 | 195 |
196 /* Function to get the device-dependent name of a joystick */ | 196 /* Function to get the device-dependent name of a joystick */ |
197 const char *SDL_SYS_JoystickName(int index) | 197 const char *SDL_SYS_JoystickName(int index) |
198 { | 198 { |
199 if ( SYS_JoystickNames[index] != NULL ) { | 199 if ( SYS_JoystickName[index] != NULL ) { |
200 return(SYS_JoystickNames[index]); | 200 return(SYS_JoystickName[index]); |
201 } else { | 201 } else { |
202 return(SYS_Joystick[index].szPname); | 202 return(SYS_Joystick[index].szPname); |
203 } | 203 } |
204 } | 204 } |
205 | 205 |
371 /* Function to perform any system-specific joystick related cleanup */ | 371 /* Function to perform any system-specific joystick related cleanup */ |
372 void SDL_SYS_JoystickQuit(void) | 372 void SDL_SYS_JoystickQuit(void) |
373 { | 373 { |
374 int i; | 374 int i; |
375 for (i = 0; i < MAX_JOYSTICKS; i++) { | 375 for (i = 0; i < MAX_JOYSTICKS; i++) { |
376 if ( SYS_JoystickNames[i] != NULL ) { | 376 if ( SYS_JoystickName[i] != NULL ) { |
377 free(SYS_JoystickNames[i]); | 377 free(SYS_JoystickName[i]); |
378 } | 378 } |
379 } | 379 } |
380 } | 380 } |
381 | 381 |
382 | 382 |