comparison include/SDL_haptic.h @ 2519:af9df9662807 gsoc2008_force_feedback

More explicit with iterations and length. Added spherical coordinates (not available on linux).
author Edgar Simo <bobbens@gmail.com>
date Tue, 15 Jul 2008 15:53:48 +0000
parents 37c13c12c878
children 366d84fdf8d1
comparison
equal deleted inserted replaced
2518:07a5b225b9c9 2519:af9df9662807
210 */ 210 */
211 #define SDL_HAPTIC_FRICTION (1<<10) /* Friction effect supported - uses axes movement */ 211 #define SDL_HAPTIC_FRICTION (1<<10) /* Friction effect supported - uses axes movement */
212 /** 212 /**
213 * \def SDL_HAPTIC_CUSTOM 213 * \def SDL_HAPTIC_CUSTOM
214 * 214 *
215 * \brief User defined custom haptic effect. TODO. 215 * \brief User defined custom haptic effect. @todo.
216 */ 216 */
217 #define SDL_HAPTIC_CUSTOM (1<<11) /* Custom effect is supported */ 217 #define SDL_HAPTIC_CUSTOM (1<<11) /* Custom effect is supported */
218 /* These last two are features the device has, not effects */ 218 /* These last two are features the device has, not effects */
219 /** 219 /**
220 * \def SDL_HAPTIC_GAIN 220 * \def SDL_HAPTIC_GAIN
259 * \brief Uses cartesian coordinates for the direction. 259 * \brief Uses cartesian coordinates for the direction.
260 * 260 *
261 * \sa SDL_HapticDirection 261 * \sa SDL_HapticDirection
262 */ 262 */
263 #define SDL_HAPTIC_CARTESIAN 1 263 #define SDL_HAPTIC_CARTESIAN 1
264 /**
265 * \def SDL_HAPTIC_SHPERICAL
266 *
267 * \brief Uses spherical coordinates for the direction.
268 *
269 * \sa SDL_HapticDirection
270 */
271 #define SDL_HAPTIC_SPHERICAL 2
264 272
265 273
266 /* 274 /*
267 * Misc defines. 275 * Misc defines.
268 */ 276 */
271 * 279 *
272 * \brief Used to play a device an infinite number of times. 280 * \brief Used to play a device an infinite number of times.
273 * 281 *
274 * \sa SDL_HapticRunEffect 282 * \sa SDL_HapticRunEffect
275 */ 283 */
276 #define SDL_HAPTIC_INFINITY -1 284 #define SDL_HAPTIC_INFINITY 4294967295U
277 285
278 286
279 /** 287 /**
280 * \struct SDL_HapticDirection 288 * \struct SDL_HapticDirection
281 * 289 *
315 * (o o) 323 * (o o)
316 * ---ooO-(_)-Ooo--- 324 * ---ooO-(_)-Ooo---
317 * \endcode 325 * \endcode
318 * 326 *
319 * If type is SDL_HAPTIC_POLAR, direction is encoded by hundredths of a 327 * If type is SDL_HAPTIC_POLAR, direction is encoded by hundredths of a
320 * degree starting north and turning clockwise. The cardinal directions would be: 328 * degree starting north and turning clockwise. SDL_HAPTIC_POLAR only uses
329 * the first dir parameter. The cardinal directions would be:
321 * - North: 0 (0 degrees) 330 * - North: 0 (0 degrees)
322 * - East: 9000 (90 degrees) 331 * - East: 9000 (90 degrees)
323 * - South: 18000 (180 degrees) 332 * - South: 18000 (180 degrees)
324 * - West: 27000 (270 degrees) 333 * - West: 27000 (270 degrees)
325 * 334 *
326 * If type is SDL_HAPTIC_CARTESIAN, direction is encoded by position. 335 * If type is SDL_HAPTIC_CARTESIAN, direction is encoded by two positions
327 * The cardinal directions would be: 336 * (X axis and Y axis). SDL_HAPTIC_CARTESIAN uses the first two dir
337 * parameters. The cardinal directions would be:
328 * - North: 0,-1 338 * - North: 0,-1
329 * - East: -1, 0 339 * - East: -1, 0
330 * - South: 0, 1 340 * - South: 0, 1
331 * - West: 1, 0 341 * - West: 1, 0
332 * 342 *
343 * If type is SDL_HAPTIC_SPHERICAL, direction is encoded by three rotations.
344 * All three dir parameters are used. The dir parameters are as follows
345 * (all values are in hundredths of degrees):
346 * 1) Degrees from (1, 0) rotated towards (0, 1).
347 * 2) Degrees towards (0, 0, 1) (device needs at least 3 axes).
348 * 3) Degrees tworads (0, 0, 0, 1) (device needs at least 4 axes).
349 *
333 * 350 *
334 * Example: 351 * Example:
335 * \code 352 * \code
336 * SDL_HapticDirection direction; 353 * SDL_HapticDirection direction;
337 * 354 *
340 * // have to pull the stick to counteract. 357 * // have to pull the stick to counteract.
341 * \endcode 358 * \endcode
342 * 359 *
343 * \sa SDL_HAPTIC_POLAR 360 * \sa SDL_HAPTIC_POLAR
344 * \sa SDL_HAPTIC_CARTESIAN 361 * \sa SDL_HAPTIC_CARTESIAN
362 * \sa SDL_HAPTIC_SHPERICAL
345 * \sa SDL_HapticEffect 363 * \sa SDL_HapticEffect
346 */ 364 */
347 typedef struct SDL_HapticDirection { 365 typedef struct SDL_HapticDirection {
348 Uint8 type; /**< The type of encoding. */ 366 Uint8 type; /**< The type of encoding. */
349 Uint16 dir[2]; /**< The encoded direction. */ 367 Uint16 dir[3]; /**< The encoded direction. */
350 } SDL_HapticDirection; 368 } SDL_HapticDirection;
351 369
352 370
353 /** 371 /**
354 * \struct SDL_HapticConstant 372 * \struct SDL_HapticConstant
367 /* Header */ 385 /* Header */
368 Uint16 type; /**< SDL_HAPTIC_CONSTANT */ 386 Uint16 type; /**< SDL_HAPTIC_CONSTANT */
369 SDL_HapticDirection direction; /**< Direction of the effect. */ 387 SDL_HapticDirection direction; /**< Direction of the effect. */
370 388
371 /* Replay */ 389 /* Replay */
372 Uint16 length; /**< Duration of the effect. */ 390 Uint32 length; /**< Duration of the effect. */
373 Uint16 delay; /**< Delay before starting the effect. */ 391 Uint16 delay; /**< Delay before starting the effect. */
374 392
375 /* Trigger */ 393 /* Trigger */
376 Uint16 button; /**< Button that triggers the effect. */ 394 Uint16 button; /**< Button that triggers the effect. */
377 Uint16 interval; /**< How soon it can be triggered again after button. */ 395 Uint16 interval; /**< How soon it can be triggered again after button. */
442 SDL_HAPTIC_TRIANGLE, SDL_HAPTIC_SAWTOOTHUP or 460 SDL_HAPTIC_TRIANGLE, SDL_HAPTIC_SAWTOOTHUP or
443 SDL_HAPTIC_SAWTOOTHDOWN */ 461 SDL_HAPTIC_SAWTOOTHDOWN */
444 SDL_HapticDirection direction; /**< Direction of the effect. */ 462 SDL_HapticDirection direction; /**< Direction of the effect. */
445 463
446 /* Replay */ 464 /* Replay */
447 Uint16 length; /**< Duration of the effect. */ 465 Uint32 length; /**< Duration of the effect. */
448 Uint16 delay; /**< Delay before starting the effect. */ 466 Uint16 delay; /**< Delay before starting the effect. */
449 467
450 /* Trigger */ 468 /* Trigger */
451 Uint16 button; /**< Button that triggers the effect. */ 469 Uint16 button; /**< Button that triggers the effect. */
452 Uint16 interval; /**< How soon it can be triggered again after button. */ 470 Uint16 interval; /**< How soon it can be triggered again after button. */
492 /* Header */ 510 /* Header */
493 Uint16 type; /**< SDL_HAPTIC_SPRING, SDL_HAPTIC_DAMPER, 511 Uint16 type; /**< SDL_HAPTIC_SPRING, SDL_HAPTIC_DAMPER,
494 SDL_HAPTIC_INERTIA or SDL_HAPTIC_FRICTION */ 512 SDL_HAPTIC_INERTIA or SDL_HAPTIC_FRICTION */
495 513
496 /* Replay */ 514 /* Replay */
497 Uint16 length; /**< Duration of the effect. */ 515 Uint32 length; /**< Duration of the effect. */
498 Uint16 delay; /**< Delay before starting the effect. */ 516 Uint16 delay; /**< Delay before starting the effect. */
499 517
500 /* Trigger */ 518 /* Trigger */
501 Uint16 button; /**< Button that triggers the effect. */ 519 Uint16 button; /**< Button that triggers the effect. */
502 Uint16 interval; /**< How soon it can be triggered again after button. */ 520 Uint16 interval; /**< How soon it can be triggered again after button. */
528 /* Header */ 546 /* Header */
529 Uint16 type; /**< SDL_HAPTIC_RAMP */ 547 Uint16 type; /**< SDL_HAPTIC_RAMP */
530 SDL_HapticDirection direction; /**< Direction of the effect. */ 548 SDL_HapticDirection direction; /**< Direction of the effect. */
531 549
532 /* Replay */ 550 /* Replay */
533 Uint16 length; /**< Duration of the effect. */ 551 Uint32 length; /**< Duration of the effect. */
534 Uint16 delay; /**< Delay before starting the effect. */ 552 Uint16 delay; /**< Delay before starting the effect. */
535 553
536 /* Trigger */ 554 /* Trigger */
537 Uint16 button; /**< Button that triggers the effect. */ 555 Uint16 button; /**< Button that triggers the effect. */
538 Uint16 interval; /**< How soon it can be triggered again after button. */ 556 Uint16 interval; /**< How soon it can be triggered again after button. */
553 * \brief The generic template for any haptic effect. 571 * \brief The generic template for any haptic effect.
554 * 572 *
555 * All values max at 32767 (0x7FFF). Signed values also can be negative. 573 * All values max at 32767 (0x7FFF). Signed values also can be negative.
556 * Time values unless specified otherwise are in milliseconds. 574 * Time values unless specified otherwise are in milliseconds.
557 * 575 *
576 * You can also pass SDL_HAPTIC_INFINITY to length instead of a 0-32767 value.
577 * Neither delay, interval, attack_length nor fade_length support
578 * SDL_HAPTIC_INFINITY.
579 *
558 * Common parts: 580 * Common parts:
559 * \code 581 * \code
560 * // Replay - All effects have this 582 * // Replay - All effects have this
561 * Uint16 length; // Duration of effect (ms). 583 * Uint32 length; // Duration of effect (ms).
562 * Uint16 delay; // Delay before starting effect. 584 * Uint16 delay; // Delay before starting effect.
563 * 585 *
564 * // Trigger - All effects have this 586 * // Trigger - All effects have this
565 * Uint16 button; // Button that triggers effect. 587 * Uint16 button; // Button that triggers effect.
566 * Uint16 interval; // How soon before effect can be triggered again. 588 * Uint16 interval; // How soon before effect can be triggered again.
855 * 877 *
856 * \sa SDL_HapticStopEffect 878 * \sa SDL_HapticStopEffect
857 * \sa SDL_HapticDestroyEffect 879 * \sa SDL_HapticDestroyEffect
858 * \sa SDL_HapticGetEffectStatus 880 * \sa SDL_HapticGetEffectStatus
859 */ 881 */
860 extern DECLSPEC int SDL_HapticRunEffect(SDL_Haptic * haptic, int effect, int iterations); 882 extern DECLSPEC int SDL_HapticRunEffect(SDL_Haptic * haptic, int effect, Uint32 iterations);
861 883
862 /** 884 /**
863 * \fn int SDL_HapticStopEffect(SDL_Haptic * haptic, int effect) 885 * \fn int SDL_HapticStopEffect(SDL_Haptic * haptic, int effect)
864 * 886 *
865 * \brief Stops the haptic effect on it's assosciated haptic device. 887 * \brief Stops the haptic effect on it's assosciated haptic device.