Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Added SDL_HapticOpened().
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbens committed Jul 8, 2008
1 parent fe47286 commit e46b791
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
13 changes: 13 additions & 0 deletions include/SDL_haptic.h
Expand Up @@ -642,6 +642,18 @@ extern DECLSPEC const char *SDLCALL SDL_HapticName(int device_index);
*/
extern DECLSPEC SDL_Haptic * SDL_HapticOpen(int device_index);

/**
* \fn int SDL_HapticOpened(int device_index)
*
* \brief Checks if the haptic device at index has been opened.
*
* \param device_index Index to check to see if it has been opened.
* \return 1 if it has been opened or 0 if it hasn't.
*
* \sa SDL_HapticOpen
* \sa SDL_HapticIndex
*/
extern DECLSPEC int SDL_HapticOpened(int device_index);

/**
* \fn int SDL_HapticIndex(SDL_Haptic * haptic)
Expand All @@ -652,6 +664,7 @@ extern DECLSPEC SDL_Haptic * SDL_HapticOpen(int device_index);
* \return The index of the haptic device or -1 on error.
*
* \sa SDL_HapticOpen
* \sa SDL_HapticOpened
*/
extern DECLSPEC int SDL_HapticIndex(SDL_Haptic * haptic);

Expand Down
19 changes: 19 additions & 0 deletions src/haptic/SDL_haptic.c
Expand Up @@ -148,6 +148,25 @@ SDL_HapticOpen(int device_index)
}


/*
* Returns 1 if the device has been opened.
*/
int
SDL_HapticOpened(int device_index)
{
int i, opened;

opened = 0;
for (i=0; SDL_haptics[i]; i++) {
if (SDL_haptics[i]->index == (Uint8) device_index) {
opened = 1;
break;
}
}
return opened;
}


/*
* Returns the index to a haptic device.
*/
Expand Down

0 comments on commit e46b791

Please sign in to comment.