Skip to content

Commit 2b16c96

Browse files
maia-sslouken
authored andcommitted
Add and use typedefs SDL_HapticEffectType and SDL_HapticDirectionType
1 parent a1332d7 commit 2b16c96

File tree

1 file changed

+35
-25
lines changed

1 file changed

+35
-25
lines changed

include/SDL3/SDL_haptic.h

+35-25
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,19 @@ extern "C" {
149149
*/
150150
typedef struct SDL_Haptic SDL_Haptic;
151151

152+
/*
153+
* Misc defines.
154+
*/
155+
156+
/**
157+
* Used to play a device an infinite number of times.
158+
*
159+
* \since This macro is available since SDL 3.2.0.
160+
*
161+
* \sa SDL_RunHapticEffect
162+
*/
163+
#define SDL_HAPTIC_INFINITY 4294967295U
164+
152165

153166
/**
154167
* \name Haptic features
@@ -162,6 +175,11 @@ typedef struct SDL_Haptic SDL_Haptic;
162175
*/
163176
/* @{ */
164177

178+
/**
179+
* Type of haptic effect.
180+
*/
181+
typedef Uint16 SDL_HapticEffectType;
182+
165183
/**
166184
* Constant effect supported.
167185
*
@@ -383,6 +401,11 @@ typedef struct SDL_Haptic SDL_Haptic;
383401
*/
384402
/* @{ */
385403

404+
/**
405+
* Type of coordinates used for haptic direction.
406+
*/
407+
typedef Uint8 SDL_HapticDirectionType;
408+
386409
/**
387410
* Uses polar coordinates for the direction.
388411
*
@@ -426,19 +449,6 @@ typedef struct SDL_Haptic SDL_Haptic;
426449

427450
/* @} *//* Haptic features */
428451

429-
/*
430-
* Misc defines.
431-
*/
432-
433-
/**
434-
* Used to play a device an infinite number of times.
435-
*
436-
* \since This macro is available since SDL 3.2.0.
437-
*
438-
* \sa SDL_RunHapticEffect
439-
*/
440-
#define SDL_HAPTIC_INFINITY 4294967295U
441-
442452

443453
/**
444454
* Structure that represents a haptic direction.
@@ -545,8 +555,8 @@ typedef struct SDL_Haptic SDL_Haptic;
545555
*/
546556
typedef struct SDL_HapticDirection
547557
{
548-
Uint8 type; /**< The type of encoding. */
549-
Sint32 dir[3]; /**< The encoded direction. */
558+
SDL_HapticDirectionType type; /**< The type of encoding. */
559+
Sint32 dir[3]; /**< The encoded direction. */
550560
} SDL_HapticDirection;
551561

552562

@@ -566,7 +576,7 @@ typedef struct SDL_HapticDirection
566576
typedef struct SDL_HapticConstant
567577
{
568578
/* Header */
569-
Uint16 type; /**< SDL_HAPTIC_CONSTANT */
579+
SDL_HapticEffectType type; /**< SDL_HAPTIC_CONSTANT */
570580
SDL_HapticDirection direction; /**< Direction of the effect. */
571581

572582
/* Replay */
@@ -652,9 +662,9 @@ typedef struct SDL_HapticConstant
652662
typedef struct SDL_HapticPeriodic
653663
{
654664
/* Header */
655-
Uint16 type; /**< SDL_HAPTIC_SINE, SDL_HAPTIC_SQUARE
656-
SDL_HAPTIC_TRIANGLE, SDL_HAPTIC_SAWTOOTHUP or
657-
SDL_HAPTIC_SAWTOOTHDOWN */
665+
SDL_HapticEffectType type; /**< SDL_HAPTIC_SINE, SDL_HAPTIC_SQUARE
666+
SDL_HAPTIC_TRIANGLE, SDL_HAPTIC_SAWTOOTHUP or
667+
SDL_HAPTIC_SAWTOOTHDOWN */
658668
SDL_HapticDirection direction; /**< Direction of the effect. */
659669

660670
/* Replay */
@@ -708,8 +718,8 @@ typedef struct SDL_HapticPeriodic
708718
typedef struct SDL_HapticCondition
709719
{
710720
/* Header */
711-
Uint16 type; /**< SDL_HAPTIC_SPRING, SDL_HAPTIC_DAMPER,
712-
SDL_HAPTIC_INERTIA or SDL_HAPTIC_FRICTION */
721+
SDL_HapticEffectType type; /**< SDL_HAPTIC_SPRING, SDL_HAPTIC_DAMPER,
722+
SDL_HAPTIC_INERTIA or SDL_HAPTIC_FRICTION */
713723
SDL_HapticDirection direction; /**< Direction of the effect. */
714724

715725
/* Replay */
@@ -747,7 +757,7 @@ typedef struct SDL_HapticCondition
747757
typedef struct SDL_HapticRamp
748758
{
749759
/* Header */
750-
Uint16 type; /**< SDL_HAPTIC_RAMP */
760+
SDL_HapticEffectType type; /**< SDL_HAPTIC_RAMP */
751761
SDL_HapticDirection direction; /**< Direction of the effect. */
752762

753763
/* Replay */
@@ -786,7 +796,7 @@ typedef struct SDL_HapticRamp
786796
typedef struct SDL_HapticLeftRight
787797
{
788798
/* Header */
789-
Uint16 type; /**< SDL_HAPTIC_LEFTRIGHT */
799+
SDL_HapticEffectType type; /**< SDL_HAPTIC_LEFTRIGHT */
790800

791801
/* Replay */
792802
Uint32 length; /**< Duration of the effect in milliseconds. */
@@ -816,7 +826,7 @@ typedef struct SDL_HapticLeftRight
816826
typedef struct SDL_HapticCustom
817827
{
818828
/* Header */
819-
Uint16 type; /**< SDL_HAPTIC_CUSTOM */
829+
SDL_HapticEffectType type; /**< SDL_HAPTIC_CUSTOM */
820830
SDL_HapticDirection direction; /**< Direction of the effect. */
821831

822832
/* Replay */
@@ -915,7 +925,7 @@ typedef struct SDL_HapticCustom
915925
typedef union SDL_HapticEffect
916926
{
917927
/* Common for all force feedback effects */
918-
Uint16 type; /**< Effect type. */
928+
SDL_HapticEffectType type; /**< Effect type. */
919929
SDL_HapticConstant constant; /**< Constant effect. */
920930
SDL_HapticPeriodic periodic; /**< Periodic effect. */
921931
SDL_HapticCondition condition; /**< Condition effect. */

0 commit comments

Comments
 (0)