Mercurial > sdl-ios-xcode
comparison src/joystick/bsd/SDL_sysjoystick.c @ 1338:604d73db6802
Removed uses of stdlib.h and string.h
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Tue, 07 Feb 2006 09:29:18 +0000 |
parents | 3692456e7b0f |
children | c71e05b4dc2e |
comparison
equal
deleted
inserted
replaced
1337:c687f06c7473 | 1338:604d73db6802 |
---|---|
27 * Maintainer: <vedge at csoft.org> | 27 * Maintainer: <vedge at csoft.org> |
28 */ | 28 */ |
29 | 29 |
30 #include <sys/param.h> | 30 #include <sys/param.h> |
31 | 31 |
32 #include <stdio.h> | |
33 #include <stdlib.h> | |
34 #include <unistd.h> | 32 #include <unistd.h> |
35 #include <fcntl.h> | 33 #include <fcntl.h> |
36 #include <string.h> | |
37 #include <errno.h> | 34 #include <errno.h> |
38 | 35 |
39 #if defined(HAVE_USB_H) | 36 #if defined(HAVE_USB_H) |
40 #include <usb.h> | 37 #include <usb.h> |
41 #endif | 38 #endif |
57 | 54 |
58 #if defined(__NetBSD__) || (defined(__OpenBSD__) && defined(__i386__)) | 55 #if defined(__NetBSD__) || (defined(__OpenBSD__) && defined(__i386__)) |
59 #include <machine/joystick.h> | 56 #include <machine/joystick.h> |
60 #endif | 57 #endif |
61 | 58 |
59 #include "SDL_stdlib.h" | |
60 #include "SDL_string.h" | |
62 #include "SDL_error.h" | 61 #include "SDL_error.h" |
63 #include "SDL_joystick.h" | 62 #include "SDL_joystick.h" |
64 #include "SDL_sysjoystick.h" | 63 #include "SDL_sysjoystick.h" |
65 #include "SDL_joystick_c.h" | 64 #include "SDL_joystick_c.h" |
66 | 65 |
143 SDL_memset(joydevnames, 0, sizeof(joydevnames)); | 142 SDL_memset(joydevnames, 0, sizeof(joydevnames)); |
144 | 143 |
145 for (i = 0; i < MAX_UHID_JOYS; i++) { | 144 for (i = 0; i < MAX_UHID_JOYS; i++) { |
146 SDL_Joystick nj; | 145 SDL_Joystick nj; |
147 | 146 |
148 sprintf(s, "/dev/uhid%d", i); | 147 SDL_snprintf(s, SDL_arraysize(s), "/dev/uhid%d", i); |
149 | 148 |
150 nj.index = SDL_numjoysticks; | 149 nj.index = SDL_numjoysticks; |
151 joynames[nj.index] = strdup(s); | 150 joynames[nj.index] = strdup(s); |
152 | 151 |
153 if (SDL_SYS_JoystickOpen(&nj) == 0) { | 152 if (SDL_SYS_JoystickOpen(&nj) == 0) { |
157 SDL_free(joynames[nj.index]); | 156 SDL_free(joynames[nj.index]); |
158 joynames[nj.index] = NULL; | 157 joynames[nj.index] = NULL; |
159 } | 158 } |
160 } | 159 } |
161 for (i = 0; i < MAX_JOY_JOYS; i++) { | 160 for (i = 0; i < MAX_JOY_JOYS; i++) { |
162 sprintf(s, "/dev/joy%d", i); | 161 SDL_snprintf(s, SDL_arraysize(s), "/dev/joy%d", i); |
163 fd = open(s, O_RDONLY); | 162 fd = open(s, O_RDONLY); |
164 if (fd != -1) { | 163 if (fd != -1) { |
165 joynames[SDL_numjoysticks++] = strdup(s); | 164 joynames[SDL_numjoysticks++] = strdup(s); |
166 close(fd); | 165 close(fd); |
167 } | 166 } |
310 switch (HID_USAGE(hitem.usage)) { | 309 switch (HID_USAGE(hitem.usage)) { |
311 case HUG_JOYSTICK: | 310 case HUG_JOYSTICK: |
312 case HUG_GAME_PAD: | 311 case HUG_GAME_PAD: |
313 s = hid_usage_in_page(hitem.usage); | 312 s = hid_usage_in_page(hitem.usage); |
314 sp = SDL_malloc(SDL_strlen(s) + 5); | 313 sp = SDL_malloc(SDL_strlen(s) + 5); |
315 sprintf(sp, "%s (%d)", s, | 314 SDL_snprintf(sp, SDL_strlen(s) + 5, "%s (%d)", s, |
316 joy->index); | 315 joy->index); |
317 joydevnames[joy->index] = sp; | 316 joydevnames[joy->index] = sp; |
318 } | 317 } |
319 } | 318 } |
320 break; | 319 break; |