zenilib  0.5.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
SDL_syshaptic.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 
22 #include "SDL_config.h"
23 
24 #include "SDL_haptic.h"
25 
26 
27 /*
28  * Number of haptic devices on the system.
29  */
30 extern Uint8 SDL_numhaptics;
31 
32 
34 {
35  SDL_HapticEffect effect; /* The current event */
36  struct haptic_hweffect *hweffect; /* The hardware behind the event */
37 };
38 
39 /*
40  * The real SDL_Haptic struct.
41  */
43 {
44  Uint8 index; /* Stores index it is attached to */
45 
46  struct haptic_effect *effects; /* Allocated effects */
47  int neffects; /* Maximum amount of effects */
48  int nplaying; /* Maximum amount of effects to play at the same time */
49  unsigned int supported; /* Supported effects */
50  int naxes; /* Number of axes on the device. */
51 
52  struct haptic_hwdata *hwdata; /* Driver dependent */
53  int ref_count; /* Count for multiple opens */
54 
55  int rumble_id; /* ID of rumble effect for simple rumble API. */
56  SDL_HapticEffect rumble_effect; /* Rumble effect. */
57 };
58 
59 /*
60  * Scans the system for haptic devices.
61  *
62  * Returns number of devices on success, -1 on error.
63  */
64 extern int SDL_SYS_HapticInit(void);
65 
66 /*
67  * Gets the device dependent name of the haptic device
68  */
69 extern const char *SDL_SYS_HapticName(int index);
70 
71 /*
72  * Opens the haptic device for usage. The haptic device should have
73  * the index value set previously.
74  *
75  * Returns 0 on success, -1 on error.
76  */
77 extern int SDL_SYS_HapticOpen(SDL_Haptic * haptic);
78 
79 /*
80  * Returns the index of the haptic core pointer or -1 if none is found.
81  */
82 int SDL_SYS_HapticMouse(void);
83 
84 /*
85  * Checks to see if the joystick has haptic capabilities.
86  *
87  * Returns >0 if haptic capabilities are detected, 0 if haptic
88  * capabilities aren't detected and -1 on error.
89  */
90 extern int SDL_SYS_JoystickIsHaptic(SDL_Joystick * joystick);
91 
92 /*
93  * Opens the haptic device for usage using the same device as
94  * the joystick.
95  *
96  * Returns 0 on success, -1 on error.
97  */
98 extern int SDL_SYS_HapticOpenFromJoystick(SDL_Haptic * haptic,
99  SDL_Joystick * joystick);
100 /*
101  * Checks to see if haptic device and joystick device are the same.
102  *
103  * Returns 1 if they are the same, 0 if they aren't.
104  */
105 extern int SDL_SYS_JoystickSameHaptic(SDL_Haptic * haptic,
106  SDL_Joystick * joystick);
107 
108 /*
109  * Closes a haptic device after usage.
110  */
111 extern void SDL_SYS_HapticClose(SDL_Haptic * haptic);
112 
113 /*
114  * Performs a cleanup on the haptic subsystem.
115  */
116 extern void SDL_SYS_HapticQuit(void);
117 
118 /*
119  * Creates a new haptic effect on the haptic device using base
120  * as a template for the effect.
121  *
122  * Returns 0 on success, -1 on error.
123  */
124 extern int SDL_SYS_HapticNewEffect(SDL_Haptic * haptic,
125  struct haptic_effect *effect,
126  SDL_HapticEffect * base);
127 
128 /*
129  * Updates the haptic effect on the haptic device using data
130  * as a template.
131  *
132  * Returns 0 on success, -1 on error.
133  */
134 extern int SDL_SYS_HapticUpdateEffect(SDL_Haptic * haptic,
135  struct haptic_effect *effect,
137 
138 /*
139  * Runs the effect on the haptic device.
140  *
141  * Returns 0 on success, -1 on error.
142  */
143 extern int SDL_SYS_HapticRunEffect(SDL_Haptic * haptic,
144  struct haptic_effect *effect,
145  Uint32 iterations);
146 
147 /*
148  * Stops the effect on the haptic device.
149  *
150  * Returns 0 on success, -1 on error.
151  */
152 extern int SDL_SYS_HapticStopEffect(SDL_Haptic * haptic,
153  struct haptic_effect *effect);
154 
155 /*
156  * Cleanups up the effect on the haptic device.
157  */
158 extern void SDL_SYS_HapticDestroyEffect(SDL_Haptic * haptic,
159  struct haptic_effect *effect);
160 
161 /*
162  * Queries the device for the status of effect.
163  *
164  * Returns 0 if device is stopped, >0 if device is playing and
165  * -1 on error.
166  */
167 extern int SDL_SYS_HapticGetEffectStatus(SDL_Haptic * haptic,
168  struct haptic_effect *effect);
169 
170 /*
171  * Sets the global gain of the haptic device.
172  *
173  * Returns 0 on success, -1 on error.
174  */
175 extern int SDL_SYS_HapticSetGain(SDL_Haptic * haptic, int gain);
176 
177 /*
178  * Sets the autocenter feature of the haptic device.
179  *
180  * Returns 0 on success, -1 on error.
181  */
182 extern int SDL_SYS_HapticSetAutocenter(SDL_Haptic * haptic, int autocenter);
183 
184 /*
185  * Pauses the haptic device.
186  *
187  * Returns 0 on success, -1 on error.
188  */
189 extern int SDL_SYS_HapticPause(SDL_Haptic * haptic);
190 
191 /*
192  * Unpauses the haptic device.
193  *
194  * Returns 0 on success, -1 on error.
195  */
196 extern int SDL_SYS_HapticUnpause(SDL_Haptic * haptic);
197 
198 /*
199  * Stops all the currently playing haptic effects on the device.
200  *
201  * Returns 0 on success, -1 on error.
202  */
203 extern int SDL_SYS_HapticStopAll(SDL_Haptic * haptic);
int SDL_SYS_HapticOpenFromJoystick(SDL_Haptic *haptic, SDL_Joystick *joystick)
struct haptic_hwdata * hwdata
Definition: SDL_syshaptic.h:52
struct haptic_effect * effects
Definition: SDL_syshaptic.h:46
int SDL_SYS_HapticOpen(SDL_Haptic *haptic)
int SDL_SYS_HapticMouse(void)
int SDL_SYS_JoystickSameHaptic(SDL_Haptic *haptic, SDL_Joystick *joystick)
int SDL_SYS_HapticStopEffect(SDL_Haptic *haptic, struct haptic_effect *effect)
const char * SDL_SYS_HapticName(int index)
The SDL Haptic subsystem allows you to control haptic (force feedback) devices.
int SDL_SYS_HapticUnpause(SDL_Haptic *haptic)
int SDL_SYS_HapticGetEffectStatus(SDL_Haptic *haptic, struct haptic_effect *effect)
Uint8 SDL_numhaptics
Definition: SDL_haptic.c:28
uint32_t Uint32
An unsigned 32-bit integer type.
Definition: SDL_stdinc.h:145
unsigned int supported
Definition: SDL_syshaptic.h:49
The generic template for any haptic effect.
Definition: SDL_haptic.h:787
int SDL_SYS_HapticSetAutocenter(SDL_Haptic *haptic, int autocenter)
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl2ext.h:848
GLuint index
Definition: glew.h:1800
int SDL_SYS_HapticUpdateEffect(SDL_Haptic *haptic, struct haptic_effect *effect, SDL_HapticEffect *data)
int SDL_SYS_JoystickIsHaptic(SDL_Joystick *joystick)
void SDL_SYS_HapticDestroyEffect(SDL_Haptic *haptic, struct haptic_effect *effect)
SDL_HapticEffect effect
Definition: SDL_syshaptic.h:35
int SDL_SYS_HapticInit(void)
void SDL_SYS_HapticQuit(void)
struct haptic_hweffect * hweffect
Definition: SDL_syshaptic.h:36
void SDL_SYS_HapticClose(SDL_Haptic *haptic)
int SDL_SYS_HapticPause(SDL_Haptic *haptic)
uint8_t Uint8
An unsigned 8-bit integer type.
Definition: SDL_stdinc.h:129
int SDL_SYS_HapticStopAll(SDL_Haptic *haptic)
int SDL_SYS_HapticSetGain(SDL_Haptic *haptic, int gain)
int SDL_SYS_HapticRunEffect(SDL_Haptic *haptic, struct haptic_effect *effect, Uint32 iterations)
SDL_HapticEffect rumble_effect
Definition: SDL_syshaptic.h:56
int SDL_SYS_HapticNewEffect(SDL_Haptic *haptic, struct haptic_effect *effect, SDL_HapticEffect *base)