Go to the documentation of this file.
21 #include "../SDL_internal.h"
25 #include "../joystick/SDL_joystick_c.h"
55 SDL_Haptic *hapticlist;
62 if (hapticlist ==
haptic) {
66 hapticlist = hapticlist->next;
72 SDL_SetError(
"Haptic: Invalid haptic device identifier");
96 SDL_SetError(
"Haptic: There are %d haptic devices available",
111 SDL_Haptic *hapticlist;
114 SDL_SetError(
"Haptic: There are %d haptic devices available",
125 if (device_index == hapticlist->index) {
130 hapticlist = hapticlist->next;
143 haptic->index = device_index;
172 SDL_Haptic *hapticlist;
176 SDL_SetError(
"Haptic: There are %d haptic devices available",
186 if (hapticlist->index == (
Uint8) device_index) {
190 hapticlist = hapticlist->next;
232 if (device_index < 0) {
272 SDL_Haptic *hapticlist;
276 SDL_SetError(
"Haptic: There are %d haptic devices available",
289 SDL_SetError(
"Haptic: Joystick isn't a haptic device.");
302 hapticlist = hapticlist->next;
316 SDL_SetError(
"Haptic: SDL_SYS_HapticOpenFromJoystick failed.");
338 SDL_Haptic *hapticlist;
339 SDL_Haptic *hapticlistprev;
347 if (--
haptic->ref_count > 0) {
361 hapticlistprev =
NULL;
366 if ( hapticlistprev )
369 hapticlistprev->next = hapticlist->next;
378 hapticlistprev = hapticlist;
379 hapticlist = hapticlist->next;
484 return SDL_SetError(
"Haptic: Effect not supported by haptic device.");
503 return SDL_SetError(
"Haptic: Device has no free space left.");
512 if ((effect < 0) || (effect >=
haptic->neffects)) {
531 if (
data->type !=
haptic->effects[effect].effect.type) {
532 return SDL_SetError(
"Haptic: Updating effect type is illegal.");
595 if (
haptic->effects[effect].hweffect ==
NULL) {
613 return SDL_SetError(
"Haptic: Device does not support status queries.");
626 int real_gain, max_gain;
633 return SDL_SetError(
"Haptic: Device does not support setting gain.");
636 if ((gain < 0) || (gain > 100)) {
637 return SDL_SetError(
"Haptic: Gain must be between 0 and 100.");
648 else if (max_gain > 100)
652 real_gain = (gain * max_gain) / 100;
675 return SDL_SetError(
"Haptic: Device does not support setting autocenter.");
678 if ((autocenter < 0) || (autocenter > 100)) {
679 return SDL_SetError(
"Haptic: Autocenter must be between 0 and 100.");
700 return SDL_SetError(
"Haptic: Device does not support setting pausing.");
763 if (
haptic->rumble_id >= 0) {
786 if (
haptic->rumble_id >= 0) {
805 if (
haptic->rumble_id < 0) {
806 return SDL_SetError(
"Haptic: Rumble effect not initialized on haptic device");
810 if (strength > 1.0
f) {
812 }
else if (strength < 0.0
f) {
815 magnitude = (
Sint16)(32767.0
f*strength);
817 efx = &
haptic->rumble_effect;
825 SDL_assert(0 &&
"This should have been caught elsewhere");
845 if (
haptic->rumble_id < 0) {
846 return SDL_SetError(
"Haptic: Rumble effect not initialized on haptic device");
#define SDL_HAPTIC_LEFTRIGHT
Left/Right effect supported.
int SDL_HapticNumEffectsPlaying(SDL_Haptic *haptic)
Returns the number of effects a haptic device can play at the same time.
SDL_Haptic * SDL_HapticOpen(int device_index)
Opens a haptic device for use.
#define SDL_HAPTIC_CARTESIAN
Uses cartesian coordinates for the direction.
int SDL_SYS_HapticPause(SDL_Haptic *haptic)
int SDL_HapticNumEffects(SDL_Haptic *haptic)
Returns the number of effects a haptic device can store.
int SDL_HapticIndex(SDL_Haptic *haptic)
Gets the index of a haptic device.
int SDL_HapticEffectSupported(SDL_Haptic *haptic, SDL_HapticEffect *effect)
Checks to see if effect is supported by haptic.
unsigned int SDL_HapticQuery(SDL_Haptic *haptic)
Gets the haptic device's supported features in bitwise manner.
void SDL_HapticQuit(void)
const char * SDL_HapticName(int device_index)
Get the implementation dependent name of a haptic device.
const char * SDL_SYS_HapticName(int index)
int SDL_SYS_HapticUnpause(SDL_Haptic *haptic)
#define SDL_HAPTIC_STATUS
Device can be queried for effect status.
int SDL_HapticUnpause(SDL_Haptic *haptic)
Unpauses a haptic device.
int SDL_SYS_HapticInit(void)
int SDL_HapticRunEffect(SDL_Haptic *haptic, int effect, Uint32 iterations)
Runs the haptic effect on its associated haptic device.
void SDL_HapticDestroyEffect(SDL_Haptic *haptic, int effect)
Destroys a haptic effect on the device.
static int ValidHaptic(SDL_Haptic *haptic)
int SDL_HapticStopAll(SDL_Haptic *haptic)
Stops all the currently playing effects on a haptic device.
int SDL_SYS_HapticUpdateEffect(SDL_Haptic *haptic, struct haptic_effect *effect, SDL_HapticEffect *data)
SDL_HapticLeftRight leftright
int SDL_MouseIsHaptic(void)
Gets whether or not the current mouse has haptic capabilities.
static int ValidEffect(SDL_Haptic *haptic, int effect)
int SDL_HapticRumbleSupported(SDL_Haptic *haptic)
Checks to see if rumble is supported on a haptic device.
#define SDL_HAPTIC_AUTOCENTER
Device can set autocenter.
GLuint GLsizei GLsizei * length
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
void SDL_SYS_HapticDestroyEffect(SDL_Haptic *haptic, struct haptic_effect *effect)
int SDL_SYS_HapticRunEffect(SDL_Haptic *haptic, struct haptic_effect *effect, Uint32 iterations)
int SDL_HapticSetAutocenter(SDL_Haptic *haptic, int autocenter)
Sets the global autocenter of the device.
void SDL_HapticClose(SDL_Haptic *haptic)
Closes a haptic device previously opened with SDL_HapticOpen().
void SDL_SYS_HapticQuit(void)
int SDL_HapticRumblePlay(SDL_Haptic *haptic, float strength, Uint32 length)
Runs simple rumble on a haptic device.
int SDL_SYS_HapticSetGain(SDL_Haptic *haptic, int gain)
int SDL_SYS_HapticGetEffectStatus(SDL_Haptic *haptic, struct haptic_effect *effect)
SDL_HapticPeriodic periodic
int SDL_PrivateJoystickValid(SDL_Joystick *joystick)
int SDL_JoystickIsHaptic(SDL_Joystick *joystick)
Checks to see if a joystick has haptic features.
The generic template for any haptic effect.
#define SDL_HAPTIC_SINE
Sine wave effect supported.
int SDL_SYS_HapticStopEffect(SDL_Haptic *haptic, struct haptic_effect *effect)
int SDL_HapticOpened(int device_index)
Checks if the haptic device at index has been opened.
int SDL_HapticNewEffect(SDL_Haptic *haptic, SDL_HapticEffect *effect)
Creates a new haptic effect on the device.
SDL_Haptic * SDL_HapticOpenFromMouse(void)
Tries to open a haptic device from the current mouse.
int SDL_SYS_HapticStopAll(SDL_Haptic *haptic)
int SDL_NumHaptics(void)
Count the number of haptic devices attached to the system.
void SDL_SYS_HapticClose(SDL_Haptic *haptic)
#define SDL_assert(condition)
int SDL_HapticStopEffect(SDL_Haptic *haptic, int effect)
Stops the haptic effect on its associated haptic device.
#define SDL_OutOfMemory()
int SDL_HapticGetEffectStatus(SDL_Haptic *haptic, int effect)
Gets the status of the current effect on the haptic device.
#define SDL_HAPTIC_GAIN
Device can set global gain.
int SDL_SYS_HapticOpen(SDL_Haptic *haptic)
int SDL_SYS_HapticMouse(void)
int SDL_SYS_HapticNewEffect(SDL_Haptic *haptic, struct haptic_effect *effect, SDL_HapticEffect *base)
static SDL_Haptic * haptic
int SDL_HapticRumbleStop(SDL_Haptic *haptic)
Stops the simple rumble on a haptic device.
int SDL_HapticSetGain(SDL_Haptic *haptic, int gain)
Sets the global gain of the device.
int SDL_HapticRumbleInit(SDL_Haptic *haptic)
Initializes the haptic device for simple rumble playback.
int SDL_HapticUpdateEffect(SDL_Haptic *haptic, int effect, SDL_HapticEffect *data)
Updates the properties of an effect.
int SDL_SYS_HapticSetAutocenter(SDL_Haptic *haptic, int autocenter)
SDL_Haptic * SDL_HapticOpenFromJoystick(SDL_Joystick *joystick)
Opens a haptic device for use from a joystick device.
int SDL_SYS_NumHaptics(void)
int SDL_SYS_JoystickIsHaptic(SDL_Joystick *joystick)
int SDL_SYS_JoystickSameHaptic(SDL_Haptic *haptic, SDL_Joystick *joystick)
int SDL_SYS_HapticOpenFromJoystick(SDL_Haptic *haptic, SDL_Joystick *joystick)
SDL_HapticDirection direction
int SDL_HapticNumAxes(SDL_Haptic *haptic)
Gets the number of haptic axes the device has.
#define SDL_HAPTIC_PAUSE
Device can be paused.
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
int SDL_HapticPause(SDL_Haptic *haptic)
Pauses a haptic device.