src/haptic/SDL_syshaptic.h
changeset 2713 0906692aa6a4
child 5360 220d3af9121f
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/haptic/SDL_syshaptic.h	Mon Aug 25 09:55:03 2008 +0000
     1.3 @@ -0,0 +1,201 @@
     1.4 +/*
     1.5 +    SDL - Simple DirectMedia Layer
     1.6 +    Copyright (C) 2008 Edgar Simo
     1.7 +
     1.8 +    This library is free software; you can redistribute it and/or
     1.9 +    modify it under the terms of the GNU Lesser General Public
    1.10 +    License as published by the Free Software Foundation; either
    1.11 +    version 2.1 of the License, or (at your option) any later version.
    1.12 +
    1.13 +    This library is distributed in the hope that it will be useful,
    1.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    1.16 +    Lesser General Public License for more details.
    1.17 +
    1.18 +    You should have received a copy of the GNU Lesser General Public
    1.19 +    License along with this library; if not, write to the Free Software
    1.20 +    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    1.21 +
    1.22 +    Sam Lantinga
    1.23 +    slouken@libsdl.org
    1.24 +*/
    1.25 +
    1.26 +#include "SDL_config.h"
    1.27 +
    1.28 +#include "SDL_haptic.h"
    1.29 +
    1.30 +
    1.31 +/*
    1.32 + * Number of haptic devices on the system.
    1.33 + */
    1.34 +extern Uint8 SDL_numhaptics;
    1.35 +
    1.36 +
    1.37 +struct haptic_effect
    1.38 +{
    1.39 +    SDL_HapticEffect effect;    /* The current event */
    1.40 +    struct haptic_hweffect *hweffect;   /* The hardware behind the event */
    1.41 +};
    1.42 +
    1.43 +/*
    1.44 + * The real SDL_Haptic struct.
    1.45 + */
    1.46 +struct _SDL_Haptic
    1.47 +{
    1.48 +    Uint8 index;                /* Stores index it is attached to */
    1.49 +
    1.50 +    struct haptic_effect *effects;      /* Allocated effects */
    1.51 +    int neffects;               /* Maximum amount of effects */
    1.52 +    int nplaying;               /* Maximum amount of effects to play at the same time */
    1.53 +    unsigned int supported;     /* Supported effects */
    1.54 +    int naxes;                  /* Number of axes on the device. */
    1.55 +
    1.56 +    struct haptic_hwdata *hwdata;       /* Driver dependent */
    1.57 +    int ref_count;              /* Count for multiple opens */
    1.58 +};
    1.59 +
    1.60 +/* 
    1.61 + * Scans the system for haptic devices.
    1.62 + *
    1.63 + * Returns 0 on success, -1 on error.
    1.64 + */
    1.65 +extern int SDL_SYS_HapticInit(void);
    1.66 +
    1.67 +/*
    1.68 + * Gets the device dependent name of the haptic device
    1.69 + */
    1.70 +extern const char *SDL_SYS_HapticName(int index);
    1.71 +
    1.72 +/*
    1.73 + * Opens the haptic device for usage.  The haptic device should have
    1.74 + * the index value set previously.
    1.75 + *
    1.76 + * Returns 0 on success, -1 on error.
    1.77 + */
    1.78 +extern int SDL_SYS_HapticOpen(SDL_Haptic * haptic);
    1.79 +
    1.80 +/*
    1.81 + * Returns the index of the haptic core pointer or -1 if none is found.
    1.82 + */
    1.83 +int SDL_SYS_HapticMouse(void);
    1.84 +
    1.85 +/*
    1.86 + * Checks to see if the joystick has haptic capabilities.
    1.87 + *
    1.88 + * Returns >0 if haptic capabilities are detected, 0 if haptic
    1.89 + * capabilities aren't detected and -1 on error.
    1.90 + */
    1.91 +extern int SDL_SYS_JoystickIsHaptic(SDL_Joystick * joystick);
    1.92 +
    1.93 +/*
    1.94 + * Opens the haptic device for usage using the same device as
    1.95 + * the joystick.
    1.96 + *
    1.97 + * Returns 0 on success, -1 on error.
    1.98 + */
    1.99 +extern int SDL_SYS_HapticOpenFromJoystick(SDL_Haptic * haptic,
   1.100 +                                          SDL_Joystick * joystick);
   1.101 +/*
   1.102 + * Checks to see if haptic device and joystick device are the same.
   1.103 + *
   1.104 + * Returns 1 if they are the same, 0 if they aren't.
   1.105 + */
   1.106 +extern int SDL_SYS_JoystickSameHaptic(SDL_Haptic * haptic,
   1.107 +                                      SDL_Joystick * joystick);
   1.108 +
   1.109 +/*
   1.110 + * Closes a haptic device after usage.
   1.111 + */
   1.112 +extern void SDL_SYS_HapticClose(SDL_Haptic * haptic);
   1.113 +
   1.114 +/*
   1.115 + * Performs a cleanup on the haptic subsystem.
   1.116 + */
   1.117 +extern void SDL_SYS_HapticQuit(void);
   1.118 +
   1.119 +/*
   1.120 + * Creates a new haptic effect on the haptic device using base
   1.121 + * as a template for the effect.
   1.122 + *
   1.123 + * Returns 0 on success, -1 on error.
   1.124 + */
   1.125 +extern int SDL_SYS_HapticNewEffect(SDL_Haptic * haptic,
   1.126 +                                   struct haptic_effect *effect,
   1.127 +                                   SDL_HapticEffect * base);
   1.128 +
   1.129 +/*
   1.130 + * Updates the haptic effect on the haptic device using data
   1.131 + * as a template.
   1.132 + *
   1.133 + * Returns 0 on success, -1 on error.
   1.134 + */
   1.135 +extern int SDL_SYS_HapticUpdateEffect(SDL_Haptic * haptic,
   1.136 +                                      struct haptic_effect *effect,
   1.137 +                                      SDL_HapticEffect * data);
   1.138 +
   1.139 +/*
   1.140 + * Runs the effect on the haptic device.
   1.141 + *
   1.142 + * Returns 0 on success, -1 on error.
   1.143 + */
   1.144 +extern int SDL_SYS_HapticRunEffect(SDL_Haptic * haptic,
   1.145 +                                   struct haptic_effect *effect,
   1.146 +                                   Uint32 iterations);
   1.147 +
   1.148 +/*
   1.149 + * Stops the effect on the haptic device.
   1.150 + *
   1.151 + * Returns 0 on success, -1 on error.
   1.152 + */
   1.153 +extern int SDL_SYS_HapticStopEffect(SDL_Haptic * haptic,
   1.154 +                                    struct haptic_effect *effect);
   1.155 +
   1.156 +/*
   1.157 + * Cleanups up the effect on the haptic device.
   1.158 + */
   1.159 +extern void SDL_SYS_HapticDestroyEffect(SDL_Haptic * haptic,
   1.160 +                                        struct haptic_effect *effect);
   1.161 +
   1.162 +/*
   1.163 + * Queries the device for the status of effect.
   1.164 + *
   1.165 + * Returns 0 if device is stopped, >0 if device is playing and
   1.166 + * -1 on error.
   1.167 + */
   1.168 +extern int SDL_SYS_HapticGetEffectStatus(SDL_Haptic * haptic,
   1.169 +                                         struct haptic_effect *effect);
   1.170 +
   1.171 +/*
   1.172 + * Sets the global gain of the haptic device.
   1.173 + *
   1.174 + * Returns 0 on success, -1 on error.
   1.175 + */
   1.176 +extern int SDL_SYS_HapticSetGain(SDL_Haptic * haptic, int gain);
   1.177 +
   1.178 +/*
   1.179 + * Sets the autocenter feature of the haptic device.
   1.180 + *
   1.181 + * Returns 0 on success, -1 on error.
   1.182 + */
   1.183 +extern int SDL_SYS_HapticSetAutocenter(SDL_Haptic * haptic, int autocenter);
   1.184 +
   1.185 +/*
   1.186 + * Pauses the haptic device.
   1.187 + *
   1.188 + * Returns 0 on success, -1 on error.
   1.189 + */
   1.190 +extern int SDL_SYS_HapticPause(SDL_Haptic * haptic);
   1.191 +
   1.192 +/*
   1.193 + * Unpauses the haptic device.
   1.194 + *
   1.195 + * Returns 0 on success, -1 on error.
   1.196 + */
   1.197 +extern int SDL_SYS_HapticUnpause(SDL_Haptic * haptic);
   1.198 +
   1.199 +/*
   1.200 + * Stops all the currently playing haptic effects on the device.
   1.201 + *
   1.202 + * Returns 0 on success, -1 on error.
   1.203 + */
   1.204 +extern int SDL_SYS_HapticStopAll(SDL_Haptic * haptic);