Commented SDL_syshaptic.h. gsoc2008_force_feedback
authorEdgar Simo <bobbens@gmail.com>
Wed, 02 Jul 2008 10:26:35 +0000
branchgsoc2008_force_feedback
changeset 249110bc7aaf5114
parent 2490 be9b206d44af
child 2492 31444718601e
Commented SDL_syshaptic.h.
Removed SDL_haptic_c.h (no private functions).
Fixed bug with SDL_HapticFromJoystick().
src/haptic/SDL_haptic.c
src/haptic/SDL_haptic_c.h
src/haptic/SDL_syshaptic.h
src/haptic/linux/SDL_syshaptic.c
     1.1 --- a/src/haptic/SDL_haptic.c	Wed Jul 02 09:52:44 2008 +0000
     1.2 +++ b/src/haptic/SDL_haptic.c	Wed Jul 02 10:26:35 2008 +0000
     1.3 @@ -21,7 +21,6 @@
     1.4  */
     1.5  #include "SDL_config.h"
     1.6  
     1.7 -#include "SDL_haptic_c.h"
     1.8  #include "SDL_syshaptic.h"
     1.9  #include "../joystick/SDL_joystick_c.h" /* For SDL_PrivateJoystickValid */
    1.10  
    1.11 @@ -173,7 +172,7 @@
    1.12  
    1.13     /* Check to see if joystick's haptic is already open */
    1.14     for (i=0; SDL_haptics[i]; i++) {
    1.15 -      if (SDL_SYS_JoystickSameHaptic(&SDL_haptics[i],joystick)) {
    1.16 +      if (SDL_SYS_JoystickSameHaptic(SDL_haptics[i],joystick)) {
    1.17           haptic = SDL_haptics[i];
    1.18           ++haptic->ref_count;
    1.19           return haptic;
     2.1 --- a/src/haptic/SDL_haptic_c.h	Wed Jul 02 09:52:44 2008 +0000
     2.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.3 @@ -1,34 +0,0 @@
     2.4 -/*
     2.5 -    SDL - Simple DirectMedia Layer
     2.6 -    Copyright (C) 2008 Edgar Simo
     2.7 -
     2.8 -    This library is free software; you can redistribute it and/or
     2.9 -    modify it under the terms of the GNU Lesser General Public
    2.10 -    License as published by the Free Software Foundation; either
    2.11 -    version 2.1 of the License, or (at your option) any later version.
    2.12 -
    2.13 -    This library is distributed in the hope that it will be useful,
    2.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
    2.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    2.16 -    Lesser General Public License for more details.
    2.17 -
    2.18 -    You should have received a copy of the GNU Lesser General Public
    2.19 -    License along with this library; if not, write to the Free Software
    2.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    2.21 -
    2.22 -    Sam Lantinga
    2.23 -    slouken@libsdl.org
    2.24 -*/
    2.25 -
    2.26 -#include "SDL_haptic.h"
    2.27 -
    2.28 -struct _SDL_Haptic;
    2.29 -
    2.30 -extern int SDL_HapticInit(void);
    2.31 -extern int SDL_NumHaptics(void);
    2.32 -extern const char * SDL_HapticName(int device_index);
    2.33 -extern struct _SDL_Haptic * SDL_HapticOpen(int device_index);
    2.34 -extern int SDL_HapticOpened(int device_index);
    2.35 -extern int SDL_HapticIndex(SDL_Haptic * haptic);
    2.36 -extern void SDL_HapticClose(SDL_Haptic * haptic);
    2.37 -extern void SDL_HapticQuit(void);
     3.1 --- a/src/haptic/SDL_syshaptic.h	Wed Jul 02 09:52:44 2008 +0000
     3.2 +++ b/src/haptic/SDL_syshaptic.h	Wed Jul 02 10:26:35 2008 +0000
     3.3 @@ -47,22 +47,116 @@
     3.4     int ref_count; /* Count for multiple opens */
     3.5  };
     3.6  
     3.7 +/* 
     3.8 + * Scans the system for haptic devices.
     3.9 + *
    3.10 + * Returns 0 on success, -1 on error.
    3.11 + */
    3.12  extern int SDL_SYS_HapticInit(void);
    3.13 +
    3.14 +/*
    3.15 + * Gets the device dependent name of the haptic device
    3.16 + */
    3.17  extern const char * SDL_SYS_HapticName(int index);
    3.18 +
    3.19 +/*
    3.20 + * Opens the haptic device for usage.  The haptic device should have
    3.21 + * the index value set previously.
    3.22 + *
    3.23 + * Returns 0 on success, -1 on error.
    3.24 + */
    3.25  extern int SDL_SYS_HapticOpen(SDL_Haptic * haptic);
    3.26 +
    3.27 +/*
    3.28 + * Checks to see if the joystick has haptic capabilities.
    3.29 + *
    3.30 + * Returns >0 if haptic capabilities are detected, 0 if haptic
    3.31 + * capabilities aren't detected and -1 on error.
    3.32 + */
    3.33 +extern int SDL_JoystickIsHaptic(SDL_Joystick * joystick);
    3.34 +
    3.35 +/*
    3.36 + * Opens the haptic device for usage using the same device as
    3.37 + * the joystick.
    3.38 + *
    3.39 + * Returns 0 on success, -1 on error.
    3.40 + */
    3.41 +extern int SDL_SYS_HapticOpenFromJoystick(SDL_Haptic * haptic,
    3.42 +                                          SDL_Joystick * joystick);
    3.43 +
    3.44 +/*
    3.45 + * Checks to see if haptic device and joystick device are the same.
    3.46 + *
    3.47 + * Returns 1 if they are the same, 0 if they aren't.
    3.48 + */
    3.49 +extern int SDL_SYS_JoystickSameHaptic(SDL_Haptic * haptic,
    3.50 +                                      SDL_Joystick * joystick);
    3.51 +
    3.52 +/*
    3.53 + * Closes a haptic device after usage.
    3.54 + */
    3.55  extern void SDL_SYS_HapticClose(SDL_Haptic * haptic);
    3.56 +
    3.57 +/*
    3.58 + * Performs a cleanup on the haptic subsystem.
    3.59 + */
    3.60  extern void SDL_SYS_HapticQuit(void);
    3.61 +
    3.62 +/*
    3.63 + * Creates a new haptic effect on the haptic device using base
    3.64 + * as a template for the effect.
    3.65 + *
    3.66 + * Returns 0 on success, -1 on error.
    3.67 + */
    3.68  extern int SDL_SYS_HapticNewEffect(SDL_Haptic * haptic,
    3.69 -      struct haptic_effect * effect, SDL_HapticEffect * base);
    3.70 +                                 struct haptic_effect * effect,
    3.71 +                                 SDL_HapticEffect * base);
    3.72 +
    3.73 +/*
    3.74 + * Updates the haptic effect on the haptic device using data
    3.75 + * as a template.
    3.76 + *
    3.77 + * Returns 0 on success, -1 on error.
    3.78 + */
    3.79  extern int SDL_SYS_HapticUpdateEffect(SDL_Haptic * haptic,
    3.80 -      struct haptic_effect * effect, SDL_HapticEffect * data);
    3.81 +                                      struct haptic_effect * effect,
    3.82 +                                      SDL_HapticEffect * data);
    3.83 +
    3.84 +/*
    3.85 + * Runs the effect on the haptic device.
    3.86 + *
    3.87 + * Returns 0 on success, -1 on error.
    3.88 + */
    3.89  extern int SDL_SYS_HapticRunEffect(SDL_Haptic * haptic,
    3.90 -      struct haptic_effect * effect);
    3.91 +                                   struct haptic_effect * effect);
    3.92 +
    3.93 +/*
    3.94 + * Stops the effect on the haptic device.
    3.95 + *
    3.96 + * Returns 0 on success, -1 on error.
    3.97 + */
    3.98  extern int SDL_SYS_HapticStopEffect(SDL_Haptic * haptic,
    3.99 -      struct haptic_effect * effect);
   3.100 +                                    struct haptic_effect * effect);
   3.101 +
   3.102 +/*
   3.103 + * Cleanups up the effect on the haptic device.
   3.104 + */
   3.105  extern void SDL_SYS_HapticDestroyEffect(SDL_Haptic * haptic,
   3.106 -      struct haptic_effect * effect);
   3.107 +                                        struct haptic_effect * effect);
   3.108 +
   3.109 +/*
   3.110 + * Sets the global gain of the haptic device.
   3.111 + *
   3.112 + * Returns 0 on success, -1 on error.
   3.113 + */
   3.114  extern int SDL_SYS_HapticSetGain(SDL_Haptic * haptic, int gain);
   3.115 -extern int SDL_SYS_HapticSetAutocenter(SDL_Haptic * haptic, int autocenter);
   3.116  
   3.117 +/*
   3.118 + * Sets the autocenter feature of the haptic device.
   3.119 + *
   3.120 + * Returns 0 on success, -1 on error.
   3.121 + */
   3.122 +extern int SDL_SYS_HapticSetAutocenter(SDL_Haptic * haptic,
   3.123 +                                       int autocenter);
   3.124  
   3.125 +
     4.1 --- a/src/haptic/linux/SDL_syshaptic.c	Wed Jul 02 09:52:44 2008 +0000
     4.2 +++ b/src/haptic/linux/SDL_syshaptic.c	Wed Jul 02 10:26:35 2008 +0000
     4.3 @@ -24,7 +24,6 @@
     4.4  #ifdef SDL_JOYSTICK_LINUX
     4.5  
     4.6  #include "SDL_haptic.h"
     4.7 -#include "../SDL_haptic_c.h"
     4.8  #include "../SDL_syshaptic.h"
     4.9  #include "SDL_joystick.h"
    4.10  #include "../../joystick/SDL_sysjoystick.h" /* For the real SDL_Joystick */