comparison src/haptic/linux/SDL_syshaptic.c @ 2511:f12ae0bae468 gsoc2008_force_feedback

Fixed bugs in documentation. Improved code correctness a bit.
author Edgar Simo <bobbens@gmail.com>
date Wed, 09 Jul 2008 18:29:11 +0000
parents e6ad7e678fca
children ef147ee4896c
comparison
equal deleted inserted replaced
2510:e6ad7e678fca 2511:f12ae0bae468
70 /* 70 /*
71 * Haptic system effect data. 71 * Haptic system effect data.
72 */ 72 */
73 struct haptic_hweffect 73 struct haptic_hweffect
74 { 74 {
75 struct ff_effect effect; 75 struct ff_effect effect; /* The linux kernel effect structure. */
76 }; 76 };
77 77
78 78
79 79
80 #define test_bit(nr, addr) \ 80 #define test_bit(nr, addr) \
341 */ 341 */
342 static Uint16 342 static Uint16
343 SDL_SYS_ToDirection( SDL_HapticDirection * dir ) 343 SDL_SYS_ToDirection( SDL_HapticDirection * dir )
344 { 344 {
345 Uint32 tmp; 345 Uint32 tmp;
346 float f; 346 float f; /* Ideally we'd use fixed point math instead of floats... */
347 347
348 switch (dir->type) { 348 switch (dir->type) {
349 case SDL_HAPTIC_POLAR: 349 case SDL_HAPTIC_POLAR:
350 /* Linux directions are inverted. */ 350 /* Linux directions are inverted. */
351 tmp = (((18000 + dir->dir[0]) % 36000) * 0xFFFF) / 36000; 351 tmp = (((18000 + dir->dir[0]) % 36000) * 0xFFFF) / 36000;
352 return (Uint16) tmp; 352 return (Uint16) tmp;
353 break;
354 case SDL_HAPTIC_CARTESIAN: 353 case SDL_HAPTIC_CARTESIAN:
354 /* We must invert "x" and "y" to go clockwise. */
355 f = atan2(dir->dir[0], dir->dir[1]); 355 f = atan2(dir->dir[0], dir->dir[1]);
356 tmp = (int)(f*18000./M_PI) % 36000; 356 tmp = (int)(f*18000./M_PI) % 36000;
357 tmp = (tmp * 0xFFFF) / 36000; 357 tmp = (tmp * 0xFFFF) / 36000;
358 return (Uint16) tmp; 358 return (Uint16) tmp;
359 break;
360 359
361 default: 360 default:
362 return -1; 361 return -1;
363 } 362 }
364 363