Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Added SDL_HapticIndex.

  • Loading branch information
bobbens committed Jul 8, 2008
1 parent f57909c commit fe47286610f81db7a9fb2693fd16ea59f9557ef7
Showing with 46 additions and 18 deletions.
  1. +14 −0 include/SDL_haptic.h
  2. +32 −18 src/haptic/SDL_haptic.c
@@ -636,11 +636,25 @@ extern DECLSPEC const char *SDLCALL SDL_HapticName(int device_index);
* \param device_index Index of the device to open.
* \return Device identifier or NULL on error.
*
* \sa SDL_HapticIndex
* \sa SDL_HapticOpenFromJoystick
* \sa SDL_HapticClose
*/
extern DECLSPEC SDL_Haptic * SDL_HapticOpen(int device_index);


/**
* \fn int SDL_HapticIndex(SDL_Haptic * haptic)
*
* \brief Gets the index of a haptic device.
*
* \param haptic Haptic device to get the index of.
* \return The index of the haptic device or -1 on error.
*
* \sa SDL_HapticOpen
*/
extern DECLSPEC int SDL_HapticIndex(SDL_Haptic * haptic);

/**
* \fn int SDL_JoystickIsHaptic(SDL_Joystick * joystick)
*
@@ -58,6 +58,24 @@ SDL_HapticInit(void)
}


/*
* Checks to see if the haptic device is valid
*/
static int
ValidHaptic(SDL_Haptic ** haptic)
{
int valid;

if (*haptic == NULL) {
SDL_SetError("Haptic device hasn't been opened yet");
valid = 0;
} else {
valid = 1;
}
return valid;
}


/*
* Returns the number of available devices.
*/
@@ -130,6 +148,20 @@ SDL_HapticOpen(int device_index)
}


/*
* Returns the index to a haptic device.
*/
int
SDL_HapticIndex(SDL_Haptic * haptic)
{
if (!ValidHaptic(&haptic)) {
return -1;
}

return haptic->index;
}


/*
* Returns SDL_TRUE if joystick has haptic features.
*/
@@ -203,24 +235,6 @@ SDL_HapticOpenFromJoystick(SDL_Joystick * joystick)
}


/*
* Checks to see if the haptic device is valid
*/
static int
ValidHaptic(SDL_Haptic ** haptic)
{
int valid;

if (*haptic == NULL) {
SDL_SetError("Haptic device hasn't been opened yet");
valid = 0;
} else {
valid = 1;
}
return valid;
}


/*
* Closes a SDL_Haptic device.
*/

0 comments on commit fe47286

Please sign in to comment.