5 * The SDL Haptic subsystem allows you to control haptic (force feedback)
8 * The basic usage is as follows:
9 * - Initialize the Subsystem (::SDL_INIT_HAPTIC).
10 * - Open a Haptic Device.
11 * - SDL_HapticOpen() to open from index.
12 * - SDL_HapticOpenFromJoystick() to open from an existing joystick.
13 * - Create an effect (::SDL_HapticEffect).
14 * - Upload the effect with SDL_HapticNewEffect().
15 * - Run the effect with SDL_HapticRunEffect().
16 * - (optional) Free the effect with SDL_HapticDestroyEffect().
17 * - Close the haptic device with SDL_HapticClose().
19 * Simple rumble example:
24 * haptic = SDL_HapticOpen( 0 );
28 * // Initialize simple rumble
29 * if (SDL_HapticRumbleInit( haptic ) != 0)
32 * // Play effect at 50% strength for 2 seconds
33 * if (SDL_HapticRumblePlay( haptic, 0.5, 2000 ) != 0)
38 * SDL_HapticClose( haptic );
43 * int test_haptic( SDL_Joystick * joystick )
45 * SDL_HapticEffect effect;
49 * haptic = SDL_HapticOpenFromJoystick( joystick );
50 * if (haptic == NULL) return -1; // Most likely joystick isn't haptic
52 * // See if it can do sine waves
53 * if ((SDL_HapticQuery(haptic) & SDL_HAPTIC_SINE)==0)
54 * SDL_HapticClose(haptic); // No sine effect
58 * // Create the effect
59 * memset( &effect, 0, sizeof(SDL_HapticEffect) ); // 0 is safe default
60 * effect.type = SDL_HAPTIC_SINE;
61 * effect.periodic.direction.type = SDL_HAPTIC_POLAR; // Polar coordinates
62 * effect.periodic.direction.dir[0] = 18000; // Force comes from south
63 * effect.periodic.period = 1000; // 1000 ms
64 * effect.periodic.magnitude = 20000; // 20000/32767 strength
65 * effect.periodic.length = 5000; // 5 seconds long
66 * effect.periodic.attack_length = 1000; // Takes 1 second to get max strength
67 * effect.periodic.fade_length = 1000; // Takes 1 second to fade away
69 * // Upload the effect
70 * effect_id = SDL_HapticNewEffect( haptic, &effect );
73 * SDL_HapticRunEffect( haptic, effect_id, 1 );
74 * SDL_Delay( 5000); // Wait for the effect to finish
76 * // We destroy the effect, although closing the device also does this
77 * SDL_HapticDestroyEffect( haptic, effect_id );
80 * SDL_HapticClose(haptic);
82 * return 0; // Success
86 * You can also find out more information on my blog:
87 * http://bobbens.dyndns.org/journal/2010/sdl_haptic/
97 * The haptic structure used to identify an SDL haptic.
100 * SDL_HapticOpenFromJoystick
104 PSDL_Haptic = ^TSDL_Haptic;
105 TSDL_Haptic = record end;
110 * Different haptic features a device can have.
118 * Constant effect supported.
120 * Constant haptic effect.
122 * SDL_HapticCondition
125 SDL_HAPTIC_CONSTANT = (1 shl 0);
128 * Sine wave effect supported.
130 * Periodic haptic effect that simulates sine waves.
135 SDL_HAPTIC_SINE = (1 shl 1);
138 * Square wave effect supported.
140 * Periodic haptic effect that simulates square waves.
145 SDL_HAPTIC_SQUARE = (1 shl 2);
148 * Triangle wave effect supported.
150 * Periodic haptic effect that simulates triangular waves.
155 SDL_HAPTIC_TRIANGLE = (1 shl 3);
158 * Sawtoothup wave effect supported.
160 * Periodic haptic effect that simulates saw tooth up waves.
165 SDL_HAPTIC_SAWTOOTHUP = (1 shl 4);
168 * Sawtoothdown wave effect supported.
170 * Periodic haptic effect that simulates saw tooth down waves.
175 SDL_HAPTIC_SAWTOOTHDOWN = (1 shl 5);
178 * Ramp effect supported.
180 * Ramp haptic effect.
185 SDL_HAPTIC_RAMP = (1 shl 6);
188 * Spring effect supported - uses axes position.
190 * Condition haptic effect that simulates a spring. Effect is based on the
193 * SDL_HapticCondition
196 SDL_HAPTIC_SPRING = (1 shl 7);
199 * Damper effect supported - uses axes velocity.
201 * Condition haptic effect that simulates dampening. Effect is based on the
204 * SDL_HapticCondition
207 SDL_HAPTIC_DAMPER = (1 shl 8);
210 * Inertia effect supported - uses axes acceleration.
212 * Condition haptic effect that simulates inertia. Effect is based on the axes
215 * SDL_HapticCondition
218 SDL_HAPTIC_INERTIA = (1 shl 9);
221 * Friction effect supported - uses axes movement.
223 * Condition haptic effect that simulates friction. Effect is based on the
226 * SDL_HapticCondition
229 SDL_HAPTIC_FRICTION = (1 shl 10);
232 * Custom effect is supported.
234 * User defined custom haptic effect.
237 SDL_HAPTIC_CUSTOM = (1 shl 11);
241 {* These last few are features the device has, not effects *}
244 * Device can set global gain.
246 * Device supports setting the global gain.
251 SDL_HAPTIC_GAIN = (1 shl 12);
254 * Device can set autocenter.
256 * Device supports setting autocenter.
258 * SDL_HapticSetAutocenter
261 SDL_HAPTIC_AUTOCENTER = (1 shl 13);
264 * Device can be queried for effect status.
266 * Device can be queried for effect status.
268 * SDL_HapticGetEffectStatus
271 SDL_HAPTIC_STATUS = (1 shl 14);
274 * Device can be paused.
280 SDL_HAPTIC_PAUSE = (1 shl 15);
283 * Direction encodings
287 * Uses polar coordinates for the direction.
289 * SDL_HapticDirection
292 SDL_HAPTIC_POLAR = 0;
295 * Uses cartesian coordinates for the direction.
297 * SDL_HapticDirection
300 SDL_HAPTIC_CARTESIAN = 1;
303 * Uses spherical coordinates for the direction.
305 * SDL_HapticDirection
308 SDL_HAPTIC_SPHERICAL = 2;
310 {*Direction encodings*}
319 * Used to play a device an infinite number of times.
321 * SDL_HapticRunEffect
324 //SDL_HAPTIC_INFINITY = 4294967295U;
325 SDL_HAPTIC_INFINITY = 4294967295; //right?!
328 * Structure that represents a haptic direction.
330 * Directions can be specified by:
331 * - SDL_HAPTIC_POLAR : Specified by polar coordinates.
332 * - SDL_HAPTIC_CARTESIAN : Specified by cartesian coordinates.
333 * - SDL_HAPTIC_SPHERICAL : Specified by spherical coordinates.
335 * Cardinal directions of the haptic device are relative to the positioning
336 * of the device. North is considered to be away from the user.
338 * The following diagram represents the cardinal directions:
353 (1,0) West <----[ HAPTIC ]----> East (-1,0)
366 * If type is SDL_HAPTIC_POLAR, direction is encoded by hundredths of a
367 * degree starting north and turning clockwise. ::SDL_HAPTIC_POLAR only uses
368 * the first dir parameter. The cardinal directions would be:
369 * - North: 0 (0 degrees)
370 * - East: 9000 (90 degrees)
371 * - South: 18000 (180 degrees)
372 * - West: 27000 (270 degrees)
374 * If type is SDL_HAPTIC_CARTESIAN, direction is encoded by three positions
375 * (X axis, Y axis and Z axis (with 3 axes)). ::SDL_HAPTIC_CARTESIAN uses
376 * the first three dir parameters. The cardinal directions would be:
382 * The Z axis represents the height of the effect if supported, otherwise
383 * it's unused. In cartesian encoding (1, 2) would be the same as (2, 4), you
384 * can use any multiple you want, only the direction matters.
386 * If type is SDL_HAPTIC_SPHERICAL, direction is encoded by two rotations.
387 * The first two dir parameters are used. The dir parameters are as
388 * follows (all values are in hundredths of degrees):
389 * - Degrees from (1, 0) rotated towards (0, 1).
390 * - Degrees towards (0, 0, 1) (device needs at least 3 axes).
393 * Example of force coming from the south with all encodings (force coming
394 * from the south means the user will have to pull the stick to counteract):
396 * SDL_HapticDirection direction;
398 * // Cartesian directions
399 * direction.type = SDL_HAPTIC_CARTESIAN; // Using cartesian direction encoding.
400 * direction.dir[0] = 0; // X position
401 * direction.dir[1] = 1; // Y position
402 * // Assuming the device has 2 axes, we don't need to specify third parameter.
404 * // Polar directions
405 * direction.type = SDL_HAPTIC_POLAR; // We'll be using polar direction encoding.
406 * direction.dir[0] = 18000; // Polar only uses first parameter
408 * // Spherical coordinates
409 * direction.type = SDL_HAPTIC_SPHERICAL; // Spherical encoding
410 * direction.dir[0] = 9000; // Since we only have two axes we don't need more parameters.
414 * SDL_HAPTIC_CARTESIAN
415 * SDL_HAPTIC_SPHERICAL
420 TSDL_HapticDirection = record
421 _type: UInt8; {**< The type of encoding. *}
422 dir: array[0..2] of SInt32; {**< The encoded direction. *}
426 * A structure containing a template for a Constant effect.
428 * The struct is exclusive to the ::SDL_HAPTIC_CONSTANT effect.
430 * A constant effect applies a constant force in the specified direction
433 * SDL_HAPTIC_CONSTANT
437 TSDL_HapticConstant = record
439 _type: UInt16; {**< SDL_HAPTIC_CONSTANT *}
440 direction: TSDL_HapticDirection; {**< Direction of the effect. *}
443 length: UInt32; {**< Duration of the effect. *}
444 delay: UInt16; {**< Delay before starting the effect. *}
447 button: UInt16; {**< Button that triggers the effect. *}
448 interval: UInt16; {**< How soon it can be triggered again after button. *}
451 level: SInt16; {**< Strength of the constant effect. *}
454 attack_length: UInt16; {**< Duration of the attack. *}
455 attack_level: UInt16; {**< Level at the start of the attack. *}
456 fade_length: UInt16; {**< Duration of the fade. *}
457 fade_level: UInt16; {**< Level at the end of the fade. *}
461 * A structure containing a template for a Periodic effect.
463 * The struct handles the following effects:
465 * - SDL_HAPTIC_SQUARE
466 * - SDL_HAPTIC_TRIANGLE
467 * - SDL_HAPTIC_SAWTOOTHUP
468 * - SDL_HAPTIC_SAWTOOTHDOWN
470 * A periodic effect consists in a wave-shaped effect that repeats itself
471 * over time. The type determines the shape of the wave and the parameters
472 * determine the dimensions of the wave.
474 * Phase is given by hundredth of a cycle meaning that giving the phase a value
475 * of 9000 will displace it 25% of its period. Here are sample values:
476 * - 0: No phase displacement.
477 * - 9000: Displaced 25% of its period.
478 * - 18000: Displaced 50% of its period.
479 * - 27000: Displaced 75% of its period.
480 * - 36000: Displaced 100% of its period, same as 0, but 0 is preferred.
492 | |__| |__| |__| |__| |
499 SDL_HAPTIC_SAWTOOTHUP
501 / | / | / | / | / | / | / |
502 / |/ |/ |/ |/ |/ |/ |
504 SDL_HAPTIC_SAWTOOTHDOWN
505 \ |\ |\ |\ |\ |\ |\ |
506 \ | \ | \ | \ | \ | \ | \ |
512 * SDL_HAPTIC_TRIANGLE
513 * SDL_HAPTIC_SAWTOOTHUP
514 * SDL_HAPTIC_SAWTOOTHDOWN
518 TSDL_HapticPeriodic = record
520 _type: UInt16; {**< SDL_HAPTIC_SINE, SDL_HAPTIC_SQUARE,
521 SDL_HAPTIC_TRIANGLE, SDL_HAPTIC_SAWTOOTHUP or
522 SDL_HAPTIC_SAWTOOTHDOWN *}
523 direction: TSDL_HapticDirection; {**< Direction of the effect. *}
526 length: UInt32; {**< Duration of the effect. *}
527 delay: UInt16; {**< Delay before starting the effect. *}
530 button: UInt16; {**< Button that triggers the effect. *}
531 interval: UInt16; {**< How soon it can be triggered again after button. *}
534 period: UInt16; {**< Period of the wave. *}
535 magnitude: SInt16; {**< Peak value. *}
536 offset: SInt16; {**< Mean value of the wave. *}
537 phase: UInt16; {**< Horizontal shift given by hundredth of a cycle. *}
540 attack_length: UInt16; {**< Duration of the attack. *}
541 attack_level: UInt16; {**< Level at the start of the attack. *}
542 fade_length: UInt16; {**< Duration of the fade. *}
543 fade_level: UInt16; {**< Level at the end of the fade. *}
547 * A structure containing a template for a Condition effect.
549 * The struct handles the following effects:
550 * - SDL_HAPTIC_SPRING: Effect based on axes position.
551 * - SDL_HAPTIC_DAMPER: Effect based on axes velocity.
552 * - SDL_HAPTIC_INERTIA: Effect based on axes acceleration.
553 * - SDL_HAPTIC_FRICTION: Effect based on axes movement.
555 * Direction is handled by condition internals instead of a direction member.
556 * The condition effect specific members have three parameters. The first
557 * refers to the X axis, the second refers to the Y axis and the third
558 * refers to the Z axis. The right terms refer to the positive side of the
559 * axis and the left terms refer to the negative side of the axis. Please
560 * refer to the ::SDL_HapticDirection diagram for which side is positive and
563 * SDL_HapticDirection
567 * SDL_HAPTIC_FRICTION
571 TSDL_HapticCondition = record
573 _type: UInt16; {**< SDL_HAPTIC_SPRING, SDL_HAPTIC_DAMPER,
574 SDL_HAPTIC_INERTIA or SDL_HAPTIC_FRICTION *}
575 direction: TSDL_HapticDirection; {**< Direction of the effect - Not used ATM. *}
578 length: UInt32; {**< Duration of the effect. *}
579 delay: UInt16; {**< Delay before starting the effect. *}
582 button: UInt16; {**< Button that triggers the effect. *}
583 interval: UInt16; {**< How soon it can be triggered again after button. *}
586 right_sat: array[0..2] of UInt16; {**< Level when joystick is to the positive side. *}
587 left_sat: array[0..2] of UInt16; {**< Level when joystick is to the negative side. *}
588 right_coeff: array[0..2] of SInt16; {**< How fast to increase the force towards the positive side. *}
589 left_coeff: array[0..2] of SInt16; {**< How fast to increase the force towards the negative side. *}
590 deadband: array[0..2] of UInt16; {**< Size of the dead zone. *}
591 center: array[0..2] of SInt16; {**< Position of the dead zone. *}
595 * A structure containing a template for a Ramp effect.
597 * This struct is exclusively for the ::SDL_HAPTIC_RAMP effect.
599 * The ramp effect starts at start strength and ends at end strength.
600 * It augments in linear fashion. If you use attack and fade with a ramp
601 * the effects get added to the ramp effect making the effect become
602 * quadratic instead of linear.
608 TSDL_HapticRamp = record
610 _type: UInt16; {**< SDL_HAPTIC_RAMP *}
611 direction: TSDL_HapticDirection; {**< Direction of the effect. *}
614 length: UInt32; {**< Duration of the effect. *}
615 delay: UInt16; {**< Delay before starting the effect. *}
618 button: UInt16; {**< Button that triggers the effect. *}
619 interval: UInt16; {**< How soon it can be triggered again after button. *}
622 start: SInt16; {**< Beginning strength level. *}
623 _end: SInt16; {**< Ending strength level. *}
626 attack_length: UInt16; {**< Duration of the attack. *}
627 attack_level: UInt16; {**< Level at the start of the attack. *}
628 fade_length: UInt16; {**< Duration of the fade. *}
629 fade_level: UInt16; {**< Level at the end of the fade. *}
633 * A structure containing a template for the ::SDL_HAPTIC_CUSTOM effect.
635 * A custom force feedback effect is much like a periodic effect, where the
636 * application can define its exact shape. You will have to allocate the
637 * data yourself. Data should consist of channels * samples Uint16 samples.
639 * If channels is one, the effect is rotated using the defined direction.
640 * Otherwise it uses the samples in data for the different axes.
646 TSDL_HapticCustom = record
648 _type: UInt16; {**< SDL_HAPTIC_CUSTOM *}
649 direction: TSDL_HapticDirection; {**< Direction of the effect. *}
652 length: UInt32; {**< Duration of the effect. *}
653 delay: UInt16; {**< Delay before starting the effect. *}
656 button: UInt16; {**< Button that triggers the effect. *}
657 interval: UInt16; {**< How soon it can be triggered again after button. *}
660 channels: UInt8; {**< Axes to use, minimum of one. *}
661 period: UInt16; {**< Sample periods. *}
662 samples: UInt16; {**< Amount of samples. *}
663 data: PUInt16; {**< Should contain channels*samples items. *}
666 attack_length: UInt16; {**< Duration of the attack. *}
667 attack_level: UInt16; {**< Level at the start of the attack. *}
668 fade_length: UInt16; {**< Duration of the fade. *}
669 fade_level: UInt16; {**< Level at the end of the fade. *}
673 * The generic template for any haptic effect.
675 * All values max at 32767 (0x7FFF). Signed values also can be negative.
676 * Time values unless specified otherwise are in milliseconds.
678 * You can also pass SDL_HAPTIC_INFINITY to length instead of a 0-32767
679 * value. Neither delay, interval, attack_length nor fade_length support
680 * SDL_HAPTIC_INFINITY. Fade will also not be used since effect never ends.
682 * Additionally, the SDL_HAPTIC_RAMP effect does not support a duration of
683 * SDL_HAPTIC_INFINITY.
685 * Button triggers may not be supported on all devices, it is advised to not
686 * use them if possible. Buttons start at index 1 instead of index 0 like
689 * If both attack_length and fade_level are 0, the envelope is not used,
690 * otherwise both values are used.
694 * // Replay - All effects have this
695 * Uint32 length; // Duration of effect (ms).
696 * Uint16 delay; // Delay before starting effect.
698 * // Trigger - All effects have this
699 * Uint16 button; // Button that triggers effect.
700 * Uint16 interval; // How soon before effect can be triggered again.
702 * // Envelope - All effects except condition effects have this
703 * Uint16 attack_length; // Duration of the attack (ms).
704 * Uint16 attack_level; // Level at the start of the attack.
705 * Uint16 fade_length; // Duration of the fade out (ms).
706 * Uint16 fade_level; // Level at the end of the fade.
710 * Here we have an example of a constant effect evolution in time:
715 | effect level --> _________________
720 | attack_level --> | \
721 | | | <--- fade_level
723 +--------------------------------------------------> Time
725 attack_length fade_length
727 [------------------][-----------------------]
731 * Note either the attack_level or the fade_level may be above the actual
736 * SDL_HapticCondition
741 PSDL_HapticEffect = ^TSDL_HapticEffect;
742 TSDL_HapticEffect = record
743 {* Common for all force feedback effects *}
744 _type: UInt16; {**< Effect type. *}
746 0: (constant: TSDL_HapticConstant;); {**< Constant effect. *}
747 1: (periodic: TSDL_HapticPeriodic;); {**< Periodic effect. *}
748 2: (condition: TSDL_HapticCondition;); {**< Condition effect. *}
749 3: (ramp: TSDL_HapticRamp;); {**< Ramp effect. *}
750 4: (custom: TSDL_HapticCustom;); {**< Custom effect. *}
753 {* Function prototypes *}
756 * Count the number of haptic devices attached to the system.
758 * Number of haptic devices detected on the system.
760 function SDL_NumHaptics: Integer cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_NumHaptics' {$ENDIF} {$ENDIF};
763 * Get the implementation dependent name of a Haptic device.
765 * This can be called before any joysticks are opened.
766 * If no name can be found, this function returns NULL.
768 * device_index Index of the device to get its name.
769 * Name of the device or NULL on error.
773 function SDL_HapticName(device_index: Integer): PAnsiChar cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_HapticName' {$ENDIF} {$ENDIF};
776 * Opens a Haptic device for usage.
778 * The index passed as an argument refers to the N'th Haptic device on this
781 * When opening a haptic device, its gain will be set to maximum and
782 * autocenter will be disabled. To modify these values use
783 * SDL_HapticSetGain() and SDL_HapticSetAutocenter().
785 * device_index Index of the device to open.
786 * Device identifier or NULL on error.
789 * SDL_HapticOpenFromMouse
790 * SDL_HapticOpenFromJoystick
793 * SDL_HapticSetAutocenter
797 function SDL_HapticOpen(device_index: Integer): PSDL_Haptic cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_HapticOpen' {$ENDIF} {$ENDIF};
800 * Checks if the haptic device at index has been opened.
802 * device_index Index to check to see if it has been opened.
803 * 1 if it has been opened or 0 if it hasn't.
808 function SDL_HapticOpened(device_index: Integer): Integer cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_HapticOpened' {$ENDIF} {$ENDIF};
811 * Gets the index of a haptic device.
813 * haptic Haptic device to get the index of.
814 * The index of the haptic device or -1 on error.
819 function SDL_HapticIndex(haptic: PSDL_Haptic): Integer cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_HapticIndex' {$ENDIF} {$ENDIF};
822 * Gets whether or not the current mouse has haptic capabilities.
824 * SDL_TRUE if the mouse is haptic, SDL_FALSE if it isn't.
826 * SDL_HapticOpenFromMouse
828 function SDL_MouseIsHaptic: Integer cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_MouseInHaptic' {$ENDIF} {$ENDIF};
831 * Tries to open a haptic device from the current mouse.
833 * The haptic device identifier or NULL on error.
838 function SDL_HapticOpenFromMouse: PSDL_Haptic cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_HapticOpenFromMouse' {$ENDIF} {$ENDIF};
841 * Checks to see if a joystick has haptic features.
843 * joystick Joystick to test for haptic capabilities.
844 * 1 if the joystick is haptic, 0 if it isn't
845 * or -1 if an error ocurred.
847 * SDL_HapticOpenFromJoystick
849 function SDL_JoystickIsHaptic(joystick: PSDL_Joystick): Integer cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_JoystickIsHaptic' {$ENDIF} {$ENDIF};
852 * Opens a Haptic device for usage from a Joystick device.
854 * You must still close the haptic device seperately. It will not be closed
857 * When opening from a joystick you should first close the haptic device before
858 * closing the joystick device. If not, on some implementations the haptic
859 * device will also get unallocated and you'll be unable to use force feedback
862 * joystick Joystick to create a haptic device from.
863 * A valid haptic device identifier on success or NULL on error.
868 function SDL_HapticOpenFromJoystick(joystick: PSDL_Joystick): PSDL_Haptic cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_HapticOpenFromJoystick' {$ENDIF} {$ENDIF};
871 * Closes a Haptic device previously opened with SDL_HapticOpen().
873 * haptic Haptic device to close.
875 procedure SDL_HapticClose(haptic: PSDL_Haptic) cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_HapticClose' {$ENDIF} {$ENDIF};
878 * Returns the number of effects a haptic device can store.
880 * On some platforms this isn't fully supported, and therefore is an
881 * approximation. Always check to see if your created effect was actually
882 * created and do not rely solely on SDL_HapticNumEffects().
884 * haptic The haptic device to query effect max.
885 * The number of effects the haptic device can store or
888 * SDL_HapticNumEffectsPlaying
891 function SDL_HapticNumEffects(haptic: PSDL_Haptic): Integer cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_HapticNumEffects' {$ENDIF} {$ENDIF};
894 * Returns the number of effects a haptic device can play at the same
897 * This is not supported on all platforms, but will always return a value.
898 * Added here for the sake of completeness.
900 * haptic The haptic device to query maximum playing effects.
901 * The number of effects the haptic device can play at the same time
904 * SDL_HapticNumEffects
907 function SDL_HapticNumEffectsPlaying(haptic: PSDL_Haptic): Integer cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_HapticNumEffectsPlaying' {$ENDIF} {$ENDIF};
910 * Gets the haptic devices supported features in bitwise matter.
914 * if (SDL_HapticQueryEffects(haptic) & SDL_HAPTIC_CONSTANT)
915 * printf("We have constant haptic effect!");
919 * haptic The haptic device to query.
920 * Haptic features in bitwise manner (OR'd).
922 * SDL_HapticNumEffects
923 * SDL_HapticEffectSupported
925 function SDL_HapticQuery(haptic: PSDL_Haptic): UInt32 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_HapticQuery' {$ENDIF} {$ENDIF};
928 * Gets the number of haptic axes the device has.
930 * SDL_HapticDirection
932 function SDL_HapticNumAxes(haptic: PSDL_Haptic): Integer cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_HapticNumAxes' {$ENDIF} {$ENDIF};
935 * Checks to see if effect is supported by haptic.
937 * haptic Haptic device to check on.
938 * effect Effect to check to see if it is supported.
939 * SDL_TRUE if effect is supported, SDL_FALSE if it isn't or -1 on error.
942 * SDL_HapticNewEffect
944 function SDL_HapticEffectSupported(haptic: PSDL_Haptic; effect: PSDL_HapticEffect): Integer cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_HapticEffectSupported' {$ENDIF} {$ENDIF};
947 * Creates a new haptic effect on the device.
949 * haptic Haptic device to create the effect on.
950 * effect Properties of the effect to create.
951 * The id of the effect on success or -1 on error.
953 * SDL_HapticUpdateEffect
954 * SDL_HapticRunEffect
955 * SDL_HapticDestroyEffect
957 function SDL_HapticNewEffect(haptic: PSDL_Haptic; effect: PSDL_HapticEffect): Integer cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_HapticNewEffect' {$ENDIF} {$ENDIF};
960 * Updates the properties of an effect.
962 * Can be used dynamically, although behaviour when dynamically changing
963 * direction may be strange. Specifically the effect may reupload itself
964 * and start playing from the start. You cannot change the type either when
965 * running SDL_HapticUpdateEffect().
967 * haptic Haptic device that has the effect.
968 * effect Effect to update.
969 * data New effect properties to use.
970 * The id of the effect on success or -1 on error.
972 * SDL_HapticNewEffect
973 * SDL_HapticRunEffect
974 * SDL_HapticDestroyEffect
976 function SDL_HapticUpdateEffect(haptic: PSDL_Haptic; effect: Integer; data: PSDL_HapticEffect): Integer cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_HapticUpdateEffect' {$ENDIF} {$ENDIF};
979 * Runs the haptic effect on its associated haptic device.
981 * If iterations are ::SDL_HAPTIC_INFINITY, it'll run the effect over and over
982 * repeating the envelope (attack and fade) every time. If you only want the
983 * effect to last forever, set ::SDL_HAPTIC_INFINITY in the effect's length
986 * haptic Haptic device to run the effect on.
987 * effect Identifier of the haptic effect to run.
988 * iterations Number of iterations to run the effect. Use
989 * SDL_HAPTIC_INFINITY for infinity.
990 * 0 on success or -1 on error.
992 * SDL_HapticStopEffect
993 * SDL_HapticDestroyEffect
994 * SDL_HapticGetEffectStatus
996 function SDL_HapticRunEffect(haptic: PSDL_Haptic; effect: Integer; iterations: UInt32): Integer cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_HapticRunEffect' {$ENDIF} {$ENDIF};
999 * Stops the haptic effect on its associated haptic device.
1001 * haptic Haptic device to stop the effect on.
1002 * effect Identifier of the effect to stop.
1003 * 0 on success or -1 on error.
1005 * SDL_HapticRunEffect
1006 * SDL_HapticDestroyEffect
1008 function SDL_HapticStopEffect(haptic: PSDL_Haptic; effect: Integer): Integer cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_HapticStopEffect' {$ENDIF} {$ENDIF};
1011 * Destroys a haptic effect on the device.
1013 * This will stop the effect if it's running. Effects are automatically
1014 * destroyed when the device is closed.
1016 * haptic Device to destroy the effect on.
1017 * effect Identifier of the effect to destroy.
1019 * SDL_HapticNewEffect
1021 procedure SDL_HapticDestroyEffect(haptic: PSDL_Haptic; effect: Integer) cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_HapticDestroyEffect' {$ENDIF} {$ENDIF};
1024 * Gets the status of the current effect on the haptic device.
1026 * Device must support the ::SDL_HAPTIC_STATUS feature.
1028 * haptic Haptic device to query the effect status on.
1029 * effect Identifier of the effect to query its status.
1030 * 0 if it isn't playing, 1 if it is playing or -1 on error.
1032 * SDL_HapticRunEffect
1033 * SDL_HapticStopEffect
1035 function SDL_HapticGetEffectStatus(haptic: PSDL_Haptic; effect: Integer): Integer cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_HapticGetEffectStatus' {$ENDIF} {$ENDIF};
1038 * Sets the global gain of the device.
1040 * Device must support the SDL_HAPTIC_GAIN feature.
1042 * The user may specify the maximum gain by setting the environment variable
1043 * SDL_HAPTIC_GAIN_MAX which should be between 0 and 100. All calls to
1044 * SDL_HapticSetGain() will scale linearly using SDL_HAPTIC_GAIN_MAX as the
1047 * haptic Haptic device to set the gain on.
1048 * gain Value to set the gain to, should be between 0 and 100.
1049 * 0 on success or -1 on error.
1053 function SDL_HapticSetGain(haptic: PSDL_Haptic; gain: Integer): Integer cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_HapticSetGain' {$ENDIF} {$ENDIF};
1056 * Sets the global autocenter of the device.
1058 * Autocenter should be between 0 and 100. Setting it to 0 will disable
1061 * Device must support the ::SDL_HAPTIC_AUTOCENTER feature.
1063 * haptic Haptic device to set autocentering on.
1064 * autocenter Value to set autocenter to, 0 disables autocentering.
1065 * 0 on success or -1 on error.
1069 function SDL_HapticSetAutocenter(haptic: PSDL_Haptic; autocenter: Integer): Integer cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_HapticSetAutocenter' {$ENDIF} {$ENDIF};
1072 * Pauses a haptic device.
1074 * Device must support the SDL_HAPTIC_PAUSE feature. Call
1075 * SDL_HapticUnpause() to resume playback.
1077 * Do not modify the effects nor add new ones while the device is paused.
1078 * That can cause all sorts of weird errors.
1080 * haptic Haptic device to pause.
1081 * 0 on success or -1 on error.
1085 function SDL_HapticPause(haptic: PSDL_Haptic): Integer cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_HapticPause' {$ENDIF} {$ENDIF};
1088 * Unpauses a haptic device.
1090 * Call to unpause after SDL_HapticPause().
1092 * haptic Haptic device to pause.
1093 * 0 on success or -1 on error.
1097 function SDL_HapticUnpause(haptic: PSDL_Haptic): Integer cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_HapticUnPause' {$ENDIF} {$ENDIF};
1100 * Stops all the currently playing effects on a haptic device.
1102 * haptic Haptic device to stop.
1103 * 0 on success or -1 on error.
1105 function SDL_HapticStopAll(haptic: PSDL_Haptic): Integer cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_HapticStopAll' {$ENDIF} {$ENDIF};
1108 * Checks to see if rumble is supported on a haptic device..
1110 * haptic Haptic device to check to see if it supports rumble.
1111 * SDL_TRUE if effect is supported, SDL_FALSE if it isn't or -1 on error.
1113 * SDL_HapticRumbleInit
1114 * SDL_HapticRumblePlay
1115 * SDL_HapticRumbleStop
1117 function SDL_HapticRumbleSupported(haptic: PSDL_Haptic): Integer cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_HapticRumbleSupported' {$ENDIF} {$ENDIF};
1120 * Initializes the haptic device for simple rumble playback.
1122 * haptic Haptic device to initialize for simple rumble playback.
1123 * 0 on success or -1 on error.
1126 * SDL_HapticRumbleSupported
1127 * SDL_HapticRumblePlay
1128 * SDL_HapticRumbleStop
1130 function SDL_HapticRumbleInit(haptic: PSDL_Haptic): Integer cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_HapticRumbleInit' {$ENDIF} {$ENDIF};
1133 * Runs simple rumble on a haptic device
1135 * haptic Haptic device to play rumble effect on.
1136 * strength Strength of the rumble to play as a 0-1 float value.
1137 * length Length of the rumble to play in milliseconds.
1138 * 0 on success or -1 on error.
1140 * SDL_HapticRumbleSupported
1141 * SDL_HapticRumbleInit
1142 * SDL_HapticRumbleStop
1144 function SDL_HapticRumblePlay(haptic: PSDL_Haptic; strength: Float; length: UInt32): Integer cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_HapticRumblePlay' {$ENDIF} {$ENDIF};
1147 * Stops the simple rumble on a haptic device.
1149 * haptic Haptic to stop the rumble on.
1150 * 0 on success or -1 on error.
1152 * SDL_HapticRumbleSupported
1153 * SDL_HapticRumbleInit
1154 * SDL_HapticRumblePlay
1156 function SDL_HapticRumbleStop(haptic: PSDL_Haptic): Integer cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_HapticRumbleStop' {$ENDIF} {$ENDIF};