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