src/haptic/SDL_syshaptic.h
author Edgar Simo <bobbens@gmail.com>
Wed, 02 Jul 2008 10:26:35 +0000
branchgsoc2008_force_feedback
changeset 2491 10bc7aaf5114
parent 2488 8e2bdbccf7ff
child 2495 66c02abeef0e
permissions -rw-r--r--
Commented SDL_syshaptic.h.
Removed SDL_haptic_c.h (no private functions).
Fixed bug with SDL_HapticFromJoystick().
     1 /*
     2     SDL - Simple DirectMedia Layer
     3     Copyright (C) 2008 Edgar Simo
     4 
     5     This library is free software; you can redistribute it and/or
     6     modify it under the terms of the GNU Lesser General Public
     7     License as published by the Free Software Foundation; either
     8     version 2.1 of the License, or (at your option) any later version.
     9 
    10     This library is distributed in the hope that it will be useful,
    11     but WITHOUT ANY WARRANTY; without even the implied warranty of
    12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    13     Lesser General Public License for more details.
    14 
    15     You should have received a copy of the GNU Lesser General Public
    16     License along with this library; if not, write to the Free Software
    17     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    18 
    19     Sam Lantinga
    20     slouken@libsdl.org
    21 */
    22 
    23 #include "SDL_config.h"
    24 
    25 #include "SDL_haptic.h"
    26 
    27 
    28 struct haptic_effect
    29 {
    30    SDL_HapticEffect effect; /* The current event */
    31    struct haptic_hweffect *hweffect; /* The hardware behind the event */
    32 };
    33 
    34 /*
    35  * The real SDL_Haptic event.
    36  */
    37 struct _SDL_Haptic
    38 {  
    39    Uint8 index; /* Stores index it is attached to */
    40    const char* name; /* Stores the name of the device */
    41 
    42    struct haptic_effect *effects; /* Allocated effects */
    43    int neffects; /* Maximum amount of effects */
    44    unsigned int supported; /* Supported effects */
    45 
    46    struct haptic_hwdata *hwdata; /* Driver dependent */
    47    int ref_count; /* Count for multiple opens */
    48 };
    49 
    50 /* 
    51  * Scans the system for haptic devices.
    52  *
    53  * Returns 0 on success, -1 on error.
    54  */
    55 extern int SDL_SYS_HapticInit(void);
    56 
    57 /*
    58  * Gets the device dependent name of the haptic device
    59  */
    60 extern const char * SDL_SYS_HapticName(int index);
    61 
    62 /*
    63  * Opens the haptic device for usage.  The haptic device should have
    64  * the index value set previously.
    65  *
    66  * Returns 0 on success, -1 on error.
    67  */
    68 extern int SDL_SYS_HapticOpen(SDL_Haptic * haptic);
    69 
    70 /*
    71  * Checks to see if the joystick has haptic capabilities.
    72  *
    73  * Returns >0 if haptic capabilities are detected, 0 if haptic
    74  * capabilities aren't detected and -1 on error.
    75  */
    76 extern int SDL_JoystickIsHaptic(SDL_Joystick * joystick);
    77 
    78 /*
    79  * Opens the haptic device for usage using the same device as
    80  * the joystick.
    81  *
    82  * Returns 0 on success, -1 on error.
    83  */
    84 extern int SDL_SYS_HapticOpenFromJoystick(SDL_Haptic * haptic,
    85                                           SDL_Joystick * joystick);
    86 
    87 /*
    88  * Checks to see if haptic device and joystick device are the same.
    89  *
    90  * Returns 1 if they are the same, 0 if they aren't.
    91  */
    92 extern int SDL_SYS_JoystickSameHaptic(SDL_Haptic * haptic,
    93                                       SDL_Joystick * joystick);
    94 
    95 /*
    96  * Closes a haptic device after usage.
    97  */
    98 extern void SDL_SYS_HapticClose(SDL_Haptic * haptic);
    99 
   100 /*
   101  * Performs a cleanup on the haptic subsystem.
   102  */
   103 extern void SDL_SYS_HapticQuit(void);
   104 
   105 /*
   106  * Creates a new haptic effect on the haptic device using base
   107  * as a template for the effect.
   108  *
   109  * Returns 0 on success, -1 on error.
   110  */
   111 extern int SDL_SYS_HapticNewEffect(SDL_Haptic * haptic,
   112                                  struct haptic_effect * effect,
   113                                  SDL_HapticEffect * base);
   114 
   115 /*
   116  * Updates the haptic effect on the haptic device using data
   117  * as a template.
   118  *
   119  * Returns 0 on success, -1 on error.
   120  */
   121 extern int SDL_SYS_HapticUpdateEffect(SDL_Haptic * haptic,
   122                                       struct haptic_effect * effect,
   123                                       SDL_HapticEffect * data);
   124 
   125 /*
   126  * Runs the effect on the haptic device.
   127  *
   128  * Returns 0 on success, -1 on error.
   129  */
   130 extern int SDL_SYS_HapticRunEffect(SDL_Haptic * haptic,
   131                                    struct haptic_effect * effect);
   132 
   133 /*
   134  * Stops the effect on the haptic device.
   135  *
   136  * Returns 0 on success, -1 on error.
   137  */
   138 extern int SDL_SYS_HapticStopEffect(SDL_Haptic * haptic,
   139                                     struct haptic_effect * effect);
   140 
   141 /*
   142  * Cleanups up the effect on the haptic device.
   143  */
   144 extern void SDL_SYS_HapticDestroyEffect(SDL_Haptic * haptic,
   145                                         struct haptic_effect * effect);
   146 
   147 /*
   148  * Sets the global gain of the haptic device.
   149  *
   150  * Returns 0 on success, -1 on error.
   151  */
   152 extern int SDL_SYS_HapticSetGain(SDL_Haptic * haptic, int gain);
   153 
   154 /*
   155  * Sets the autocenter feature of the haptic device.
   156  *
   157  * Returns 0 on success, -1 on error.
   158  */
   159 extern int SDL_SYS_HapticSetAutocenter(SDL_Haptic * haptic,
   160                                        int autocenter);
   161 
   162