comparison src/joystick/beos/SDL_bejoystick.cc @ 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 c9b51268668f
children 604d73db6802
comparison
equal deleted inserted replaced
1335:c39265384763 1336:3692456e7b0f
65 char name[B_OS_NAME_LENGTH]; 65 char name[B_OS_NAME_LENGTH];
66 66
67 /* Search for attached joysticks */ 67 /* Search for attached joysticks */
68 nports = joystick.CountDevices(); 68 nports = joystick.CountDevices();
69 numjoysticks = 0; 69 numjoysticks = 0;
70 memset(SDL_joyport, 0, (sizeof SDL_joyport)); 70 SDL_memset(SDL_joyport, 0, (sizeof SDL_joyport));
71 memset(SDL_joyname, 0, (sizeof SDL_joyname)); 71 SDL_memset(SDL_joyname, 0, (sizeof SDL_joyname));
72 for ( i=0; (SDL_numjoysticks < MAX_JOYSTICKS) && (i < nports); ++i ) { 72 for ( i=0; (SDL_numjoysticks < MAX_JOYSTICKS) && (i < nports); ++i ) {
73 if ( joystick.GetDeviceName(i, name) == B_OK ) { 73 if ( joystick.GetDeviceName(i, name) == B_OK ) {
74 if ( joystick.Open(name) != B_ERROR ) { 74 if ( joystick.Open(name) != B_ERROR ) {
75 BString stick_name; 75 BString stick_name;
76 joystick.GetControllerName(&stick_name); 76 joystick.GetControllerName(&stick_name);
100 { 100 {
101 BJoystick *stick; 101 BJoystick *stick;
102 102
103 /* Create the joystick data structure */ 103 /* Create the joystick data structure */
104 joystick->hwdata = (struct joystick_hwdata *) 104 joystick->hwdata = (struct joystick_hwdata *)
105 malloc(sizeof(*joystick->hwdata)); 105 SDL_malloc(sizeof(*joystick->hwdata));
106 if ( joystick->hwdata == NULL ) { 106 if ( joystick->hwdata == NULL ) {
107 SDL_OutOfMemory(); 107 SDL_OutOfMemory();
108 return(-1); 108 return(-1);
109 } 109 }
110 memset(joystick->hwdata, 0, sizeof(*joystick->hwdata)); 110 SDL_memset(joystick->hwdata, 0, sizeof(*joystick->hwdata));
111 stick = new BJoystick; 111 stick = new BJoystick;
112 joystick->hwdata->stick = stick; 112 joystick->hwdata->stick = stick;
113 113
114 /* Open the requested joystick for use */ 114 /* Open the requested joystick for use */
115 if ( stick->Open(SDL_joyport[joystick->index]) == B_ERROR ) { 115 if ( stick->Open(SDL_joyport[joystick->index]) == B_ERROR ) {
125 joystick->nbuttons = stick->CountButtons(); 125 joystick->nbuttons = stick->CountButtons();
126 joystick->naxes = stick->CountAxes(); 126 joystick->naxes = stick->CountAxes();
127 joystick->nhats = stick->CountHats(); 127 joystick->nhats = stick->CountHats();
128 128
129 joystick->hwdata->new_axes = (int16 *) 129 joystick->hwdata->new_axes = (int16 *)
130 malloc(joystick->naxes*sizeof(int16)); 130 SDL_malloc(joystick->naxes*sizeof(int16));
131 joystick->hwdata->new_hats = (uint8 *) 131 joystick->hwdata->new_hats = (uint8 *)
132 malloc(joystick->nhats*sizeof(uint8)); 132 SDL_malloc(joystick->nhats*sizeof(uint8));
133 if ( ! joystick->hwdata->new_hats || ! joystick->hwdata->new_axes ) { 133 if ( ! joystick->hwdata->new_hats || ! joystick->hwdata->new_axes ) {
134 SDL_OutOfMemory(); 134 SDL_OutOfMemory();
135 SDL_SYS_JoystickClose(joystick); 135 SDL_SYS_JoystickClose(joystick);
136 return(-1); 136 return(-1);
137 } 137 }
206 { 206 {
207 if ( joystick->hwdata ) { 207 if ( joystick->hwdata ) {
208 joystick->hwdata->stick->Close(); 208 joystick->hwdata->stick->Close();
209 delete joystick->hwdata->stick; 209 delete joystick->hwdata->stick;
210 if ( joystick->hwdata->new_hats ) { 210 if ( joystick->hwdata->new_hats ) {
211 free(joystick->hwdata->new_hats); 211 SDL_free(joystick->hwdata->new_hats);
212 } 212 }
213 if ( joystick->hwdata->new_axes ) { 213 if ( joystick->hwdata->new_axes ) {
214 free(joystick->hwdata->new_axes); 214 SDL_free(joystick->hwdata->new_axes);
215 } 215 }
216 free(joystick->hwdata); 216 SDL_free(joystick->hwdata);
217 joystick->hwdata = NULL; 217 joystick->hwdata = NULL;
218 } 218 }
219 } 219 }
220 220
221 /* Function to perform any system-specific joystick related cleanup */ 221 /* Function to perform any system-specific joystick related cleanup */
222 void SDL_SYS_JoystickQuit(void) 222 void SDL_SYS_JoystickQuit(void)
223 { 223 {
224 int i; 224 int i;
225 225
226 for ( i=0; SDL_joyport[i]; ++i ) { 226 for ( i=0; SDL_joyport[i]; ++i ) {
227 free(SDL_joyport[i]); 227 SDL_free(SDL_joyport[i]);
228 } 228 }
229 SDL_joyport[0] = NULL; 229 SDL_joyport[0] = NULL;
230 230
231 for ( i=0; SDL_joyname[i]; ++i ) { 231 for ( i=0; SDL_joyname[i]; ++i ) {
232 free(SDL_joyname[i]); 232 SDL_free(SDL_joyname[i]);
233 } 233 }
234 SDL_joyname[0] = NULL; 234 SDL_joyname[0] = NULL;
235 } 235 }
236 236
237 }; // extern "C" 237 }; // extern "C"