Added SDL_HapticOpened(). gsoc2008_force_feedback
authorEdgar Simo <bobbens@gmail.com>
Tue, 08 Jul 2008 19:35:10 +0000
branchgsoc2008_force_feedback
changeset 2506ba8e99fe92c1
parent 2505 abfcba0f3bd1
child 2507 8ef1d0f4d0c1
Added SDL_HapticOpened().
include/SDL_haptic.h
src/haptic/SDL_haptic.c
     1.1 --- a/include/SDL_haptic.h	Tue Jul 08 19:23:03 2008 +0000
     1.2 +++ b/include/SDL_haptic.h	Tue Jul 08 19:35:10 2008 +0000
     1.3 @@ -642,6 +642,18 @@
     1.4   */
     1.5  extern DECLSPEC SDL_Haptic * SDL_HapticOpen(int device_index);
     1.6  
     1.7 +/**
     1.8 + * \fn int SDL_HapticOpened(int device_index)
     1.9 + *
    1.10 + * \brief Checks if the haptic device at index has been opened.
    1.11 + *
    1.12 + *    \param device_index Index to check to see if it has been opened.
    1.13 + *    \return 1 if it has been opened or 0 if it hasn't.
    1.14 + * 
    1.15 + * \sa SDL_HapticOpen
    1.16 + * \sa SDL_HapticIndex
    1.17 + */
    1.18 +extern DECLSPEC int SDL_HapticOpened(int device_index);
    1.19  
    1.20  /**
    1.21   * \fn int SDL_HapticIndex(SDL_Haptic * haptic)
    1.22 @@ -652,6 +664,7 @@
    1.23   *    \return The index of the haptic device or -1 on error.
    1.24   *
    1.25   * \sa SDL_HapticOpen
    1.26 + * \sa SDL_HapticOpened
    1.27   */
    1.28  extern DECLSPEC int SDL_HapticIndex(SDL_Haptic * haptic);
    1.29  
     2.1 --- a/src/haptic/SDL_haptic.c	Tue Jul 08 19:23:03 2008 +0000
     2.2 +++ b/src/haptic/SDL_haptic.c	Tue Jul 08 19:35:10 2008 +0000
     2.3 @@ -149,6 +149,25 @@
     2.4  
     2.5  
     2.6  /*
     2.7 + * Returns 1 if the device has been opened.
     2.8 + */
     2.9 +int
    2.10 +SDL_HapticOpened(int device_index)
    2.11 +{
    2.12 +   int i, opened;
    2.13 +
    2.14 +   opened = 0;
    2.15 +   for (i=0; SDL_haptics[i]; i++) {
    2.16 +      if (SDL_haptics[i]->index == (Uint8) device_index) {
    2.17 +         opened = 1;
    2.18 +         break;
    2.19 +      }
    2.20 +   }
    2.21 +   return opened;
    2.22 +}
    2.23 +
    2.24 +
    2.25 +/*
    2.26   * Returns the index to a haptic device.
    2.27   */
    2.28  int