SDL 2.0
SDL_haptic.h
Go to the documentation of this file.
1/*
2 Simple DirectMedia Layer
3 Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
4
5 This software is provided 'as-is', without any express or implied
6 warranty. In no event will the authors be held liable for any damages
7 arising from the use of this software.
8
9 Permission is granted to anyone to use this software for any purpose,
10 including commercial applications, and to alter it and redistribute it
11 freely, subject to the following restrictions:
12
13 1. The origin of this software must not be misrepresented; you must not
14 claim that you wrote the original software. If you use this software
15 in a product, an acknowledgment in the product documentation would be
16 appreciated but is not required.
17 2. Altered source versions must be plainly marked as such, and must not be
18 misrepresented as being the original software.
19 3. This notice may not be removed or altered from any source distribution.
20*/
21
22/**
23 * # CategoryHaptic
24 *
25 * SDL haptic subsystem allows you to control haptic (force feedback) devices.
26 *
27 * The basic usage is as follows:
28 *
29 * - Initialize the subsystem (SDL_INIT_HAPTIC).
30 * - Open a haptic device.
31 * - SDL_HapticOpen() to open from index.
32 * - SDL_HapticOpenFromJoystick() to open from an existing joystick.
33 * - Create an effect (SDL_HapticEffect).
34 * - Upload the effect with SDL_HapticNewEffect().
35 * - Run the effect with SDL_HapticRunEffect().
36 * - (optional) Free the effect with SDL_HapticDestroyEffect().
37 * - Close the haptic device with SDL_HapticClose().
38 *
39 * Simple rumble example:
40 *
41 * ```c
42 * SDL_Haptic *haptic;
43 *
44 * // Open the device
45 * haptic = SDL_HapticOpen( 0 );
46 * if (haptic == NULL)
47 * return -1;
48 *
49 * // Initialize simple rumble
50 * if (SDL_HapticRumbleInit( haptic ) != 0)
51 * return -1;
52 *
53 * // Play effect at 50% strength for 2 seconds
54 * if (SDL_HapticRumblePlay( haptic, 0.5, 2000 ) != 0)
55 * return -1;
56 * SDL_Delay( 2000 );
57 *
58 * // Clean up
59 * SDL_HapticClose( haptic );
60 * ```
61 *
62 * Complete example:
63 *
64 * ```c
65 * int test_haptic( SDL_Joystick * joystick ) {
66 * SDL_Haptic *haptic;
67 * SDL_HapticEffect effect;
68 * int effect_id;
69 *
70 * // Open the device
71 * haptic = SDL_HapticOpenFromJoystick( joystick );
72 * if (haptic == NULL) return -1; // Most likely joystick isn't haptic
73 *
74 * // See if it can do sine waves
75 * if ((SDL_HapticQuery(haptic) & SDL_HAPTIC_SINE)==0) {
76 * SDL_HapticClose(haptic); // No sine effect
77 * return -1;
78 * }
79 *
80 * // Create the effect
81 * SDL_memset( &effect, 0, sizeof(SDL_HapticEffect) ); // 0 is safe default
82 * effect.type = SDL_HAPTIC_SINE;
83 * effect.periodic.direction.type = SDL_HAPTIC_POLAR; // Polar coordinates
84 * effect.periodic.direction.dir[0] = 18000; // Force comes from south
85 * effect.periodic.period = 1000; // 1000 ms
86 * effect.periodic.magnitude = 20000; // 20000/32767 strength
87 * effect.periodic.length = 5000; // 5 seconds long
88 * effect.periodic.attack_length = 1000; // Takes 1 second to get max strength
89 * effect.periodic.fade_length = 1000; // Takes 1 second to fade away
90 *
91 * // Upload the effect
92 * effect_id = SDL_HapticNewEffect( haptic, &effect );
93 *
94 * // Test the effect
95 * SDL_HapticRunEffect( haptic, effect_id, 1 );
96 * SDL_Delay( 5000); // Wait for the effect to finish
97 *
98 * // We destroy the effect, although closing the device also does this
99 * SDL_HapticDestroyEffect( haptic, effect_id );
100 *
101 * // Close the device
102 * SDL_HapticClose(haptic);
103 *
104 * return 0; // Success
105 * }
106 * ```
107 */
108
109#ifndef SDL_haptic_h_
110#define SDL_haptic_h_
111
112#include "SDL_stdinc.h"
113#include "SDL_error.h"
114#include "SDL_joystick.h"
115
116#include "begin_code.h"
117/* Set up for C function definitions, even when using C++ */
118#ifdef __cplusplus
119extern "C" {
120#endif /* __cplusplus */
121
122/* FIXME: For SDL 2.1, adjust all the magnitude variables to be Uint16 (0xFFFF).
123 *
124 * At the moment the magnitude variables are mixed between signed/unsigned, and
125 * it is also not made clear that ALL of those variables expect a max of 0x7FFF.
126 *
127 * Some platforms may have higher precision than that (Linux FF, Windows XInput)
128 * so we should fix the inconsistency in favor of higher possible precision,
129 * adjusting for platforms that use different scales.
130 * -flibit
131 */
132
133/**
134 * \typedef SDL_Haptic
135 *
136 * \brief The haptic structure used to identify an SDL haptic.
137 *
138 * \sa SDL_HapticOpen
139 * \sa SDL_HapticOpenFromJoystick
140 * \sa SDL_HapticClose
141 */
142struct _SDL_Haptic;
143typedef struct _SDL_Haptic SDL_Haptic;
144
145
146/**
147 * \name Haptic features
148 *
149 * Different haptic features a device can have.
150 */
151/* @{ */
152
153/**
154 * \name Haptic effects
155 */
156/* @{ */
157
158/**
159 * Constant effect supported.
160 *
161 * Constant haptic effect.
162 *
163 * \sa SDL_HapticCondition
164 */
165#define SDL_HAPTIC_CONSTANT (1u<<0)
166
167/**
168 * Sine wave effect supported.
169 *
170 * Periodic haptic effect that simulates sine waves.
171 *
172 * \sa SDL_HapticPeriodic
173 */
174#define SDL_HAPTIC_SINE (1u<<1)
175
176/**
177 * Left/Right effect supported.
178 *
179 * Haptic effect for direct control over high/low frequency motors.
180 *
181 * \sa SDL_HapticLeftRight
182 */
183#define SDL_HAPTIC_LEFTRIGHT (1u<<2)
184
185/* !!! FIXME: put this back when we have more bits in 2.1 */
186/* #define SDL_HAPTIC_SQUARE (1<<2) */
187
188/**
189 * Triangle wave effect supported.
190 *
191 * Periodic haptic effect that simulates triangular waves.
192 *
193 * \sa SDL_HapticPeriodic
194 */
195#define SDL_HAPTIC_TRIANGLE (1u<<3)
196
197/**
198 * Sawtoothup wave effect supported.
199 *
200 * Periodic haptic effect that simulates saw tooth up waves.
201 *
202 * \sa SDL_HapticPeriodic
203 */
204#define SDL_HAPTIC_SAWTOOTHUP (1u<<4)
205
206/**
207 * Sawtoothdown wave effect supported.
208 *
209 * Periodic haptic effect that simulates saw tooth down waves.
210 *
211 * \sa SDL_HapticPeriodic
212 */
213#define SDL_HAPTIC_SAWTOOTHDOWN (1u<<5)
214
215/**
216 * Ramp effect supported.
217 *
218 * Ramp haptic effect.
219 *
220 * \sa SDL_HapticRamp
221 */
222#define SDL_HAPTIC_RAMP (1u<<6)
223
224/**
225 * Spring effect supported - uses axes position.
226 *
227 * Condition haptic effect that simulates a spring. Effect is based on the
228 * axes position.
229 *
230 * \sa SDL_HapticCondition
231 */
232#define SDL_HAPTIC_SPRING (1u<<7)
233
234/**
235 * Damper effect supported - uses axes velocity.
236 *
237 * Condition haptic effect that simulates dampening. Effect is based on the
238 * axes velocity.
239 *
240 * \sa SDL_HapticCondition
241 */
242#define SDL_HAPTIC_DAMPER (1u<<8)
243
244/**
245 * Inertia effect supported - uses axes acceleration.
246 *
247 * Condition haptic effect that simulates inertia. Effect is based on the axes
248 * acceleration.
249 *
250 * \sa SDL_HapticCondition
251 */
252#define SDL_HAPTIC_INERTIA (1u<<9)
253
254/**
255 * Friction effect supported - uses axes movement.
256 *
257 * Condition haptic effect that simulates friction. Effect is based on the
258 * axes movement.
259 *
260 * \sa SDL_HapticCondition
261 */
262#define SDL_HAPTIC_FRICTION (1u<<10)
263
264/**
265 * Custom effect is supported.
266 *
267 * User defined custom haptic effect.
268 */
269#define SDL_HAPTIC_CUSTOM (1u<<11)
270
271/* @} *//* Haptic effects */
272
273/* These last few are features the device has, not effects */
274
275/**
276 * Device can set global gain.
277 *
278 * Device supports setting the global gain.
279 *
280 * \sa SDL_HapticSetGain
281 */
282#define SDL_HAPTIC_GAIN (1u<<12)
283
284/**
285 * Device can set autocenter.
286 *
287 * Device supports setting autocenter.
288 *
289 * \sa SDL_HapticSetAutocenter
290 */
291#define SDL_HAPTIC_AUTOCENTER (1u<<13)
292
293/**
294 * Device can be queried for effect status.
295 *
296 * Device supports querying effect status.
297 *
298 * \sa SDL_HapticGetEffectStatus
299 */
300#define SDL_HAPTIC_STATUS (1u<<14)
301
302/**
303 * Device can be paused.
304 *
305 * Devices supports being paused.
306 *
307 * \sa SDL_HapticPause
308 * \sa SDL_HapticUnpause
309 */
310#define SDL_HAPTIC_PAUSE (1u<<15)
311
312
313/**
314 * \name Direction encodings
315 */
316/* @{ */
317
318/**
319 * Uses polar coordinates for the direction.
320 *
321 * \sa SDL_HapticDirection
322 */
323#define SDL_HAPTIC_POLAR 0
324
325/**
326 * Uses cartesian coordinates for the direction.
327 *
328 * \sa SDL_HapticDirection
329 */
330#define SDL_HAPTIC_CARTESIAN 1
331
332/**
333 * Uses spherical coordinates for the direction.
334 *
335 * \sa SDL_HapticDirection
336 */
337#define SDL_HAPTIC_SPHERICAL 2
338
339/**
340 * Use this value to play an effect on the steering wheel axis.
341 *
342 * This provides better compatibility across platforms and devices as SDL will
343 * guess the correct axis.
344 *
345 * \sa SDL_HapticDirection
346 */
347#define SDL_HAPTIC_STEERING_AXIS 3
348
349/* @} *//* Direction encodings */
350
351/* @} *//* Haptic features */
352
353/*
354 * Misc defines.
355 */
356
357/**
358 * Used to play a device an infinite number of times.
359 *
360 * \sa SDL_HapticRunEffect
361 */
362#define SDL_HAPTIC_INFINITY 4294967295U
363
364
365/**
366 * Structure that represents a haptic direction.
367 *
368 * This is the direction where the force comes from, instead of the direction
369 * in which the force is exerted.
370 *
371 * Directions can be specified by:
372 *
373 * - SDL_HAPTIC_POLAR : Specified by polar coordinates.
374 * - SDL_HAPTIC_CARTESIAN : Specified by cartesian coordinates.
375 * - SDL_HAPTIC_SPHERICAL : Specified by spherical coordinates.
376 *
377 * Cardinal directions of the haptic device are relative to the positioning of
378 * the device. North is considered to be away from the user.
379 *
380 * The following diagram represents the cardinal directions:
381 *
382 * ```
383 * .--.
384 * |__| .-------.
385 * |=.| |.-----.|
386 * |--| || ||
387 * | | |'-----'|
388 * |__|~')_____('
389 * [ COMPUTER ]
390 *
391 *
392 * North (0,-1)
393 * ^
394 * |
395 * |
396 * (-1,0) West <----[ HAPTIC ]----> East (1,0)
397 * |
398 * |
399 * v
400 * South (0,1)
401 *
402 *
403 * [ USER ]
404 * \|||/
405 * (o o)
406 * ---ooO-(_)-Ooo---
407 * ```
408 *
409 * If type is SDL_HAPTIC_POLAR, direction is encoded by hundredths of a degree
410 * starting north and turning clockwise. SDL_HAPTIC_POLAR only uses the first
411 * `dir` parameter. The cardinal directions would be:
412 *
413 * - North: 0 (0 degrees)
414 * - East: 9000 (90 degrees)
415 * - South: 18000 (180 degrees)
416 * - West: 27000 (270 degrees)
417 *
418 * If type is SDL_HAPTIC_CARTESIAN, direction is encoded by three positions (X
419 * axis, Y axis and Z axis (with 3 axes)). SDL_HAPTIC_CARTESIAN uses the first
420 * three `dir` parameters. The cardinal directions would be:
421 *
422 * - North: 0,-1, 0
423 * - East: 1, 0, 0
424 * - South: 0, 1, 0
425 * - West: -1, 0, 0
426 *
427 * The Z axis represents the height of the effect if supported, otherwise it's
428 * unused. In cartesian encoding (1, 2) would be the same as (2, 4), you can
429 * use any multiple you want, only the direction matters.
430 *
431 * If type is SDL_HAPTIC_SPHERICAL, direction is encoded by two rotations. The
432 * first two `dir` parameters are used. The `dir` parameters are as follows
433 * (all values are in hundredths of degrees):
434 *
435 * - Degrees from (1, 0) rotated towards (0, 1).
436 * - Degrees towards (0, 0, 1) (device needs at least 3 axes).
437 *
438 * Example of force coming from the south with all encodings (force coming
439 * from the south means the user will have to pull the stick to counteract):
440 *
441 * ```c
442 * SDL_HapticDirection direction;
443 *
444 * // Cartesian directions
445 * direction.type = SDL_HAPTIC_CARTESIAN; // Using cartesian direction encoding.
446 * direction.dir[0] = 0; // X position
447 * direction.dir[1] = 1; // Y position
448 * // Assuming the device has 2 axes, we don't need to specify third parameter.
449 *
450 * // Polar directions
451 * direction.type = SDL_HAPTIC_POLAR; // We'll be using polar direction encoding.
452 * direction.dir[0] = 18000; // Polar only uses first parameter
453 *
454 * // Spherical coordinates
455 * direction.type = SDL_HAPTIC_SPHERICAL; // Spherical encoding
456 * direction.dir[0] = 9000; // Since we only have two axes we don't need more parameters.
457 * ```
458 *
459 * \sa SDL_HAPTIC_POLAR
460 * \sa SDL_HAPTIC_CARTESIAN
461 * \sa SDL_HAPTIC_SPHERICAL
462 * \sa SDL_HAPTIC_STEERING_AXIS
463 * \sa SDL_HapticEffect
464 * \sa SDL_HapticNumAxes
465 */
467{
468 Uint8 type; /**< The type of encoding. */
469 Sint32 dir[3]; /**< The encoded direction. */
471
472
473/**
474 * A structure containing a template for a Constant effect.
475 *
476 * This struct is exclusively for the SDL_HAPTIC_CONSTANT effect.
477 *
478 * A constant effect applies a constant force in the specified direction to
479 * the joystick.
480 *
481 * \sa SDL_HAPTIC_CONSTANT
482 * \sa SDL_HapticEffect
483 */
484typedef struct SDL_HapticConstant
485{
486 /* Header */
487 Uint16 type; /**< SDL_HAPTIC_CONSTANT */
488 SDL_HapticDirection direction; /**< Direction of the effect. */
489
490 /* Replay */
491 Uint32 length; /**< Duration of the effect. */
492 Uint16 delay; /**< Delay before starting the effect. */
493
494 /* Trigger */
495 Uint16 button; /**< Button that triggers the effect. */
496 Uint16 interval; /**< How soon it can be triggered again after button. */
497
498 /* Constant */
499 Sint16 level; /**< Strength of the constant effect. */
500
501 /* Envelope */
502 Uint16 attack_length; /**< Duration of the attack. */
503 Uint16 attack_level; /**< Level at the start of the attack. */
504 Uint16 fade_length; /**< Duration of the fade. */
505 Uint16 fade_level; /**< Level at the end of the fade. */
507
508/**
509 * A structure containing a template for a Periodic effect.
510 *
511 * The struct handles the following effects:
512 *
513 * - SDL_HAPTIC_SINE
514 * - SDL_HAPTIC_SQUARE
515 * - SDL_HAPTIC_TRIANGLE
516 * - SDL_HAPTIC_SAWTOOTHUP
517 * - SDL_HAPTIC_SAWTOOTHDOWN
518 *
519 * A periodic effect consists in a wave-shaped effect that repeats itself over
520 * time. The type determines the shape of the wave and the parameters
521 * determine the dimensions of the wave.
522 *
523 * Phase is given by hundredth of a degree meaning that giving the phase a
524 * value of 9000 will displace it 25% of its period. Here are sample values:
525 *
526 * - 0: No phase displacement.
527 * - 9000: Displaced 25% of its period.
528 * - 18000: Displaced 50% of its period.
529 * - 27000: Displaced 75% of its period.
530 * - 36000: Displaced 100% of its period, same as 0, but 0 is preferred.
531 *
532 * Examples:
533 *
534 * ```
535 * SDL_HAPTIC_SINE
536 * __ __ __ __
537 * / \ / \ / \ /
538 * / \__/ \__/ \__/
539 *
540 * SDL_HAPTIC_SQUARE
541 * __ __ __ __ __
542 * | | | | | | | | | |
543 * | |__| |__| |__| |__| |
544 *
545 * SDL_HAPTIC_TRIANGLE
546 * /\ /\ /\ /\ /\
547 * / \ / \ / \ / \ /
548 * / \/ \/ \/ \/
549 *
550 * SDL_HAPTIC_SAWTOOTHUP
551 * /| /| /| /| /| /| /|
552 * / | / | / | / | / | / | / |
553 * / |/ |/ |/ |/ |/ |/ |
554 *
555 * SDL_HAPTIC_SAWTOOTHDOWN
556 * \ |\ |\ |\ |\ |\ |\ |
557 * \ | \ | \ | \ | \ | \ | \ |
558 * \| \| \| \| \| \| \|
559 * ```
560 *
561 * \sa SDL_HAPTIC_SINE
562 * \sa SDL_HAPTIC_LEFTRIGHT
563 * \sa SDL_HAPTIC_TRIANGLE
564 * \sa SDL_HAPTIC_SAWTOOTHUP
565 * \sa SDL_HAPTIC_SAWTOOTHDOWN
566 * \sa SDL_HapticEffect
567 */
568typedef struct SDL_HapticPeriodic
569{
570 /* Header */
571 Uint16 type; /**< SDL_HAPTIC_SINE, SDL_HAPTIC_LEFTRIGHT,
572 SDL_HAPTIC_TRIANGLE, SDL_HAPTIC_SAWTOOTHUP or
573 SDL_HAPTIC_SAWTOOTHDOWN */
574 SDL_HapticDirection direction; /**< Direction of the effect. */
575
576 /* Replay */
577 Uint32 length; /**< Duration of the effect. */
578 Uint16 delay; /**< Delay before starting the effect. */
579
580 /* Trigger */
581 Uint16 button; /**< Button that triggers the effect. */
582 Uint16 interval; /**< How soon it can be triggered again after button. */
583
584 /* Periodic */
585 Uint16 period; /**< Period of the wave. */
586 Sint16 magnitude; /**< Peak value; if negative, equivalent to 180 degrees extra phase shift. */
587 Sint16 offset; /**< Mean value of the wave. */
588 Uint16 phase; /**< Positive phase shift given by hundredth of a degree. */
589
590 /* Envelope */
591 Uint16 attack_length; /**< Duration of the attack. */
592 Uint16 attack_level; /**< Level at the start of the attack. */
593 Uint16 fade_length; /**< Duration of the fade. */
594 Uint16 fade_level; /**< Level at the end of the fade. */
596
597/**
598 * A structure containing a template for a Condition effect.
599 *
600 * The struct handles the following effects:
601 *
602 * - SDL_HAPTIC_SPRING: Effect based on axes position.
603 * - SDL_HAPTIC_DAMPER: Effect based on axes velocity.
604 * - SDL_HAPTIC_INERTIA: Effect based on axes acceleration.
605 * - SDL_HAPTIC_FRICTION: Effect based on axes movement.
606 *
607 * Direction is handled by condition internals instead of a direction member.
608 * The condition effect specific members have three parameters. The first
609 * refers to the X axis, the second refers to the Y axis and the third refers
610 * to the Z axis. The right terms refer to the positive side of the axis and
611 * the left terms refer to the negative side of the axis. Please refer to the
612 * SDL_HapticDirection diagram for which side is positive and which is
613 * negative.
614 *
615 * \sa SDL_HapticDirection
616 * \sa SDL_HAPTIC_SPRING
617 * \sa SDL_HAPTIC_DAMPER
618 * \sa SDL_HAPTIC_INERTIA
619 * \sa SDL_HAPTIC_FRICTION
620 * \sa SDL_HapticEffect
621 */
623{
624 /* Header */
625 Uint16 type; /**< SDL_HAPTIC_SPRING, SDL_HAPTIC_DAMPER,
626 SDL_HAPTIC_INERTIA or SDL_HAPTIC_FRICTION */
627 SDL_HapticDirection direction; /**< Direction of the effect. */
628
629 /* Replay */
630 Uint32 length; /**< Duration of the effect. */
631 Uint16 delay; /**< Delay before starting the effect. */
632
633 /* Trigger */
634 Uint16 button; /**< Button that triggers the effect. */
635 Uint16 interval; /**< How soon it can be triggered again after button. */
636
637 /* Condition */
638 Uint16 right_sat[3]; /**< Level when joystick is to the positive side; max 0xFFFF. */
639 Uint16 left_sat[3]; /**< Level when joystick is to the negative side; max 0xFFFF. */
640 Sint16 right_coeff[3]; /**< How fast to increase the force towards the positive side. */
641 Sint16 left_coeff[3]; /**< How fast to increase the force towards the negative side. */
642 Uint16 deadband[3]; /**< Size of the dead zone; max 0xFFFF: whole axis-range when 0-centered. */
643 Sint16 center[3]; /**< Position of the dead zone. */
645
646/**
647 * A structure containing a template for a Ramp effect.
648 *
649 * This struct is exclusively for the SDL_HAPTIC_RAMP effect.
650 *
651 * The ramp effect starts at start strength and ends at end strength. It
652 * augments in linear fashion. If you use attack and fade with a ramp the
653 * effects get added to the ramp effect making the effect become quadratic
654 * instead of linear.
655 *
656 * \sa SDL_HAPTIC_RAMP
657 * \sa SDL_HapticEffect
658 */
659typedef struct SDL_HapticRamp
660{
661 /* Header */
662 Uint16 type; /**< SDL_HAPTIC_RAMP */
663 SDL_HapticDirection direction; /**< Direction of the effect. */
664
665 /* Replay */
666 Uint32 length; /**< Duration of the effect. */
667 Uint16 delay; /**< Delay before starting the effect. */
668
669 /* Trigger */
670 Uint16 button; /**< Button that triggers the effect. */
671 Uint16 interval; /**< How soon it can be triggered again after button. */
672
673 /* Ramp */
674 Sint16 start; /**< Beginning strength level. */
675 Sint16 end; /**< Ending strength level. */
676
677 /* Envelope */
678 Uint16 attack_length; /**< Duration of the attack. */
679 Uint16 attack_level; /**< Level at the start of the attack. */
680 Uint16 fade_length; /**< Duration of the fade. */
681 Uint16 fade_level; /**< Level at the end of the fade. */
683
684/**
685 * A structure containing a template for a Left/Right effect.
686 *
687 * This struct is exclusively for the SDL_HAPTIC_LEFTRIGHT effect.
688 *
689 * The Left/Right effect is used to explicitly control the large and small
690 * motors, commonly found in modern game controllers. The small (right) motor
691 * is high frequency, and the large (left) motor is low frequency.
692 *
693 * \sa SDL_HAPTIC_LEFTRIGHT
694 * \sa SDL_HapticEffect
695 */
697{
698 /* Header */
699 Uint16 type; /**< SDL_HAPTIC_LEFTRIGHT */
700
701 /* Replay */
702 Uint32 length; /**< Duration of the effect in milliseconds. */
703
704 /* Rumble */
705 Uint16 large_magnitude; /**< Control of the large controller motor. */
706 Uint16 small_magnitude; /**< Control of the small controller motor. */
708
709/**
710 * A structure containing a template for the SDL_HAPTIC_CUSTOM effect.
711 *
712 * This struct is exclusively for the SDL_HAPTIC_CUSTOM effect.
713 *
714 * A custom force feedback effect is much like a periodic effect, where the
715 * application can define its exact shape. You will have to allocate the data
716 * yourself. Data should consist of channels * samples Uint16 samples.
717 *
718 * If channels is one, the effect is rotated using the defined direction.
719 * Otherwise it uses the samples in data for the different axes.
720 *
721 * \sa SDL_HAPTIC_CUSTOM
722 * \sa SDL_HapticEffect
723 */
724typedef struct SDL_HapticCustom
725{
726 /* Header */
727 Uint16 type; /**< SDL_HAPTIC_CUSTOM */
728 SDL_HapticDirection direction; /**< Direction of the effect. */
729
730 /* Replay */
731 Uint32 length; /**< Duration of the effect. */
732 Uint16 delay; /**< Delay before starting the effect. */
733
734 /* Trigger */
735 Uint16 button; /**< Button that triggers the effect. */
736 Uint16 interval; /**< How soon it can be triggered again after button. */
737
738 /* Custom */
739 Uint8 channels; /**< Axes to use, minimum of one. */
740 Uint16 period; /**< Sample periods. */
741 Uint16 samples; /**< Amount of samples. */
742 Uint16 *data; /**< Should contain channels*samples items. */
743
744 /* Envelope */
745 Uint16 attack_length; /**< Duration of the attack. */
746 Uint16 attack_level; /**< Level at the start of the attack. */
747 Uint16 fade_length; /**< Duration of the fade. */
748 Uint16 fade_level; /**< Level at the end of the fade. */
750
751/**
752 * The generic template for any haptic effect.
753 *
754 * All values max at 32767 (0x7FFF). Signed values also can be negative. Time
755 * values unless specified otherwise are in milliseconds.
756 *
757 * You can also pass SDL_HAPTIC_INFINITY to length instead of a 0-32767 value.
758 * Neither delay, interval, attack_length nor fade_length support
759 * SDL_HAPTIC_INFINITY. Fade will also not be used since effect never ends.
760 *
761 * Additionally, the SDL_HAPTIC_RAMP effect does not support a duration of
762 * SDL_HAPTIC_INFINITY.
763 *
764 * Button triggers may not be supported on all devices, it is advised to not
765 * use them if possible. Buttons start at index 1 instead of index 0 like the
766 * joystick.
767 *
768 * If both attack_length and fade_level are 0, the envelope is not used,
769 * otherwise both values are used.
770 *
771 * Common parts:
772 *
773 * ```c
774 * // Replay - All effects have this
775 * Uint32 length; // Duration of effect (ms).
776 * Uint16 delay; // Delay before starting effect.
777 *
778 * // Trigger - All effects have this
779 * Uint16 button; // Button that triggers effect.
780 * Uint16 interval; // How soon before effect can be triggered again.
781 *
782 * // Envelope - All effects except condition effects have this
783 * Uint16 attack_length; // Duration of the attack (ms).
784 * Uint16 attack_level; // Level at the start of the attack.
785 * Uint16 fade_length; // Duration of the fade out (ms).
786 * Uint16 fade_level; // Level at the end of the fade.
787 * ```
788 *
789 * Here we have an example of a constant effect evolution in time:
790 *
791 * ```
792 * Strength
793 * ^
794 * |
795 * | effect level --> _________________
796 * | / \
797 * | / \
798 * | / \
799 * | / \
800 * | attack_level --> | \
801 * | | | <--- fade_level
802 * |
803 * +--------------------------------------------------> Time
804 * [--] [---]
805 * attack_length fade_length
806 *
807 * [------------------][-----------------------]
808 * delay length
809 * ```
810 *
811 * Note either the attack_level or the fade_level may be above the actual
812 * effect level.
813 *
814 * \sa SDL_HapticConstant
815 * \sa SDL_HapticPeriodic
816 * \sa SDL_HapticCondition
817 * \sa SDL_HapticRamp
818 * \sa SDL_HapticLeftRight
819 * \sa SDL_HapticCustom
820 */
821typedef union SDL_HapticEffect
822{
823 /* Common for all force feedback effects */
824 Uint16 type; /**< Effect type. */
825 SDL_HapticConstant constant; /**< Constant effect. */
826 SDL_HapticPeriodic periodic; /**< Periodic effect. */
827 SDL_HapticCondition condition; /**< Condition effect. */
828 SDL_HapticRamp ramp; /**< Ramp effect. */
829 SDL_HapticLeftRight leftright; /**< Left/Right effect. */
830 SDL_HapticCustom custom; /**< Custom effect. */
832
833
834/* Function prototypes */
835
836/**
837 * Count the number of haptic devices attached to the system.
838 *
839 * \returns the number of haptic devices detected on the system or a negative
840 * error code on failure; call SDL_GetError() for more information.
841 *
842 * \since This function is available since SDL 2.0.0.
843 *
844 * \sa SDL_HapticName
845 */
846extern DECLSPEC int SDLCALL SDL_NumHaptics(void);
847
848/**
849 * Get the implementation dependent name of a haptic device.
850 *
851 * This can be called before any joysticks are opened. If no name can be
852 * found, this function returns NULL.
853 *
854 * \param device_index index of the device to query.
855 * \returns the name of the device or NULL on failure; call SDL_GetError() for
856 * more information.
857 *
858 * \since This function is available since SDL 2.0.0.
859 *
860 * \sa SDL_NumHaptics
861 */
862extern DECLSPEC const char *SDLCALL SDL_HapticName(int device_index);
863
864/**
865 * Open a haptic device for use.
866 *
867 * The index passed as an argument refers to the N'th haptic device on this
868 * system.
869 *
870 * When opening a haptic device, its gain will be set to maximum and
871 * autocenter will be disabled. To modify these values use SDL_HapticSetGain()
872 * and SDL_HapticSetAutocenter().
873 *
874 * \param device_index index of the device to open.
875 * \returns the device identifier or NULL on failure; call SDL_GetError() for
876 * more information.
877 *
878 * \since This function is available since SDL 2.0.0.
879 *
880 * \sa SDL_HapticClose
881 * \sa SDL_HapticIndex
882 * \sa SDL_HapticOpenFromJoystick
883 * \sa SDL_HapticOpenFromMouse
884 * \sa SDL_HapticPause
885 * \sa SDL_HapticSetAutocenter
886 * \sa SDL_HapticSetGain
887 * \sa SDL_HapticStopAll
888 */
889extern DECLSPEC SDL_Haptic *SDLCALL SDL_HapticOpen(int device_index);
890
891/**
892 * Check if the haptic device at the designated index has been opened.
893 *
894 * \param device_index the index of the device to query.
895 * \returns 1 if it has been opened, 0 if it hasn't or on failure; call
896 * SDL_GetError() for more information.
897 *
898 * \since This function is available since SDL 2.0.0.
899 *
900 * \sa SDL_HapticIndex
901 * \sa SDL_HapticOpen
902 */
903extern DECLSPEC int SDLCALL SDL_HapticOpened(int device_index);
904
905/**
906 * Get the index of a haptic device.
907 *
908 * \param haptic the SDL_Haptic device to query.
909 * \returns the index of the specified haptic device or a negative error code
910 * on failure; call SDL_GetError() for more information.
911 *
912 * \since This function is available since SDL 2.0.0.
913 *
914 * \sa SDL_HapticOpen
915 * \sa SDL_HapticOpened
916 */
917extern DECLSPEC int SDLCALL SDL_HapticIndex(SDL_Haptic * haptic);
918
919/**
920 * Query whether or not the current mouse has haptic capabilities.
921 *
922 * \returns SDL_TRUE if the mouse is haptic or SDL_FALSE if it isn't.
923 *
924 * \since This function is available since SDL 2.0.0.
925 *
926 * \sa SDL_HapticOpenFromMouse
927 */
928extern DECLSPEC int SDLCALL SDL_MouseIsHaptic(void);
929
930/**
931 * Try to open a haptic device from the current mouse.
932 *
933 * \returns the haptic device identifier or NULL on failure; call
934 * SDL_GetError() for more information.
935 *
936 * \since This function is available since SDL 2.0.0.
937 *
938 * \sa SDL_HapticOpen
939 * \sa SDL_MouseIsHaptic
940 */
941extern DECLSPEC SDL_Haptic *SDLCALL SDL_HapticOpenFromMouse(void);
942
943/**
944 * Query if a joystick has haptic features.
945 *
946 * \param joystick the SDL_Joystick to test for haptic capabilities.
947 * \returns SDL_TRUE if the joystick is haptic, SDL_FALSE if it isn't, or a
948 * negative error code on failure; call SDL_GetError() for more
949 * information.
950 *
951 * \since This function is available since SDL 2.0.0.
952 *
953 * \sa SDL_HapticOpenFromJoystick
954 */
955extern DECLSPEC int SDLCALL SDL_JoystickIsHaptic(SDL_Joystick * joystick);
956
957/**
958 * Open a haptic device for use from a joystick device.
959 *
960 * You must still close the haptic device separately. It will not be closed
961 * with the joystick.
962 *
963 * When opened from a joystick you should first close the haptic device before
964 * closing the joystick device. If not, on some implementations the haptic
965 * device will also get unallocated and you'll be unable to use force feedback
966 * on that device.
967 *
968 * \param joystick the SDL_Joystick to create a haptic device from.
969 * \returns a valid haptic device identifier on success or NULL on failure;
970 * call SDL_GetError() for more information.
971 *
972 * \since This function is available since SDL 2.0.0.
973 *
974 * \sa SDL_HapticClose
975 * \sa SDL_HapticOpen
976 * \sa SDL_JoystickIsHaptic
977 */
979 joystick);
980
981/**
982 * Close a haptic device previously opened with SDL_HapticOpen().
983 *
984 * \param haptic the SDL_Haptic device to close.
985 *
986 * \since This function is available since SDL 2.0.0.
987 *
988 * \sa SDL_HapticOpen
989 */
990extern DECLSPEC void SDLCALL SDL_HapticClose(SDL_Haptic * haptic);
991
992/**
993 * Get the number of effects a haptic device can store.
994 *
995 * On some platforms this isn't fully supported, and therefore is an
996 * approximation. Always check to see if your created effect was actually
997 * created and do not rely solely on SDL_HapticNumEffects().
998 *
999 * \param haptic the SDL_Haptic device to query.
1000 * \returns the number of effects the haptic device can store or a negative
1001 * error code on failure; call SDL_GetError() for more information.
1002 *
1003 * \since This function is available since SDL 2.0.0.
1004 *
1005 * \sa SDL_HapticNumEffectsPlaying
1006 * \sa SDL_HapticQuery
1007 */
1008extern DECLSPEC int SDLCALL SDL_HapticNumEffects(SDL_Haptic * haptic);
1009
1010/**
1011 * Get the number of effects a haptic device can play at the same time.
1012 *
1013 * This is not supported on all platforms, but will always return a value.
1014 *
1015 * \param haptic the SDL_Haptic device to query maximum playing effects.
1016 * \returns the number of effects the haptic device can play at the same time
1017 * or a negative error code on failure; call SDL_GetError() for more
1018 * information.
1019 *
1020 * \since This function is available since SDL 2.0.0.
1021 *
1022 * \sa SDL_HapticNumEffects
1023 * \sa SDL_HapticQuery
1024 */
1025extern DECLSPEC int SDLCALL SDL_HapticNumEffectsPlaying(SDL_Haptic * haptic);
1026
1027/**
1028 * Get the haptic device's supported features in bitwise manner.
1029 *
1030 * \param haptic the SDL_Haptic device to query.
1031 * \returns a list of supported haptic features in bitwise manner (OR'd), or 0
1032 * on failure; call SDL_GetError() for more information.
1033 *
1034 * \since This function is available since SDL 2.0.0.
1035 *
1036 * \sa SDL_HapticEffectSupported
1037 * \sa SDL_HapticNumEffects
1038 */
1039extern DECLSPEC unsigned int SDLCALL SDL_HapticQuery(SDL_Haptic * haptic);
1040
1041
1042/**
1043 * Get the number of haptic axes the device has.
1044 *
1045 * The number of haptic axes might be useful if working with the
1046 * SDL_HapticDirection effect.
1047 *
1048 * \param haptic the SDL_Haptic device to query.
1049 * \returns the number of axes on success or a negative error code on failure;
1050 * call SDL_GetError() for more information.
1051 *
1052 * \since This function is available since SDL 2.0.0.
1053 */
1054extern DECLSPEC int SDLCALL SDL_HapticNumAxes(SDL_Haptic * haptic);
1055
1056/**
1057 * Check to see if an effect is supported by a haptic device.
1058 *
1059 * \param haptic the SDL_Haptic device to query.
1060 * \param effect the desired effect to query.
1061 * \returns SDL_TRUE if effect is supported, SDL_FALSE if it isn't, or a
1062 * negative error code on failure; call SDL_GetError() for more
1063 * information.
1064 *
1065 * \since This function is available since SDL 2.0.0.
1066 *
1067 * \sa SDL_HapticNewEffect
1068 * \sa SDL_HapticQuery
1069 */
1070extern DECLSPEC int SDLCALL SDL_HapticEffectSupported(SDL_Haptic * haptic,
1072 effect);
1073
1074/**
1075 * Create a new haptic effect on a specified device.
1076 *
1077 * \param haptic an SDL_Haptic device to create the effect on.
1078 * \param effect an SDL_HapticEffect structure containing the properties of
1079 * the effect to create.
1080 * \returns the ID of the effect on success or a negative error code on
1081 * failure; call SDL_GetError() for more information.
1082 *
1083 * \since This function is available since SDL 2.0.0.
1084 *
1085 * \sa SDL_HapticDestroyEffect
1086 * \sa SDL_HapticRunEffect
1087 * \sa SDL_HapticUpdateEffect
1088 */
1089extern DECLSPEC int SDLCALL SDL_HapticNewEffect(SDL_Haptic * haptic,
1090 SDL_HapticEffect * effect);
1091
1092/**
1093 * Update the properties of an effect.
1094 *
1095 * Can be used dynamically, although behavior when dynamically changing
1096 * direction may be strange. Specifically the effect may re-upload itself and
1097 * start playing from the start. You also cannot change the type either when
1098 * running SDL_HapticUpdateEffect().
1099 *
1100 * \param haptic the SDL_Haptic device that has the effect.
1101 * \param effect the identifier of the effect to update.
1102 * \param data an SDL_HapticEffect structure containing the new effect
1103 * properties to use.
1104 * \returns 0 on success or a negative error code on failure; call
1105 * SDL_GetError() for more information.
1106 *
1107 * \since This function is available since SDL 2.0.0.
1108 *
1109 * \sa SDL_HapticDestroyEffect
1110 * \sa SDL_HapticNewEffect
1111 * \sa SDL_HapticRunEffect
1112 */
1113extern DECLSPEC int SDLCALL SDL_HapticUpdateEffect(SDL_Haptic * haptic,
1114 int effect,
1115 SDL_HapticEffect * data);
1116
1117/**
1118 * Run the haptic effect on its associated haptic device.
1119 *
1120 * To repeat the effect over and over indefinitely, set `iterations` to
1121 * `SDL_HAPTIC_INFINITY`. (Repeats the envelope - attack and fade.) To make
1122 * one instance of the effect last indefinitely (so the effect does not fade),
1123 * set the effect's `length` in its structure/union to `SDL_HAPTIC_INFINITY`
1124 * instead.
1125 *
1126 * \param haptic the SDL_Haptic device to run the effect on.
1127 * \param effect the ID of the haptic effect to run.
1128 * \param iterations the number of iterations to run the effect; use
1129 * `SDL_HAPTIC_INFINITY` to repeat forever.
1130 * \returns 0 on success or a negative error code on failure; call
1131 * SDL_GetError() for more information.
1132 *
1133 * \since This function is available since SDL 2.0.0.
1134 *
1135 * \sa SDL_HapticDestroyEffect
1136 * \sa SDL_HapticGetEffectStatus
1137 * \sa SDL_HapticStopEffect
1138 */
1139extern DECLSPEC int SDLCALL SDL_HapticRunEffect(SDL_Haptic * haptic,
1140 int effect,
1141 Uint32 iterations);
1142
1143/**
1144 * Stop the haptic effect on its associated haptic device.
1145 *
1146 * *
1147 *
1148 * \param haptic the SDL_Haptic device to stop the effect on.
1149 * \param effect the ID of the haptic effect to stop.
1150 * \returns 0 on success or a negative error code on failure; call
1151 * SDL_GetError() for more information.
1152 *
1153 * \since This function is available since SDL 2.0.0.
1154 *
1155 * \sa SDL_HapticDestroyEffect
1156 * \sa SDL_HapticRunEffect
1157 */
1158extern DECLSPEC int SDLCALL SDL_HapticStopEffect(SDL_Haptic * haptic,
1159 int effect);
1160
1161/**
1162 * Destroy a haptic effect on the device.
1163 *
1164 * This will stop the effect if it's running. Effects are automatically
1165 * destroyed when the device is closed.
1166 *
1167 * \param haptic the SDL_Haptic device to destroy the effect on.
1168 * \param effect the ID of the haptic effect to destroy.
1169 *
1170 * \since This function is available since SDL 2.0.0.
1171 *
1172 * \sa SDL_HapticNewEffect
1173 */
1174extern DECLSPEC void SDLCALL SDL_HapticDestroyEffect(SDL_Haptic * haptic,
1175 int effect);
1176
1177/**
1178 * Get the status of the current effect on the specified haptic device.
1179 *
1180 * Device must support the SDL_HAPTIC_STATUS feature.
1181 *
1182 * \param haptic the SDL_Haptic device to query for the effect status on.
1183 * \param effect the ID of the haptic effect to query its status.
1184 * \returns 0 if it isn't playing, 1 if it is playing, or a negative error
1185 * code on failure; call SDL_GetError() for more information.
1186 *
1187 * \since This function is available since SDL 2.0.0.
1188 *
1189 * \sa SDL_HapticRunEffect
1190 * \sa SDL_HapticStopEffect
1191 */
1192extern DECLSPEC int SDLCALL SDL_HapticGetEffectStatus(SDL_Haptic * haptic,
1193 int effect);
1194
1195/**
1196 * Set the global gain of the specified haptic device.
1197 *
1198 * Device must support the SDL_HAPTIC_GAIN feature.
1199 *
1200 * The user may specify the maximum gain by setting the environment variable
1201 * `SDL_HAPTIC_GAIN_MAX` which should be between 0 and 100. All calls to
1202 * SDL_HapticSetGain() will scale linearly using `SDL_HAPTIC_GAIN_MAX` as the
1203 * maximum.
1204 *
1205 * \param haptic the SDL_Haptic device to set the gain on.
1206 * \param gain value to set the gain to, should be between 0 and 100 (0 -
1207 * 100).
1208 * \returns 0 on success or a negative error code on failure; call
1209 * SDL_GetError() for more information.
1210 *
1211 * \since This function is available since SDL 2.0.0.
1212 *
1213 * \sa SDL_HapticQuery
1214 */
1215extern DECLSPEC int SDLCALL SDL_HapticSetGain(SDL_Haptic * haptic, int gain);
1216
1217/**
1218 * Set the global autocenter of the device.
1219 *
1220 * Autocenter should be between 0 and 100. Setting it to 0 will disable
1221 * autocentering.
1222 *
1223 * Device must support the SDL_HAPTIC_AUTOCENTER feature.
1224 *
1225 * \param haptic the SDL_Haptic device to set autocentering on.
1226 * \param autocenter value to set autocenter to (0-100).
1227 * \returns 0 on success or a negative error code on failure; call
1228 * SDL_GetError() for more information.
1229 *
1230 * \since This function is available since SDL 2.0.0.
1231 *
1232 * \sa SDL_HapticQuery
1233 */
1234extern DECLSPEC int SDLCALL SDL_HapticSetAutocenter(SDL_Haptic * haptic,
1235 int autocenter);
1236
1237/**
1238 * Pause a haptic device.
1239 *
1240 * Device must support the `SDL_HAPTIC_PAUSE` feature. Call
1241 * SDL_HapticUnpause() to resume playback.
1242 *
1243 * Do not modify the effects nor add new ones while the device is paused. That
1244 * can cause all sorts of weird errors.
1245 *
1246 * \param haptic the SDL_Haptic device to pause.
1247 * \returns 0 on success or a negative error code on failure; call
1248 * SDL_GetError() for more information.
1249 *
1250 * \since This function is available since SDL 2.0.0.
1251 *
1252 * \sa SDL_HapticUnpause
1253 */
1254extern DECLSPEC int SDLCALL SDL_HapticPause(SDL_Haptic * haptic);
1255
1256/**
1257 * Unpause a haptic device.
1258 *
1259 * Call to unpause after SDL_HapticPause().
1260 *
1261 * \param haptic the SDL_Haptic device to unpause.
1262 * \returns 0 on success or a negative error code on failure; call
1263 * SDL_GetError() for more information.
1264 *
1265 * \since This function is available since SDL 2.0.0.
1266 *
1267 * \sa SDL_HapticPause
1268 */
1269extern DECLSPEC int SDLCALL SDL_HapticUnpause(SDL_Haptic * haptic);
1270
1271/**
1272 * Stop all the currently playing effects on a haptic device.
1273 *
1274 * \param haptic the SDL_Haptic device to stop.
1275 * \returns 0 on success or a negative error code on failure; call
1276 * SDL_GetError() for more information.
1277 *
1278 * \since This function is available since SDL 2.0.0.
1279 */
1280extern DECLSPEC int SDLCALL SDL_HapticStopAll(SDL_Haptic * haptic);
1281
1282/**
1283 * Check whether rumble is supported on a haptic device.
1284 *
1285 * \param haptic haptic device to check for rumble support.
1286 * \returns SDL_TRUE if effect is supported, SDL_FALSE if it isn't, or a
1287 * negative error code on failure; call SDL_GetError() for more
1288 * information.
1289 *
1290 * \since This function is available since SDL 2.0.0.
1291 *
1292 * \sa SDL_HapticRumbleInit
1293 * \sa SDL_HapticRumblePlay
1294 * \sa SDL_HapticRumbleStop
1295 */
1296extern DECLSPEC int SDLCALL SDL_HapticRumbleSupported(SDL_Haptic * haptic);
1297
1298/**
1299 * Initialize a haptic device for simple rumble playback.
1300 *
1301 * \param haptic the haptic device to initialize for simple rumble playback.
1302 * \returns 0 on success or a negative error code on failure; call
1303 * SDL_GetError() for more information.
1304 *
1305 * \since This function is available since SDL 2.0.0.
1306 *
1307 * \sa SDL_HapticOpen
1308 * \sa SDL_HapticRumblePlay
1309 * \sa SDL_HapticRumbleStop
1310 * \sa SDL_HapticRumbleSupported
1311 */
1312extern DECLSPEC int SDLCALL SDL_HapticRumbleInit(SDL_Haptic * haptic);
1313
1314/**
1315 * Run a simple rumble effect on a haptic device.
1316 *
1317 * \param haptic the haptic device to play the rumble effect on.
1318 * \param strength strength of the rumble to play as a 0-1 float value.
1319 * \param length length of the rumble to play in milliseconds.
1320 * \returns 0 on success or a negative error code on failure; call
1321 * SDL_GetError() for more information.
1322 *
1323 * \since This function is available since SDL 2.0.0.
1324 *
1325 * \sa SDL_HapticRumbleInit
1326 * \sa SDL_HapticRumbleStop
1327 * \sa SDL_HapticRumbleSupported
1328 */
1329extern DECLSPEC int SDLCALL SDL_HapticRumblePlay(SDL_Haptic * haptic, float strength, Uint32 length );
1330
1331/**
1332 * Stop the simple rumble on a haptic device.
1333 *
1334 * \param haptic the haptic device to stop the rumble effect on.
1335 * \returns 0 on success or a negative error code on failure; call
1336 * SDL_GetError() for more information.
1337 *
1338 * \since This function is available since SDL 2.0.0.
1339 *
1340 * \sa SDL_HapticRumbleInit
1341 * \sa SDL_HapticRumblePlay
1342 * \sa SDL_HapticRumbleSupported
1343 */
1344extern DECLSPEC int SDLCALL SDL_HapticRumbleStop(SDL_Haptic * haptic);
1345
1346/* Ends C function definitions when using C++ */
1347#ifdef __cplusplus
1348}
1349#endif
1350#include "close_code.h"
1351
1352#endif /* SDL_haptic_h_ */
1353
1354/* vi: set ts=4 sw=4 expandtab: */
int SDL_HapticRumblePlay(SDL_Haptic *haptic, float strength, Uint32 length)
int SDL_HapticStopAll(SDL_Haptic *haptic)
int SDL_HapticStopEffect(SDL_Haptic *haptic, int effect)
int SDL_HapticSetAutocenter(SDL_Haptic *haptic, int autocenter)
int SDL_JoystickIsHaptic(SDL_Joystick *joystick)
unsigned int SDL_HapticQuery(SDL_Haptic *haptic)
int SDL_HapticPause(SDL_Haptic *haptic)
int SDL_HapticNewEffect(SDL_Haptic *haptic, SDL_HapticEffect *effect)
int SDL_HapticOpened(int device_index)
int SDL_NumHaptics(void)
int SDL_HapticRumbleInit(SDL_Haptic *haptic)
int SDL_HapticSetGain(SDL_Haptic *haptic, int gain)
int SDL_HapticUnpause(SDL_Haptic *haptic)
void SDL_HapticClose(SDL_Haptic *haptic)
int SDL_HapticNumEffectsPlaying(SDL_Haptic *haptic)
SDL_Haptic * SDL_HapticOpenFromJoystick(SDL_Joystick *joystick)
void SDL_HapticDestroyEffect(SDL_Haptic *haptic, int effect)
int SDL_HapticRumbleSupported(SDL_Haptic *haptic)
int SDL_HapticIndex(SDL_Haptic *haptic)
struct _SDL_Haptic SDL_Haptic
The haptic structure used to identify an SDL haptic.
Definition SDL_haptic.h:143
int SDL_HapticRunEffect(SDL_Haptic *haptic, int effect, Uint32 iterations)
int SDL_HapticNumEffects(SDL_Haptic *haptic)
int SDL_HapticNumAxes(SDL_Haptic *haptic)
const char * SDL_HapticName(int device_index)
int SDL_MouseIsHaptic(void)
int SDL_HapticGetEffectStatus(SDL_Haptic *haptic, int effect)
int SDL_HapticEffectSupported(SDL_Haptic *haptic, SDL_HapticEffect *effect)
int SDL_HapticRumbleStop(SDL_Haptic *haptic)
int SDL_HapticUpdateEffect(SDL_Haptic *haptic, int effect, SDL_HapticEffect *data)
SDL_Haptic * SDL_HapticOpenFromMouse(void)
SDL_Haptic * SDL_HapticOpen(int device_index)
struct _SDL_Joystick SDL_Joystick
uint8_t Uint8
Definition SDL_stdinc.h:203
uint16_t Uint16
Definition SDL_stdinc.h:217
int32_t Sint32
Definition SDL_stdinc.h:224
int16_t Sint16
Definition SDL_stdinc.h:210
uint32_t Uint32
Definition SDL_stdinc.h:231
Sint16 right_coeff[3]
Definition SDL_haptic.h:640
SDL_HapticDirection direction
Definition SDL_haptic.h:627
SDL_HapticDirection direction
Definition SDL_haptic.h:488
SDL_HapticDirection direction
Definition SDL_haptic.h:728
SDL_HapticDirection direction
Definition SDL_haptic.h:574
Uint16 fade_level
Definition SDL_haptic.h:681
SDL_HapticDirection direction
Definition SDL_haptic.h:663
Uint16 attack_level
Definition SDL_haptic.h:679
Uint16 fade_length
Definition SDL_haptic.h:680
Uint16 attack_length
Definition SDL_haptic.h:678
SDL_HapticCustom custom
Definition SDL_haptic.h:830
SDL_HapticRamp ramp
Definition SDL_haptic.h:828
SDL_HapticLeftRight leftright
Definition SDL_haptic.h:829
SDL_HapticPeriodic periodic
Definition SDL_haptic.h:826
SDL_HapticCondition condition
Definition SDL_haptic.h:827
SDL_HapticConstant constant
Definition SDL_haptic.h:825