src/haptic/SDL_syshaptic.h
author Sam Lantinga <slouken@libsdl.org>
Mon, 07 Jul 2014 10:26:28 -0700
changeset 8976 1a5d959d7b32
parent 8176 9efac2fd6ed6
child 9272 5c894fec85b9
permissions -rw-r--r--
Fixed mingw64 build and warnings
     1 /*
     2   Simple DirectMedia Layer
     3   Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
     4 
     5   This software is provided 'as-is', without any express or implied
     6   warranty.  In no event will the authors be held liable for any damages
     7   arising from the use of this software.
     8 
     9   Permission is granted to anyone to use this software for any purpose,
    10   including commercial applications, and to alter it and redistribute it
    11   freely, subject to the following restrictions:
    12 
    13   1. The origin of this software must not be misrepresented; you must not
    14      claim that you wrote the original software. If you use this software
    15      in a product, an acknowledgment in the product documentation would be
    16      appreciated but is not required.
    17   2. Altered source versions must be plainly marked as such, and must not be
    18      misrepresented as being the original software.
    19   3. This notice may not be removed or altered from any source distribution.
    20 */
    21 
    22 #include "../SDL_internal.h"
    23 
    24 #ifndef _SDL_syshaptic_h
    25 #define _SDL_syshaptic_h
    26 
    27 #include "SDL_haptic.h"
    28 
    29 
    30 /*
    31  * Number of haptic devices on the system.
    32  */
    33 extern Uint8 SDL_numhaptics;
    34 
    35 
    36 struct haptic_effect
    37 {
    38     SDL_HapticEffect effect;    /* The current event */
    39     struct haptic_hweffect *hweffect;   /* The hardware behind the event */
    40 };
    41 
    42 /*
    43  * The real SDL_Haptic struct.
    44  */
    45 struct _SDL_Haptic
    46 {
    47     Uint8 index;                /* Stores index it is attached to */
    48 
    49     struct haptic_effect *effects;      /* Allocated effects */
    50     int neffects;               /* Maximum amount of effects */
    51     int nplaying;               /* Maximum amount of effects to play at the same time */
    52     unsigned int supported;     /* Supported effects */
    53     int naxes;                  /* Number of axes on the device. */
    54 
    55     struct haptic_hwdata *hwdata;       /* Driver dependent */
    56     int ref_count;              /* Count for multiple opens */
    57 
    58     int rumble_id;              /* ID of rumble effect for simple rumble API. */
    59     SDL_HapticEffect rumble_effect; /* Rumble effect. */
    60     struct _SDL_Haptic *next; /* pointer to next haptic we have allocated */
    61 };
    62 
    63 /*
    64  * Scans the system for haptic devices.
    65  *
    66  * Returns number of devices on success, -1 on error.
    67  */
    68 extern int SDL_SYS_HapticInit(void);
    69 
    70 /* Function to return the number of haptic devices plugged in right now */
    71 extern int SDL_SYS_NumHaptics();
    72 
    73 /*
    74  * Gets the device dependent name of the haptic device
    75  */
    76 extern const char *SDL_SYS_HapticName(int index);
    77 
    78 /*
    79  * Opens the haptic device for usage.  The haptic device should have
    80  * the index value set previously.
    81  *
    82  * Returns 0 on success, -1 on error.
    83  */
    84 extern int SDL_SYS_HapticOpen(SDL_Haptic * haptic);
    85 
    86 /*
    87  * Returns the index of the haptic core pointer or -1 if none is found.
    88  */
    89 int SDL_SYS_HapticMouse(void);
    90 
    91 /*
    92  * Checks to see if the joystick has haptic capabilities.
    93  *
    94  * Returns >0 if haptic capabilities are detected, 0 if haptic
    95  * capabilities aren't detected and -1 on error.
    96  */
    97 extern int SDL_SYS_JoystickIsHaptic(SDL_Joystick * joystick);
    98 
    99 /*
   100  * Opens the haptic device for usage using the same device as
   101  * the joystick.
   102  *
   103  * Returns 0 on success, -1 on error.
   104  */
   105 extern int SDL_SYS_HapticOpenFromJoystick(SDL_Haptic * haptic,
   106                                           SDL_Joystick * joystick);
   107 /*
   108  * Checks to see if haptic device and joystick device are the same.
   109  *
   110  * Returns 1 if they are the same, 0 if they aren't.
   111  */
   112 extern int SDL_SYS_JoystickSameHaptic(SDL_Haptic * haptic,
   113                                       SDL_Joystick * joystick);
   114 
   115 /*
   116  * Closes a haptic device after usage.
   117  */
   118 extern void SDL_SYS_HapticClose(SDL_Haptic * haptic);
   119 
   120 /*
   121  * Performs a cleanup on the haptic subsystem.
   122  */
   123 extern void SDL_SYS_HapticQuit(void);
   124 
   125 /*
   126  * Creates a new haptic effect on the haptic device using base
   127  * as a template for the effect.
   128  *
   129  * Returns 0 on success, -1 on error.
   130  */
   131 extern int SDL_SYS_HapticNewEffect(SDL_Haptic * haptic,
   132                                    struct haptic_effect *effect,
   133                                    SDL_HapticEffect * base);
   134 
   135 /*
   136  * Updates the haptic effect on the haptic device using data
   137  * as a template.
   138  *
   139  * Returns 0 on success, -1 on error.
   140  */
   141 extern int SDL_SYS_HapticUpdateEffect(SDL_Haptic * haptic,
   142                                       struct haptic_effect *effect,
   143                                       SDL_HapticEffect * data);
   144 
   145 /*
   146  * Runs the effect on the haptic device.
   147  *
   148  * Returns 0 on success, -1 on error.
   149  */
   150 extern int SDL_SYS_HapticRunEffect(SDL_Haptic * haptic,
   151                                    struct haptic_effect *effect,
   152                                    Uint32 iterations);
   153 
   154 /*
   155  * Stops the effect on the haptic device.
   156  *
   157  * Returns 0 on success, -1 on error.
   158  */
   159 extern int SDL_SYS_HapticStopEffect(SDL_Haptic * haptic,
   160                                     struct haptic_effect *effect);
   161 
   162 /*
   163  * Cleanups up the effect on the haptic device.
   164  */
   165 extern void SDL_SYS_HapticDestroyEffect(SDL_Haptic * haptic,
   166                                         struct haptic_effect *effect);
   167 
   168 /*
   169  * Queries the device for the status of effect.
   170  *
   171  * Returns 0 if device is stopped, >0 if device is playing and
   172  * -1 on error.
   173  */
   174 extern int SDL_SYS_HapticGetEffectStatus(SDL_Haptic * haptic,
   175                                          struct haptic_effect *effect);
   176 
   177 /*
   178  * Sets the global gain of the haptic device.
   179  *
   180  * Returns 0 on success, -1 on error.
   181  */
   182 extern int SDL_SYS_HapticSetGain(SDL_Haptic * haptic, int gain);
   183 
   184 /*
   185  * Sets the autocenter feature of the haptic device.
   186  *
   187  * Returns 0 on success, -1 on error.
   188  */
   189 extern int SDL_SYS_HapticSetAutocenter(SDL_Haptic * haptic, int autocenter);
   190 
   191 /*
   192  * Pauses the haptic device.
   193  *
   194  * Returns 0 on success, -1 on error.
   195  */
   196 extern int SDL_SYS_HapticPause(SDL_Haptic * haptic);
   197 
   198 /*
   199  * Unpauses the haptic device.
   200  *
   201  * Returns 0 on success, -1 on error.
   202  */
   203 extern int SDL_SYS_HapticUnpause(SDL_Haptic * haptic);
   204 
   205 /*
   206  * Stops all the currently playing haptic effects on the device.
   207  *
   208  * Returns 0 on success, -1 on error.
   209  */
   210 extern int SDL_SYS_HapticStopAll(SDL_Haptic * haptic);
   211 
   212 #endif /* _SDL_syshaptic_h */
   213 
   214 /* vi: set ts=4 sw=4 expandtab: */
   215