25 #include "../joystick/SDL_joystick_c.h"
44 arraylen = (status + 1) *
sizeof(*SDL_haptics);
46 if (SDL_haptics ==
NULL) {
71 if (SDL_haptics[i] == haptic) {
80 SDL_SetError(
"Haptic: Invalid haptic device identifier");
104 SDL_SetError(
"Haptic: There are %d haptic devices available",
122 SDL_SetError(
"Haptic: There are %d haptic devices available",
128 for (i = 0; SDL_haptics[
i]; i++) {
129 if (device_index == SDL_haptics[i]->
index) {
130 haptic = SDL_haptics[
i];
138 if (haptic ==
NULL) {
146 haptic->
index = device_index;
153 for (i = 0; SDL_haptics[
i]; i++)
157 SDL_SetError(
"Haptic: Trying to add device past the number originally detected");
160 SDL_haptics[
i] = haptic;
183 SDL_SetError(
"Haptic: There are %d haptic devices available",
189 for (i = 0; SDL_haptics[
i]; i++) {
190 if (SDL_haptics[i]->
index == (
Uint8) device_index) {
209 return haptic->
index;
235 if (device_index < 0) {
279 SDL_SetError(
"Haptic: There are %d haptic devices available",
292 SDL_SetError(
"Haptic: Joystick isn't a haptic device.");
297 for (i = 0; SDL_haptics[
i]; i++) {
299 haptic = SDL_haptics[
i];
307 if (haptic ==
NULL) {
321 for (i = 0; SDL_haptics[
i]; i++)
325 SDL_SetError(
"Haptic: Trying to add device past the number originally detected");
328 SDL_haptics[
i] = haptic;
354 for (i = 0; i < haptic->
neffects; i++) {
362 for (i = 0; SDL_haptics[
i]; ++
i) {
363 if (haptic == SDL_haptics[i]) {
364 SDL_haptics[
i] =
NULL;
365 SDL_memcpy(&SDL_haptics[i], &SDL_haptics[i + 1],
439 return haptic->
naxes;
472 return SDL_SetError(
"Haptic: Effect not supported by haptic device.");
476 for (i = 0; i < haptic->
neffects; i++) {
491 return SDL_SetError(
"Haptic: Device has no free space left.");
500 if ((effect < 0) || (effect >= haptic->
neffects)) {
520 return SDL_SetError(
"Haptic: Updating effect type is illegal.");
601 return SDL_SetError(
"Haptic: Device does not support status queries.");
614 int real_gain, max_gain;
621 return SDL_SetError(
"Haptic: Device does not support setting gain.");
624 if ((gain < 0) || (gain > 100)) {
625 return SDL_SetError(
"Haptic: Gain must be between 0 and 100.");
636 else if (max_gain > 100)
640 real_gain = (gain * max_gain) / 100;
663 return SDL_SetError(
"Haptic: Device does not support setting autocenter.");
666 if ((autocenter < 0) || (autocenter > 100)) {
667 return SDL_SetError(
"Haptic: Autocenter must be between 0 and 100.");
688 return SDL_SetError(
"Haptic: Device does not support setting pausing.");
793 return SDL_SetError(
"Haptic: Rumble effect not initialized on haptic device");
797 if (strength > 1.0
f) {
799 }
else if (strength < 0.0
f) {
802 magnitude = (
Sint16)(32767.0
f*strength);
812 SDL_assert(0 &&
"This should have been caught elsewhere");
833 return SDL_SetError(
"Haptic: Rumble effect not initialized on haptic device");
int SDL_SYS_HapticOpenFromJoystick(SDL_Haptic *haptic, SDL_Joystick *joystick)
DECLSPEC int SDLCALL SDL_HapticStopAll(SDL_Haptic *haptic)
Stops all the currently playing effects on a haptic device.
int SDL_PrivateJoystickValid(SDL_Joystick *joystick)
struct haptic_effect * effects
void SDL_HapticQuit(void)
#define SDL_HAPTIC_AUTOCENTER
Device can set autocenter.
DECLSPEC int SDLCALL SDL_HapticRumblePlay(SDL_Haptic *haptic, float strength, Uint32 length)
Runs simple rumble on a haptic device.
DECLSPEC int SDLCALL SDL_HapticUpdateEffect(SDL_Haptic *haptic, int effect, SDL_HapticEffect *data)
Updates the properties of an effect.
#define SDL_HAPTIC_GAIN
Device can set global gain.
int SDL_SYS_HapticOpen(SDL_Haptic *haptic)
int SDL_SYS_HapticMouse(void)
int SDL_SYS_JoystickSameHaptic(SDL_Haptic *haptic, SDL_Joystick *joystick)
DECLSPEC SDL_Haptic *SDLCALL SDL_HapticOpenFromJoystick(SDL_Joystick *joystick)
Opens a Haptic device for usage from a Joystick device.
DECLSPEC int SDLCALL SDL_HapticNumEffects(SDL_Haptic *haptic)
Returns the number of effects a haptic device can store.
DECLSPEC void SDLCALL SDL_free(void *mem)
DECLSPEC int SDLCALL SDL_HapticStopEffect(SDL_Haptic *haptic, int effect)
Stops the haptic effect on its associated haptic device.
DECLSPEC void SDLCALL SDL_HapticClose(SDL_Haptic *haptic)
Closes a Haptic device previously opened with SDL_HapticOpen().
DECLSPEC int SDLCALL SDL_HapticSetAutocenter(SDL_Haptic *haptic, int autocenter)
Sets the global autocenter of the device.
int SDL_SYS_HapticStopEffect(SDL_Haptic *haptic, struct haptic_effect *effect)
const char * SDL_SYS_HapticName(int index)
DECLSPEC int SDLCALL SDL_HapticUnpause(SDL_Haptic *haptic)
Unpauses a haptic device.
int SDL_SYS_HapticUnpause(SDL_Haptic *haptic)
#define SDL_HAPTIC_SINE
Sine wave effect supported.
DECLSPEC unsigned int SDLCALL SDL_HapticQuery(SDL_Haptic *haptic)
Gets the haptic devices supported features in bitwise matter.
int SDL_SYS_HapticGetEffectStatus(SDL_Haptic *haptic, struct haptic_effect *effect)
DECLSPEC int SDLCALL SDL_MouseIsHaptic(void)
Gets whether or not the current mouse has haptic capabilities.
uint32_t Uint32
An unsigned 32-bit integer type.
DECLSPEC int SDLCALL SDL_JoystickIsHaptic(SDL_Joystick *joystick)
Checks to see if a joystick has haptic features.
DECLSPEC int SDLCALL SDL_HapticEffectSupported(SDL_Haptic *haptic, SDL_HapticEffect *effect)
Checks to see if effect is supported by haptic.
DECLSPEC int SDLCALL SDL_HapticNumAxes(SDL_Haptic *haptic)
Gets the number of haptic axes the device has.
DECLSPEC int SDLCALL SDL_HapticNumEffectsPlaying(SDL_Haptic *haptic)
Returns the number of effects a haptic device can play at the same time.
The generic template for any haptic effect.
int SDL_SYS_HapticSetAutocenter(SDL_Haptic *haptic, int autocenter)
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
DECLSPEC int SDLCALL SDL_HapticOpened(int device_index)
Checks if the haptic device at index has been opened.
DECLSPEC int SDLCALL SDL_HapticNewEffect(SDL_Haptic *haptic, SDL_HapticEffect *effect)
Creates a new haptic effect on the device.
DECLSPEC void *SDLCALL SDL_memset(void *dst, int c, size_t len)
static int ValidHaptic(SDL_Haptic *haptic)
DECLSPEC int SDLCALL SDL_SetError(const char *fmt,...)
#define SDL_HAPTIC_PAUSE
Device can be paused.
DECLSPEC void *SDLCALL SDL_malloc(size_t size)
int SDL_SYS_HapticUpdateEffect(SDL_Haptic *haptic, struct haptic_effect *effect, SDL_HapticEffect *data)
DECLSPEC SDL_Haptic *SDLCALL SDL_HapticOpen(int device_index)
Opens a Haptic device for usage.
int SDL_SYS_JoystickIsHaptic(SDL_Joystick *joystick)
void SDL_SYS_HapticDestroyEffect(SDL_Haptic *haptic, struct haptic_effect *effect)
#define SDL_assert(condition)
DECLSPEC int SDLCALL SDL_HapticIndex(SDL_Haptic *haptic)
Gets the index of a haptic device.
#define SDL_OutOfMemory()
DECLSPEC int SDLCALL SDL_HapticRumbleSupported(SDL_Haptic *haptic)
Checks to see if rumble is supported on a haptic device.
int SDL_SYS_HapticInit(void)
void SDL_SYS_HapticQuit(void)
struct haptic_hweffect * hweffect
#define SDL_HAPTIC_STATUS
Device can be queried for effect status.
void SDL_SYS_HapticClose(SDL_Haptic *haptic)
int SDL_SYS_HapticPause(SDL_Haptic *haptic)
DECLSPEC void *SDLCALL SDL_memcpy(void *dst, const void *src, size_t len)
SDL_HapticLeftRight leftright
SDL_Haptic ** SDL_haptics
uint8_t Uint8
An unsigned 8-bit integer type.
DECLSPEC int SDLCALL SDL_atoi(const char *str)
int16_t Sint16
A signed 16-bit integer type.
DECLSPEC void SDLCALL SDL_HapticDestroyEffect(SDL_Haptic *haptic, int effect)
Destroys a haptic effect on the device.
static int ValidEffect(SDL_Haptic *haptic, int effect)
DECLSPEC int SDLCALL SDL_HapticRunEffect(SDL_Haptic *haptic, int effect, Uint32 iterations)
Runs the haptic effect on its associated haptic device.
int SDL_SYS_HapticStopAll(SDL_Haptic *haptic)
DECLSPEC int SDLCALL SDL_HapticRumbleStop(SDL_Haptic *haptic)
Stops the simple rumble on a haptic device.
DECLSPEC char *SDLCALL SDL_getenv(const char *name)
DECLSPEC int SDLCALL SDL_HapticSetGain(SDL_Haptic *haptic, int gain)
Sets the global gain of the device.
int SDL_SYS_HapticSetGain(SDL_Haptic *haptic, int gain)
DECLSPEC const char *SDLCALL SDL_HapticName(int device_index)
Get the implementation dependent name of a Haptic device.
DECLSPEC int SDLCALL SDL_HapticRumbleInit(SDL_Haptic *haptic)
Initializes the haptic device for simple rumble playback.
#define SDL_HAPTIC_LEFTRIGHT
Left/Right effect supported.
int SDL_SYS_HapticRunEffect(SDL_Haptic *haptic, struct haptic_effect *effect, Uint32 iterations)
SDL_HapticPeriodic periodic
DECLSPEC int SDLCALL SDL_NumHaptics(void)
Count the number of haptic devices attached to the system.
DECLSPEC int SDLCALL SDL_HapticGetEffectStatus(SDL_Haptic *haptic, int effect)
Gets the status of the current effect on the haptic device.
DECLSPEC SDL_Haptic *SDLCALL SDL_HapticOpenFromMouse(void)
Tries to open a haptic device from the current mouse.
SDL_HapticEffect rumble_effect
int SDL_SYS_HapticNewEffect(SDL_Haptic *haptic, struct haptic_effect *effect, SDL_HapticEffect *base)
DECLSPEC int SDLCALL SDL_HapticPause(SDL_Haptic *haptic)
Pauses a haptic device.