My Project
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
SDL_haptic.h
Go to the documentation of this file.
1 /*
2  Simple DirectMedia Layer
3  Copyright (C) 1997-2016 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 
107 #ifndef _SDL_haptic_h
108 #define _SDL_haptic_h
109 
110 #include "SDL_stdinc.h"
111 #include "SDL_error.h"
112 #include "SDL_joystick.h"
113 
114 #include "begin_code.h"
115 /* Set up for C function definitions, even when using C++ */
116 #ifdef __cplusplus
117 extern "C" {
118 #endif /* __cplusplus */
119 
129 struct _SDL_Haptic;
130 typedef struct _SDL_Haptic SDL_Haptic;
131 
132 
138 /* @{ */
139 
143 /* @{ */
144 
152 #define SDL_HAPTIC_CONSTANT (1<<0)
153 
161 #define SDL_HAPTIC_SINE (1<<1)
162 
172 #define SDL_HAPTIC_LEFTRIGHT (1<<2)
173 
174 /* !!! FIXME: put this back when we have more bits in 2.1 */
175 /* #define SDL_HAPTIC_SQUARE (1<<2) */
176 
184 #define SDL_HAPTIC_TRIANGLE (1<<3)
185 
193 #define SDL_HAPTIC_SAWTOOTHUP (1<<4)
194 
202 #define SDL_HAPTIC_SAWTOOTHDOWN (1<<5)
203 
211 #define SDL_HAPTIC_RAMP (1<<6)
212 
221 #define SDL_HAPTIC_SPRING (1<<7)
222 
231 #define SDL_HAPTIC_DAMPER (1<<8)
232 
241 #define SDL_HAPTIC_INERTIA (1<<9)
242 
251 #define SDL_HAPTIC_FRICTION (1<<10)
252 
258 #define SDL_HAPTIC_CUSTOM (1<<11)
259 
260 /* @} *//* Haptic effects */
261 
262 /* These last few are features the device has, not effects */
263 
271 #define SDL_HAPTIC_GAIN (1<<12)
272 
280 #define SDL_HAPTIC_AUTOCENTER (1<<13)
281 
289 #define SDL_HAPTIC_STATUS (1<<14)
290 
297 #define SDL_HAPTIC_PAUSE (1<<15)
298 
299 
303 /* @{ */
304 
310 #define SDL_HAPTIC_POLAR 0
311 
317 #define SDL_HAPTIC_CARTESIAN 1
318 
324 #define SDL_HAPTIC_SPHERICAL 2
325 
326 /* @} *//* Direction encodings */
327 
328 /* @} *//* Haptic features */
329 
330 /*
331  * Misc defines.
332  */
333 
339 #define SDL_HAPTIC_INFINITY 4294967295U
340 
341 
437 typedef struct SDL_HapticDirection
438 {
440  Sint32 dir[3];
442 
443 
455 typedef struct SDL_HapticConstant
456 {
457  /* Header */
461  /* Replay */
465  /* Trigger */
469  /* Constant */
472  /* Envelope */
478 
536 typedef struct SDL_HapticPeriodic
537 {
538  /* Header */
544  /* Replay */
548  /* Trigger */
552  /* Periodic */
558  /* Envelope */
564 
589 typedef struct SDL_HapticCondition
590 {
591  /* Header */
596  /* Replay */
600  /* Trigger */
604  /* Condition */
612 
626 typedef struct SDL_HapticRamp
627 {
628  /* Header */
632  /* Replay */
636  /* Trigger */
640  /* Ramp */
644  /* Envelope */
650 
663 typedef struct SDL_HapticLeftRight
664 {
665  /* Header */
668  /* Replay */
671  /* Rumble */
675 
689 typedef struct SDL_HapticCustom
690 {
691  /* Header */
695  /* Replay */
699  /* Trigger */
703  /* Custom */
709  /* Envelope */
715 
785 typedef union SDL_HapticEffect
786 {
787  /* Common for all force feedback effects */
796 
797 
798 /* Function prototypes */
804 extern DECLSPEC int SDLCALL SDL_NumHaptics(void);
805 
817 extern DECLSPEC const char *SDLCALL SDL_HapticName(int device_index);
818 
841 extern DECLSPEC SDL_Haptic *SDLCALL SDL_HapticOpen(int device_index);
842 
852 extern DECLSPEC int SDLCALL SDL_HapticOpened(int device_index);
853 
863 extern DECLSPEC int SDLCALL SDL_HapticIndex(SDL_Haptic * haptic);
864 
872 extern DECLSPEC int SDLCALL SDL_MouseIsHaptic(void);
873 
882 extern DECLSPEC SDL_Haptic *SDLCALL SDL_HapticOpenFromMouse(void);
883 
893 extern DECLSPEC int SDLCALL SDL_JoystickIsHaptic(SDL_Joystick * joystick);
894 
912 extern DECLSPEC SDL_Haptic *SDLCALL SDL_HapticOpenFromJoystick(SDL_Joystick *
913  joystick);
914 
920 extern DECLSPEC void SDLCALL SDL_HapticClose(SDL_Haptic * haptic);
921 
936 extern DECLSPEC int SDLCALL SDL_HapticNumEffects(SDL_Haptic * haptic);
937 
952 extern DECLSPEC int SDLCALL SDL_HapticNumEffectsPlaying(SDL_Haptic * haptic);
953 
970 extern DECLSPEC unsigned int SDLCALL SDL_HapticQuery(SDL_Haptic * haptic);
971 
972 
978 extern DECLSPEC int SDLCALL SDL_HapticNumAxes(SDL_Haptic * haptic);
979 
990 extern DECLSPEC int SDLCALL SDL_HapticEffectSupported(SDL_Haptic * haptic,
992  effect);
993 
1005 extern DECLSPEC int SDLCALL SDL_HapticNewEffect(SDL_Haptic * haptic,
1006  SDL_HapticEffect * effect);
1007 
1025 extern DECLSPEC int SDLCALL SDL_HapticUpdateEffect(SDL_Haptic * haptic,
1026  int effect,
1027  SDL_HapticEffect * data);
1028 
1047 extern DECLSPEC int SDLCALL SDL_HapticRunEffect(SDL_Haptic * haptic,
1048  int effect,
1049  Uint32 iterations);
1050 
1061 extern DECLSPEC int SDLCALL SDL_HapticStopEffect(SDL_Haptic * haptic,
1062  int effect);
1063 
1075 extern DECLSPEC void SDLCALL SDL_HapticDestroyEffect(SDL_Haptic * haptic,
1076  int effect);
1077 
1090 extern DECLSPEC int SDLCALL SDL_HapticGetEffectStatus(SDL_Haptic * haptic,
1091  int effect);
1092 
1109 extern DECLSPEC int SDLCALL SDL_HapticSetGain(SDL_Haptic * haptic, int gain);
1110 
1125 extern DECLSPEC int SDLCALL SDL_HapticSetAutocenter(SDL_Haptic * haptic,
1126  int autocenter);
1127 
1142 extern DECLSPEC int SDLCALL SDL_HapticPause(SDL_Haptic * haptic);
1143 
1154 extern DECLSPEC int SDLCALL SDL_HapticUnpause(SDL_Haptic * haptic);
1155 
1162 extern DECLSPEC int SDLCALL SDL_HapticStopAll(SDL_Haptic * haptic);
1163 
1174 extern DECLSPEC int SDLCALL SDL_HapticRumbleSupported(SDL_Haptic * haptic);
1175 
1187 extern DECLSPEC int SDLCALL SDL_HapticRumbleInit(SDL_Haptic * haptic);
1188 
1201 extern DECLSPEC int SDLCALL SDL_HapticRumblePlay(SDL_Haptic * haptic, float strength, Uint32 length );
1202 
1213 extern DECLSPEC int SDLCALL SDL_HapticRumbleStop(SDL_Haptic * haptic);
1214 
1215 /* Ends C function definitions when using C++ */
1216 #ifdef __cplusplus
1217 }
1218 #endif
1219 #include "close_code.h"
1220 
1221 #endif /* _SDL_haptic_h */
1222 
1223 /* vi: set ts=4 sw=4 expandtab: */
DECLSPEC SDL_Haptic *SDLCALL SDL_HapticOpenFromMouse(void)
Tries to open a haptic device from the current mouse.
DECLSPEC SDL_Haptic *SDLCALL SDL_HapticOpen(int device_index)
Opens a Haptic device for usage.
uint8_t Uint8
An unsigned 8-bit integer type.
Definition: SDL_stdinc.h:139
DECLSPEC void SDLCALL SDL_HapticClose(SDL_Haptic *haptic)
Closes a Haptic device previously opened with SDL_HapticOpen().
Uint16 right_sat[3]
Definition: SDL_haptic.h:605
SDL_HapticCustom custom
Definition: SDL_haptic.h:794
Uint16 interval
Definition: SDL_haptic.h:701
A structure containing a template for the SDL_HAPTIC_CUSTOM effect.
Definition: SDL_haptic.h:689
Sint16 level
Definition: SDL_haptic.h:470
Uint16 samples
Definition: SDL_haptic.h:706
Uint16 fade_level
Definition: SDL_haptic.h:648
struct SDL_HapticRamp SDL_HapticRamp
A structure containing a template for a Ramp effect.
DECLSPEC int SDLCALL SDL_HapticIndex(SDL_Haptic *haptic)
Gets the index of a haptic device.
Uint16 attack_length
Definition: SDL_haptic.h:559
Uint16 large_magnitude
Definition: SDL_haptic.h:672
uint32_t Uint32
An unsigned 32-bit integer type.
Definition: SDL_stdinc.h:155
struct _SDL_Haptic SDL_Haptic
The haptic structure used to identify an SDL haptic.
Definition: SDL_haptic.h:130
struct SDL_HapticPeriodic SDL_HapticPeriodic
A structure containing a template for a Periodic effect.
Uint16 fade_level
Definition: SDL_haptic.h:476
DECLSPEC int SDLCALL SDL_HapticStopAll(SDL_Haptic *haptic)
Stops all the currently playing effects on a haptic device.
DECLSPEC int SDLCALL SDL_HapticStopEffect(SDL_Haptic *haptic, int effect)
Stops the haptic effect on its associated haptic device.
Sint16 center[3]
Definition: SDL_haptic.h:610
Uint8 type
Definition: SDL_haptic.h:439
Uint16 button
Definition: SDL_haptic.h:637
Sint32 dir[3]
Definition: SDL_haptic.h:440
uint16_t Uint16
An unsigned 16-bit integer type.
Definition: SDL_stdinc.h:147
Uint16 attack_level
Definition: SDL_haptic.h:560
Uint16 period
Definition: SDL_haptic.h:705
Uint16 small_magnitude
Definition: SDL_haptic.h:673
Uint16 fade_length
Definition: SDL_haptic.h:561
Uint16 attack_length
Definition: SDL_haptic.h:710
Uint16 deadband[3]
Definition: SDL_haptic.h:609
Uint16 attack_level
Definition: SDL_haptic.h:474
Uint16 delay
Definition: SDL_haptic.h:634
Uint16 delay
Definition: SDL_haptic.h:546
SDL_HapticConstant constant
Definition: SDL_haptic.h:789
Uint16 button
Definition: SDL_haptic.h:549
Uint16 type
Definition: SDL_haptic.h:458
SDL_HapticDirection direction
Definition: SDL_haptic.h:594
Uint16 button
Definition: SDL_haptic.h:466
DECLSPEC int SDLCALL SDL_HapticOpened(int device_index)
Checks if the haptic device at index has been opened.
Uint16 * data
Definition: SDL_haptic.h:707
Uint16 period
Definition: SDL_haptic.h:553
Uint32 length
Definition: SDL_haptic.h:462
DECLSPEC int SDLCALL SDL_HapticUpdateEffect(SDL_Haptic *haptic, int effect, SDL_HapticEffect *data)
Updates the properties of an effect.
A structure containing a template for a Constant effect.
Definition: SDL_haptic.h:455
DECLSPEC int SDLCALL SDL_HapticRumbleInit(SDL_Haptic *haptic)
Initializes the haptic device for simple rumble playback.
Uint16 button
Definition: SDL_haptic.h:700
Uint8 channels
Definition: SDL_haptic.h:704
Uint16 fade_length
Definition: SDL_haptic.h:712
DECLSPEC int SDLCALL SDL_HapticNumEffectsPlaying(SDL_Haptic *haptic)
Returns the number of effects a haptic device can play at the same time.
struct SDL_HapticLeftRight SDL_HapticLeftRight
A structure containing a template for a Left/Right effect.
SDL_HapticDirection direction
Definition: SDL_haptic.h:693
DECLSPEC int SDLCALL SDL_HapticNewEffect(SDL_Haptic *haptic, SDL_HapticEffect *effect)
Creates a new haptic effect on the device.
SDL_HapticDirection direction
Definition: SDL_haptic.h:630
DECLSPEC int SDLCALL SDL_HapticRumblePlay(SDL_Haptic *haptic, float strength, Uint32 length)
Runs simple rumble on a haptic device.
Uint32 length
Definition: SDL_haptic.h:696
Uint16 button
Definition: SDL_haptic.h:601
SDL_HapticDirection direction
Definition: SDL_haptic.h:459
DECLSPEC int SDLCALL SDL_HapticGetEffectStatus(SDL_Haptic *haptic, int effect)
Gets the status of the current effect on the haptic device.
Uint32 length
Definition: SDL_haptic.h:545
Uint16 delay
Definition: SDL_haptic.h:598
DECLSPEC SDL_Haptic *SDLCALL SDL_HapticOpenFromJoystick(SDL_Joystick *joystick)
Opens a Haptic device for usage from a Joystick device.
SDL_HapticCondition condition
Definition: SDL_haptic.h:791
Uint16 type
Definition: SDL_haptic.h:539
Sint16 end
Definition: SDL_haptic.h:642
DECLSPEC void SDLCALL SDL_HapticDestroyEffect(SDL_Haptic *haptic, int effect)
Destroys a haptic effect on the device.
int32_t Sint32
A signed 32-bit integer type.
Definition: SDL_stdinc.h:151
Uint16 fade_length
Definition: SDL_haptic.h:647
Uint16 type
Definition: SDL_haptic.h:629
Uint16 interval
Definition: SDL_haptic.h:467
A structure containing a template for a Periodic effect.
Definition: SDL_haptic.h:536
DECLSPEC int SDLCALL SDL_HapticEffectSupported(SDL_Haptic *haptic, SDL_HapticEffect *effect)
Checks to see if effect is supported by haptic.
Uint16 type
Definition: SDL_haptic.h:666
Sint16 magnitude
Definition: SDL_haptic.h:554
Sint16 right_coeff[3]
Definition: SDL_haptic.h:607
Uint32 length
Definition: SDL_haptic.h:669
Uint16 fade_length
Definition: SDL_haptic.h:475
Uint16 fade_level
Definition: SDL_haptic.h:713
SDL_HapticDirection direction
Definition: SDL_haptic.h:542
DECLSPEC int SDLCALL SDL_MouseIsHaptic(void)
Gets whether or not the current mouse has haptic capabilities.
DECLSPEC int SDLCALL SDL_HapticRunEffect(SDL_Haptic *haptic, int effect, Uint32 iterations)
Runs the haptic effect on its associated haptic device.
Uint16 interval
Definition: SDL_haptic.h:638
The generic template for any haptic effect.
Definition: SDL_haptic.h:785
Sint16 left_coeff[3]
Definition: SDL_haptic.h:608
Sint16 offset
Definition: SDL_haptic.h:555
DECLSPEC int SDLCALL SDL_HapticSetAutocenter(SDL_Haptic *haptic, int autocenter)
Sets the global autocenter of the device.
A structure containing a template for a Condition effect.
Definition: SDL_haptic.h:589
DECLSPEC const char *SDLCALL SDL_HapticName(int device_index)
Get the implementation dependent name of a Haptic device.
DECLSPEC unsigned int SDLCALL SDL_HapticQuery(SDL_Haptic *haptic)
Gets the haptic device's supported features in bitwise manner.
struct SDL_HapticCondition SDL_HapticCondition
A structure containing a template for a Condition effect.
SDL_HapticLeftRight leftright
Definition: SDL_haptic.h:793
DECLSPEC int SDLCALL SDL_JoystickIsHaptic(SDL_Joystick *joystick)
Checks to see if a joystick has haptic features.
Uint16 delay
Definition: SDL_haptic.h:697
struct SDL_HapticConstant SDL_HapticConstant
A structure containing a template for a Constant effect.
Uint16 delay
Definition: SDL_haptic.h:463
Structure that represents a haptic direction.
Definition: SDL_haptic.h:437
DECLSPEC int SDLCALL SDL_HapticRumbleSupported(SDL_Haptic *haptic)
Checks to see if rumble is supported on a haptic device.
struct SDL_HapticCustom SDL_HapticCustom
A structure containing a template for the SDL_HAPTIC_CUSTOM effect.
SDL_HapticRamp ramp
Definition: SDL_haptic.h:792
Uint16 type
Definition: SDL_haptic.h:788
DECLSPEC int SDLCALL SDL_HapticSetGain(SDL_Haptic *haptic, int gain)
Sets the global gain of the device.
A structure containing a template for a Ramp effect.
Definition: SDL_haptic.h:626
Uint16 fade_level
Definition: SDL_haptic.h:562
Uint16 attack_level
Definition: SDL_haptic.h:646
DECLSPEC int SDLCALL SDL_HapticUnpause(SDL_Haptic *haptic)
Unpauses a haptic device.
SDL_HapticPeriodic periodic
Definition: SDL_haptic.h:790
Uint16 attack_length
Definition: SDL_haptic.h:645
DECLSPEC int SDLCALL SDL_HapticRumbleStop(SDL_Haptic *haptic)
Stops the simple rumble on a haptic device.
Uint32 length
Definition: SDL_haptic.h:633
DECLSPEC int SDLCALL SDL_NumHaptics(void)
Count the number of haptic devices attached to the system.
Uint16 type
Definition: SDL_haptic.h:592
int16_t Sint16
A signed 16-bit integer type.
Definition: SDL_stdinc.h:143
Sint16 start
Definition: SDL_haptic.h:641
Uint16 interval
Definition: SDL_haptic.h:602
DECLSPEC int SDLCALL SDL_HapticNumEffects(SDL_Haptic *haptic)
Returns the number of effects a haptic device can store.
struct SDL_HapticDirection SDL_HapticDirection
Structure that represents a haptic direction.
Uint16 type
Definition: SDL_haptic.h:692
Uint16 attack_length
Definition: SDL_haptic.h:473
Uint32 length
Definition: SDL_haptic.h:597
DECLSPEC int SDLCALL SDL_HapticNumAxes(SDL_Haptic *haptic)
Gets the number of haptic axes the device has.
Uint16 attack_level
Definition: SDL_haptic.h:711
Uint16 phase
Definition: SDL_haptic.h:556
DECLSPEC int SDLCALL SDL_HapticPause(SDL_Haptic *haptic)
Pauses a haptic device.
A structure containing a template for a Left/Right effect.
Definition: SDL_haptic.h:663
union SDL_HapticEffect SDL_HapticEffect
The generic template for any haptic effect.
Uint16 interval
Definition: SDL_haptic.h:550
Uint16 left_sat[3]
Definition: SDL_haptic.h:606