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