Properly quit the SDL_haptic subsystem. gsoc2008_force_feedback
authorEdgar Simo <bobbens@gmail.com>
Sun, 01 Jun 2008 18:46:51 +0000
branchgsoc2008_force_feedback
changeset 24743f80bf1528b4
parent 2473 20730743769d
child 2475 4b874e3a3a2c
Properly quit the SDL_haptic subsystem.
Added SDL_Haptic dummy driver.
configure.in
src/haptic/SDL_haptic.c
src/haptic/SDL_haptic_c.h
src/haptic/dummy/SDL_syshaptic.c
src/haptic/linux/SDL_syshaptic.c
     1.1 --- a/configure.in	Sun Jun 01 18:40:47 2008 +0000
     1.2 +++ b/configure.in	Sun Jun 01 18:46:51 2008 +0000
     1.3 @@ -2580,6 +2580,11 @@
     1.4      SOURCES="$SOURCES $srcdir/src/joystick/dummy/*.c"
     1.5    fi
     1.6  fi
     1.7 +if test x$enable_haptic = xyes; then
     1.8 +  if test x$have_haptic != xyes; then
     1.9 +    SOURCES="$SOURCES $srcdir/src/haptic/dummy/*.c"
    1.10 +  fi
    1.11 +fi
    1.12  if test x$have_cdrom != xyes; then
    1.13      if test x$enable_cdrom = xyes; then
    1.14          AC_DEFINE(SDL_CDROM_DISABLED)
     2.1 --- a/src/haptic/SDL_haptic.c	Sun Jun 01 18:40:47 2008 +0000
     2.2 +++ b/src/haptic/SDL_haptic.c	Sun Jun 01 18:46:51 2008 +0000
     2.3 @@ -125,3 +125,16 @@
     2.4     }
     2.5     return haptic;
     2.6  }
     2.7 +
     2.8 +
     2.9 +void
    2.10 +SDL_HapticQuit(void)
    2.11 +{
    2.12 +   SDL_numhaptics = 0;
    2.13 +
    2.14 +   SDL_SYS_HapticQuit();
    2.15 +   if (SDL_haptics != NULL) {
    2.16 +      SDL_free(SDL_haptics);
    2.17 +      SDL_haptics = NULL;
    2.18 +   }
    2.19 +}
     3.1 --- a/src/haptic/SDL_haptic_c.h	Sun Jun 01 18:40:47 2008 +0000
     3.2 +++ b/src/haptic/SDL_haptic_c.h	Sun Jun 01 18:46:51 2008 +0000
     3.3 @@ -31,3 +31,4 @@
     3.4  extern int SDL_HapticOpened(int device_index);
     3.5  extern int SDL_HapticIndex(struct _SDL_Haptic *haptic);
     3.6  extern void SDL_HapticClose(struct _SDL_Haptic *haptic);
     3.7 +extern void SDL_HapticQuit(void);
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/src/haptic/dummy/SDL_syshaptic.c	Sun Jun 01 18:46:51 2008 +0000
     4.3 @@ -0,0 +1,69 @@
     4.4 +/*
     4.5 +    SDL - Simple DirectMedia Layer
     4.6 +    Copyright (C) 2008 Edgar Simo
     4.7 +
     4.8 +    This library is free software; you can redistribute it and/or
     4.9 +    modify it under the terms of the GNU Lesser General Public
    4.10 +    License as published by the Free Software Foundation; either
    4.11 +    version 2.1 of the License, or (at your option) any later version.
    4.12 +
    4.13 +    This library is distributed in the hope that it will be useful,
    4.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
    4.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    4.16 +    Lesser General Public License for more details.
    4.17 +
    4.18 +    You should have received a copy of the GNU Lesser General Public
    4.19 +    License along with this library; if not, write to the Free Software
    4.20 +    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    4.21 +
    4.22 +    Sam Lantinga
    4.23 +    slouken@libsdl.org
    4.24 +*/
    4.25 +#include "SDL_config.h"
    4.26 +
    4.27 +#ifdef defined(SDL_HAPTIC_DUMMY) || defined(SDL_HAPTIC_DISABLED)
    4.28 +
    4.29 +#include "SDL_haptic.h"
    4.30 +#include "../SDL_haptic_c.h"
    4.31 +#include "../SDL_syshaptic.h"
    4.32 +
    4.33 +
    4.34 +int
    4.35 +SDL_SYS_HapticInit(void)
    4.36 +{
    4.37 +   SDL_numhaptics = 0;
    4.38 +   return (0);
    4.39 +}
    4.40 +
    4.41 +
    4.42 +const char *
    4.43 +SDL_SYS_HapticName(int index)
    4.44 +{
    4.45 +   SDL_SetError("Logic error: No haptic (force feedback) devices available");
    4.46 +   return (NULL);
    4.47 +}
    4.48 +
    4.49 +
    4.50 +int
    4.51 +SDL_SYS_HapticOpen(SDL_Haptic * haptic)
    4.52 +{
    4.53 +   SDL_SetError("Logic error: No joysticks available");
    4.54 +   return (-1);
    4.55 +}
    4.56 +
    4.57 +
    4.58 +void
    4.59 +SDL_SYS_HapticClose(SDL_Haptic * haptic)
    4.60 +{
    4.61 +   return;
    4.62 +}
    4.63 +
    4.64 +
    4.65 +void
    4.66 +SDL_SYS_HapticQuit(void)
    4.67 +{
    4.68 +   return;
    4.69 +}
    4.70 +
    4.71 +
    4.72 +#endif /* SDL_HAPTIC_DUMMY || SDL_HAPTIC_DISABLED */
     5.1 --- a/src/haptic/linux/SDL_syshaptic.c	Sun Jun 01 18:40:47 2008 +0000
     5.2 +++ b/src/haptic/linux/SDL_syshaptic.c	Sun Jun 01 18:46:51 2008 +0000
     5.3 @@ -182,4 +182,17 @@
     5.4  }
     5.5  
     5.6  
     5.7 +/* Clean up after system specific haptic stuff */
     5.8 +void
     5.9 +SDL_SYS_HapticQuit(void)
    5.10 +{
    5.11 +   int i;
    5.12 +
    5.13 +   for (i=0; SDL_hapticlist[i].fname != NULL; i++) {
    5.14 +      SDL_free(SDL_hapticlist[i].fname);
    5.15 +   }
    5.16 +   SDL_hapticlist[0].fname = NULL;
    5.17 +}
    5.18 +
    5.19 +
    5.20  #endif /* SDL_HAPTIC_LINUX */