comparison src/haptic/linux/SDL_syshaptic.c @ 2475:4b874e3a3a2c gsoc2008_force_feedback

Some code cleanup.
author Edgar Simo <bobbens@gmail.com>
date Sun, 01 Jun 2008 19:11:49 +0000
parents 3f80bf1528b4
children 242d8a668ebb
comparison
equal deleted inserted replaced
2474:3f80bf1528b4 2475:4b874e3a3a2c
35 #include <fcntl.h> 35 #include <fcntl.h>
36 #include <linux/limits.h> 36 #include <linux/limits.h>
37 #include <string.h> 37 #include <string.h>
38 38
39 39
40 #include <stdio.h>
41
42
43 #define MAX_HAPTICS 32 40 #define MAX_HAPTICS 32
44 41
45 42
43 /*
44 * List of available haptic devices.
45 */
46 static struct 46 static struct
47 { 47 {
48 char *fname; 48 char *fname;
49 SDL_Haptic *haptic; 49 SDL_Haptic *haptic;
50 } SDL_hapticlist[MAX_HAPTICS]; 50 } SDL_hapticlist[MAX_HAPTICS];
51 51
52
53 /*
54 * Haptic system hardware data.
55 */
52 struct haptic_hwdata 56 struct haptic_hwdata
53 { 57 {
54 int fd; 58 int fd;
55 }; 59 };
60
56 61
57 62
58 #define test_bit(nr, addr) \ 63 #define test_bit(nr, addr) \
59 (((1UL << ((nr) & 31)) & (((const unsigned int *) addr)[(nr) >> 5])) != 0) 64 (((1UL << ((nr) & 31)) & (((const unsigned int *) addr)[(nr) >> 5])) != 0)
60 #define EV_TEST(ev,f) \ 65 #define EV_TEST(ev,f) \
61 if (test_bit((ev), features)) ret |= (f); 66 if (test_bit((ev), features)) ret |= (f);
67 /*
68 * Test whether a device has haptic properties.
69 * Returns available properties or 0 if there are none.
70 */
62 static int 71 static int
63 EV_IsHaptic(int fd) 72 EV_IsHaptic(int fd)
64 { 73 {
65 unsigned int ret; 74 unsigned int ret;
66 unsigned long features[1 + FF_MAX/sizeof(unsigned long)]; 75 unsigned long features[1 + FF_MAX/sizeof(unsigned long)];
137 146
138 return numhaptics; 147 return numhaptics;
139 } 148 }
140 149
141 150
151 /*
152 * Return the name of a haptic device, does not need to be opened.
153 */
142 const char * 154 const char *
143 SDL_SYS_HapticName(int index) 155 SDL_SYS_HapticName(int index)
144 { 156 {
145 int fd; 157 int fd;
146 static char namebuf[128]; 158 static char namebuf[128];
160 172
161 return name; 173 return name;
162 } 174 }
163 175
164 176
177 /*
178 * Opens a haptic device for usage.
179 */
165 int 180 int
166 SDL_SYS_HapticOpen(SDL_Haptic * haptic) 181 SDL_SYS_HapticOpen(SDL_Haptic * haptic)
167 { 182 {
168 /* TODO finish 183 /* TODO finish
169 int fd; 184 int fd;
180 return 0; 195 return 0;
181 */ 196 */
182 } 197 }
183 198
184 199
200 /*
201 * Closes the haptic device.
202 */
203 void
204 SDL_SYS_HapticClose(SDL_Haptic * haptic)
205 {
206 }
207
208
185 /* Clean up after system specific haptic stuff */ 209 /* Clean up after system specific haptic stuff */
186 void 210 void
187 SDL_SYS_HapticQuit(void) 211 SDL_SYS_HapticQuit(void)
188 { 212 {
189 int i; 213 int i;