Mercurial > sdl-ios-xcode
comparison src/joystick/win32/SDL_mmjoystick.c @ 1336:3692456e7b0f
Use SDL_ prefixed versions of C library functions.
FIXME:
Change #include <stdlib.h> to #include "SDL_stdlib.h"
Change #include <string.h> to #include "SDL_string.h"
Make sure nothing else broke because of this...
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Tue, 07 Feb 2006 06:59:48 +0000 |
parents | 450721ad5436 |
children | 604d73db6802 |
comparison
equal
deleted
inserted
replaced
1335:c39265384763 | 1336:3692456e7b0f |
---|---|
80 LONG regresult; | 80 LONG regresult; |
81 unsigned char regkey[256]; | 81 unsigned char regkey[256]; |
82 unsigned char regvalue[256]; | 82 unsigned char regvalue[256]; |
83 unsigned char regname[256]; | 83 unsigned char regname[256]; |
84 | 84 |
85 snprintf((char *) regkey, SDL_arraysize(regkey), "%s\\%s\\%s", | 85 SDL_snprintf((char *) regkey, SDL_arraysize(regkey), "%s\\%s\\%s", |
86 REGSTR_PATH_JOYCONFIG, | 86 REGSTR_PATH_JOYCONFIG, |
87 szRegKey, | 87 szRegKey, |
88 REGSTR_KEY_JOYCURR); | 88 REGSTR_KEY_JOYCURR); |
89 regresult = RegOpenKeyExA(HKEY_LOCAL_MACHINE, | 89 regresult = RegOpenKeyExA(HKEY_LOCAL_MACHINE, |
90 (LPTSTR) ®key, 0, KEY_READ, &hKey); | 90 (LPTSTR) ®key, 0, KEY_READ, &hKey); |
93 /* | 93 /* |
94 find the registry key name for the | 94 find the registry key name for the |
95 joystick's properties | 95 joystick's properties |
96 */ | 96 */ |
97 regsize = sizeof(regname); | 97 regsize = sizeof(regname); |
98 snprintf((char *) regvalue, SDL_arraysize(regvalue), | 98 SDL_snprintf((char *) regvalue, SDL_arraysize(regvalue), |
99 "Joystick%d%s", index+1, | 99 "Joystick%d%s", index+1, |
100 REGSTR_VAL_JOYOEMNAME); | 100 REGSTR_VAL_JOYOEMNAME); |
101 regresult = RegQueryValueExA(hKey, | 101 regresult = RegQueryValueExA(hKey, |
102 (char *) regvalue, 0, 0, (LPBYTE) ®name, | 102 (char *) regvalue, 0, 0, (LPBYTE) ®name, |
103 (LPDWORD) ®size); | 103 (LPDWORD) ®size); |
104 RegCloseKey(hKey); | 104 RegCloseKey(hKey); |
105 if (regresult == ERROR_SUCCESS) | 105 if (regresult == ERROR_SUCCESS) |
106 { | 106 { |
107 /* open that registry key */ | 107 /* open that registry key */ |
108 snprintf((char *) regkey, SDL_arraysize(regkey), "%s\\%s", | 108 SDL_snprintf((char *) regkey, SDL_arraysize(regkey), "%s\\%s", |
109 REGSTR_PATH_JOYOEM, regname); | 109 REGSTR_PATH_JOYOEM, regname); |
110 regresult = RegOpenKeyExA(HKEY_LOCAL_MACHINE, | 110 regresult = RegOpenKeyExA(HKEY_LOCAL_MACHINE, |
111 (char *) regkey, 0, KEY_READ, &hKey); | 111 (char *) regkey, 0, KEY_READ, &hKey); |
112 if (regresult == ERROR_SUCCESS) | 112 if (regresult == ERROR_SUCCESS) |
113 { | 113 { |
122 { | 122 { |
123 /* | 123 /* |
124 allocate enough memory | 124 allocate enough memory |
125 for the OEM name text ... | 125 for the OEM name text ... |
126 */ | 126 */ |
127 name = (char *) malloc(regsize); | 127 name = (char *) SDL_malloc(regsize); |
128 /* ... and read it from the registry */ | 128 /* ... and read it from the registry */ |
129 regresult = | 129 regresult = |
130 RegQueryValueExA(hKey, | 130 RegQueryValueExA(hKey, |
131 REGSTR_VAL_JOYOEMNAME, 0, 0, | 131 REGSTR_VAL_JOYOEMNAME, 0, 0, |
132 (LPBYTE) name, | 132 (LPBYTE) name, |
225 axis_max[4] = SYS_Joystick[index].wUmax; | 225 axis_max[4] = SYS_Joystick[index].wUmax; |
226 axis_min[5] = SYS_Joystick[index].wVmin; | 226 axis_min[5] = SYS_Joystick[index].wVmin; |
227 axis_max[5] = SYS_Joystick[index].wVmax; | 227 axis_max[5] = SYS_Joystick[index].wVmax; |
228 | 228 |
229 /* allocate memory for system specific hardware data */ | 229 /* allocate memory for system specific hardware data */ |
230 joystick->hwdata = (struct joystick_hwdata *) malloc(sizeof(*joystick->hwdata)); | 230 joystick->hwdata = (struct joystick_hwdata *) SDL_malloc(sizeof(*joystick->hwdata)); |
231 if (joystick->hwdata == NULL) | 231 if (joystick->hwdata == NULL) |
232 { | 232 { |
233 SDL_OutOfMemory(); | 233 SDL_OutOfMemory(); |
234 return(-1); | 234 return(-1); |
235 } | 235 } |
236 memset(joystick->hwdata, 0, sizeof(*joystick->hwdata)); | 236 SDL_memset(joystick->hwdata, 0, sizeof(*joystick->hwdata)); |
237 | 237 |
238 /* set hardware data */ | 238 /* set hardware data */ |
239 joystick->hwdata->id = SYS_JoystickID[index]; | 239 joystick->hwdata->id = SYS_JoystickID[index]; |
240 for ( i = 0; i < MAX_AXES; ++i ) { | 240 for ( i = 0; i < MAX_AXES; ++i ) { |
241 if ( (i<2) || (SYS_Joystick[index].wCaps & caps_flags[i-2]) ) { | 241 if ( (i<2) || (SYS_Joystick[index].wCaps & caps_flags[i-2]) ) { |
357 /* Function to close a joystick after use */ | 357 /* Function to close a joystick after use */ |
358 void SDL_SYS_JoystickClose(SDL_Joystick *joystick) | 358 void SDL_SYS_JoystickClose(SDL_Joystick *joystick) |
359 { | 359 { |
360 if (joystick->hwdata != NULL) { | 360 if (joystick->hwdata != NULL) { |
361 /* free system specific hardware data */ | 361 /* free system specific hardware data */ |
362 free(joystick->hwdata); | 362 SDL_free(joystick->hwdata); |
363 } | 363 } |
364 } | 364 } |
365 | 365 |
366 /* Function to perform any system-specific joystick related cleanup */ | 366 /* Function to perform any system-specific joystick related cleanup */ |
367 void SDL_SYS_JoystickQuit(void) | 367 void SDL_SYS_JoystickQuit(void) |
368 { | 368 { |
369 int i; | 369 int i; |
370 for (i = 0; i < MAX_JOYSTICKS; i++) { | 370 for (i = 0; i < MAX_JOYSTICKS; i++) { |
371 if ( SYS_JoystickName[i] != NULL ) { | 371 if ( SYS_JoystickName[i] != NULL ) { |
372 free(SYS_JoystickName[i]); | 372 SDL_free(SYS_JoystickName[i]); |
373 } | 373 } |
374 } | 374 } |
375 } | 375 } |
376 | 376 |
377 | 377 |
404 case JOYERR_NOCANDO: | 404 case JOYERR_NOCANDO: |
405 error = "Can't capture joystick input"; | 405 error = "Can't capture joystick input"; |
406 break; | 406 break; |
407 | 407 |
408 default: | 408 default: |
409 snprintf(errbuf, SDL_arraysize(errbuf), | 409 SDL_snprintf(errbuf, SDL_arraysize(errbuf), |
410 "%s: Unknown Multimedia system error: 0x%x", | 410 "%s: Unknown Multimedia system error: 0x%x", |
411 function, code); | 411 function, code); |
412 break; | 412 break; |
413 } | 413 } |
414 | 414 |
415 if ( ! errbuf[0] ) { | 415 if ( ! errbuf[0] ) { |
416 snprintf(errbuf, SDL_arraysize(errbuf), "%s: %s", function, error); | 416 SDL_snprintf(errbuf, SDL_arraysize(errbuf), "%s: %s", function, error); |
417 } | 417 } |
418 SDL_SetError("%s", errbuf); | 418 SDL_SetError("%s", errbuf); |
419 } | 419 } |