comparison include/SDL_haptic.h @ 2504:e68c99a19a2f gsoc2008_force_feedback

Fixed more mistakes in documentation.
author Edgar Simo <bobbens@gmail.com>
date Mon, 07 Jul 2008 18:42:10 +0000
parents 5356ca0c36a3
children abfcba0f3bd1
comparison
equal deleted inserted replaced
2503:84a634009a83 2504:e68c99a19a2f
35 * - Upload the effect with SDL_HapticNewEffect(...). 35 * - Upload the effect with SDL_HapticNewEffect(...).
36 * - Run the effect with SDL_HapticRunEffect(...). 36 * - Run the effect with SDL_HapticRunEffect(...).
37 * - (optional) Free the effect with SDL_HapticDestroyEffect(...). 37 * - (optional) Free the effect with SDL_HapticDestroyEffect(...).
38 * - Close the haptic device with SDL_HapticClose(...). 38 * - Close the haptic device with SDL_HapticClose(...).
39 * 39 *
40 *
41 * Example: 40 * Example:
42 * 41 *
43 * \code 42 * \code
44 * int test_haptic( SDL_Joystick * joystick ) { 43 * int test_haptic( SDL_Joystick * joystick ) {
45 * SDL_Haptic *haptic; 44 * SDL_Haptic *haptic;
49 * // Open the device 48 * // Open the device
50 * haptic = SDL_HapticOpenFromJoystick( joystick ); 49 * haptic = SDL_HapticOpenFromJoystick( joystick );
51 * if (haptic == NULL) return -1; // Most likely joystick isn't haptic 50 * if (haptic == NULL) return -1; // Most likely joystick isn't haptic
52 * 51 *
53 * // See if it can do sine waves 52 * // See if it can do sine waves
54 * if ((SDL_HapticQueryEffects(haptic) & SDL_HAPTIC_SINE)==0) { 53 * if ((SDL_HapticQuery(haptic) & SDL_HAPTIC_SINE)==0) {
55 * SDL_HapticClose(haptic); // No sine effect 54 * SDL_HapticClose(haptic); // No sine effect
56 * return -1; 55 * return -1;
57 * } 56 * }
58 * 57 *
59 * // Create the effect 58 * // Create the effect
98 /* Set up for C function definitions, even when using C++ */ 97 /* Set up for C function definitions, even when using C++ */
99 #ifdef __cplusplus 98 #ifdef __cplusplus
100 /* *INDENT-OFF* */ 99 /* *INDENT-OFF* */
101 extern "C" { 100 extern "C" {
102 /* *INDENT-ON* */ 101 /* *INDENT-ON* */
103 #endif /* __cpluspuls */ 102 #endif /* __cplusplus */
104 103
105 /** 104 /**
106 * \typedef SDL_Haptic 105 * \typedef SDL_Haptic
107 * 106 *
108 * \brief The haptic structure used to identify an SDL haptic. 107 * \brief The haptic structure used to identify an SDL haptic.
268 * \struct SDL_HapticDirection 267 * \struct SDL_HapticDirection
269 * 268 *
270 * \brief Structure that represents a haptic direction. 269 * \brief Structure that represents a haptic direction.
271 * 270 *
272 * Directions can be specified by: 271 * Directions can be specified by:
273 * - SDL_HAPTIC_POLAR: Specified by polar coordinates. 272 * - SDL_HAPTIC_POLAR : Specified by polar coordinates.
274 * - SDL_HAPTIC_CARTESIAN: Specified by cartesian coordinates. 273 * - SDL_HAPTIC_CARTESIAN : Specified by cartesian coordinates.
275 * 274 *
276 * Cardinal directions of the haptic device are relative to the positioning 275 * Cardinal directions of the haptic device are relative to the positioning
277 * of the device. North is considered to be away from the user. 276 * of the device. North is considered to be away from the user.
278 * 277 *
279 * The following diagram represents the cardinal directions: 278 * The following diagram represents the cardinal directions:
343 * 342 *
344 * \brief A structure containing a template for a Constant effect. 343 * \brief A structure containing a template for a Constant effect.
345 * 344 *
346 * The struct is exclusive to the SDL_HAPTIC_CONSTANT effect. 345 * The struct is exclusive to the SDL_HAPTIC_CONSTANT effect.
347 * 346 *
347 * A constant effect applies a constant force in the specified direction
348 * to the joystick.
349 *
348 * \sa SDL_HAPTIC_CONSTANT 350 * \sa SDL_HAPTIC_CONSTANT
349 * \sa SDL_HapticEffect 351 * \sa SDL_HapticEffect
350 */ 352 */
351 typedef struct SDL_HapticConstant { 353 typedef struct SDL_HapticConstant {
352 /* Header */ 354 /* Header */
380 * - SDL_HAPTIC_SQUARE 382 * - SDL_HAPTIC_SQUARE
381 * - SDL_HAPTIC_TRIANGLE 383 * - SDL_HAPTIC_TRIANGLE
382 * - SDL_HAPTIC_SAWTOOTHUP 384 * - SDL_HAPTIC_SAWTOOTHUP
383 * - SDL_HAPTIC_SAWTOOTHDOWN 385 * - SDL_HAPTIC_SAWTOOTHDOWN
384 * 386 *
387 * A periodic effect consists in a wave-shaped effect that repeats itself
388 * over time. The type determines the shape of the wave and the parameters
389 * determine the dimensions of the wave.
390 *
385 * Examples: 391 * Examples:
386 * \code 392 * \code
387 * SDL_HAPTIC_SINE 393 * SDL_HAPTIC_SINE
388 * __ __ __ __ 394 * __ __ __ __
389 * / \ / \ / \ / 395 * / \ / \ / \ /
398 * /\ /\ /\ /\ /\ 404 * /\ /\ /\ /\ /\
399 * / \ / \ / \ / \ / 405 * / \ / \ / \ / \ /
400 * / \/ \/ \/ \/ 406 * / \/ \/ \/ \/
401 * 407 *
402 * SDL_HAPTIC_SAWTOOTHUP 408 * SDL_HAPTIC_SAWTOOTHUP
403 * __ __ __ __ _ 409 * /| /| /| /| /| /| /|
404 * / | / | / | / | / 410 * / | / | / | / | / | / | / |
405 * / | / | / | / | / 411 * / |/ |/ |/ |/ |/ |/ |
406 * / |/ |/ |/ |/
407 * 412 *
408 * SDL_HAPTIC_SAWTOOTHDOWN 413 * SDL_HAPTIC_SAWTOOTHDOWN
409 * __ __ __ __ __ 414 * \ |\ |\ |\ |\ |\ |\ |
410 * \ | \ | \ | \ | \ 415 * \ | \ | \ | \ | \ | \ | \ |
411 * \ | \ | \ | \ | \ 416 * \| \| \| \| \| \| \|
412 * \| \| \| \|
413 * \endcode 417 * \endcode
414 * 418 *
415 * \sa SDL_HAPTIC_SINE 419 * \sa SDL_HAPTIC_SINE
416 * \sa SDL_HAPTIC_SQUARE 420 * \sa SDL_HAPTIC_SQUARE
417 * \sa SDL_HAPTIC_TRIANGLE 421 * \sa SDL_HAPTIC_TRIANGLE
418 * \sa SDL_HAPTIC_SAWTOOTHUP 422 * \sa SDL_HAPTIC_SAWTOOTHUP
419 * \sa SDL_HAPTIC SAWTOOTHDOWN 423 * \sa SDL_HAPTIC_SAWTOOTHDOWN
420 * \sa SDL_HapticEffect 424 * \sa SDL_HapticEffect
421 */ 425 */
422 typedef struct SDL_HapticPeriodic { 426 typedef struct SDL_HapticPeriodic {
423 /* Header */ 427 /* Header */
424 Uint16 type; /**< SDL_HAPTIC_{SINE,SQUARE,TRIANGLE,SAWTOOTHUP,SAWTOOTHDOWN} */ 428 Uint16 type; /**< SDL_HAPTIC_SINE, SDL_HAPTIC_SQUARE,
429 SDL_HAPTIC_TRIANGLE, SDL_HAPTIC_SAWTOOTHUP or
430 SDL_HAPTIC_SAWTOOTHDOWN */
425 SDL_HapticDirection direction; /**< Direction of the effect. */ 431 SDL_HapticDirection direction; /**< Direction of the effect. */
426 432
427 /* Replay */ 433 /* Replay */
428 Uint16 length; /**< Duration of the effect. */ 434 Uint16 length; /**< Duration of the effect. */
429 Uint16 delay; /**< Delay before starting the effect. */ 435 Uint16 delay; /**< Delay before starting the effect. */
447 /** 453 /**
448 * \struct SDL_HapticCondition 454 * \struct SDL_HapticCondition
449 * 455 *
450 * \brief A structure containing a template for a Condition effect. 456 * \brief A structure containing a template for a Condition effect.
451 * 457 *
452 * Direction is handled by condition internals instead of a direction member.
453 * Each of right_sat, lefT-sat, right_coeff, left_coeff, deadband and center
454 * have two parameters, first is for x value, second is for y value following
455 * the scheme set by SDL_HapticDirection.
456 *
457 * The struct handles the following effects: 458 * The struct handles the following effects:
458 * - SDL_HAPTIC_SPRING: Effect based on axes position. 459 * - SDL_HAPTIC_SPRING: Effect based on axes position.
459 * - SDL_HAPTIC_DAMPER: Effect based on axes velocity. 460 * - SDL_HAPTIC_DAMPER: Effect based on axes velocity.
460 * - SDL_HAPTIC_INERTIA: Effect based on axes acceleration. 461 * - SDL_HAPTIC_INERTIA: Effect based on axes acceleration.
461 * - SDL_HAPTIC_FRICTION: Effect based on axes movement. 462 * - SDL_HAPTIC_FRICTION: Effect based on axes movement.
463 *
464 * Direction is handled by condition internals instead of a direction member.
465 * The condition effect specific members have two parameters. The first
466 * refers to the X axis, the second refers to the Y axis. The right terms
467 * refer to the positive side of the axis and the left terms refer to the
468 * negative side of the axis. Please refer to the SDL_HapticDirection
469 * diagram for which side is positive and which is negative.
462 * 470 *
463 * \sa SDL_HapticDirection 471 * \sa SDL_HapticDirection
464 * \sa SDL_HAPTIC_SPRING 472 * \sa SDL_HAPTIC_SPRING
465 * \sa SDL_HAPTIC_DAMPER 473 * \sa SDL_HAPTIC_DAMPER
466 * \sa SDL_HAPTIC_INERTIA 474 * \sa SDL_HAPTIC_INERTIA
467 * \sa SDL_HAPTIC_FRICTION 475 * \sa SDL_HAPTIC_FRICTION
468 * \sa SDL_HapticEffect 476 * \sa SDL_HapticEffect
469 */ 477 */
470 typedef struct SDL_HapticCondition { 478 typedef struct SDL_HapticCondition {
471 /* Header */ 479 /* Header */
472 Uint16 type; /**< SDL_HAPTIC_{SPRING,DAMPER,INERTIA,FRICTION} */ 480 Uint16 type; /**< SDL_HAPTIC_SPRING, SDL_HAPTIC_DAMPER,
481 SDL_HAPTIC_INERTIA or SDL_HAPTIC_FRICTION */
473 482
474 /* Replay */ 483 /* Replay */
475 Uint16 length; /**< Duration of the effect. */ 484 Uint16 length; /**< Duration of the effect. */
476 Uint16 delay; /**< Delay before starting the effect. */ 485 Uint16 delay; /**< Delay before starting the effect. */
477 486
478 /* Trigger */ 487 /* Trigger */
479 Uint16 button; /**< Button that triggers the effect. */ 488 Uint16 button; /**< Button that triggers the effect. */
480 Uint16 interval; /**< How soon it can be triggered again after button. */ 489 Uint16 interval; /**< How soon it can be triggered again after button. */
481 490
482 /* Condition */ 491 /* Condition */
483 Uint16 right_sat[2]; /**< Level when joystick is to the right. */ 492 Uint16 right_sat[2]; /**< Level when joystick is to the positive side. */
484 Uint16 left_sat[2]; /**< Level when joystick is to the left. */ 493 Uint16 left_sat[2]; /**< Level when joystick is to the negative side. */
485 Sint16 right_coeff[2]; /**< How fast to increase the force towards the right. */ 494 Sint16 right_coeff[2]; /**< How fast to increase the force towards the positive side. */
486 Sint16 left_coeff[2]; /**< How fast to increase the force towards the left. */ 495 Sint16 left_coeff[2]; /**< How fast to increase the force towards the negative side. */
487 Uint16 deadband[2]; /**< Size of the dead zone. */ 496 Uint16 deadband[2]; /**< Size of the dead zone. */
488 Sint16 center[2]; /**< Position of the dead zone. */ 497 Sint16 center[2]; /**< Position of the dead zone. */
489 } SDL_HapticCondition; 498 } SDL_HapticCondition;
490 /** 499 /**
491 * \struct SDL_HapticRamp 500 * \struct SDL_HapticRamp
492 * 501 *
493 * \brief A structure containing a template for a Ramp effect. 502 * \brief A structure containing a template for a Ramp effect.
494 * 503 *
495 * This struct is exclusively for the SDL_HAPTIC_RAMP effect. 504 * This struct is exclusively for the SDL_HAPTIC_RAMP effect.
505 *
506 * The ramp effect starts at start strength and ends at end strength.
507 * It augments in linear fashion. If you use attack and fade with a ramp
508 * they effects get added to the ramp effect making the effect become
509 * quadratic instead of linear.
496 * 510 *
497 * \sa SDL_HAPTIC_RAMP 511 * \sa SDL_HAPTIC_RAMP
498 * \sa SDL_HapticEffect 512 * \sa SDL_HapticEffect
499 */ 513 */
500 typedef struct SDL_HapticRamp { 514 typedef struct SDL_HapticRamp {
524 * \union SDL_HapticEffect 538 * \union SDL_HapticEffect
525 * 539 *
526 * \brief The generic template for any haptic effect. 540 * \brief The generic template for any haptic effect.
527 * 541 *
528 * All values max at 32767 (0x7FFF). Signed values also can be negative. 542 * All values max at 32767 (0x7FFF). Signed values also can be negative.
529 * Time values unless specified otherwise are in milliseconds. 543 * Time values unless specified otherwise are in milliseconds.
530 * 544 *
531 * Common parts: 545 * Common parts:
532 * \code 546 * \code
533 * // Replay - All effects have this 547 * // Replay - All effects have this
534 * Uint16 length; // Duration of effect (ms). 548 * Uint16 length; // Duration of effect (ms).
536 * 550 *
537 * // Trigger - All effects have this 551 * // Trigger - All effects have this
538 * Uint16 button; // Button that triggers effect. 552 * Uint16 button; // Button that triggers effect.
539 * Uint16 interval; // How soon before effect can be triggered again. 553 * Uint16 interval; // How soon before effect can be triggered again.
540 * 554 *
541 * // Envelope - Not all effects have this 555 * // Envelope - All effects except condition effects have this
542 * Uint16 attack_length; // Duration of the attack (ms). 556 * Uint16 attack_length; // Duration of the attack (ms).
543 * Uint16 attack_level; // Level at the start of the attack. 557 * Uint16 attack_level; // Level at the start of the attack.
544 * Uint16 fade_length; // Duration of the fade out (ms). 558 * Uint16 fade_length; // Duration of the fade out (ms).
545 * Uint16 fade_level; // Level at the end of the fade. 559 * Uint16 fade_level; // Level at the end of the fade.
546 * \endcode 560 * \endcode
547 * 561 *
548 * 562 *
549 * Here we have an example of an effect evolution in time: 563 * Here we have an example of a constant effect evolution in time:
550 * 564 *
551 * \code 565 * \code
552 * Strength 566 * Strength
553 * ^ 567 * ^
554 * | 568 * |
555 * | effect strength --> _________________ 569 * | effect level --> _________________
556 * | / \ 570 * | / \
557 * | / \ 571 * | / \
558 * | / \ 572 * | / \
559 * | / \ 573 * | / \
560 * | attack_level --> | \ 574 * | attack_level --> | \
566 * 580 *
567 * [------------------][-----------------------] 581 * [------------------][-----------------------]
568 * delay length 582 * delay length
569 * \endcode 583 * \endcode
570 * 584 *
585 * Note either the attack_level or the fade_level may be above the actual
586 * effect level.
587 *
571 * \sa SDL_HapticConstant 588 * \sa SDL_HapticConstant
572 * \sa SDL_HapticPeriodic 589 * \sa SDL_HapticPeriodic
573 * \sa SDL_HapticCondition 590 * \sa SDL_HapticCondition
574 * \sa SDL_HapticRamp 591 * \sa SDL_HapticRamp
575 */ 592 */