mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-09-27 14:24:13 +08:00
Update for SDL3 coding style (#6717)
I updated .clang-format and ran clang-format 14 over the src and test directories to standardize the code base. In general I let clang-format have it's way, and added markup to prevent formatting of code that would break or be completely unreadable if formatted. The script I ran for the src directory is added as build-scripts/clang-format-src.sh This fixes: #6592 #6593 #6594
This commit is contained in:
+50
-96
@@ -27,15 +27,14 @@
|
||||
/* Global for SDL_windowshaptic.c */
|
||||
#if (defined(SDL_HAPTIC_DINPUT) && SDL_HAPTIC_DINPUT) || (defined(SDL_HAPTIC_XINPUT) && SDL_HAPTIC_XINPUT)
|
||||
SDL_Haptic *SDL_haptics = NULL;
|
||||
#else
|
||||
#else
|
||||
static SDL_Haptic *SDL_haptics = NULL;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Initializes the Haptic devices.
|
||||
*/
|
||||
int
|
||||
SDL_HapticInit(void)
|
||||
int SDL_HapticInit(void)
|
||||
{
|
||||
int status;
|
||||
|
||||
@@ -47,12 +46,10 @@ SDL_HapticInit(void)
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Checks to see if the haptic device is valid
|
||||
*/
|
||||
static int
|
||||
ValidHaptic(SDL_Haptic * haptic)
|
||||
static int ValidHaptic(SDL_Haptic *haptic)
|
||||
{
|
||||
int valid;
|
||||
SDL_Haptic *hapticlist;
|
||||
@@ -60,7 +57,7 @@ ValidHaptic(SDL_Haptic * haptic)
|
||||
valid = 0;
|
||||
if (haptic != NULL) {
|
||||
hapticlist = SDL_haptics;
|
||||
while ( hapticlist ) {
|
||||
while (hapticlist) {
|
||||
if (hapticlist == haptic) {
|
||||
valid = 1;
|
||||
break;
|
||||
@@ -77,17 +74,14 @@ ValidHaptic(SDL_Haptic * haptic)
|
||||
return valid;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Returns the number of available devices.
|
||||
*/
|
||||
int
|
||||
SDL_NumHaptics(void)
|
||||
int SDL_NumHaptics(void)
|
||||
{
|
||||
return SDL_SYS_NumHaptics();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Gets the name of a Haptic device by index.
|
||||
*/
|
||||
@@ -102,7 +96,6 @@ SDL_HapticName(int device_index)
|
||||
return SDL_SYS_HapticName(device_index);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Opens a Haptic device.
|
||||
*/
|
||||
@@ -120,9 +113,9 @@ SDL_HapticOpen(int device_index)
|
||||
|
||||
hapticlist = SDL_haptics;
|
||||
/* If the haptic is already open, return it
|
||||
* TODO: Should we create haptic instance IDs like the Joystick API?
|
||||
*/
|
||||
while ( hapticlist ) {
|
||||
* TODO: Should we create haptic instance IDs like the Joystick API?
|
||||
*/
|
||||
while (hapticlist) {
|
||||
if (device_index == hapticlist->index) {
|
||||
haptic = hapticlist;
|
||||
++haptic->ref_count;
|
||||
@@ -132,7 +125,7 @@ SDL_HapticOpen(int device_index)
|
||||
}
|
||||
|
||||
/* Create the haptic device */
|
||||
haptic = (SDL_Haptic *) SDL_malloc((sizeof *haptic));
|
||||
haptic = (SDL_Haptic *)SDL_malloc((sizeof *haptic));
|
||||
if (haptic == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
@@ -164,12 +157,10 @@ SDL_HapticOpen(int device_index)
|
||||
return haptic;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Returns 1 if the device has been opened.
|
||||
*/
|
||||
int
|
||||
SDL_HapticOpened(int device_index)
|
||||
int SDL_HapticOpened(int device_index)
|
||||
{
|
||||
int opened;
|
||||
SDL_Haptic *hapticlist;
|
||||
@@ -184,8 +175,8 @@ SDL_HapticOpened(int device_index)
|
||||
opened = 0;
|
||||
hapticlist = SDL_haptics;
|
||||
/* TODO Should this use an instance ID? */
|
||||
while ( hapticlist ) {
|
||||
if (hapticlist->index == (Uint8) device_index) {
|
||||
while (hapticlist) {
|
||||
if (hapticlist->index == (Uint8)device_index) {
|
||||
opened = 1;
|
||||
break;
|
||||
}
|
||||
@@ -194,12 +185,10 @@ SDL_HapticOpened(int device_index)
|
||||
return opened;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Returns the index to a haptic device.
|
||||
*/
|
||||
int
|
||||
SDL_HapticIndex(SDL_Haptic * haptic)
|
||||
int SDL_HapticIndex(SDL_Haptic *haptic)
|
||||
{
|
||||
if (!ValidHaptic(haptic)) {
|
||||
return -1;
|
||||
@@ -208,12 +197,10 @@ SDL_HapticIndex(SDL_Haptic * haptic)
|
||||
return haptic->index;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Returns SDL_TRUE if mouse is haptic, SDL_FALSE if it isn't.
|
||||
*/
|
||||
int
|
||||
SDL_MouseIsHaptic(void)
|
||||
int SDL_MouseIsHaptic(void)
|
||||
{
|
||||
if (SDL_SYS_HapticMouse() < 0) {
|
||||
return SDL_FALSE;
|
||||
@@ -221,7 +208,6 @@ SDL_MouseIsHaptic(void)
|
||||
return SDL_TRUE;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Returns the haptic device if mouse is haptic or NULL elsewise.
|
||||
*/
|
||||
@@ -240,12 +226,10 @@ SDL_HapticOpenFromMouse(void)
|
||||
return SDL_HapticOpen(device_index);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Returns SDL_TRUE if joystick has haptic features.
|
||||
*/
|
||||
int
|
||||
SDL_JoystickIsHaptic(SDL_Joystick * joystick)
|
||||
int SDL_JoystickIsHaptic(SDL_Joystick *joystick)
|
||||
{
|
||||
int ret;
|
||||
|
||||
@@ -264,12 +248,11 @@ SDL_JoystickIsHaptic(SDL_Joystick * joystick)
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Opens a haptic device from a joystick.
|
||||
*/
|
||||
SDL_Haptic *
|
||||
SDL_HapticOpenFromJoystick(SDL_Joystick * joystick)
|
||||
SDL_HapticOpenFromJoystick(SDL_Joystick *joystick)
|
||||
{
|
||||
SDL_Haptic *haptic;
|
||||
SDL_Haptic *hapticlist;
|
||||
@@ -295,7 +278,7 @@ SDL_HapticOpenFromJoystick(SDL_Joystick * joystick)
|
||||
|
||||
hapticlist = SDL_haptics;
|
||||
/* Check to see if joystick's haptic is already open */
|
||||
while ( hapticlist ) {
|
||||
while (hapticlist) {
|
||||
if (SDL_SYS_JoystickSameHaptic(hapticlist, joystick)) {
|
||||
haptic = hapticlist;
|
||||
++haptic->ref_count;
|
||||
@@ -305,7 +288,7 @@ SDL_HapticOpenFromJoystick(SDL_Joystick * joystick)
|
||||
}
|
||||
|
||||
/* Create the haptic device */
|
||||
haptic = (SDL_Haptic *) SDL_malloc((sizeof *haptic));
|
||||
haptic = (SDL_Haptic *)SDL_malloc((sizeof *haptic));
|
||||
if (haptic == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
@@ -329,12 +312,10 @@ SDL_HapticOpenFromJoystick(SDL_Joystick * joystick)
|
||||
return haptic;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Closes a SDL_Haptic device.
|
||||
*/
|
||||
void
|
||||
SDL_HapticClose(SDL_Haptic * haptic)
|
||||
void SDL_HapticClose(SDL_Haptic *haptic)
|
||||
{
|
||||
int i;
|
||||
SDL_Haptic *hapticlist;
|
||||
@@ -361,9 +342,9 @@ SDL_HapticClose(SDL_Haptic * haptic)
|
||||
/* Remove from the list */
|
||||
hapticlist = SDL_haptics;
|
||||
hapticlistprev = NULL;
|
||||
while ( hapticlist ) {
|
||||
while (hapticlist) {
|
||||
if (haptic == hapticlist) {
|
||||
if ( hapticlistprev ) {
|
||||
if (hapticlistprev) {
|
||||
/* unlink this entry */
|
||||
hapticlistprev->next = hapticlist->next;
|
||||
} else {
|
||||
@@ -383,8 +364,7 @@ SDL_HapticClose(SDL_Haptic * haptic)
|
||||
/*
|
||||
* Cleans up after the subsystem.
|
||||
*/
|
||||
void
|
||||
SDL_HapticQuit(void)
|
||||
void SDL_HapticQuit(void)
|
||||
{
|
||||
while (SDL_haptics) {
|
||||
SDL_HapticClose(SDL_haptics);
|
||||
@@ -396,8 +376,7 @@ SDL_HapticQuit(void)
|
||||
/*
|
||||
* Returns the number of effects a haptic device has.
|
||||
*/
|
||||
int
|
||||
SDL_HapticNumEffects(SDL_Haptic * haptic)
|
||||
int SDL_HapticNumEffects(SDL_Haptic *haptic)
|
||||
{
|
||||
if (!ValidHaptic(haptic)) {
|
||||
return -1;
|
||||
@@ -406,12 +385,10 @@ SDL_HapticNumEffects(SDL_Haptic * haptic)
|
||||
return haptic->neffects;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Returns the number of effects a haptic device can play.
|
||||
*/
|
||||
int
|
||||
SDL_HapticNumEffectsPlaying(SDL_Haptic * haptic)
|
||||
int SDL_HapticNumEffectsPlaying(SDL_Haptic *haptic)
|
||||
{
|
||||
if (!ValidHaptic(haptic)) {
|
||||
return -1;
|
||||
@@ -420,12 +397,11 @@ SDL_HapticNumEffectsPlaying(SDL_Haptic * haptic)
|
||||
return haptic->nplaying;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Returns supported effects by the device.
|
||||
*/
|
||||
unsigned int
|
||||
SDL_HapticQuery(SDL_Haptic * haptic)
|
||||
SDL_HapticQuery(SDL_Haptic *haptic)
|
||||
{
|
||||
if (!ValidHaptic(haptic)) {
|
||||
return 0; /* same as if no effects were supported */
|
||||
@@ -434,12 +410,10 @@ SDL_HapticQuery(SDL_Haptic * haptic)
|
||||
return haptic->supported;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Returns the number of axis on the device.
|
||||
*/
|
||||
int
|
||||
SDL_HapticNumAxes(SDL_Haptic * haptic)
|
||||
int SDL_HapticNumAxes(SDL_Haptic *haptic)
|
||||
{
|
||||
if (!ValidHaptic(haptic)) {
|
||||
return -1;
|
||||
@@ -451,8 +425,7 @@ SDL_HapticNumAxes(SDL_Haptic * haptic)
|
||||
/*
|
||||
* Checks to see if the device can support the effect.
|
||||
*/
|
||||
int
|
||||
SDL_HapticEffectSupported(SDL_Haptic * haptic, SDL_HapticEffect * effect)
|
||||
int SDL_HapticEffectSupported(SDL_Haptic *haptic, SDL_HapticEffect *effect)
|
||||
{
|
||||
if (!ValidHaptic(haptic)) {
|
||||
return -1;
|
||||
@@ -467,8 +440,7 @@ SDL_HapticEffectSupported(SDL_Haptic * haptic, SDL_HapticEffect * effect)
|
||||
/*
|
||||
* Creates a new haptic effect.
|
||||
*/
|
||||
int
|
||||
SDL_HapticNewEffect(SDL_Haptic * haptic, SDL_HapticEffect * effect)
|
||||
int SDL_HapticNewEffect(SDL_Haptic *haptic, SDL_HapticEffect *effect)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -487,9 +459,8 @@ SDL_HapticNewEffect(SDL_Haptic * haptic, SDL_HapticEffect * effect)
|
||||
if (haptic->effects[i].hweffect == NULL) {
|
||||
|
||||
/* Now let the backend create the real effect */
|
||||
if (SDL_SYS_HapticNewEffect(haptic, &haptic->effects[i], effect)
|
||||
!= 0) {
|
||||
return -1; /* Backend failed to create effect */
|
||||
if (SDL_SYS_HapticNewEffect(haptic, &haptic->effects[i], effect) != 0) {
|
||||
return -1; /* Backend failed to create effect */
|
||||
}
|
||||
|
||||
SDL_memcpy(&haptic->effects[i].effect, effect,
|
||||
@@ -504,8 +475,7 @@ SDL_HapticNewEffect(SDL_Haptic * haptic, SDL_HapticEffect * effect)
|
||||
/*
|
||||
* Checks to see if an effect is valid.
|
||||
*/
|
||||
static int
|
||||
ValidEffect(SDL_Haptic * haptic, int effect)
|
||||
static int ValidEffect(SDL_Haptic *haptic, int effect)
|
||||
{
|
||||
if ((effect < 0) || (effect >= haptic->neffects)) {
|
||||
SDL_SetError("Haptic: Invalid effect identifier.");
|
||||
@@ -517,9 +487,8 @@ ValidEffect(SDL_Haptic * haptic, int effect)
|
||||
/*
|
||||
* Updates an effect.
|
||||
*/
|
||||
int
|
||||
SDL_HapticUpdateEffect(SDL_Haptic * haptic, int effect,
|
||||
SDL_HapticEffect * data)
|
||||
int SDL_HapticUpdateEffect(SDL_Haptic *haptic, int effect,
|
||||
SDL_HapticEffect *data)
|
||||
{
|
||||
if (!ValidHaptic(haptic) || !ValidEffect(haptic, effect)) {
|
||||
return -1;
|
||||
@@ -541,20 +510,17 @@ SDL_HapticUpdateEffect(SDL_Haptic * haptic, int effect,
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Runs the haptic effect on the device.
|
||||
*/
|
||||
int
|
||||
SDL_HapticRunEffect(SDL_Haptic * haptic, int effect, Uint32 iterations)
|
||||
int SDL_HapticRunEffect(SDL_Haptic *haptic, int effect, Uint32 iterations)
|
||||
{
|
||||
if (!ValidHaptic(haptic) || !ValidEffect(haptic, effect)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Run the effect */
|
||||
if (SDL_SYS_HapticRunEffect(haptic, &haptic->effects[effect], iterations)
|
||||
< 0) {
|
||||
if (SDL_SYS_HapticRunEffect(haptic, &haptic->effects[effect], iterations) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -564,8 +530,7 @@ SDL_HapticRunEffect(SDL_Haptic * haptic, int effect, Uint32 iterations)
|
||||
/*
|
||||
* Stops the haptic effect on the device.
|
||||
*/
|
||||
int
|
||||
SDL_HapticStopEffect(SDL_Haptic * haptic, int effect)
|
||||
int SDL_HapticStopEffect(SDL_Haptic *haptic, int effect)
|
||||
{
|
||||
if (!ValidHaptic(haptic) || !ValidEffect(haptic, effect)) {
|
||||
return -1;
|
||||
@@ -582,8 +547,7 @@ SDL_HapticStopEffect(SDL_Haptic * haptic, int effect)
|
||||
/*
|
||||
* Gets rid of a haptic effect.
|
||||
*/
|
||||
void
|
||||
SDL_HapticDestroyEffect(SDL_Haptic * haptic, int effect)
|
||||
void SDL_HapticDestroyEffect(SDL_Haptic *haptic, int effect)
|
||||
{
|
||||
if (!ValidHaptic(haptic) || !ValidEffect(haptic, effect)) {
|
||||
return;
|
||||
@@ -600,8 +564,7 @@ SDL_HapticDestroyEffect(SDL_Haptic * haptic, int effect)
|
||||
/*
|
||||
* Gets the status of a haptic effect.
|
||||
*/
|
||||
int
|
||||
SDL_HapticGetEffectStatus(SDL_Haptic * haptic, int effect)
|
||||
int SDL_HapticGetEffectStatus(SDL_Haptic *haptic, int effect)
|
||||
{
|
||||
if (!ValidHaptic(haptic) || !ValidEffect(haptic, effect)) {
|
||||
return -1;
|
||||
@@ -617,8 +580,7 @@ SDL_HapticGetEffectStatus(SDL_Haptic * haptic, int effect)
|
||||
/*
|
||||
* Sets the global gain of the device.
|
||||
*/
|
||||
int
|
||||
SDL_HapticSetGain(SDL_Haptic * haptic, int gain)
|
||||
int SDL_HapticSetGain(SDL_Haptic *haptic, int gain)
|
||||
{
|
||||
const char *env;
|
||||
int real_gain, max_gain;
|
||||
@@ -663,8 +625,7 @@ SDL_HapticSetGain(SDL_Haptic * haptic, int gain)
|
||||
/*
|
||||
* Makes the device autocenter, 0 disables.
|
||||
*/
|
||||
int
|
||||
SDL_HapticSetAutocenter(SDL_Haptic * haptic, int autocenter)
|
||||
int SDL_HapticSetAutocenter(SDL_Haptic *haptic, int autocenter)
|
||||
{
|
||||
if (!ValidHaptic(haptic)) {
|
||||
return -1;
|
||||
@@ -688,8 +649,7 @@ SDL_HapticSetAutocenter(SDL_Haptic * haptic, int autocenter)
|
||||
/*
|
||||
* Pauses the haptic device.
|
||||
*/
|
||||
int
|
||||
SDL_HapticPause(SDL_Haptic * haptic)
|
||||
int SDL_HapticPause(SDL_Haptic *haptic)
|
||||
{
|
||||
if (!ValidHaptic(haptic)) {
|
||||
return -1;
|
||||
@@ -705,15 +665,14 @@ SDL_HapticPause(SDL_Haptic * haptic)
|
||||
/*
|
||||
* Unpauses the haptic device.
|
||||
*/
|
||||
int
|
||||
SDL_HapticUnpause(SDL_Haptic * haptic)
|
||||
int SDL_HapticUnpause(SDL_Haptic *haptic)
|
||||
{
|
||||
if (!ValidHaptic(haptic)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((haptic->supported & SDL_HAPTIC_PAUSE) == 0) {
|
||||
return 0; /* Not going to be paused, so we pretend it's unpaused. */
|
||||
return 0; /* Not going to be paused, so we pretend it's unpaused. */
|
||||
}
|
||||
|
||||
return SDL_SYS_HapticUnpause(haptic);
|
||||
@@ -722,8 +681,7 @@ SDL_HapticUnpause(SDL_Haptic * haptic)
|
||||
/*
|
||||
* Stops all the currently playing effects.
|
||||
*/
|
||||
int
|
||||
SDL_HapticStopAll(SDL_Haptic * haptic)
|
||||
int SDL_HapticStopAll(SDL_Haptic *haptic)
|
||||
{
|
||||
if (!ValidHaptic(haptic)) {
|
||||
return -1;
|
||||
@@ -735,8 +693,7 @@ SDL_HapticStopAll(SDL_Haptic * haptic)
|
||||
/*
|
||||
* Checks to see if rumble is supported.
|
||||
*/
|
||||
int
|
||||
SDL_HapticRumbleSupported(SDL_Haptic * haptic)
|
||||
int SDL_HapticRumbleSupported(SDL_Haptic *haptic)
|
||||
{
|
||||
if (!ValidHaptic(haptic)) {
|
||||
return -1;
|
||||
@@ -749,8 +706,7 @@ SDL_HapticRumbleSupported(SDL_Haptic * haptic)
|
||||
/*
|
||||
* Initializes the haptic device for simple rumble playback.
|
||||
*/
|
||||
int
|
||||
SDL_HapticRumbleInit(SDL_Haptic * haptic)
|
||||
int SDL_HapticRumbleInit(SDL_Haptic *haptic)
|
||||
{
|
||||
SDL_HapticEffect *efx = &haptic->rumble_effect;
|
||||
|
||||
@@ -772,7 +728,7 @@ SDL_HapticRumbleInit(SDL_Haptic * haptic)
|
||||
efx->periodic.length = 5000;
|
||||
efx->periodic.attack_length = 0;
|
||||
efx->periodic.fade_length = 0;
|
||||
} else if (haptic->supported & SDL_HAPTIC_LEFTRIGHT) { /* XInput? */
|
||||
} else if (haptic->supported & SDL_HAPTIC_LEFTRIGHT) { /* XInput? */
|
||||
efx->type = SDL_HAPTIC_LEFTRIGHT;
|
||||
efx->leftright.length = 5000;
|
||||
efx->leftright.large_magnitude = 0x4000;
|
||||
@@ -791,8 +747,7 @@ SDL_HapticRumbleInit(SDL_Haptic * haptic)
|
||||
/*
|
||||
* Runs simple rumble on a haptic device
|
||||
*/
|
||||
int
|
||||
SDL_HapticRumblePlay(SDL_Haptic * haptic, float strength, Uint32 length)
|
||||
int SDL_HapticRumblePlay(SDL_Haptic *haptic, float strength, Uint32 length)
|
||||
{
|
||||
SDL_HapticEffect *efx;
|
||||
Sint16 magnitude;
|
||||
@@ -811,7 +766,7 @@ SDL_HapticRumblePlay(SDL_Haptic * haptic, float strength, Uint32 length)
|
||||
} else if (strength < 0.0f) {
|
||||
strength = 0.0f;
|
||||
}
|
||||
magnitude = (Sint16)(32767.0f*strength);
|
||||
magnitude = (Sint16)(32767.0f * strength);
|
||||
|
||||
efx = &haptic->rumble_effect;
|
||||
if (efx->type == SDL_HAPTIC_SINE) {
|
||||
@@ -834,8 +789,7 @@ SDL_HapticRumblePlay(SDL_Haptic * haptic, float strength, Uint32 length)
|
||||
/*
|
||||
* Stops the simple rumble on a haptic device.
|
||||
*/
|
||||
int
|
||||
SDL_HapticRumbleStop(SDL_Haptic * haptic)
|
||||
int SDL_HapticRumbleStop(SDL_Haptic *haptic)
|
||||
{
|
||||
if (!ValidHaptic(haptic)) {
|
||||
return -1;
|
||||
|
||||
+32
-33
@@ -24,7 +24,6 @@
|
||||
#ifndef SDL_syshaptic_h_
|
||||
#define SDL_syshaptic_h_
|
||||
|
||||
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -32,8 +31,8 @@ extern "C" {
|
||||
|
||||
struct haptic_effect
|
||||
{
|
||||
SDL_HapticEffect effect; /* The current event */
|
||||
struct haptic_hweffect *hweffect; /* The hardware behind the event */
|
||||
SDL_HapticEffect effect; /* The current event */
|
||||
struct haptic_hweffect *hweffect; /* The hardware behind the event */
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -41,20 +40,20 @@ struct haptic_effect
|
||||
*/
|
||||
struct _SDL_Haptic
|
||||
{
|
||||
Uint8 index; /* Stores index it is attached to */
|
||||
Uint8 index; /* Stores index it is attached to */
|
||||
|
||||
struct haptic_effect *effects; /* Allocated effects */
|
||||
int neffects; /* Maximum amount of effects */
|
||||
int nplaying; /* Maximum amount of effects to play at the same time */
|
||||
unsigned int supported; /* Supported effects */
|
||||
int naxes; /* Number of axes on the device. */
|
||||
struct haptic_effect *effects; /* Allocated effects */
|
||||
int neffects; /* Maximum amount of effects */
|
||||
int nplaying; /* Maximum amount of effects to play at the same time */
|
||||
unsigned int supported; /* Supported effects */
|
||||
int naxes; /* Number of axes on the device. */
|
||||
|
||||
struct haptic_hwdata *hwdata; /* Driver dependent */
|
||||
int ref_count; /* Count for multiple opens */
|
||||
struct haptic_hwdata *hwdata; /* Driver dependent */
|
||||
int ref_count; /* Count for multiple opens */
|
||||
|
||||
int rumble_id; /* ID of rumble effect for simple rumble API. */
|
||||
int rumble_id; /* ID of rumble effect for simple rumble API. */
|
||||
SDL_HapticEffect rumble_effect; /* Rumble effect. */
|
||||
struct _SDL_Haptic *next; /* pointer to next haptic we have allocated */
|
||||
struct _SDL_Haptic *next; /* pointer to next haptic we have allocated */
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -78,7 +77,7 @@ extern const char *SDL_SYS_HapticName(int index);
|
||||
*
|
||||
* Returns 0 on success, -1 on error.
|
||||
*/
|
||||
extern int SDL_SYS_HapticOpen(SDL_Haptic * haptic);
|
||||
extern int SDL_SYS_HapticOpen(SDL_Haptic *haptic);
|
||||
|
||||
/*
|
||||
* Returns the index of the haptic core pointer or -1 if none is found.
|
||||
@@ -91,7 +90,7 @@ int SDL_SYS_HapticMouse(void);
|
||||
* Returns >0 if haptic capabilities are detected, 0 if haptic
|
||||
* capabilities aren't detected and -1 on error.
|
||||
*/
|
||||
extern int SDL_SYS_JoystickIsHaptic(SDL_Joystick * joystick);
|
||||
extern int SDL_SYS_JoystickIsHaptic(SDL_Joystick *joystick);
|
||||
|
||||
/*
|
||||
* Opens the haptic device for usage using the same device as
|
||||
@@ -99,20 +98,20 @@ extern int SDL_SYS_JoystickIsHaptic(SDL_Joystick * joystick);
|
||||
*
|
||||
* Returns 0 on success, -1 on error.
|
||||
*/
|
||||
extern int SDL_SYS_HapticOpenFromJoystick(SDL_Haptic * haptic,
|
||||
SDL_Joystick * joystick);
|
||||
extern int SDL_SYS_HapticOpenFromJoystick(SDL_Haptic *haptic,
|
||||
SDL_Joystick *joystick);
|
||||
/*
|
||||
* Checks to see if haptic device and joystick device are the same.
|
||||
*
|
||||
* Returns 1 if they are the same, 0 if they aren't.
|
||||
*/
|
||||
extern int SDL_SYS_JoystickSameHaptic(SDL_Haptic * haptic,
|
||||
SDL_Joystick * joystick);
|
||||
extern int SDL_SYS_JoystickSameHaptic(SDL_Haptic *haptic,
|
||||
SDL_Joystick *joystick);
|
||||
|
||||
/*
|
||||
* Closes a haptic device after usage.
|
||||
*/
|
||||
extern void SDL_SYS_HapticClose(SDL_Haptic * haptic);
|
||||
extern void SDL_SYS_HapticClose(SDL_Haptic *haptic);
|
||||
|
||||
/*
|
||||
* Performs a cleanup on the haptic subsystem.
|
||||
@@ -125,9 +124,9 @@ extern void SDL_SYS_HapticQuit(void);
|
||||
*
|
||||
* Returns 0 on success, -1 on error.
|
||||
*/
|
||||
extern int SDL_SYS_HapticNewEffect(SDL_Haptic * haptic,
|
||||
extern int SDL_SYS_HapticNewEffect(SDL_Haptic *haptic,
|
||||
struct haptic_effect *effect,
|
||||
SDL_HapticEffect * base);
|
||||
SDL_HapticEffect *base);
|
||||
|
||||
/*
|
||||
* Updates the haptic effect on the haptic device using data
|
||||
@@ -135,16 +134,16 @@ extern int SDL_SYS_HapticNewEffect(SDL_Haptic * haptic,
|
||||
*
|
||||
* Returns 0 on success, -1 on error.
|
||||
*/
|
||||
extern int SDL_SYS_HapticUpdateEffect(SDL_Haptic * haptic,
|
||||
extern int SDL_SYS_HapticUpdateEffect(SDL_Haptic *haptic,
|
||||
struct haptic_effect *effect,
|
||||
SDL_HapticEffect * data);
|
||||
SDL_HapticEffect *data);
|
||||
|
||||
/*
|
||||
* Runs the effect on the haptic device.
|
||||
*
|
||||
* Returns 0 on success, -1 on error.
|
||||
*/
|
||||
extern int SDL_SYS_HapticRunEffect(SDL_Haptic * haptic,
|
||||
extern int SDL_SYS_HapticRunEffect(SDL_Haptic *haptic,
|
||||
struct haptic_effect *effect,
|
||||
Uint32 iterations);
|
||||
|
||||
@@ -153,13 +152,13 @@ extern int SDL_SYS_HapticRunEffect(SDL_Haptic * haptic,
|
||||
*
|
||||
* Returns 0 on success, -1 on error.
|
||||
*/
|
||||
extern int SDL_SYS_HapticStopEffect(SDL_Haptic * haptic,
|
||||
extern int SDL_SYS_HapticStopEffect(SDL_Haptic *haptic,
|
||||
struct haptic_effect *effect);
|
||||
|
||||
/*
|
||||
* Cleanups up the effect on the haptic device.
|
||||
*/
|
||||
extern void SDL_SYS_HapticDestroyEffect(SDL_Haptic * haptic,
|
||||
extern void SDL_SYS_HapticDestroyEffect(SDL_Haptic *haptic,
|
||||
struct haptic_effect *effect);
|
||||
|
||||
/*
|
||||
@@ -168,7 +167,7 @@ extern void SDL_SYS_HapticDestroyEffect(SDL_Haptic * haptic,
|
||||
* Returns 0 if device is stopped, >0 if device is playing and
|
||||
* -1 on error.
|
||||
*/
|
||||
extern int SDL_SYS_HapticGetEffectStatus(SDL_Haptic * haptic,
|
||||
extern int SDL_SYS_HapticGetEffectStatus(SDL_Haptic *haptic,
|
||||
struct haptic_effect *effect);
|
||||
|
||||
/*
|
||||
@@ -176,35 +175,35 @@ extern int SDL_SYS_HapticGetEffectStatus(SDL_Haptic * haptic,
|
||||
*
|
||||
* Returns 0 on success, -1 on error.
|
||||
*/
|
||||
extern int SDL_SYS_HapticSetGain(SDL_Haptic * haptic, int gain);
|
||||
extern int SDL_SYS_HapticSetGain(SDL_Haptic *haptic, int gain);
|
||||
|
||||
/*
|
||||
* Sets the autocenter feature of the haptic device.
|
||||
*
|
||||
* Returns 0 on success, -1 on error.
|
||||
*/
|
||||
extern int SDL_SYS_HapticSetAutocenter(SDL_Haptic * haptic, int autocenter);
|
||||
extern int SDL_SYS_HapticSetAutocenter(SDL_Haptic *haptic, int autocenter);
|
||||
|
||||
/*
|
||||
* Pauses the haptic device.
|
||||
*
|
||||
* Returns 0 on success, -1 on error.
|
||||
*/
|
||||
extern int SDL_SYS_HapticPause(SDL_Haptic * haptic);
|
||||
extern int SDL_SYS_HapticPause(SDL_Haptic *haptic);
|
||||
|
||||
/*
|
||||
* Unpauses the haptic device.
|
||||
*
|
||||
* Returns 0 on success, -1 on error.
|
||||
*/
|
||||
extern int SDL_SYS_HapticUnpause(SDL_Haptic * haptic);
|
||||
extern int SDL_SYS_HapticUnpause(SDL_Haptic *haptic);
|
||||
|
||||
/*
|
||||
* Stops all the currently playing haptic effects on the device.
|
||||
*
|
||||
* Returns 0 on success, -1 on error.
|
||||
*/
|
||||
extern int SDL_SYS_HapticStopAll(SDL_Haptic * haptic);
|
||||
extern int SDL_SYS_HapticStopAll(SDL_Haptic *haptic);
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -25,9 +25,8 @@
|
||||
#include "SDL_syshaptic_c.h"
|
||||
#include "../SDL_syshaptic.h"
|
||||
#include "../../core/android/SDL_android.h"
|
||||
#include "../../joystick/SDL_sysjoystick.h" /* For the real SDL_Joystick */
|
||||
#include "../../joystick/android/SDL_sysjoystick_c.h" /* For joystick hwdata */
|
||||
|
||||
#include "../../joystick/SDL_sysjoystick.h" /* For the real SDL_Joystick */
|
||||
#include "../../joystick/android/SDL_sysjoystick_c.h" /* For joystick hwdata */
|
||||
|
||||
typedef struct SDL_hapticlist_item
|
||||
{
|
||||
@@ -41,9 +40,7 @@ static SDL_hapticlist_item *SDL_hapticlist = NULL;
|
||||
static SDL_hapticlist_item *SDL_hapticlist_tail = NULL;
|
||||
static int numhaptics = 0;
|
||||
|
||||
|
||||
int
|
||||
SDL_SYS_HapticInit(void)
|
||||
int SDL_SYS_HapticInit(void)
|
||||
{
|
||||
/* Support for device connect/disconnect is API >= 16 only,
|
||||
* so we poll every three seconds
|
||||
@@ -57,14 +54,12 @@ SDL_SYS_HapticInit(void)
|
||||
return numhaptics;
|
||||
}
|
||||
|
||||
int
|
||||
SDL_SYS_NumHaptics(void)
|
||||
int SDL_SYS_NumHaptics(void)
|
||||
{
|
||||
return numhaptics;
|
||||
}
|
||||
|
||||
static SDL_hapticlist_item *
|
||||
HapticByOrder(int index)
|
||||
static SDL_hapticlist_item *HapticByOrder(int index)
|
||||
{
|
||||
SDL_hapticlist_item *item = SDL_hapticlist;
|
||||
if ((index < 0) || (index >= numhaptics)) {
|
||||
@@ -78,8 +73,7 @@ HapticByOrder(int index)
|
||||
return item;
|
||||
}
|
||||
|
||||
static SDL_hapticlist_item *
|
||||
HapticByDevId (int device_id)
|
||||
static SDL_hapticlist_item *HapticByDevId(int device_id)
|
||||
{
|
||||
SDL_hapticlist_item *item;
|
||||
for (item = SDL_hapticlist; item != NULL; item = item->next) {
|
||||
@@ -95,18 +89,16 @@ const char *
|
||||
SDL_SYS_HapticName(int index)
|
||||
{
|
||||
SDL_hapticlist_item *item = HapticByOrder(index);
|
||||
if (item == NULL ) {
|
||||
if (item == NULL) {
|
||||
SDL_SetError("No such device");
|
||||
return NULL;
|
||||
}
|
||||
return item->name;
|
||||
}
|
||||
|
||||
|
||||
static SDL_hapticlist_item *
|
||||
OpenHaptic(SDL_Haptic *haptic, SDL_hapticlist_item *item)
|
||||
static SDL_hapticlist_item *OpenHaptic(SDL_Haptic *haptic, SDL_hapticlist_item *item)
|
||||
{
|
||||
if (item == NULL ) {
|
||||
if (item == NULL) {
|
||||
SDL_SetError("No such device");
|
||||
return NULL;
|
||||
}
|
||||
@@ -121,75 +113,60 @@ OpenHaptic(SDL_Haptic *haptic, SDL_hapticlist_item *item)
|
||||
haptic->supported = SDL_HAPTIC_LEFTRIGHT;
|
||||
haptic->neffects = 1;
|
||||
haptic->nplaying = haptic->neffects;
|
||||
haptic->effects = (struct haptic_effect *)SDL_malloc (sizeof (struct haptic_effect) * haptic->neffects);
|
||||
haptic->effects = (struct haptic_effect *)SDL_malloc(sizeof(struct haptic_effect) * haptic->neffects);
|
||||
if (haptic->effects == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
SDL_memset(haptic->effects, 0, sizeof (struct haptic_effect) * haptic->neffects);
|
||||
SDL_memset(haptic->effects, 0, sizeof(struct haptic_effect) * haptic->neffects);
|
||||
return item;
|
||||
}
|
||||
|
||||
static SDL_hapticlist_item *
|
||||
OpenHapticByOrder(SDL_Haptic *haptic, int index)
|
||||
static SDL_hapticlist_item *OpenHapticByOrder(SDL_Haptic *haptic, int index)
|
||||
{
|
||||
return OpenHaptic(haptic, HapticByOrder(index));
|
||||
}
|
||||
|
||||
static SDL_hapticlist_item *
|
||||
OpenHapticByDevId(SDL_Haptic *haptic, int device_id)
|
||||
static SDL_hapticlist_item *OpenHapticByDevId(SDL_Haptic *haptic, int device_id)
|
||||
{
|
||||
return OpenHaptic(haptic, HapticByDevId(device_id));
|
||||
}
|
||||
|
||||
int
|
||||
SDL_SYS_HapticOpen(SDL_Haptic *haptic)
|
||||
int SDL_SYS_HapticOpen(SDL_Haptic *haptic)
|
||||
{
|
||||
return OpenHapticByOrder(haptic, haptic->index) == NULL ? -1 : 0;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
SDL_SYS_HapticMouse(void)
|
||||
int SDL_SYS_HapticMouse(void)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
SDL_SYS_JoystickIsHaptic(SDL_Joystick *joystick)
|
||||
int SDL_SYS_JoystickIsHaptic(SDL_Joystick *joystick)
|
||||
{
|
||||
SDL_hapticlist_item *item;
|
||||
item = HapticByDevId(((joystick_hwdata *)joystick->hwdata)->device_id);
|
||||
return (item != NULL) ? 1 : 0;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
SDL_SYS_HapticOpenFromJoystick(SDL_Haptic *haptic, SDL_Joystick *joystick)
|
||||
int SDL_SYS_HapticOpenFromJoystick(SDL_Haptic *haptic, SDL_Joystick *joystick)
|
||||
{
|
||||
return OpenHapticByDevId(haptic, ((joystick_hwdata *)joystick->hwdata)->device_id) == NULL ? -1 : 0;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
SDL_SYS_JoystickSameHaptic(SDL_Haptic * haptic, SDL_Joystick * joystick)
|
||||
int SDL_SYS_JoystickSameHaptic(SDL_Haptic *haptic, SDL_Joystick *joystick)
|
||||
{
|
||||
return ((SDL_hapticlist_item *)haptic->hwdata)->device_id == ((joystick_hwdata *)joystick->hwdata)->device_id ? 1 : 0;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SDL_SYS_HapticClose(SDL_Haptic * haptic)
|
||||
void SDL_SYS_HapticClose(SDL_Haptic *haptic)
|
||||
{
|
||||
((SDL_hapticlist_item *)haptic->hwdata)->haptic = NULL;
|
||||
haptic->hwdata = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SDL_SYS_HapticQuit(void)
|
||||
void SDL_SYS_HapticQuit(void)
|
||||
{
|
||||
/* We don't have any way to scan for joysticks (and their vibrators) at init, so don't wipe the list
|
||||
* of joysticks here in case this is a reinit.
|
||||
@@ -209,107 +186,85 @@ SDL_SYS_HapticQuit(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
SDL_SYS_HapticNewEffect(SDL_Haptic * haptic,
|
||||
struct haptic_effect *effect, SDL_HapticEffect * base)
|
||||
int SDL_SYS_HapticNewEffect(SDL_Haptic *haptic,
|
||||
struct haptic_effect *effect, SDL_HapticEffect *base)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
SDL_SYS_HapticUpdateEffect(SDL_Haptic * haptic,
|
||||
struct haptic_effect *effect,
|
||||
SDL_HapticEffect * data)
|
||||
int SDL_SYS_HapticUpdateEffect(SDL_Haptic *haptic,
|
||||
struct haptic_effect *effect,
|
||||
SDL_HapticEffect *data)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
SDL_SYS_HapticRunEffect(SDL_Haptic * haptic, struct haptic_effect *effect,
|
||||
Uint32 iterations)
|
||||
int SDL_SYS_HapticRunEffect(SDL_Haptic *haptic, struct haptic_effect *effect,
|
||||
Uint32 iterations)
|
||||
{
|
||||
float large = effect->effect.leftright.large_magnitude / 32767.0f;
|
||||
float small = effect->effect.leftright.small_magnitude / 32767.0f;
|
||||
|
||||
float total = (large * 0.6f) + (small * 0.4f);
|
||||
|
||||
Android_JNI_HapticRun (((SDL_hapticlist_item *)haptic->hwdata)->device_id, total, effect->effect.leftright.length);
|
||||
Android_JNI_HapticRun(((SDL_hapticlist_item *)haptic->hwdata)->device_id, total, effect->effect.leftright.length);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
SDL_SYS_HapticStopEffect(SDL_Haptic * haptic, struct haptic_effect *effect)
|
||||
int SDL_SYS_HapticStopEffect(SDL_Haptic *haptic, struct haptic_effect *effect)
|
||||
{
|
||||
Android_JNI_HapticStop (((SDL_hapticlist_item *)haptic->hwdata)->device_id);
|
||||
Android_JNI_HapticStop(((SDL_hapticlist_item *)haptic->hwdata)->device_id);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SDL_SYS_HapticDestroyEffect(SDL_Haptic * haptic, struct haptic_effect *effect)
|
||||
void SDL_SYS_HapticDestroyEffect(SDL_Haptic *haptic, struct haptic_effect *effect)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
SDL_SYS_HapticGetEffectStatus(SDL_Haptic * haptic,
|
||||
struct haptic_effect *effect)
|
||||
int SDL_SYS_HapticGetEffectStatus(SDL_Haptic *haptic,
|
||||
struct haptic_effect *effect)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
SDL_SYS_HapticSetGain(SDL_Haptic * haptic, int gain)
|
||||
int SDL_SYS_HapticSetGain(SDL_Haptic *haptic, int gain)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
SDL_SYS_HapticSetAutocenter(SDL_Haptic * haptic, int autocenter)
|
||||
int SDL_SYS_HapticSetAutocenter(SDL_Haptic *haptic, int autocenter)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
SDL_SYS_HapticPause(SDL_Haptic * haptic)
|
||||
int SDL_SYS_HapticPause(SDL_Haptic *haptic)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
SDL_SYS_HapticUnpause(SDL_Haptic * haptic)
|
||||
int SDL_SYS_HapticUnpause(SDL_Haptic *haptic)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
SDL_SYS_HapticStopAll(SDL_Haptic * haptic)
|
||||
int SDL_SYS_HapticStopAll(SDL_Haptic *haptic)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
Android_AddHaptic(int device_id, const char *name)
|
||||
int Android_AddHaptic(int device_id, const char *name)
|
||||
{
|
||||
SDL_hapticlist_item *item;
|
||||
item = (SDL_hapticlist_item *) SDL_calloc(1, sizeof (SDL_hapticlist_item));
|
||||
item = (SDL_hapticlist_item *)SDL_calloc(1, sizeof(SDL_hapticlist_item));
|
||||
if (item == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
item->device_id = device_id;
|
||||
item->name = SDL_strdup (name);
|
||||
item->name = SDL_strdup(name);
|
||||
if (item->name == NULL) {
|
||||
SDL_free (item);
|
||||
SDL_free(item);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -324,8 +279,7 @@ Android_AddHaptic(int device_id, const char *name)
|
||||
return numhaptics;
|
||||
}
|
||||
|
||||
int
|
||||
Android_RemoveHaptic(int device_id)
|
||||
int Android_RemoveHaptic(int device_id)
|
||||
{
|
||||
SDL_hapticlist_item *item;
|
||||
SDL_hapticlist_item *prev = NULL;
|
||||
@@ -358,7 +312,6 @@ Android_RemoveHaptic(int device_id)
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
#endif /* SDL_HAPTIC_ANDROID */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
||||
+112
-183
File diff suppressed because it is too large
Load Diff
@@ -25,8 +25,7 @@
|
||||
#define kIOMainPortDefault kIOMasterPortDefault
|
||||
#endif
|
||||
|
||||
extern int MacHaptic_MaybeAddDevice( io_object_t device );
|
||||
extern int MacHaptic_MaybeRemoveDevice( io_object_t device );
|
||||
extern int MacHaptic_MaybeAddDevice(io_object_t device);
|
||||
extern int MacHaptic_MaybeRemoveDevice(io_object_t device);
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
||||
|
||||
@@ -24,22 +24,17 @@
|
||||
|
||||
#include "../SDL_syshaptic.h"
|
||||
|
||||
|
||||
static int
|
||||
SDL_SYS_LogicError(void)
|
||||
static int SDL_SYS_LogicError(void)
|
||||
{
|
||||
return SDL_SetError("Logic error: No haptic devices available.");
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
SDL_SYS_HapticInit(void)
|
||||
int SDL_SYS_HapticInit(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
SDL_SYS_NumHaptics(void)
|
||||
int SDL_SYS_NumHaptics(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -51,131 +46,98 @@ SDL_SYS_HapticName(int index)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
SDL_SYS_HapticOpen(SDL_Haptic * haptic)
|
||||
int SDL_SYS_HapticOpen(SDL_Haptic *haptic)
|
||||
{
|
||||
return SDL_SYS_LogicError();
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
SDL_SYS_HapticMouse(void)
|
||||
int SDL_SYS_HapticMouse(void)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
SDL_SYS_JoystickIsHaptic(SDL_Joystick * joystick)
|
||||
int SDL_SYS_JoystickIsHaptic(SDL_Joystick *joystick)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
SDL_SYS_HapticOpenFromJoystick(SDL_Haptic * haptic, SDL_Joystick * joystick)
|
||||
int SDL_SYS_HapticOpenFromJoystick(SDL_Haptic *haptic, SDL_Joystick *joystick)
|
||||
{
|
||||
return SDL_SYS_LogicError();
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
SDL_SYS_JoystickSameHaptic(SDL_Haptic * haptic, SDL_Joystick * joystick)
|
||||
int SDL_SYS_JoystickSameHaptic(SDL_Haptic *haptic, SDL_Joystick *joystick)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SDL_SYS_HapticClose(SDL_Haptic * haptic)
|
||||
void SDL_SYS_HapticClose(SDL_Haptic *haptic)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SDL_SYS_HapticQuit(void)
|
||||
void SDL_SYS_HapticQuit(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
SDL_SYS_HapticNewEffect(SDL_Haptic * haptic,
|
||||
struct haptic_effect *effect, SDL_HapticEffect * base)
|
||||
int SDL_SYS_HapticNewEffect(SDL_Haptic *haptic,
|
||||
struct haptic_effect *effect, SDL_HapticEffect *base)
|
||||
{
|
||||
return SDL_SYS_LogicError();
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
SDL_SYS_HapticUpdateEffect(SDL_Haptic * haptic,
|
||||
struct haptic_effect *effect,
|
||||
SDL_HapticEffect * data)
|
||||
int SDL_SYS_HapticUpdateEffect(SDL_Haptic *haptic,
|
||||
struct haptic_effect *effect,
|
||||
SDL_HapticEffect *data)
|
||||
{
|
||||
return SDL_SYS_LogicError();
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
SDL_SYS_HapticRunEffect(SDL_Haptic * haptic, struct haptic_effect *effect,
|
||||
Uint32 iterations)
|
||||
int SDL_SYS_HapticRunEffect(SDL_Haptic *haptic, struct haptic_effect *effect,
|
||||
Uint32 iterations)
|
||||
{
|
||||
return SDL_SYS_LogicError();
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
SDL_SYS_HapticStopEffect(SDL_Haptic * haptic, struct haptic_effect *effect)
|
||||
int SDL_SYS_HapticStopEffect(SDL_Haptic *haptic, struct haptic_effect *effect)
|
||||
{
|
||||
return SDL_SYS_LogicError();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SDL_SYS_HapticDestroyEffect(SDL_Haptic * haptic, struct haptic_effect *effect)
|
||||
void SDL_SYS_HapticDestroyEffect(SDL_Haptic *haptic, struct haptic_effect *effect)
|
||||
{
|
||||
SDL_SYS_LogicError();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
SDL_SYS_HapticGetEffectStatus(SDL_Haptic * haptic,
|
||||
struct haptic_effect *effect)
|
||||
int SDL_SYS_HapticGetEffectStatus(SDL_Haptic *haptic,
|
||||
struct haptic_effect *effect)
|
||||
{
|
||||
return SDL_SYS_LogicError();
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
SDL_SYS_HapticSetGain(SDL_Haptic * haptic, int gain)
|
||||
int SDL_SYS_HapticSetGain(SDL_Haptic *haptic, int gain)
|
||||
{
|
||||
return SDL_SYS_LogicError();
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
SDL_SYS_HapticSetAutocenter(SDL_Haptic * haptic, int autocenter)
|
||||
int SDL_SYS_HapticSetAutocenter(SDL_Haptic *haptic, int autocenter)
|
||||
{
|
||||
return SDL_SYS_LogicError();
|
||||
}
|
||||
|
||||
int
|
||||
SDL_SYS_HapticPause(SDL_Haptic * haptic)
|
||||
int SDL_SYS_HapticPause(SDL_Haptic *haptic)
|
||||
{
|
||||
return SDL_SYS_LogicError();
|
||||
}
|
||||
|
||||
int
|
||||
SDL_SYS_HapticUnpause(SDL_Haptic * haptic)
|
||||
int SDL_SYS_HapticUnpause(SDL_Haptic *haptic)
|
||||
{
|
||||
return SDL_SYS_LogicError();
|
||||
}
|
||||
|
||||
int
|
||||
SDL_SYS_HapticStopAll(SDL_Haptic * haptic)
|
||||
int SDL_SYS_HapticStopAll(SDL_Haptic *haptic)
|
||||
{
|
||||
return SDL_SYS_LogicError();
|
||||
}
|
||||
|
||||
+113
-179
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -30,22 +30,22 @@ extern "C" {
|
||||
extern int SDL_DINPUT_HapticInit(void);
|
||||
extern int SDL_DINPUT_HapticMaybeAddDevice(const DIDEVICEINSTANCE *pdidInstance);
|
||||
extern int SDL_DINPUT_HapticMaybeRemoveDevice(const DIDEVICEINSTANCE *pdidInstance);
|
||||
extern int SDL_DINPUT_HapticOpen(SDL_Haptic * haptic, SDL_hapticlist_item *item);
|
||||
extern int SDL_DINPUT_JoystickSameHaptic(SDL_Haptic * haptic, SDL_Joystick * joystick);
|
||||
extern int SDL_DINPUT_HapticOpenFromJoystick(SDL_Haptic * haptic, SDL_Joystick * joystick);
|
||||
extern void SDL_DINPUT_HapticClose(SDL_Haptic * haptic);
|
||||
extern int SDL_DINPUT_HapticOpen(SDL_Haptic *haptic, SDL_hapticlist_item *item);
|
||||
extern int SDL_DINPUT_JoystickSameHaptic(SDL_Haptic *haptic, SDL_Joystick *joystick);
|
||||
extern int SDL_DINPUT_HapticOpenFromJoystick(SDL_Haptic *haptic, SDL_Joystick *joystick);
|
||||
extern void SDL_DINPUT_HapticClose(SDL_Haptic *haptic);
|
||||
extern void SDL_DINPUT_HapticQuit(void);
|
||||
extern int SDL_DINPUT_HapticNewEffect(SDL_Haptic * haptic, struct haptic_effect *effect, SDL_HapticEffect * base);
|
||||
extern int SDL_DINPUT_HapticUpdateEffect(SDL_Haptic * haptic, struct haptic_effect *effect, SDL_HapticEffect * data);
|
||||
extern int SDL_DINPUT_HapticRunEffect(SDL_Haptic * haptic, struct haptic_effect *effect, Uint32 iterations);
|
||||
extern int SDL_DINPUT_HapticStopEffect(SDL_Haptic * haptic, struct haptic_effect *effect);
|
||||
extern void SDL_DINPUT_HapticDestroyEffect(SDL_Haptic * haptic, struct haptic_effect *effect);
|
||||
extern int SDL_DINPUT_HapticGetEffectStatus(SDL_Haptic * haptic, struct haptic_effect *effect);
|
||||
extern int SDL_DINPUT_HapticSetGain(SDL_Haptic * haptic, int gain);
|
||||
extern int SDL_DINPUT_HapticSetAutocenter(SDL_Haptic * haptic, int autocenter);
|
||||
extern int SDL_DINPUT_HapticPause(SDL_Haptic * haptic);
|
||||
extern int SDL_DINPUT_HapticUnpause(SDL_Haptic * haptic);
|
||||
extern int SDL_DINPUT_HapticStopAll(SDL_Haptic * haptic);
|
||||
extern int SDL_DINPUT_HapticNewEffect(SDL_Haptic *haptic, struct haptic_effect *effect, SDL_HapticEffect *base);
|
||||
extern int SDL_DINPUT_HapticUpdateEffect(SDL_Haptic *haptic, struct haptic_effect *effect, SDL_HapticEffect *data);
|
||||
extern int SDL_DINPUT_HapticRunEffect(SDL_Haptic *haptic, struct haptic_effect *effect, Uint32 iterations);
|
||||
extern int SDL_DINPUT_HapticStopEffect(SDL_Haptic *haptic, struct haptic_effect *effect);
|
||||
extern void SDL_DINPUT_HapticDestroyEffect(SDL_Haptic *haptic, struct haptic_effect *effect);
|
||||
extern int SDL_DINPUT_HapticGetEffectStatus(SDL_Haptic *haptic, struct haptic_effect *effect);
|
||||
extern int SDL_DINPUT_HapticSetGain(SDL_Haptic *haptic, int gain);
|
||||
extern int SDL_DINPUT_HapticSetAutocenter(SDL_Haptic *haptic, int autocenter);
|
||||
extern int SDL_DINPUT_HapticPause(SDL_Haptic *haptic);
|
||||
extern int SDL_DINPUT_HapticUnpause(SDL_Haptic *haptic);
|
||||
extern int SDL_DINPUT_HapticStopAll(SDL_Haptic *haptic);
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -23,9 +23,9 @@
|
||||
#if SDL_HAPTIC_DINPUT || SDL_HAPTIC_XINPUT
|
||||
|
||||
#include "../SDL_syshaptic.h"
|
||||
#include "../../joystick/SDL_sysjoystick.h" /* For the real SDL_Joystick */
|
||||
#include "../../joystick/windows/SDL_windowsjoystick_c.h" /* For joystick hwdata */
|
||||
#include "../../joystick/windows/SDL_xinputjoystick_c.h" /* For xinput rumble */
|
||||
#include "../../joystick/SDL_sysjoystick.h" /* For the real SDL_Joystick */
|
||||
#include "../../joystick/windows/SDL_windowsjoystick_c.h" /* For joystick hwdata */
|
||||
#include "../../joystick/windows/SDL_xinputjoystick_c.h" /* For xinput rumble */
|
||||
|
||||
#include "SDL_windowshaptic_c.h"
|
||||
#include "SDL_dinputhaptic_c.h"
|
||||
@@ -43,14 +43,12 @@ SDL_hapticlist_item *SDL_hapticlist = NULL;
|
||||
static SDL_hapticlist_item *SDL_hapticlist_tail = NULL;
|
||||
static int numhaptics = 0;
|
||||
|
||||
|
||||
/*
|
||||
* Initializes the haptic subsystem.
|
||||
*/
|
||||
int
|
||||
SDL_SYS_HapticInit(void)
|
||||
int SDL_SYS_HapticInit(void)
|
||||
{
|
||||
JoyStick_DeviceData* device;
|
||||
JoyStick_DeviceData *device;
|
||||
|
||||
if (SDL_DINPUT_HapticInit() < 0) {
|
||||
return -1;
|
||||
@@ -75,8 +73,7 @@ SDL_SYS_HapticInit(void)
|
||||
return numhaptics;
|
||||
}
|
||||
|
||||
int
|
||||
SDL_SYS_AddHapticDevice(SDL_hapticlist_item *item)
|
||||
int SDL_SYS_AddHapticDevice(SDL_hapticlist_item *item)
|
||||
{
|
||||
if (SDL_hapticlist_tail == NULL) {
|
||||
SDL_hapticlist = SDL_hapticlist_tail = item;
|
||||
@@ -91,8 +88,7 @@ SDL_SYS_AddHapticDevice(SDL_hapticlist_item *item)
|
||||
return numhaptics;
|
||||
}
|
||||
|
||||
int
|
||||
SDL_SYS_RemoveHapticDevice(SDL_hapticlist_item *prev, SDL_hapticlist_item *item)
|
||||
int SDL_SYS_RemoveHapticDevice(SDL_hapticlist_item *prev, SDL_hapticlist_item *item)
|
||||
{
|
||||
const int retval = item->haptic ? item->haptic->index : -1;
|
||||
if (prev != NULL) {
|
||||
@@ -110,14 +106,12 @@ SDL_SYS_RemoveHapticDevice(SDL_hapticlist_item *prev, SDL_hapticlist_item *item)
|
||||
return retval;
|
||||
}
|
||||
|
||||
int
|
||||
SDL_SYS_NumHaptics(void)
|
||||
int SDL_SYS_NumHaptics(void)
|
||||
{
|
||||
return numhaptics;
|
||||
}
|
||||
|
||||
static SDL_hapticlist_item *
|
||||
HapticByDevIndex(int device_index)
|
||||
static SDL_hapticlist_item *HapticByDevIndex(int device_index)
|
||||
{
|
||||
SDL_hapticlist_item *item = SDL_hapticlist;
|
||||
|
||||
@@ -146,8 +140,7 @@ SDL_SYS_HapticName(int index)
|
||||
/*
|
||||
* Opens a haptic device for usage.
|
||||
*/
|
||||
int
|
||||
SDL_SYS_HapticOpen(SDL_Haptic * haptic)
|
||||
int SDL_SYS_HapticOpen(SDL_Haptic *haptic)
|
||||
{
|
||||
SDL_hapticlist_item *item = HapticByDevIndex(haptic->index);
|
||||
if (item->bXInputHaptic) {
|
||||
@@ -157,12 +150,10 @@ SDL_SYS_HapticOpen(SDL_Haptic * haptic)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Opens a haptic device from first mouse it finds for usage.
|
||||
*/
|
||||
int
|
||||
SDL_SYS_HapticMouse(void)
|
||||
int SDL_SYS_HapticMouse(void)
|
||||
{
|
||||
#if SDL_HAPTIC_DINPUT
|
||||
SDL_hapticlist_item *item;
|
||||
@@ -179,12 +170,10 @@ SDL_SYS_HapticMouse(void)
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Checks to see if a joystick has haptic features.
|
||||
*/
|
||||
int
|
||||
SDL_SYS_JoystickIsHaptic(SDL_Joystick * joystick)
|
||||
int SDL_SYS_JoystickIsHaptic(SDL_Joystick *joystick)
|
||||
{
|
||||
if (joystick->driver != &SDL_WINDOWS_JoystickDriver) {
|
||||
return 0;
|
||||
@@ -205,14 +194,13 @@ SDL_SYS_JoystickIsHaptic(SDL_Joystick * joystick)
|
||||
/*
|
||||
* Checks to see if the haptic device and joystick are in reality the same.
|
||||
*/
|
||||
int
|
||||
SDL_SYS_JoystickSameHaptic(SDL_Haptic * haptic, SDL_Joystick * joystick)
|
||||
int SDL_SYS_JoystickSameHaptic(SDL_Haptic *haptic, SDL_Joystick *joystick)
|
||||
{
|
||||
if (joystick->driver != &SDL_WINDOWS_JoystickDriver) {
|
||||
return 0;
|
||||
}
|
||||
if (joystick->hwdata->bXInputHaptic != haptic->hwdata->bXInputHaptic) {
|
||||
return 0; /* one is XInput, one is not; not the same device. */
|
||||
return 0; /* one is XInput, one is not; not the same device. */
|
||||
} else if (joystick->hwdata->bXInputHaptic) {
|
||||
return SDL_XINPUT_JoystickSameHaptic(haptic, joystick);
|
||||
} else {
|
||||
@@ -223,8 +211,7 @@ SDL_SYS_JoystickSameHaptic(SDL_Haptic * haptic, SDL_Joystick * joystick)
|
||||
/*
|
||||
* Opens a SDL_Haptic from a SDL_Joystick.
|
||||
*/
|
||||
int
|
||||
SDL_SYS_HapticOpenFromJoystick(SDL_Haptic * haptic, SDL_Joystick * joystick)
|
||||
int SDL_SYS_HapticOpenFromJoystick(SDL_Haptic *haptic, SDL_Joystick *joystick)
|
||||
{
|
||||
SDL_assert(joystick->driver == &SDL_WINDOWS_JoystickDriver);
|
||||
|
||||
@@ -238,8 +225,7 @@ SDL_SYS_HapticOpenFromJoystick(SDL_Haptic * haptic, SDL_Joystick * joystick)
|
||||
/*
|
||||
* Closes the haptic device.
|
||||
*/
|
||||
void
|
||||
SDL_SYS_HapticClose(SDL_Haptic * haptic)
|
||||
void SDL_SYS_HapticClose(SDL_Haptic *haptic)
|
||||
{
|
||||
if (haptic->hwdata) {
|
||||
|
||||
@@ -264,8 +250,7 @@ SDL_SYS_HapticClose(SDL_Haptic * haptic)
|
||||
/*
|
||||
* Clean up after system specific haptic stuff
|
||||
*/
|
||||
void
|
||||
SDL_SYS_HapticQuit(void)
|
||||
void SDL_SYS_HapticQuit(void)
|
||||
{
|
||||
SDL_hapticlist_item *item;
|
||||
SDL_hapticlist_item *next = NULL;
|
||||
@@ -301,9 +286,8 @@ SDL_SYS_HapticQuit(void)
|
||||
/*
|
||||
* Creates a new haptic effect.
|
||||
*/
|
||||
int
|
||||
SDL_SYS_HapticNewEffect(SDL_Haptic * haptic, struct haptic_effect *effect,
|
||||
SDL_HapticEffect * base)
|
||||
int SDL_SYS_HapticNewEffect(SDL_Haptic *haptic, struct haptic_effect *effect,
|
||||
SDL_HapticEffect *base)
|
||||
{
|
||||
int result;
|
||||
|
||||
@@ -331,10 +315,9 @@ SDL_SYS_HapticNewEffect(SDL_Haptic * haptic, struct haptic_effect *effect,
|
||||
/*
|
||||
* Updates an effect.
|
||||
*/
|
||||
int
|
||||
SDL_SYS_HapticUpdateEffect(SDL_Haptic * haptic,
|
||||
struct haptic_effect *effect,
|
||||
SDL_HapticEffect * data)
|
||||
int SDL_SYS_HapticUpdateEffect(SDL_Haptic *haptic,
|
||||
struct haptic_effect *effect,
|
||||
SDL_HapticEffect *data)
|
||||
{
|
||||
if (haptic->hwdata->bXInputHaptic) {
|
||||
return SDL_XINPUT_HapticUpdateEffect(haptic, effect, data);
|
||||
@@ -346,9 +329,8 @@ SDL_SYS_HapticUpdateEffect(SDL_Haptic * haptic,
|
||||
/*
|
||||
* Runs an effect.
|
||||
*/
|
||||
int
|
||||
SDL_SYS_HapticRunEffect(SDL_Haptic * haptic, struct haptic_effect *effect,
|
||||
Uint32 iterations)
|
||||
int SDL_SYS_HapticRunEffect(SDL_Haptic *haptic, struct haptic_effect *effect,
|
||||
Uint32 iterations)
|
||||
{
|
||||
if (haptic->hwdata->bXInputHaptic) {
|
||||
return SDL_XINPUT_HapticRunEffect(haptic, effect, iterations);
|
||||
@@ -360,8 +342,7 @@ SDL_SYS_HapticRunEffect(SDL_Haptic * haptic, struct haptic_effect *effect,
|
||||
/*
|
||||
* Stops an effect.
|
||||
*/
|
||||
int
|
||||
SDL_SYS_HapticStopEffect(SDL_Haptic * haptic, struct haptic_effect *effect)
|
||||
int SDL_SYS_HapticStopEffect(SDL_Haptic *haptic, struct haptic_effect *effect)
|
||||
{
|
||||
if (haptic->hwdata->bXInputHaptic) {
|
||||
return SDL_XINPUT_HapticStopEffect(haptic, effect);
|
||||
@@ -373,8 +354,7 @@ SDL_SYS_HapticStopEffect(SDL_Haptic * haptic, struct haptic_effect *effect)
|
||||
/*
|
||||
* Frees the effect.
|
||||
*/
|
||||
void
|
||||
SDL_SYS_HapticDestroyEffect(SDL_Haptic * haptic, struct haptic_effect *effect)
|
||||
void SDL_SYS_HapticDestroyEffect(SDL_Haptic *haptic, struct haptic_effect *effect)
|
||||
{
|
||||
if (haptic->hwdata->bXInputHaptic) {
|
||||
SDL_XINPUT_HapticDestroyEffect(haptic, effect);
|
||||
@@ -388,9 +368,8 @@ SDL_SYS_HapticDestroyEffect(SDL_Haptic * haptic, struct haptic_effect *effect)
|
||||
/*
|
||||
* Gets the status of a haptic effect.
|
||||
*/
|
||||
int
|
||||
SDL_SYS_HapticGetEffectStatus(SDL_Haptic * haptic,
|
||||
struct haptic_effect *effect)
|
||||
int SDL_SYS_HapticGetEffectStatus(SDL_Haptic *haptic,
|
||||
struct haptic_effect *effect)
|
||||
{
|
||||
if (haptic->hwdata->bXInputHaptic) {
|
||||
return SDL_XINPUT_HapticGetEffectStatus(haptic, effect);
|
||||
@@ -402,8 +381,7 @@ SDL_SYS_HapticGetEffectStatus(SDL_Haptic * haptic,
|
||||
/*
|
||||
* Sets the gain.
|
||||
*/
|
||||
int
|
||||
SDL_SYS_HapticSetGain(SDL_Haptic * haptic, int gain)
|
||||
int SDL_SYS_HapticSetGain(SDL_Haptic *haptic, int gain)
|
||||
{
|
||||
if (haptic->hwdata->bXInputHaptic) {
|
||||
return SDL_XINPUT_HapticSetGain(haptic, gain);
|
||||
@@ -415,8 +393,7 @@ SDL_SYS_HapticSetGain(SDL_Haptic * haptic, int gain)
|
||||
/*
|
||||
* Sets the autocentering.
|
||||
*/
|
||||
int
|
||||
SDL_SYS_HapticSetAutocenter(SDL_Haptic * haptic, int autocenter)
|
||||
int SDL_SYS_HapticSetAutocenter(SDL_Haptic *haptic, int autocenter)
|
||||
{
|
||||
if (haptic->hwdata->bXInputHaptic) {
|
||||
return SDL_XINPUT_HapticSetAutocenter(haptic, autocenter);
|
||||
@@ -428,8 +405,7 @@ SDL_SYS_HapticSetAutocenter(SDL_Haptic * haptic, int autocenter)
|
||||
/*
|
||||
* Pauses the device.
|
||||
*/
|
||||
int
|
||||
SDL_SYS_HapticPause(SDL_Haptic * haptic)
|
||||
int SDL_SYS_HapticPause(SDL_Haptic *haptic)
|
||||
{
|
||||
if (haptic->hwdata->bXInputHaptic) {
|
||||
return SDL_XINPUT_HapticPause(haptic);
|
||||
@@ -441,8 +417,7 @@ SDL_SYS_HapticPause(SDL_Haptic * haptic)
|
||||
/*
|
||||
* Pauses the device.
|
||||
*/
|
||||
int
|
||||
SDL_SYS_HapticUnpause(SDL_Haptic * haptic)
|
||||
int SDL_SYS_HapticUnpause(SDL_Haptic *haptic)
|
||||
{
|
||||
if (haptic->hwdata->bXInputHaptic) {
|
||||
return SDL_XINPUT_HapticUnpause(haptic);
|
||||
@@ -454,8 +429,7 @@ SDL_SYS_HapticUnpause(SDL_Haptic * haptic)
|
||||
/*
|
||||
* Stops all the playing effects on the device.
|
||||
*/
|
||||
int
|
||||
SDL_SYS_HapticStopAll(SDL_Haptic * haptic)
|
||||
int SDL_SYS_HapticStopAll(SDL_Haptic *haptic)
|
||||
{
|
||||
if (haptic->hwdata->bXInputHaptic) {
|
||||
return SDL_XINPUT_HapticStopAll(haptic);
|
||||
|
||||
@@ -40,17 +40,16 @@ struct haptic_hwdata
|
||||
#if SDL_HAPTIC_DINPUT
|
||||
LPDIRECTINPUTDEVICE8 device;
|
||||
#endif
|
||||
DWORD axes[3]; /* Axes to use. */
|
||||
SDL_bool is_joystick; /* Device is loaded as joystick. */
|
||||
Uint8 bXInputHaptic; /* Supports force feedback via XInput. */
|
||||
Uint8 userid; /* XInput userid index for this joystick */
|
||||
DWORD axes[3]; /* Axes to use. */
|
||||
SDL_bool is_joystick; /* Device is loaded as joystick. */
|
||||
Uint8 bXInputHaptic; /* Supports force feedback via XInput. */
|
||||
Uint8 userid; /* XInput userid index for this joystick */
|
||||
SDL_Thread *thread;
|
||||
SDL_mutex *mutex;
|
||||
Uint32 stopTicks;
|
||||
SDL_atomic_t stopThread;
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* Haptic system effect data.
|
||||
*/
|
||||
@@ -68,8 +67,8 @@ struct haptic_hweffect
|
||||
#endif
|
||||
|
||||
/*
|
||||
* List of available haptic devices.
|
||||
*/
|
||||
* List of available haptic devices.
|
||||
*/
|
||||
typedef struct SDL_hapticlist_item
|
||||
{
|
||||
char *name;
|
||||
@@ -79,7 +78,7 @@ typedef struct SDL_hapticlist_item
|
||||
DIDEVCAPS capabilities;
|
||||
#endif
|
||||
SDL_bool bXInputHaptic; /* Supports force feedback via XInput. */
|
||||
Uint8 userid; /* XInput userid index for this joystick */
|
||||
Uint8 userid; /* XInput userid index for this joystick */
|
||||
struct SDL_hapticlist_item *next;
|
||||
} SDL_hapticlist_item;
|
||||
|
||||
@@ -96,4 +95,3 @@ extern int SDL_SYS_RemoveHapticDevice(SDL_hapticlist_item *prev, SDL_hapticlist_
|
||||
#endif /* SDL_windowshaptic_c_h_ */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
||||
|
||||
@@ -40,9 +40,7 @@ extern "C" {
|
||||
*/
|
||||
static SDL_bool loaded_xinput = SDL_FALSE;
|
||||
|
||||
|
||||
int
|
||||
SDL_XINPUT_HapticInit(void)
|
||||
int SDL_XINPUT_HapticInit(void)
|
||||
{
|
||||
if (SDL_GetHintBoolean(SDL_HINT_XINPUT_ENABLED, SDL_TRUE)) {
|
||||
loaded_xinput = (WIN_LoadXInputDLL() == 0) ? SDL_TRUE : SDL_FALSE;
|
||||
@@ -58,8 +56,7 @@ SDL_XINPUT_HapticInit(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
SDL_XINPUT_HapticMaybeAddDevice(const DWORD dwUserid)
|
||||
int SDL_XINPUT_HapticMaybeAddDevice(const DWORD dwUserid)
|
||||
{
|
||||
const Uint8 userid = (Uint8)dwUserid;
|
||||
SDL_hapticlist_item *item;
|
||||
@@ -72,13 +69,13 @@ SDL_XINPUT_HapticMaybeAddDevice(const DWORD dwUserid)
|
||||
/* Make sure we don't already have it */
|
||||
for (item = SDL_hapticlist; item; item = item->next) {
|
||||
if (item->bXInputHaptic && item->userid == userid) {
|
||||
return -1; /* Already added */
|
||||
return -1; /* Already added */
|
||||
}
|
||||
}
|
||||
|
||||
SDL_zero(state);
|
||||
if (XINPUTSETSTATE(dwUserid, &state) != ERROR_SUCCESS) {
|
||||
return -1; /* no force feedback on this device. */
|
||||
return -1; /* no force feedback on this device. */
|
||||
}
|
||||
|
||||
item = (SDL_hapticlist_item *)SDL_malloc(sizeof(SDL_hapticlist_item));
|
||||
@@ -107,8 +104,7 @@ SDL_XINPUT_HapticMaybeAddDevice(const DWORD dwUserid)
|
||||
return SDL_SYS_AddHapticDevice(item);
|
||||
}
|
||||
|
||||
int
|
||||
SDL_XINPUT_HapticMaybeRemoveDevice(const DWORD dwUserid)
|
||||
int SDL_XINPUT_HapticMaybeRemoveDevice(const DWORD dwUserid)
|
||||
{
|
||||
const Uint8 userid = (Uint8)dwUserid;
|
||||
SDL_hapticlist_item *item;
|
||||
@@ -142,10 +138,9 @@ SDL_XINPUT_HapticMaybeRemoveDevice(const DWORD dwUserid)
|
||||
* Mostly, this is here to get rumbling to work, and all the other features
|
||||
* are absent in the XInput path for now. :(
|
||||
*/
|
||||
static int SDLCALL
|
||||
SDL_RunXInputHaptic(void *arg)
|
||||
static int SDLCALL SDL_RunXInputHaptic(void *arg)
|
||||
{
|
||||
struct haptic_hwdata *hwdata = (struct haptic_hwdata *) arg;
|
||||
struct haptic_hwdata *hwdata = (struct haptic_hwdata *)arg;
|
||||
|
||||
while (!SDL_AtomicGet(&hwdata->stopThread)) {
|
||||
SDL_Delay(50);
|
||||
@@ -164,11 +159,10 @@ SDL_RunXInputHaptic(void *arg)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
SDL_XINPUT_HapticOpenFromUserIndex(SDL_Haptic *haptic, const Uint8 userid)
|
||||
static int SDL_XINPUT_HapticOpenFromUserIndex(SDL_Haptic *haptic, const Uint8 userid)
|
||||
{
|
||||
char threadName[32];
|
||||
XINPUT_VIBRATION vibration = { 0, 0 }; /* stop any current vibration */
|
||||
XINPUT_VIBRATION vibration = { 0, 0 }; /* stop any current vibration */
|
||||
XINPUTSETSTATE(userid, &vibration);
|
||||
|
||||
haptic->supported = SDL_HAPTIC_LEFTRIGHT;
|
||||
@@ -184,9 +178,9 @@ SDL_XINPUT_HapticOpenFromUserIndex(SDL_Haptic *haptic, const Uint8 userid)
|
||||
}
|
||||
/* Clear the memory */
|
||||
SDL_memset(haptic->effects, 0,
|
||||
sizeof(struct haptic_effect) * haptic->neffects);
|
||||
sizeof(struct haptic_effect) * haptic->neffects);
|
||||
|
||||
haptic->hwdata = (struct haptic_hwdata *) SDL_malloc(sizeof(*haptic->hwdata));
|
||||
haptic->hwdata = (struct haptic_hwdata *)SDL_malloc(sizeof(*haptic->hwdata));
|
||||
if (haptic->hwdata == NULL) {
|
||||
SDL_free(haptic->effects);
|
||||
haptic->effects = NULL;
|
||||
@@ -219,20 +213,17 @@ SDL_XINPUT_HapticOpenFromUserIndex(SDL_Haptic *haptic, const Uint8 userid)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
SDL_XINPUT_HapticOpen(SDL_Haptic * haptic, SDL_hapticlist_item *item)
|
||||
int SDL_XINPUT_HapticOpen(SDL_Haptic *haptic, SDL_hapticlist_item *item)
|
||||
{
|
||||
return SDL_XINPUT_HapticOpenFromUserIndex(haptic, item->userid);
|
||||
}
|
||||
|
||||
int
|
||||
SDL_XINPUT_JoystickSameHaptic(SDL_Haptic * haptic, SDL_Joystick * joystick)
|
||||
int SDL_XINPUT_JoystickSameHaptic(SDL_Haptic *haptic, SDL_Joystick *joystick)
|
||||
{
|
||||
return haptic->hwdata->userid == joystick->hwdata->userid;
|
||||
}
|
||||
|
||||
int
|
||||
SDL_XINPUT_HapticOpenFromJoystick(SDL_Haptic * haptic, SDL_Joystick * joystick)
|
||||
int SDL_XINPUT_HapticOpenFromJoystick(SDL_Haptic *haptic, SDL_Joystick *joystick)
|
||||
{
|
||||
SDL_hapticlist_item *item;
|
||||
int index = 0;
|
||||
@@ -249,16 +240,14 @@ SDL_XINPUT_HapticOpenFromJoystick(SDL_Haptic * haptic, SDL_Joystick * joystick)
|
||||
return SDL_SetError("Couldn't find joystick in haptic device list");
|
||||
}
|
||||
|
||||
void
|
||||
SDL_XINPUT_HapticClose(SDL_Haptic * haptic)
|
||||
void SDL_XINPUT_HapticClose(SDL_Haptic *haptic)
|
||||
{
|
||||
SDL_AtomicSet(&haptic->hwdata->stopThread, 1);
|
||||
SDL_WaitThread(haptic->hwdata->thread, NULL);
|
||||
SDL_DestroyMutex(haptic->hwdata->mutex);
|
||||
}
|
||||
|
||||
void
|
||||
SDL_XINPUT_HapticQuit(void)
|
||||
void SDL_XINPUT_HapticQuit(void)
|
||||
{
|
||||
if (loaded_xinput) {
|
||||
WIN_UnloadXInputDLL();
|
||||
@@ -266,15 +255,13 @@ SDL_XINPUT_HapticQuit(void)
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
SDL_XINPUT_HapticNewEffect(SDL_Haptic * haptic, struct haptic_effect *effect, SDL_HapticEffect * base)
|
||||
int SDL_XINPUT_HapticNewEffect(SDL_Haptic *haptic, struct haptic_effect *effect, SDL_HapticEffect *base)
|
||||
{
|
||||
SDL_assert(base->type == SDL_HAPTIC_LEFTRIGHT); /* should catch this at higher level */
|
||||
SDL_assert(base->type == SDL_HAPTIC_LEFTRIGHT); /* should catch this at higher level */
|
||||
return SDL_XINPUT_HapticUpdateEffect(haptic, effect, base);
|
||||
}
|
||||
|
||||
int
|
||||
SDL_XINPUT_HapticUpdateEffect(SDL_Haptic * haptic, struct haptic_effect *effect, SDL_HapticEffect * data)
|
||||
int SDL_XINPUT_HapticUpdateEffect(SDL_Haptic *haptic, struct haptic_effect *effect, SDL_HapticEffect *data)
|
||||
{
|
||||
XINPUT_VIBRATION *vib = &effect->hweffect->vibration;
|
||||
SDL_assert(data->type == SDL_HAPTIC_LEFTRIGHT);
|
||||
@@ -282,18 +269,17 @@ SDL_XINPUT_HapticUpdateEffect(SDL_Haptic * haptic, struct haptic_effect *effect,
|
||||
vib->wLeftMotorSpeed = data->leftright.large_magnitude * 2;
|
||||
vib->wRightMotorSpeed = data->leftright.small_magnitude * 2;
|
||||
SDL_LockMutex(haptic->hwdata->mutex);
|
||||
if (haptic->hwdata->stopTicks) { /* running right now? Update it. */
|
||||
if (haptic->hwdata->stopTicks) { /* running right now? Update it. */
|
||||
XINPUTSETSTATE(haptic->hwdata->userid, vib);
|
||||
}
|
||||
SDL_UnlockMutex(haptic->hwdata->mutex);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
SDL_XINPUT_HapticRunEffect(SDL_Haptic * haptic, struct haptic_effect *effect, Uint32 iterations)
|
||||
int SDL_XINPUT_HapticRunEffect(SDL_Haptic *haptic, struct haptic_effect *effect, Uint32 iterations)
|
||||
{
|
||||
XINPUT_VIBRATION *vib = &effect->hweffect->vibration;
|
||||
SDL_assert(effect->effect.type == SDL_HAPTIC_LEFTRIGHT); /* should catch this at higher level */
|
||||
SDL_assert(effect->effect.type == SDL_HAPTIC_LEFTRIGHT); /* should catch this at higher level */
|
||||
SDL_LockMutex(haptic->hwdata->mutex);
|
||||
if (effect->effect.leftright.length == SDL_HAPTIC_INFINITY || iterations == SDL_HAPTIC_INFINITY) {
|
||||
haptic->hwdata->stopTicks = SDL_HAPTIC_INFINITY;
|
||||
@@ -302,15 +288,14 @@ SDL_XINPUT_HapticRunEffect(SDL_Haptic * haptic, struct haptic_effect *effect, Ui
|
||||
} else {
|
||||
haptic->hwdata->stopTicks = SDL_GetTicks() + (effect->effect.leftright.length * iterations);
|
||||
if ((haptic->hwdata->stopTicks == SDL_HAPTIC_INFINITY) || (haptic->hwdata->stopTicks == 0)) {
|
||||
haptic->hwdata->stopTicks = 1; /* fix edge cases. */
|
||||
haptic->hwdata->stopTicks = 1; /* fix edge cases. */
|
||||
}
|
||||
}
|
||||
SDL_UnlockMutex(haptic->hwdata->mutex);
|
||||
return (XINPUTSETSTATE(haptic->hwdata->userid, vib) == ERROR_SUCCESS) ? 0 : -1;
|
||||
}
|
||||
|
||||
int
|
||||
SDL_XINPUT_HapticStopEffect(SDL_Haptic * haptic, struct haptic_effect *effect)
|
||||
int SDL_XINPUT_HapticStopEffect(SDL_Haptic *haptic, struct haptic_effect *effect)
|
||||
{
|
||||
XINPUT_VIBRATION vibration = { 0, 0 };
|
||||
SDL_LockMutex(haptic->hwdata->mutex);
|
||||
@@ -319,44 +304,37 @@ SDL_XINPUT_HapticStopEffect(SDL_Haptic * haptic, struct haptic_effect *effect)
|
||||
return (XINPUTSETSTATE(haptic->hwdata->userid, &vibration) == ERROR_SUCCESS) ? 0 : -1;
|
||||
}
|
||||
|
||||
void
|
||||
SDL_XINPUT_HapticDestroyEffect(SDL_Haptic * haptic, struct haptic_effect *effect)
|
||||
void SDL_XINPUT_HapticDestroyEffect(SDL_Haptic *haptic, struct haptic_effect *effect)
|
||||
{
|
||||
SDL_XINPUT_HapticStopEffect(haptic, effect);
|
||||
}
|
||||
|
||||
int
|
||||
SDL_XINPUT_HapticGetEffectStatus(SDL_Haptic * haptic, struct haptic_effect *effect)
|
||||
int SDL_XINPUT_HapticGetEffectStatus(SDL_Haptic *haptic, struct haptic_effect *effect)
|
||||
{
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
|
||||
int
|
||||
SDL_XINPUT_HapticSetGain(SDL_Haptic * haptic, int gain)
|
||||
int SDL_XINPUT_HapticSetGain(SDL_Haptic *haptic, int gain)
|
||||
{
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
|
||||
int
|
||||
SDL_XINPUT_HapticSetAutocenter(SDL_Haptic * haptic, int autocenter)
|
||||
int SDL_XINPUT_HapticSetAutocenter(SDL_Haptic *haptic, int autocenter)
|
||||
{
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
|
||||
int
|
||||
SDL_XINPUT_HapticPause(SDL_Haptic * haptic)
|
||||
int SDL_XINPUT_HapticPause(SDL_Haptic *haptic)
|
||||
{
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
|
||||
int
|
||||
SDL_XINPUT_HapticUnpause(SDL_Haptic * haptic)
|
||||
int SDL_XINPUT_HapticUnpause(SDL_Haptic *haptic)
|
||||
{
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
|
||||
int
|
||||
SDL_XINPUT_HapticStopAll(SDL_Haptic * haptic)
|
||||
int SDL_XINPUT_HapticStopAll(SDL_Haptic *haptic)
|
||||
{
|
||||
XINPUT_VIBRATION vibration = { 0, 0 };
|
||||
SDL_LockMutex(haptic->hwdata->mutex);
|
||||
@@ -376,113 +354,94 @@ SDL_XINPUT_HapticStopAll(SDL_Haptic * haptic)
|
||||
|
||||
typedef struct SDL_hapticlist_item SDL_hapticlist_item;
|
||||
|
||||
int
|
||||
SDL_XINPUT_HapticInit(void)
|
||||
int SDL_XINPUT_HapticInit(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
SDL_XINPUT_HapticMaybeAddDevice(const DWORD dwUserid)
|
||||
int SDL_XINPUT_HapticMaybeAddDevice(const DWORD dwUserid)
|
||||
{
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
|
||||
int
|
||||
SDL_XINPUT_HapticMaybeRemoveDevice(const DWORD dwUserid)
|
||||
int SDL_XINPUT_HapticMaybeRemoveDevice(const DWORD dwUserid)
|
||||
{
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
|
||||
int
|
||||
SDL_XINPUT_HapticOpen(SDL_Haptic * haptic, SDL_hapticlist_item *item)
|
||||
int SDL_XINPUT_HapticOpen(SDL_Haptic *haptic, SDL_hapticlist_item *item)
|
||||
{
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
|
||||
int
|
||||
SDL_XINPUT_JoystickSameHaptic(SDL_Haptic * haptic, SDL_Joystick * joystick)
|
||||
int SDL_XINPUT_JoystickSameHaptic(SDL_Haptic *haptic, SDL_Joystick *joystick)
|
||||
{
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
|
||||
int
|
||||
SDL_XINPUT_HapticOpenFromJoystick(SDL_Haptic * haptic, SDL_Joystick * joystick)
|
||||
int SDL_XINPUT_HapticOpenFromJoystick(SDL_Haptic *haptic, SDL_Joystick *joystick)
|
||||
{
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
|
||||
void
|
||||
SDL_XINPUT_HapticClose(SDL_Haptic * haptic)
|
||||
void SDL_XINPUT_HapticClose(SDL_Haptic *haptic)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
SDL_XINPUT_HapticQuit(void)
|
||||
void SDL_XINPUT_HapticQuit(void)
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
SDL_XINPUT_HapticNewEffect(SDL_Haptic * haptic, struct haptic_effect *effect, SDL_HapticEffect * base)
|
||||
int SDL_XINPUT_HapticNewEffect(SDL_Haptic *haptic, struct haptic_effect *effect, SDL_HapticEffect *base)
|
||||
{
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
|
||||
int
|
||||
SDL_XINPUT_HapticUpdateEffect(SDL_Haptic * haptic, struct haptic_effect *effect, SDL_HapticEffect * data)
|
||||
int SDL_XINPUT_HapticUpdateEffect(SDL_Haptic *haptic, struct haptic_effect *effect, SDL_HapticEffect *data)
|
||||
{
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
|
||||
int
|
||||
SDL_XINPUT_HapticRunEffect(SDL_Haptic * haptic, struct haptic_effect *effect, Uint32 iterations)
|
||||
int SDL_XINPUT_HapticRunEffect(SDL_Haptic *haptic, struct haptic_effect *effect, Uint32 iterations)
|
||||
{
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
|
||||
int
|
||||
SDL_XINPUT_HapticStopEffect(SDL_Haptic * haptic, struct haptic_effect *effect)
|
||||
int SDL_XINPUT_HapticStopEffect(SDL_Haptic *haptic, struct haptic_effect *effect)
|
||||
{
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
|
||||
void
|
||||
SDL_XINPUT_HapticDestroyEffect(SDL_Haptic * haptic, struct haptic_effect *effect)
|
||||
void SDL_XINPUT_HapticDestroyEffect(SDL_Haptic *haptic, struct haptic_effect *effect)
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
SDL_XINPUT_HapticGetEffectStatus(SDL_Haptic * haptic, struct haptic_effect *effect)
|
||||
int SDL_XINPUT_HapticGetEffectStatus(SDL_Haptic *haptic, struct haptic_effect *effect)
|
||||
{
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
|
||||
int
|
||||
SDL_XINPUT_HapticSetGain(SDL_Haptic * haptic, int gain)
|
||||
int SDL_XINPUT_HapticSetGain(SDL_Haptic *haptic, int gain)
|
||||
{
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
|
||||
int
|
||||
SDL_XINPUT_HapticSetAutocenter(SDL_Haptic * haptic, int autocenter)
|
||||
int SDL_XINPUT_HapticSetAutocenter(SDL_Haptic *haptic, int autocenter)
|
||||
{
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
|
||||
int
|
||||
SDL_XINPUT_HapticPause(SDL_Haptic * haptic)
|
||||
int SDL_XINPUT_HapticPause(SDL_Haptic *haptic)
|
||||
{
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
|
||||
int
|
||||
SDL_XINPUT_HapticUnpause(SDL_Haptic * haptic)
|
||||
int SDL_XINPUT_HapticUnpause(SDL_Haptic *haptic)
|
||||
{
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
|
||||
int
|
||||
SDL_XINPUT_HapticStopAll(SDL_Haptic * haptic)
|
||||
int SDL_XINPUT_HapticStopAll(SDL_Haptic *haptic)
|
||||
{
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
|
||||
@@ -30,22 +30,22 @@ extern "C" {
|
||||
extern int SDL_XINPUT_HapticInit(void);
|
||||
extern int SDL_XINPUT_HapticMaybeAddDevice(const DWORD dwUserid);
|
||||
extern int SDL_XINPUT_HapticMaybeRemoveDevice(const DWORD dwUserid);
|
||||
extern int SDL_XINPUT_HapticOpen(SDL_Haptic * haptic, SDL_hapticlist_item *item);
|
||||
extern int SDL_XINPUT_JoystickSameHaptic(SDL_Haptic * haptic, SDL_Joystick * joystick);
|
||||
extern int SDL_XINPUT_HapticOpenFromJoystick(SDL_Haptic * haptic, SDL_Joystick * joystick);
|
||||
extern void SDL_XINPUT_HapticClose(SDL_Haptic * haptic);
|
||||
extern int SDL_XINPUT_HapticOpen(SDL_Haptic *haptic, SDL_hapticlist_item *item);
|
||||
extern int SDL_XINPUT_JoystickSameHaptic(SDL_Haptic *haptic, SDL_Joystick *joystick);
|
||||
extern int SDL_XINPUT_HapticOpenFromJoystick(SDL_Haptic *haptic, SDL_Joystick *joystick);
|
||||
extern void SDL_XINPUT_HapticClose(SDL_Haptic *haptic);
|
||||
extern void SDL_XINPUT_HapticQuit(void);
|
||||
extern int SDL_XINPUT_HapticNewEffect(SDL_Haptic * haptic, struct haptic_effect *effect, SDL_HapticEffect * base);
|
||||
extern int SDL_XINPUT_HapticUpdateEffect(SDL_Haptic * haptic, struct haptic_effect *effect, SDL_HapticEffect * data);
|
||||
extern int SDL_XINPUT_HapticRunEffect(SDL_Haptic * haptic, struct haptic_effect *effect, Uint32 iterations);
|
||||
extern int SDL_XINPUT_HapticStopEffect(SDL_Haptic * haptic, struct haptic_effect *effect);
|
||||
extern void SDL_XINPUT_HapticDestroyEffect(SDL_Haptic * haptic, struct haptic_effect *effect);
|
||||
extern int SDL_XINPUT_HapticGetEffectStatus(SDL_Haptic * haptic, struct haptic_effect *effect);
|
||||
extern int SDL_XINPUT_HapticSetGain(SDL_Haptic * haptic, int gain);
|
||||
extern int SDL_XINPUT_HapticSetAutocenter(SDL_Haptic * haptic, int autocenter);
|
||||
extern int SDL_XINPUT_HapticPause(SDL_Haptic * haptic);
|
||||
extern int SDL_XINPUT_HapticUnpause(SDL_Haptic * haptic);
|
||||
extern int SDL_XINPUT_HapticStopAll(SDL_Haptic * haptic);
|
||||
extern int SDL_XINPUT_HapticNewEffect(SDL_Haptic *haptic, struct haptic_effect *effect, SDL_HapticEffect *base);
|
||||
extern int SDL_XINPUT_HapticUpdateEffect(SDL_Haptic *haptic, struct haptic_effect *effect, SDL_HapticEffect *data);
|
||||
extern int SDL_XINPUT_HapticRunEffect(SDL_Haptic *haptic, struct haptic_effect *effect, Uint32 iterations);
|
||||
extern int SDL_XINPUT_HapticStopEffect(SDL_Haptic *haptic, struct haptic_effect *effect);
|
||||
extern void SDL_XINPUT_HapticDestroyEffect(SDL_Haptic *haptic, struct haptic_effect *effect);
|
||||
extern int SDL_XINPUT_HapticGetEffectStatus(SDL_Haptic *haptic, struct haptic_effect *effect);
|
||||
extern int SDL_XINPUT_HapticSetGain(SDL_Haptic *haptic, int gain);
|
||||
extern int SDL_XINPUT_HapticSetAutocenter(SDL_Haptic *haptic, int autocenter);
|
||||
extern int SDL_XINPUT_HapticPause(SDL_Haptic *haptic);
|
||||
extern int SDL_XINPUT_HapticUnpause(SDL_Haptic *haptic);
|
||||
extern int SDL_XINPUT_HapticStopAll(SDL_Haptic *haptic);
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
|
||||
Reference in New Issue
Block a user