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_PauseHaptic
902 * \sa SDL_SetHapticAutocenter
903 * \sa SDL_SetHapticGain
904 * \sa SDL_StopHapticEffects
905 */
906extern DECLSPEC SDL_Haptic *SDLCALL SDL_OpenHaptic(SDL_HapticID instance_id);
907
908
909/**
910 * Get the SDL_Haptic associated with an instance ID, if it has been opened.
911 *
912 * \param instance_id the instance ID to get the SDL_Haptic for
913 * \returns an SDL_Haptic on success or NULL on failure or if it hasn't been
914 * opened yet; call SDL_GetError() for more information.
915 *
916 * \since This function is available since SDL 3.0.0.
917 */
918extern DECLSPEC SDL_Haptic *SDLCALL SDL_GetHapticFromInstanceID(SDL_HapticID instance_id);
919
920/**
921 * Get the instance ID of an opened haptic device.
922 *
923 * \param haptic the SDL_Haptic device to query
924 * \returns the instance ID of the specified haptic device on success or 0 on
925 * failure; call SDL_GetError() for more information.
926 *
927 * \since This function is available since SDL 3.0.0.
928 *
929 * \sa SDL_OpenHaptic
930 */
931extern DECLSPEC SDL_HapticID SDLCALL SDL_GetHapticInstanceID(SDL_Haptic *haptic);
932
933/**
934 * Get the implementation dependent name of a haptic device.
935 *
936 * \param haptic the SDL_Haptic obtained from SDL_OpenJoystick()
937 * \returns the name of the selected haptic device. If no name can be found,
938 * this function returns NULL; call SDL_GetError() for more
939 * information.
940 *
941 * \since This function is available since SDL 3.0.0.
942 *
943 * \sa SDL_GetHapticInstanceName
944 * \sa SDL_OpenHaptic
945 */
946extern DECLSPEC const char *SDLCALL SDL_GetHapticName(SDL_Haptic *haptic);
947
948/**
949 * Query whether or not the current mouse has haptic capabilities.
950 *
951 * \returns SDL_TRUE if the mouse is haptic or SDL_FALSE if it isn't.
952 *
953 * \since This function is available since SDL 3.0.0.
954 *
955 * \sa SDL_OpenHapticFromMouse
956 */
957extern DECLSPEC SDL_bool SDLCALL SDL_IsMouseHaptic(void);
958
959/**
960 * Try to open a haptic device from the current mouse.
961 *
962 * \returns the haptic device identifier or NULL on failure; call
963 * SDL_GetError() for more information.
964 *
965 * \since This function is available since SDL 3.0.0.
966 *
967 * \sa SDL_OpenHaptic
968 * \sa SDL_IsMouseHaptic
969 */
970extern DECLSPEC SDL_Haptic *SDLCALL SDL_OpenHapticFromMouse(void);
971
972/**
973 * Query if a joystick has haptic features.
974 *
975 * \param joystick the SDL_Joystick to test for haptic capabilities
976 * \returns SDL_TRUE if the joystick is haptic or SDL_FALSE if it isn't.
977 *
978 * \since This function is available since SDL 3.0.0.
979 *
980 * \sa SDL_OpenHapticFromJoystick
981 */
982extern DECLSPEC SDL_bool SDLCALL SDL_IsJoystickHaptic(SDL_Joystick *joystick);
983
984/**
985 * Open a haptic device for use from a joystick device.
986 *
987 * You must still close the haptic device separately. It will not be closed
988 * with the joystick.
989 *
990 * When opened from a joystick you should first close the haptic device before
991 * closing the joystick device. If not, on some implementations the haptic
992 * device will also get unallocated and you'll be unable to use force feedback
993 * on that device.
994 *
995 * \param joystick the SDL_Joystick to create a haptic device from
996 * \returns a valid haptic device identifier on success or NULL on failure;
997 * call SDL_GetError() for more information.
998 *
999 * \since This function is available since SDL 3.0.0.
1000 *
1001 * \sa SDL_CloseHaptic
1002 * \sa SDL_OpenHaptic
1003 * \sa SDL_IsJoystickHaptic
1004 */
1005extern DECLSPEC SDL_Haptic *SDLCALL SDL_OpenHapticFromJoystick(SDL_Joystick *joystick);
1006
1007/**
1008 * Close a haptic device previously opened with SDL_OpenHaptic().
1009 *
1010 * \param haptic the SDL_Haptic device to close
1011 *
1012 * \since This function is available since SDL 3.0.0.
1013 *
1014 * \sa SDL_OpenHaptic
1015 */
1016extern DECLSPEC void SDLCALL SDL_CloseHaptic(SDL_Haptic *haptic);
1017
1018/**
1019 * Get the number of effects a haptic device can store.
1020 *
1021 * On some platforms this isn't fully supported, and therefore is an
1022 * approximation. Always check to see if your created effect was actually
1023 * created and do not rely solely on SDL_GetMaxHapticEffects().
1024 *
1025 * \param haptic the SDL_Haptic device to query
1026 * \returns the number of effects the haptic device can store or a negative
1027 * error code on failure; call SDL_GetError() for more information.
1028 *
1029 * \since This function is available since SDL 3.0.0.
1030 *
1031 * \sa SDL_GetMaxHapticEffectsPlaying
1032 * \sa SDL_GetHapticFeatures
1033 */
1034extern DECLSPEC int SDLCALL SDL_GetMaxHapticEffects(SDL_Haptic *haptic);
1035
1036/**
1037 * Get the number of effects a haptic device can play at the same time.
1038 *
1039 * This is not supported on all platforms, but will always return a value.
1040 *
1041 * \param haptic the SDL_Haptic device to query maximum playing effects
1042 * \returns the number of effects the haptic device can play at the same time
1043 * or a negative error code on failure; call SDL_GetError() for more
1044 * information.
1045 *
1046 * \since This function is available since SDL 3.0.0.
1047 *
1048 * \sa SDL_GetMaxHapticEffects
1049 * \sa SDL_GetHapticFeatures
1050 */
1051extern DECLSPEC int SDLCALL SDL_GetMaxHapticEffectsPlaying(SDL_Haptic *haptic);
1052
1053/**
1054 * Get the haptic device's supported features in bitwise manner.
1055 *
1056 * \param haptic the SDL_Haptic device to query
1057 * \returns a list of supported haptic features in bitwise manner (OR'd), or 0
1058 * on failure; call SDL_GetError() for more information.
1059 *
1060 * \since This function is available since SDL 3.0.0.
1061 *
1062 * \sa SDL_HapticEffectSupported
1063 * \sa SDL_GetMaxHapticEffects
1064 */
1065extern DECLSPEC Uint32 SDLCALL SDL_GetHapticFeatures(SDL_Haptic *haptic);
1066
1067
1068/**
1069 * Get the number of haptic axes the device has.
1070 *
1071 * The number of haptic axes might be useful if working with the
1072 * SDL_HapticDirection effect.
1073 *
1074 * \param haptic the SDL_Haptic device to query
1075 * \returns the number of axes on success or a negative error code on failure;
1076 * call SDL_GetError() for more information.
1077 *
1078 * \since This function is available since SDL 3.0.0.
1079 */
1080extern DECLSPEC int SDLCALL SDL_GetNumHapticAxes(SDL_Haptic *haptic);
1081
1082/**
1083 * Check to see if an effect is supported by a haptic device.
1084 *
1085 * \param haptic the SDL_Haptic device to query
1086 * \param effect the desired effect to query
1087 * \returns SDL_TRUE if the effect is supported or SDL_FALSE if it isn't.
1088 *
1089 * \since This function is available since SDL 3.0.0.
1090 *
1091 * \sa SDL_CreateHapticEffect
1092 * \sa SDL_GetHapticFeatures
1093 */
1094extern DECLSPEC SDL_bool SDLCALL SDL_HapticEffectSupported(SDL_Haptic *haptic, const SDL_HapticEffect *effect);
1095
1096/**
1097 * Create a new haptic effect on a specified device.
1098 *
1099 * \param haptic an SDL_Haptic device to create the effect on
1100 * \param effect an SDL_HapticEffect structure containing the properties of
1101 * the effect to create
1102 * \returns the ID of the effect on success or a negative error code on
1103 * failure; call SDL_GetError() for more information.
1104 *
1105 * \since This function is available since SDL 3.0.0.
1106 *
1107 * \sa SDL_DestroyHapticEffect
1108 * \sa SDL_RunHapticEffect
1109 * \sa SDL_UpdateHapticEffect
1110 */
1111extern DECLSPEC int SDLCALL SDL_CreateHapticEffect(SDL_Haptic *haptic, const SDL_HapticEffect *effect);
1112
1113/**
1114 * Update the properties of an effect.
1115 *
1116 * Can be used dynamically, although behavior when dynamically changing
1117 * direction may be strange. Specifically the effect may re-upload itself and
1118 * start playing from the start. You also cannot change the type either when
1119 * running SDL_UpdateHapticEffect().
1120 *
1121 * \param haptic the SDL_Haptic device that has the effect
1122 * \param effect the identifier of the effect to update
1123 * \param data an SDL_HapticEffect structure containing the new effect
1124 * properties to use
1125 * \returns 0 on success or a negative error code on failure; call
1126 * SDL_GetError() for more information.
1127 *
1128 * \since This function is available since SDL 3.0.0.
1129 *
1130 * \sa SDL_DestroyHapticEffect
1131 * \sa SDL_CreateHapticEffect
1132 * \sa SDL_RunHapticEffect
1133 */
1134extern DECLSPEC int SDLCALL SDL_UpdateHapticEffect(SDL_Haptic *haptic, int effect, const SDL_HapticEffect *data);
1135
1136/**
1137 * Run the haptic effect on its associated haptic device.
1138 *
1139 * To repeat the effect over and over indefinitely, set `iterations` to
1140 * `SDL_HAPTIC_INFINITY`. (Repeats the envelope - attack and fade.) To make
1141 * one instance of the effect last indefinitely (so the effect does not fade),
1142 * set the effect's `length` in its structure/union to `SDL_HAPTIC_INFINITY`
1143 * instead.
1144 *
1145 * \param haptic the SDL_Haptic device to run the effect on
1146 * \param effect the ID of the haptic effect to run
1147 * \param iterations the number of iterations to run the effect; use
1148 * `SDL_HAPTIC_INFINITY` to repeat forever
1149 * \returns 0 on success or a negative error code on failure; call
1150 * SDL_GetError() for more information.
1151 *
1152 * \since This function is available since SDL 3.0.0.
1153 *
1154 * \sa SDL_DestroyHapticEffect
1155 * \sa SDL_GetHapticEffectStatus
1156 * \sa SDL_StopHapticEffect
1157 */
1158extern DECLSPEC int SDLCALL SDL_RunHapticEffect(SDL_Haptic *haptic, int effect, Uint32 iterations);
1159
1160/**
1161 * Stop the haptic effect on its associated haptic device.
1162 *
1163 * *
1164 *
1165 * \param haptic the SDL_Haptic device to stop the effect on
1166 * \param effect the ID of the haptic effect to stop
1167 * \returns 0 on success or a negative error code on failure; call
1168 * SDL_GetError() for more information.
1169 *
1170 * \since This function is available since SDL 3.0.0.
1171 *
1172 * \sa SDL_DestroyHapticEffect
1173 * \sa SDL_RunHapticEffect
1174 */
1175extern DECLSPEC int SDLCALL SDL_StopHapticEffect(SDL_Haptic *haptic, int effect);
1176
1177/**
1178 * Destroy a haptic effect on the device.
1179 *
1180 * This will stop the effect if it's running. Effects are automatically
1181 * destroyed when the device is closed.
1182 *
1183 * \param haptic the SDL_Haptic device to destroy the effect on
1184 * \param effect the ID of the haptic effect to destroy
1185 *
1186 * \since This function is available since SDL 3.0.0.
1187 *
1188 * \sa SDL_CreateHapticEffect
1189 */
1190extern DECLSPEC void SDLCALL SDL_DestroyHapticEffect(SDL_Haptic *haptic, int effect);
1191
1192/**
1193 * Get the status of the current effect on the specified haptic device.
1194 *
1195 * Device must support the SDL_HAPTIC_STATUS feature.
1196 *
1197 * \param haptic the SDL_Haptic device to query for the effect status on
1198 * \param effect the ID of the haptic effect to query its status
1199 * \returns 0 if it isn't playing, 1 if it is playing, or a negative error
1200 * code on failure; call SDL_GetError() for more information.
1201 *
1202 * \since This function is available since SDL 3.0.0.
1203 *
1204 * \sa SDL_RunHapticEffect
1205 * \sa SDL_StopHapticEffect
1206 */
1207extern DECLSPEC int SDLCALL SDL_GetHapticEffectStatus(SDL_Haptic *haptic, int effect);
1208
1209/**
1210 * Set the global gain of the specified haptic device.
1211 *
1212 * Device must support the SDL_HAPTIC_GAIN feature.
1213 *
1214 * The user may specify the maximum gain by setting the environment variable
1215 * `SDL_HAPTIC_GAIN_MAX` which should be between 0 and 100. All calls to
1216 * SDL_SetHapticGain() will scale linearly using `SDL_HAPTIC_GAIN_MAX` as the
1217 * maximum.
1218 *
1219 * \param haptic the SDL_Haptic device to set the gain on
1220 * \param gain value to set the gain to, should be between 0 and 100 (0 - 100)
1221 * \returns 0 on success or a negative error code on failure; call
1222 * SDL_GetError() for more information.
1223 *
1224 * \since This function is available since SDL 3.0.0.
1225 *
1226 * \sa SDL_GetHapticFeatures
1227 */
1228extern DECLSPEC int SDLCALL SDL_SetHapticGain(SDL_Haptic *haptic, int gain);
1229
1230/**
1231 * Set the global autocenter of the device.
1232 *
1233 * Autocenter should be between 0 and 100. Setting it to 0 will disable
1234 * autocentering.
1235 *
1236 * Device must support the SDL_HAPTIC_AUTOCENTER feature.
1237 *
1238 * \param haptic the SDL_Haptic device to set autocentering on
1239 * \param autocenter value to set autocenter to (0-100)
1240 * \returns 0 on success or a negative error code on failure; call
1241 * SDL_GetError() for more information.
1242 *
1243 * \since This function is available since SDL 3.0.0.
1244 *
1245 * \sa SDL_GetHapticFeatures
1246 */
1247extern DECLSPEC int SDLCALL SDL_SetHapticAutocenter(SDL_Haptic *haptic, int autocenter);
1248
1249/**
1250 * Pause a haptic device.
1251 *
1252 * Device must support the `SDL_HAPTIC_PAUSE` feature. Call SDL_ResumeHaptic()
1253 * to resume playback.
1254 *
1255 * Do not modify the effects nor add new ones while the device is paused. That
1256 * can cause all sorts of weird errors.
1257 *
1258 * \param haptic the SDL_Haptic device to pause
1259 * \returns 0 on success or a negative error code on failure; call
1260 * SDL_GetError() for more information.
1261 *
1262 * \since This function is available since SDL 3.0.0.
1263 *
1264 * \sa SDL_ResumeHaptic
1265 */
1266extern DECLSPEC int SDLCALL SDL_PauseHaptic(SDL_Haptic *haptic);
1267
1268/**
1269 * Resume a haptic device.
1270 *
1271 * Call to unpause after SDL_PauseHaptic().
1272 *
1273 * \param haptic the SDL_Haptic device to unpause
1274 * \returns 0 on success or a negative error code on failure; call
1275 * SDL_GetError() for more information.
1276 *
1277 * \since This function is available since SDL 3.0.0.
1278 *
1279 * \sa SDL_PauseHaptic
1280 */
1281extern DECLSPEC int SDLCALL SDL_ResumeHaptic(SDL_Haptic *haptic);
1282
1283/**
1284 * Stop all the currently playing effects on a haptic device.
1285 *
1286 * \param haptic the SDL_Haptic device to stop
1287 * \returns 0 on success or a negative error code on failure; call
1288 * SDL_GetError() for more information.
1289 *
1290 * \since This function is available since SDL 3.0.0.
1291 */
1292extern DECLSPEC int SDLCALL SDL_StopHapticEffects(SDL_Haptic *haptic);
1293
1294/**
1295 * Check whether rumble is supported on a haptic device.
1296 *
1297 * \param haptic haptic device to check for rumble support
1298 * \returns SDL_TRUE if the effect is supported or SDL_FALSE if it isn't.
1299 *
1300 * \since This function is available since SDL 3.0.0.
1301 *
1302 * \sa SDL_InitHapticRumble
1303 * \sa SDL_PlayHapticRumble
1304 * \sa SDL_StopHapticRumble
1305 */
1306extern DECLSPEC SDL_bool SDLCALL SDL_HapticRumbleSupported(SDL_Haptic *haptic);
1307
1308/**
1309 * Initialize a haptic device for simple rumble playback.
1310 *
1311 * \param haptic the haptic device to initialize for simple rumble playback
1312 * \returns 0 on success or a negative error code on failure; call
1313 * SDL_GetError() for more information.
1314 *
1315 * \since This function is available since SDL 3.0.0.
1316 *
1317 * \sa SDL_OpenHaptic
1318 * \sa SDL_PlayHapticRumble
1319 * \sa SDL_StopHapticRumble
1320 * \sa SDL_HapticRumbleSupported
1321 */
1322extern DECLSPEC int SDLCALL SDL_InitHapticRumble(SDL_Haptic *haptic);
1323
1324/**
1325 * Run a simple rumble effect on a haptic device.
1326 *
1327 * \param haptic the haptic device to play the rumble effect on
1328 * \param strength strength of the rumble to play as a 0-1 float value
1329 * \param length length of the rumble to play in milliseconds
1330 * \returns 0 on success or a negative error code on failure; call
1331 * SDL_GetError() for more information.
1332 *
1333 * \since This function is available since SDL 3.0.0.
1334 *
1335 * \sa SDL_InitHapticRumble
1336 * \sa SDL_StopHapticRumble
1337 * \sa SDL_HapticRumbleSupported
1338 */
1339extern DECLSPEC int SDLCALL SDL_PlayHapticRumble(SDL_Haptic *haptic, float strength, Uint32 length);
1340
1341/**
1342 * Stop the simple rumble on a haptic device.
1343 *
1344 * \param haptic the haptic device to stop the rumble effect on
1345 * \returns 0 on success or a negative error code on failure; call
1346 * SDL_GetError() for more information.
1347 *
1348 * \since This function is available since SDL 3.0.0.
1349 *
1350 * \sa SDL_InitHapticRumble
1351 * \sa SDL_PlayHapticRumble
1352 * \sa SDL_HapticRumbleSupported
1353 */
1354extern DECLSPEC int SDLCALL SDL_StopHapticRumble(SDL_Haptic *haptic);
1355
1356/* Ends C function definitions when using C++ */
1357#ifdef __cplusplus
1358}
1359#endif
1360#include <SDL3/SDL_close_code.h>
1361
1362#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