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