zenilib  0.5.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
SDL_haptic.h
Go to the documentation of this file.
1 /*
2  Simple DirectMedia Layer
3  Copyright (C) 1997-2013 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 
112 #ifndef _SDL_haptic_h
113 #define _SDL_haptic_h
114 
115 #include "SDL_stdinc.h"
116 #include "SDL_error.h"
117 #include "SDL_joystick.h"
118 
119 #include "begin_code.h"
120 /* Set up for C function definitions, even when using C++ */
121 #ifdef __cplusplus
122 extern "C" {
123 #endif /* __cplusplus */
124 
134 struct _SDL_Haptic;
135 typedef struct _SDL_Haptic SDL_Haptic;
136 
137 
143 /* @{ */
144 
148 /* @{ */
149 
157 #define SDL_HAPTIC_CONSTANT (1<<0)
158 
166 #define SDL_HAPTIC_SINE (1<<1)
167 
177 #define SDL_HAPTIC_LEFTRIGHT (1<<2)
178 
179 /* !!! FIXME: put this back when we have more bits in 2.1 */
180 /* #define SDL_HAPTIC_SQUARE (1<<2) */
181 
189 #define SDL_HAPTIC_TRIANGLE (1<<3)
190 
198 #define SDL_HAPTIC_SAWTOOTHUP (1<<4)
199 
207 #define SDL_HAPTIC_SAWTOOTHDOWN (1<<5)
208 
216 #define SDL_HAPTIC_RAMP (1<<6)
217 
226 #define SDL_HAPTIC_SPRING (1<<7)
227 
236 #define SDL_HAPTIC_DAMPER (1<<8)
237 
246 #define SDL_HAPTIC_INERTIA (1<<9)
247 
256 #define SDL_HAPTIC_FRICTION (1<<10)
257 
263 #define SDL_HAPTIC_CUSTOM (1<<11)
264 
265 /* @} *//* Haptic effects */
266 
267 /* These last few are features the device has, not effects */
268 
276 #define SDL_HAPTIC_GAIN (1<<12)
277 
285 #define SDL_HAPTIC_AUTOCENTER (1<<13)
286 
294 #define SDL_HAPTIC_STATUS (1<<14)
295 
302 #define SDL_HAPTIC_PAUSE (1<<15)
303 
304 
308 /* @{ */
309 
315 #define SDL_HAPTIC_POLAR 0
316 
322 #define SDL_HAPTIC_CARTESIAN 1
323 
329 #define SDL_HAPTIC_SPHERICAL 2
330 
331 /* @} *//* Direction encodings */
332 
333 /* @} *//* Haptic features */
334 
335 /*
336  * Misc defines.
337  */
338 
344 #define SDL_HAPTIC_INFINITY 4294967295U
345 
346 
439 typedef struct SDL_HapticDirection
440 {
442  Sint32 dir[3];
444 
445 
457 typedef struct SDL_HapticConstant
458 {
459  /* Header */
463  /* Replay */
467  /* Trigger */
471  /* Constant */
474  /* Envelope */
480 
538 typedef struct SDL_HapticPeriodic
539 {
540  /* Header */
546  /* Replay */
550  /* Trigger */
554  /* Periodic */
560  /* Envelope */
566 
591 typedef struct SDL_HapticCondition
592 {
593  /* Header */
598  /* Replay */
602  /* Trigger */
606  /* Condition */
614 
628 typedef struct SDL_HapticRamp
629 {
630  /* Header */
634  /* Replay */
638  /* Trigger */
642  /* Ramp */
646  /* Envelope */
652 
665 typedef struct SDL_HapticLeftRight
666 {
667  /* Header */
670  /* Replay */
673  /* Rumble */
677 
691 typedef struct SDL_HapticCustom
692 {
693  /* Header */
697  /* Replay */
701  /* Trigger */
705  /* Custom */
711  /* Envelope */
717 
787 typedef union SDL_HapticEffect
788 {
789  /* Common for all force feedback effects */
798 
799 
800 /* Function prototypes */
806 extern DECLSPEC int SDLCALL SDL_NumHaptics(void);
807 
819 extern DECLSPEC const char *SDLCALL SDL_HapticName(int device_index);
820 
843 extern DECLSPEC SDL_Haptic *SDLCALL SDL_HapticOpen(int device_index);
844 
854 extern DECLSPEC int SDLCALL SDL_HapticOpened(int device_index);
855 
865 extern DECLSPEC int SDLCALL SDL_HapticIndex(SDL_Haptic * haptic);
866 
874 extern DECLSPEC int SDLCALL SDL_MouseIsHaptic(void);
875 
885 
895 extern DECLSPEC int SDLCALL SDL_JoystickIsHaptic(SDL_Joystick * joystick);
896 
915  joystick);
916 
922 extern DECLSPEC void SDLCALL SDL_HapticClose(SDL_Haptic * haptic);
923 
938 extern DECLSPEC int SDLCALL SDL_HapticNumEffects(SDL_Haptic * haptic);
939 
955 
972 extern DECLSPEC unsigned int SDLCALL SDL_HapticQuery(SDL_Haptic * haptic);
973 
974 
980 extern DECLSPEC int SDLCALL SDL_HapticNumAxes(SDL_Haptic * haptic);
981 
994  effect);
995 
1007 extern DECLSPEC int SDLCALL SDL_HapticNewEffect(SDL_Haptic * haptic,
1008  SDL_HapticEffect * effect);
1009 
1028  int effect,
1030 
1049 extern DECLSPEC int SDLCALL SDL_HapticRunEffect(SDL_Haptic * haptic,
1050  int effect,
1051  Uint32 iterations);
1052 
1063 extern DECLSPEC int SDLCALL SDL_HapticStopEffect(SDL_Haptic * haptic,
1064  int effect);
1065 
1077 extern DECLSPEC void SDLCALL SDL_HapticDestroyEffect(SDL_Haptic * haptic,
1078  int effect);
1079 
1093  int effect);
1094 
1111 extern DECLSPEC int SDLCALL SDL_HapticSetGain(SDL_Haptic * haptic, int gain);
1112 
1128  int autocenter);
1129 
1144 extern DECLSPEC int SDLCALL SDL_HapticPause(SDL_Haptic * haptic);
1145 
1156 extern DECLSPEC int SDLCALL SDL_HapticUnpause(SDL_Haptic * haptic);
1157 
1164 extern DECLSPEC int SDLCALL SDL_HapticStopAll(SDL_Haptic * haptic);
1165 
1177 
1189 extern DECLSPEC int SDLCALL SDL_HapticRumbleInit(SDL_Haptic * haptic);
1190 
1203 extern DECLSPEC int SDLCALL SDL_HapticRumblePlay(SDL_Haptic * haptic, float strength, Uint32 length );
1204 
1215 extern DECLSPEC int SDLCALL SDL_HapticRumbleStop(SDL_Haptic * haptic);
1216 
1217 /* Ends C function definitions when using C++ */
1218 #ifdef __cplusplus
1219 }
1220 #endif
1221 #include "close_code.h"
1222 
1223 #endif /* _SDL_haptic_h */
1224 
1225 /* vi: set ts=4 sw=4 expandtab: */
struct SDL_HapticDirection SDL_HapticDirection
Structure that represents a haptic direction.
Uint16 deadband[3]
Definition: SDL_haptic.h:611
Structure that represents a haptic direction.
Definition: SDL_haptic.h:439
DECLSPEC int SDLCALL SDL_HapticStopAll(SDL_Haptic *haptic)
Stops all the currently playing effects on a haptic device.
Definition: SDL_haptic.c:715
struct SDL_HapticConstant SDL_HapticConstant
A structure containing a template for a Constant effect.
int32_t Sint32
A signed 32-bit integer type.
Definition: SDL_stdinc.h:141
DECLSPEC int SDLCALL SDL_HapticRumblePlay(SDL_Haptic *haptic, float strength, Uint32 length)
Runs simple rumble on a haptic device.
Definition: SDL_haptic.c:783
DECLSPEC int SDLCALL SDL_HapticUpdateEffect(SDL_Haptic *haptic, int effect, SDL_HapticEffect *data)
Updates the properties of an effect.
Definition: SDL_haptic.c:511
A structure containing a template for a Periodic effect.
Definition: SDL_haptic.h:538
SDL_HapticDirection direction
Definition: SDL_haptic.h:596
SDL_HapticCustom custom
Definition: SDL_haptic.h:796
DECLSPEC SDL_Haptic *SDLCALL SDL_HapticOpenFromJoystick(SDL_Joystick *joystick)
Opens a Haptic device for usage from a Joystick device.
Definition: SDL_haptic.c:272
DECLSPEC int SDLCALL SDL_HapticNumEffects(SDL_Haptic *haptic)
Returns the number of effects a haptic device can store.
Definition: SDL_haptic.c:391
Uint16 fade_level
Definition: SDL_haptic.h:650
DECLSPEC int SDLCALL SDL_HapticStopEffect(SDL_Haptic *haptic, int effect)
Stops the haptic effect on its associated haptic device.
Definition: SDL_haptic.c:558
SDL_HapticRamp ramp
Definition: SDL_haptic.h:794
DECLSPEC void SDLCALL SDL_HapticClose(SDL_Haptic *haptic)
Closes a Haptic device previously opened with SDL_HapticOpen().
Definition: SDL_haptic.c:339
DECLSPEC int SDLCALL SDL_HapticSetAutocenter(SDL_Haptic *haptic, int autocenter)
Sets the global autocenter of the device.
Definition: SDL_haptic.c:656
#define DECLSPEC
Definition: begin_code.h:62
A structure containing a template for a Condition effect.
Definition: SDL_haptic.h:591
DECLSPEC int SDLCALL SDL_HapticUnpause(SDL_Haptic *haptic)
Unpauses a haptic device.
Definition: SDL_haptic.c:698
Sint16 left_coeff[3]
Definition: SDL_haptic.h:610
Uint16 right_sat[3]
Definition: SDL_haptic.h:607
#define SDLCALL
Definition: begin_code.h:72
Uint16 fade_length
Definition: SDL_haptic.h:714
Sint16 right_coeff[3]
Definition: SDL_haptic.h:609
DECLSPEC unsigned int SDLCALL SDL_HapticQuery(SDL_Haptic *haptic)
Gets the haptic devices supported features in bitwise matter.
Definition: SDL_haptic.c:419
struct SDL_HapticRamp SDL_HapticRamp
A structure containing a template for a Ramp effect.
A structure containing a template for a Constant effect.
Definition: SDL_haptic.h:457
DECLSPEC int SDLCALL SDL_MouseIsHaptic(void)
Gets whether or not the current mouse has haptic capabilities.
Definition: SDL_haptic.c:217
Uint16 interval
Definition: SDL_haptic.h:640
uint32_t Uint32
An unsigned 32-bit integer type.
Definition: SDL_stdinc.h:145
DECLSPEC int SDLCALL SDL_JoystickIsHaptic(SDL_Joystick *joystick)
Checks to see if a joystick has haptic features.
Definition: SDL_haptic.c:248
SDL_HapticCondition condition
Definition: SDL_haptic.h:793
DECLSPEC int SDLCALL SDL_HapticEffectSupported(SDL_Haptic *haptic, SDL_HapticEffect *effect)
Checks to see if effect is supported by haptic.
Definition: SDL_haptic.c:446
A structure containing a template for a Left/Right effect.
Definition: SDL_haptic.h:665
DECLSPEC int SDLCALL SDL_HapticNumAxes(SDL_Haptic *haptic)
Gets the number of haptic axes the device has.
Definition: SDL_haptic.c:433
DECLSPEC int SDLCALL SDL_HapticNumEffectsPlaying(SDL_Haptic *haptic)
Returns the number of effects a haptic device can play at the same time.
Definition: SDL_haptic.c:405
The generic template for any haptic effect.
Definition: SDL_haptic.h:787
union SDL_HapticEffect SDL_HapticEffect
The generic template for any haptic effect.
GLsizei GLsizei * length
Definition: gl2ext.h:792
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl2ext.h:848
DECLSPEC int SDLCALL SDL_HapticOpened(int device_index)
Checks if the haptic device at index has been opened.
Definition: SDL_haptic.c:177
DECLSPEC int SDLCALL SDL_HapticNewEffect(SDL_Haptic *haptic, SDL_HapticEffect *effect)
Creates a new haptic effect on the device.
Definition: SDL_haptic.c:461
SDL_HapticConstant constant
Definition: SDL_haptic.h:791
DECLSPEC SDL_Haptic *SDLCALL SDL_HapticOpen(int device_index)
Opens a Haptic device for usage.
Definition: SDL_haptic.c:116
struct SDL_HapticCustom SDL_HapticCustom
A structure containing a template for the SDL_HAPTIC_CUSTOM effect.
SDL_HapticDirection direction
Definition: SDL_haptic.h:632
A structure containing a template for a Ramp effect.
Definition: SDL_haptic.h:628
Uint16 attack_length
Definition: SDL_haptic.h:647
DECLSPEC int SDLCALL SDL_HapticIndex(SDL_Haptic *haptic)
Gets the index of a haptic device.
Definition: SDL_haptic.c:203
Uint16 fade_length
Definition: SDL_haptic.h:649
DECLSPEC int SDLCALL SDL_HapticRumbleSupported(SDL_Haptic *haptic)
Checks to see if rumble is supported on a haptic device.
Definition: SDL_haptic.c:728
struct SDL_HapticLeftRight SDL_HapticLeftRight
A structure containing a template for a Left/Right effect.
struct SDL_HapticCondition SDL_HapticCondition
A structure containing a template for a Condition effect.
struct SDL_HapticPeriodic SDL_HapticPeriodic
A structure containing a template for a Periodic effect.
SDL_HapticDirection direction
Definition: SDL_haptic.h:544
SDL_HapticLeftRight leftright
Definition: SDL_haptic.h:795
Uint16 attack_level
Definition: SDL_haptic.h:713
uint8_t Uint8
An unsigned 8-bit integer type.
Definition: SDL_stdinc.h:129
int16_t Sint16
A signed 16-bit integer type.
Definition: SDL_stdinc.h:133
DECLSPEC void SDLCALL SDL_HapticDestroyEffect(SDL_Haptic *haptic, int effect)
Destroys a haptic effect on the device.
Definition: SDL_haptic.c:576
A structure containing a template for the SDL_HAPTIC_CUSTOM effect.
Definition: SDL_haptic.h:691
DECLSPEC int SDLCALL SDL_HapticRunEffect(SDL_Haptic *haptic, int effect, Uint32 iterations)
Runs the haptic effect on its associated haptic device.
Definition: SDL_haptic.c:539
uint16_t Uint16
An unsigned 16-bit integer type.
Definition: SDL_stdinc.h:137
DECLSPEC int SDLCALL SDL_HapticRumbleStop(SDL_Haptic *haptic)
Stops the simple rumble on a haptic device.
Definition: SDL_haptic.c:826
DECLSPEC int SDLCALL SDL_HapticSetGain(SDL_Haptic *haptic, int gain)
Sets the global gain of the device.
Definition: SDL_haptic.c:611
DECLSPEC const char *SDLCALL SDL_HapticName(int device_index)
Get the implementation dependent name of a Haptic device.
Definition: SDL_haptic.c:101
DECLSPEC int SDLCALL SDL_HapticRumbleInit(SDL_Haptic *haptic)
Initializes the haptic device for simple rumble playback.
Definition: SDL_haptic.c:742
SDL_HapticPeriodic periodic
Definition: SDL_haptic.h:792
Uint16 attack_level
Definition: SDL_haptic.h:648
Uint16 attack_length
Definition: SDL_haptic.h:712
DECLSPEC int SDLCALL SDL_NumHaptics(void)
Count the number of haptic devices attached to the system.
Definition: SDL_haptic.c:91
DECLSPEC int SDLCALL SDL_HapticGetEffectStatus(SDL_Haptic *haptic, int effect)
Gets the status of the current effect on the haptic device.
Definition: SDL_haptic.c:594
DECLSPEC SDL_Haptic *SDLCALL SDL_HapticOpenFromMouse(void)
Tries to open a haptic device from the current mouse.
Definition: SDL_haptic.c:229
SDL_HapticDirection direction
Definition: SDL_haptic.h:461
SDL_HapticDirection direction
Definition: SDL_haptic.h:695
Uint16 left_sat[3]
Definition: SDL_haptic.h:608
DECLSPEC int SDLCALL SDL_HapticPause(SDL_Haptic *haptic)
Pauses a haptic device.
Definition: SDL_haptic.c:681