include/SDL_haptic.h
author Edgar Simo <bobbens@gmail.com>
Sun, 06 Jul 2008 20:41:00 +0000
branchgsoc2008_force_feedback
changeset 2499 cc2b270608b2
parent 2498 ab567bd667bf
child 2500 5251d0510b7e
permissions -rw-r--r--
Created SDL_HapticDirection.
Fixed all doxygen errors.
Added more diagrams and documentation.
bobbens@2472
     1
/*
bobbens@2472
     2
    SDL - Simple DirectMedia Layer
bobbens@2472
     3
    Copyright (C) 2008 Edgar Simo
bobbens@2472
     4
bobbens@2472
     5
    This library is free software; you can redistribute it and/or
bobbens@2472
     6
    modify it under the terms of the GNU Lesser General Public
bobbens@2472
     7
    License as published by the Free Software Foundation; either
bobbens@2472
     8
    version 2.1 of the License, or (at your option) any later version.
bobbens@2472
     9
bobbens@2472
    10
    This library is distributed in the hope that it will be useful,
bobbens@2472
    11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
bobbens@2472
    12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
bobbens@2472
    13
    Lesser General Public License for more details.
bobbens@2472
    14
bobbens@2472
    15
    You should have received a copy of the GNU Lesser General Public
bobbens@2472
    16
    License along with this library; if not, write to the Free Software
bobbens@2472
    17
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
bobbens@2472
    18
bobbens@2472
    19
    Sam Lantinga
bobbens@2472
    20
    slouken@libsdl.org
bobbens@2472
    21
*/
bobbens@2472
    22
bobbens@2472
    23
/**
bobbens@2499
    24
 * \file SDL_haptic.h
bobbens@2472
    25
 *
bobbens@2498
    26
 * \brief The SDL Haptic subsystem allows you to control haptic (force feedback)
bobbens@2497
    27
 *  devices.
bobbens@2497
    28
 *
bobbens@2497
    29
 * The basic usage is as follows:
bobbens@2497
    30
 *   - Initialize the Subsystem (SDL_INIT_HAPTIC).
bobbens@2497
    31
 *   - Open a Haptic Device.
bobbens@2497
    32
 *     - SDL_HapticOpen(...) to open from index.
bobbens@2497
    33
 *     - SDL_HapticOpenFromJoystick(...) to open from an existing joystick.
bobbens@2497
    34
 *   - Create an effect (SDL_HapticEffect).
bobbens@2497
    35
 *   - Upload the effect with SDL_HapticNewEffect(...).
bobbens@2497
    36
 *   - Run the effect with SDL_HapticRunEffect(...).
bobbens@2497
    37
 *   - (optional) Free the effect with SDL_HapticDestroyEffect(...).
bobbens@2497
    38
 *   - Close the haptic device with SDL_HapticClose(...).
bobbens@2497
    39
 *
bobbens@2497
    40
 *
bobbens@2497
    41
 * Example:
bobbens@2497
    42
 *
bobbens@2497
    43
 * \code
bobbens@2497
    44
 * int test_haptic( SDL_Joystick * joystick ) {
bobbens@2497
    45
 *    SDL_Haptic *haptic;
bobbens@2497
    46
 *    SDL_HapticEffect effect;
bobbens@2497
    47
 *    int effect_id;
bobbens@2497
    48
 *
bobbens@2497
    49
 *    // Open the device
bobbens@2497
    50
 *    haptic = SDL_HapticOpenFromJoystick( joystick );
bobbens@2497
    51
 *    if (haptic == NULL) return -1; // Most likely joystick isn't haptic
bobbens@2497
    52
 *
bobbens@2497
    53
 *    // See if it can do sine waves
bobbens@2497
    54
 *    if ((SDL_HapticQueryEffects(haptic) & SDL_HAPTIC_SINE)==0) {
bobbens@2497
    55
 *       SDL_HapticClose(haptic); // No sine effect
bobbens@2497
    56
 *       return -1;
bobbens@2497
    57
 *    }
bobbens@2497
    58
 *
bobbens@2497
    59
 *    // Create the effect
bobbens@2497
    60
 *    memset( &effect, 0, sizeof(SDL_HapticEffect) ); // 0 is safe default
bobbens@2497
    61
 *    effect.type = SDL_HAPTIC_SINE;
bobbens@2499
    62
 *    effect.periodic.direction.type = SDL_HAPTIC_POLAR; // Polar coordinates
bobbens@2499
    63
 *    effect.periodic.direction.dir[0] = 180000; // Force comes from south
bobbens@2497
    64
 *    effect.periodic.period = 1000; // 1000 ms
bobbens@2497
    65
 *    effect.periodic.magnitude = 20000; // 20000/32767 strength
bobbens@2497
    66
 *    effect.periodic.length = 5000; // 5 seconds long
bobbens@2497
    67
 *    effect.periodic.attack_length = 1000; // Takes 1 second to get max strength
bobbens@2497
    68
 *    effect.periodic.fade_length = 1000; // Takes 1 second to fade away
bobbens@2497
    69
 *
bobbens@2497
    70
 *    // Upload the effect
bobbens@2497
    71
 *    effect_id = SDL_HapticNewEffect( haptic, &effect );
bobbens@2497
    72
 *
bobbens@2497
    73
 *    // Test the effect
bobbens@2497
    74
 *    SDL_HapticRunEffect( haptic, effect_id );
bobbens@2497
    75
 *    SDL_Delay( 5000); // Wait for the effect to finish
bobbens@2497
    76
 *
bobbens@2497
    77
 *    // We destroy the effect, although closing the device also does this
bobbens@2497
    78
 *    SDL_HapticDestroyEffect( haptic, effect_id );
bobbens@2497
    79
 *
bobbens@2497
    80
 *    // Close the device
bobbens@2497
    81
 *    SDL_HapticClose(haptic);
bobbens@2497
    82
 *
bobbens@2497
    83
 *    return 0; // Success
bobbens@2497
    84
 * }
bobbens@2497
    85
 * \endcode
bobbens@2497
    86
 *
bobbens@2497
    87
 * \author Edgar Simo Serra
bobbens@2472
    88
 */
bobbens@2472
    89
bobbens@2472
    90
#ifndef _SDL_haptic_h
bobbens@2472
    91
#define _SDL_haptic_h
bobbens@2472
    92
bobbens@2472
    93
#include "SDL_stdinc.h"
bobbens@2472
    94
#include "SDL_error.h"
bobbens@2489
    95
#include "SDL_joystick.h"
bobbens@2472
    96
bobbens@2472
    97
#include "begin_code.h"
bobbens@2472
    98
/* Set up for C function definitions, even when using C++ */
bobbens@2472
    99
#ifdef __cplusplus
bobbens@2472
   100
/* *INDENT-OFF* */
bobbens@2472
   101
extern "C" {
bobbens@2472
   102
   /* *INDENT-ON* */                                                         
bobbens@2497
   103
#endif /* __cpluspuls */
bobbens@2472
   104
bobbens@2497
   105
/**
bobbens@2498
   106
 * \typedef SDL_Haptic
bobbens@2497
   107
 *
bobbens@2497
   108
 * \brief The haptic structure used to identify an SDL haptic.
bobbens@2497
   109
 *
bobbens@2497
   110
 * \sa SDL_HapticOpen
bobbens@2497
   111
 * \sa SDL_HapticOpenFromJoystick
bobbens@2497
   112
 * \sa SDL_HapticClose
bobbens@2497
   113
 */
bobbens@2472
   114
struct _SDL_Haptic;                                                     
bobbens@2472
   115
typedef struct _SDL_Haptic SDL_Haptic;
bobbens@2472
   116
bobbens@2472
   117
bobbens@2495
   118
/*
bobbens@2495
   119
 * Different haptic features a device can have.
bobbens@2495
   120
 */
bobbens@2497
   121
/**
bobbens@2497
   122
 * \def SDL_HAPTIC_CONSTANT
bobbens@2497
   123
 *
bobbens@2497
   124
 * \brief Constant haptic effect.
bobbens@2497
   125
 *
bobbens@2497
   126
 * \sa SDL_HapticCondition
bobbens@2497
   127
 */
bobbens@2495
   128
#define SDL_HAPTIC_CONSTANT   (1<<0) /* Constant effect supported */
bobbens@2497
   129
/**
bobbens@2497
   130
 * \def SDL_HAPTIC_SINE
bobbens@2497
   131
 *
bobbens@2497
   132
 * \brief Periodic haptic effect that simulates sine waves.
bobbens@2497
   133
 *
bobbens@2497
   134
 * \sa SDL_HapticPeriodic
bobbens@2497
   135
 */
bobbens@2495
   136
#define SDL_HAPTIC_SINE       (1<<1) /* Sine wave effect supported */
bobbens@2497
   137
/**
bobbens@2497
   138
 * \def SDL_HAPTIC_SQUARE
bobbens@2497
   139
 *
bobbens@2497
   140
 * \brief Periodic haptic effect that simulates square waves.
bobbens@2499
   141
 * 
bobbens@2497
   142
 * \sa SDL_HapticPeriodic
bobbens@2497
   143
 */
bobbens@2495
   144
#define SDL_HAPTIC_SQUARE     (1<<2) /* Square wave effect supported */
bobbens@2497
   145
/**
bobbens@2497
   146
 * \def SDL_HAPTIC_TRIANGLE
bobbens@2497
   147
 *
bobbens@2497
   148
 * \brief Periodic haptic effect that simulates triangular waves.
bobbens@2497
   149
 *
bobbens@2497
   150
 * \sa SDL_HapticPeriodic
bobbens@2497
   151
 */
bobbens@2495
   152
#define SDL_HAPTIC_TRIANGLE   (1<<3) /* Triangle wave effect supported */
bobbens@2497
   153
/**
bobbens@2497
   154
 * \def SDL_HAPTIC_SAWTOOTHUP
bobbens@2497
   155
 *
bobbens@2497
   156
 * \brief Periodic haptic effect that simulates saw tooth up waves.
bobbens@2497
   157
 *
bobbens@2497
   158
 * \sa SDL_HapticPeriodic
bobbens@2497
   159
 */
bobbens@2495
   160
#define SDL_HAPTIC_SAWTOOTHUP (1<<4) /* Sawtoothup wave effect supported */
bobbens@2497
   161
/**
bobbens@2497
   162
 * \def SDL_HAPTIC_SAWTOOTHDOWN
bobbens@2497
   163
 *
bobbens@2497
   164
 * \brief Periodic haptic effect that simulates saw tooth down waves.
bobbens@2497
   165
 *
bobbens@2497
   166
 * \sa SDL_HapticPeriodic
bobbens@2497
   167
 */
bobbens@2495
   168
#define SDL_HAPTIC_SAWTOOTHDOWN (1<<5) /* Sawtoothdown wave effect supported */
bobbens@2497
   169
/**
bobbens@2497
   170
 * \def SDL_HAPTIC_RAMP
bobbens@2497
   171
 *
bobbens@2497
   172
 * \brief Ramp haptic effect.
bobbens@2497
   173
 *
bobbens@2497
   174
 * \sa SDL_HapticRamp
bobbens@2497
   175
 */
bobbens@2495
   176
#define SDL_HAPTIC_RAMP       (1<<6) /* Ramp effect supported */
bobbens@2497
   177
/**
bobbens@2497
   178
 * \def SDL_HAPTIC_SPRING
bobbens@2497
   179
 *
bobbens@2497
   180
 * \brief Condition haptic effect that simulates a spring.  Effect is based on the
bobbens@2497
   181
 * axes position.
bobbens@2497
   182
 *
bobbens@2497
   183
 * \sa SDL_HapticCondition
bobbens@2497
   184
 */
bobbens@2495
   185
#define SDL_HAPTIC_SPRING     (1<<7) /* Spring effect supported - uses axes position */
bobbens@2497
   186
/**
bobbens@2497
   187
 * \def SDL_HAPTIC_DAMPER
bobbens@2497
   188
 *
bobbens@2497
   189
 * \brief Condition haptic effect that simulates dampening.  Effect is based on the
bobbens@2497
   190
 * axes velocity.
bobbens@2497
   191
 *
bobbens@2497
   192
 * \sa SDL_HapticCondition
bobbens@2497
   193
 */
bobbens@2495
   194
#define SDL_HAPTIC_DAMPER     (1<<8) /* Damper effect supported - uses axes velocity */
bobbens@2497
   195
/**
bobbens@2497
   196
 * \def SDL_HAPTIC_INERTIA
bobbens@2497
   197
 *
bobbens@2497
   198
 * \brief Condition haptic effect that simulates inertia.  Effect is based on the axes
bobbens@2497
   199
 * acceleration.
bobbens@2497
   200
 *
bobbens@2497
   201
 * \sa SDL_HapticCondition
bobbens@2497
   202
 */
bobbens@2495
   203
#define SDL_HAPTIC_INERTIA    (1<<9) /* Inertia effect supported - uses axes acceleration */
bobbens@2497
   204
/**
bobbens@2497
   205
 * \def SDL_HAPTIC_FRICTION
bobbens@2497
   206
 *
bobbens@2497
   207
 * \brief Condition haptic effect that simulates friction.  Effect is based on the axes
bobbens@2497
   208
 * movement.
bobbens@2497
   209
 *
bobbens@2497
   210
 * \sa SDL_HapticCondition
bobbens@2497
   211
 */
bobbens@2495
   212
#define SDL_HAPTIC_FRICTION   (1<<10) /* Friction effect supported - uses axes movement */
bobbens@2497
   213
/**
bobbens@2497
   214
 * \def SDL_HAPTIC_CUSTOM
bobbens@2497
   215
 *
bobbens@2497
   216
 * \brief User defined custom haptic effect. TODO.
bobbens@2497
   217
 */
bobbens@2495
   218
#define SDL_HAPTIC_CUSTOM     (1<<11) /* Custom effect is supported */
bobbens@2487
   219
/* These last two are features the device has, not effects */
bobbens@2497
   220
/**
bobbens@2497
   221
 * \def SDL_HAPTIC_GAIN
bobbens@2497
   222
 *
bobbens@2497
   223
 * \brief Device supports setting the global gain.
bobbens@2497
   224
 *
bobbens@2497
   225
 * \sa SDL_HapticSetGain
bobbens@2497
   226
 */
bobbens@2495
   227
#define SDL_HAPTIC_GAIN       (1<<12) /* Device can set global gain */
bobbens@2497
   228
/**
bobbens@2497
   229
 * \def SDL_HAPTIC_AUTOCENTER
bobbens@2497
   230
 *
bobbens@2497
   231
 * \brief Device supports setting autocenter.
bobbens@2497
   232
 *
bobbens@2497
   233
 * \sa SDL_HapticSetAutocenter
bobbens@2497
   234
 */
bobbens@2495
   235
#define SDL_HAPTIC_AUTOCENTER (1<<13) /* Device can set autocenter */
bobbens@2497
   236
/**
bobbens@2497
   237
 * \def SDL_HAPTIC_STATUS
bobbens@2497
   238
 *
bobbens@2497
   239
 * \brief Device can be queried for effect status.
bobbens@2497
   240
 *
bobbens@2497
   241
 * \sa SDL_HapticGetEffectStatus
bobbens@2497
   242
 */
bobbens@2495
   243
#define SDL_HAPTIC_STATUS     (1<<14) /* Device can be queried for effect status */
bobbens@2481
   244
bobbens@2481
   245
bobbens@2499
   246
/*
bobbens@2499
   247
 * Direction encodings
bobbens@2499
   248
 */
bobbens@2499
   249
/**
bobbens@2499
   250
 * \def SDL_HAPTIC_POLAR
bobbens@2499
   251
 *
bobbens@2499
   252
 * \brief Uses polar coordinates for the direction.
bobbens@2499
   253
 *
bobbens@2499
   254
 * \sa SDL_HapticDirection
bobbens@2499
   255
 */
bobbens@2499
   256
#define SDL_HAPTIC_POLAR      0
bobbens@2499
   257
/**
bobbens@2499
   258
 * \def SDL_HAPTIC_CARTESIAN
bobbens@2499
   259
 *
bobbens@2499
   260
 * \brief Uses cartesian coordinates for the direction.
bobbens@2499
   261
 *
bobbens@2499
   262
 * \sa SDL_HapticDirection
bobbens@2499
   263
 */
bobbens@2499
   264
#define SDL_HAPTIC_CARTESIAN  1
bobbens@2499
   265
bobbens@2499
   266
bobbens@2499
   267
/**
bobbens@2499
   268
 * \struct SDL_HapticDirection
bobbens@2499
   269
 *
bobbens@2499
   270
 * \brief Structure that represents a haptic direction.
bobbens@2499
   271
 *
bobbens@2499
   272
 * Directions can be specified by:
bobbens@2499
   273
 *   - SDL_HAPTIC_POLAR: Specified by polar coordinates.
bobbens@2499
   274
 *   - SDL_HAPTIC_CARTESIAN: Specified by cartesian coordinates.
bobbens@2499
   275
 *
bobbens@2499
   276
 * Cardinal directions of the haptic device are relative to the positioning
bobbens@2499
   277
 *  of the device.  North is considered to be away from the user.
bobbens@2499
   278
 *
bobbens@2499
   279
 * The following diagram represents the cardinal directions:
bobbens@2499
   280
 * \code
bobbens@2499
   281
 *            .--.
bobbens@2499
   282
 *            |__| .-------.
bobbens@2499
   283
 *            |=.| |.-----.|
bobbens@2499
   284
 *            |--| ||     ||
bobbens@2499
   285
 *            |  | |'-----'|
bobbens@2499
   286
 *            |__|~')_____('
bobbens@2499
   287
 *              [ COMPUTER ]
bobbens@2499
   288
 *
bobbens@2499
   289
 *
bobbens@2499
   290
 *                  North (-1)
bobbens@2499
   291
 *                    ^
bobbens@2499
   292
 *                    |
bobbens@2499
   293
 *                    |
bobbens@2499
   294
 * (1)  East <----[ HAPTIC ]----> West (-1)
bobbens@2499
   295
 *                    |
bobbens@2499
   296
 *                    |
bobbens@2499
   297
 *                    v
bobbens@2499
   298
 *                  South (1)
bobbens@2499
   299
 *
bobbens@2499
   300
 *
bobbens@2499
   301
 *                 [ USER ]
bobbens@2499
   302
 *                   \|||/
bobbens@2499
   303
 *                   (o o)
bobbens@2499
   304
 *             ---ooO-(_)-Ooo---
bobbens@2499
   305
 * \endcode
bobbens@2499
   306
 *
bobbens@2499
   307
 * If type is SDL_HAPTIC_POLAR, direction is encoded by hundredths of a 
bobbens@2499
   308
 *  degree starting north and turning clockwise.  The cardinal directions would be:
bobbens@2499
   309
 *   - North: 0 (0 degrees)
bobbens@2499
   310
 *   - West: 9000 (90 degrees)
bobbens@2499
   311
 *   - South: 18000 (180 degrees)
bobbens@2499
   312
 *   - East: 27000 (270 degrees)
bobbens@2499
   313
 *
bobbens@2499
   314
 * If type is SDL_HAPTIC_CARTESIAN, direction is encoded by position.
bobbens@2499
   315
 *  The cardinal directions would be:
bobbens@2499
   316
 *   - North:  0,-1
bobbens@2499
   317
 *   - West:  -1, 0
bobbens@2499
   318
 *   - South:  0, 1
bobbens@2499
   319
 *   - East:   1, 0
bobbens@2499
   320
 *
bobbens@2499
   321
 *
bobbens@2499
   322
 * Example:
bobbens@2499
   323
 * \code
bobbens@2499
   324
 * SDL_HapticDirection direction;
bobbens@2499
   325
 *
bobbens@2499
   326
 * direction.type = SDL_HAPTIC_POLAR; // We'll be using polar direction encoding.
bobbens@2499
   327
 * direction.dir = 180000; // Force comes from the south meaning the user will
bobbens@2499
   328
 *                         // have to pull the stick to counteract.
bobbens@2499
   329
 * \endcode
bobbens@2499
   330
 *
bobbens@2499
   331
 * \sa SDL_HAPTIC_POLAR
bobbens@2499
   332
 * \sa SDL_HAPTIC_CARTESIAN
bobbens@2499
   333
 * \sa SDL_HapticEffect
bobbens@2499
   334
 */
bobbens@2499
   335
typedef struct SDL_HapticDirection {
bobbens@2499
   336
   Uint8 type; /**< The type of encoding. */
bobbens@2499
   337
   Uint16 dir[2]; /**< The encoded direction. */
bobbens@2499
   338
} SDL_HapticDirection;
bobbens@2499
   339
bobbens@2499
   340
bobbens@2497
   341
/**
bobbens@2497
   342
 * \struct SDL_HapticConstant
bobbens@2497
   343
 *
bobbens@2497
   344
 * \brief A structure containing a template for a Constant effect.
bobbens@2497
   345
 *
bobbens@2497
   346
 * The struct is exclusive to the SDL_HAPTIC_CONSTANT effect.
bobbens@2497
   347
 *
bobbens@2497
   348
 * \sa SDL_HAPTIC_CONSTANT
bobbens@2497
   349
 * \sa SDL_HapticEffect
bobbens@2497
   350
 */
bobbens@2497
   351
typedef struct SDL_HapticConstant {
bobbens@2497
   352
   /* Header */
bobbens@2497
   353
   Uint16 type; /**< SDL_HAPTIC_CONSTANT */
bobbens@2499
   354
   SDL_HapticDirection direction; /**< Direction of the effect. */
bobbens@2497
   355
bobbens@2497
   356
   /* Replay */
bobbens@2497
   357
   Uint16 length; /**< Duration of the effect. */
bobbens@2497
   358
   Uint16 delay; /**< Delay before starting the effect. */
bobbens@2497
   359
bobbens@2497
   360
   /* Trigger */
bobbens@2497
   361
   Uint16 button; /**< Button that triggers the effect. */
bobbens@2497
   362
   Uint16 interval; /**< How soon it can be triggered again after button. */
bobbens@2497
   363
bobbens@2497
   364
   /* Constant */
bobbens@2497
   365
   Sint16 level; /**< Strength of the constant effect. */
bobbens@2497
   366
bobbens@2497
   367
   /* Envelope */
bobbens@2497
   368
   Uint16 attack_length; /**< Duration of the attack. */
bobbens@2497
   369
   Uint16 attack_level; /**< Level at the start of the attack. */
bobbens@2497
   370
   Uint16 fade_length; /**< Duration of the fade. */
bobbens@2497
   371
   Uint16 fade_level; /**< Level at the end of the fade. */
bobbens@2497
   372
} SDL_HapticConstant;
bobbens@2497
   373
/**
bobbens@2497
   374
 * \struct SDL_HapticPeriodic
bobbens@2497
   375
 *
bobbens@2497
   376
 * \brief A structure containing a template for a Periodic effect.
bobbens@2497
   377
 *
bobbens@2497
   378
 * The struct handles the following effects:
bobbens@2497
   379
 *   - SDL_HAPTIC_SINE
bobbens@2497
   380
 *   - SDL_HAPTIC_SQUARE
bobbens@2497
   381
 *   - SDL_HAPTIC_TRIANGLE
bobbens@2497
   382
 *   - SDL_HAPTIC_SAWTOOTHUP
bobbens@2497
   383
 *   - SDL_HAPTIC_SAWTOOTHDOWN
bobbens@2497
   384
 *
bobbens@2499
   385
 * Examples:
bobbens@2499
   386
 * \code
bobbens@2499
   387
 * SDL_HAPTIC_SINE
bobbens@2499
   388
 *   __      __      __      __
bobbens@2499
   389
 *  /  \    /  \    /  \    /
bobbens@2499
   390
 * /    \__/    \__/    \__/
bobbens@2499
   391
 *
bobbens@2499
   392
 * SDL_HAPTIC_SQUARE
bobbens@2499
   393
 *  __    __    __    __    __
bobbens@2499
   394
 * |  |  |  |  |  |  |  |  |  |
bobbens@2499
   395
 * |  |__|  |__|  |__|  |__|  |
bobbens@2499
   396
 *
bobbens@2499
   397
 * SDL_HAPTIC_TRIANGLE
bobbens@2499
   398
 *   /\    /\    /\    /\    /\
bobbens@2499
   399
 *  /  \  /  \  /  \  /  \  /
bobbens@2499
   400
 * /    \/    \/    \/    \/
bobbens@2499
   401
 *
bobbens@2499
   402
 * SDL_HAPTIC_SAWTOOTHUP
bobbens@2499
   403
 *    __    __    __    __    _
bobbens@2499
   404
 *   /  |  /  |  /  |  /  |  /
bobbens@2499
   405
 *  /   | /   | /   | /   | /
bobbens@2499
   406
 * /    |/    |/    |/    |/
bobbens@2499
   407
 *
bobbens@2499
   408
 * SDL_HAPTIC_SAWTOOTHDOWN
bobbens@2499
   409
 * __    __    __    __    __
bobbens@2499
   410
 *   \  |  \  |  \  |  \  |  \
bobbens@2499
   411
 *    \ |   \ |   \ |   \ |   \
bobbens@2499
   412
 *     \|    \|    \|    \|
bobbens@2499
   413
 * \endcode
bobbens@2499
   414
 *
bobbens@2497
   415
 * \sa SDL_HAPTIC_SINE
bobbens@2497
   416
 * \sa SDL_HAPTIC_SQUARE
bobbens@2497
   417
 * \sa SDL_HAPTIC_TRIANGLE
bobbens@2497
   418
 * \sa SDL_HAPTIC_SAWTOOTHUP
bobbens@2499
   419
 * \sa SDL_HAPTIC SAWTOOTHDOWN
bobbens@2497
   420
 * \sa SDL_HapticEffect
bobbens@2497
   421
 */
bobbens@2497
   422
typedef struct SDL_HapticPeriodic {
bobbens@2497
   423
   /* Header */
bobbens@2499
   424
   Uint16 type; /**< SDL_HAPTIC_{SINE,SQUARE,TRIANGLE,SAWTOOTHUP,SAWTOOTHDOWN} */
bobbens@2499
   425
   SDL_HapticDirection direction; /**< Direction of the effect. */
bobbens@2497
   426
bobbens@2497
   427
   /* Replay */
bobbens@2497
   428
   Uint16 length; /**< Duration of the effect. */
bobbens@2497
   429
   Uint16 delay; /**< Delay before starting the effect. */
bobbens@2497
   430
bobbens@2497
   431
   /* Trigger */
bobbens@2497
   432
   Uint16 button; /**< Button that triggers the effect. */
bobbens@2497
   433
   Uint16 interval; /**< How soon it can be triggered again after button. */
bobbens@2497
   434
bobbens@2497
   435
   /* Periodic */
bobbens@2497
   436
   Uint16 period; /**< Period of the wave. */
bobbens@2497
   437
   Sint16 magnitude; /**< Peak value. */
bobbens@2497
   438
   Sint16 offset; /**< Mean value of the wave. */
bobbens@2497
   439
   Uint16 phase; /**< Horizontal shift. */
bobbens@2497
   440
bobbens@2497
   441
   /* Envelope */
bobbens@2497
   442
   Uint16 attack_length; /**< Duration of the attack. */
bobbens@2497
   443
   Uint16 attack_level; /**< Level at the start of the attack. */
bobbens@2497
   444
   Uint16 fade_length; /**< Duration of the fade. */
bobbens@2497
   445
   Uint16 fade_level; /**< Level at the end of the fade. */
bobbens@2497
   446
} SDL_HapticPeriodic;
bobbens@2497
   447
/**
bobbens@2497
   448
 * \struct SDL_HapticCondition
bobbens@2497
   449
 *
bobbens@2497
   450
 * \brief A structure containing a template for a Condition effect.
bobbens@2497
   451
 *
bobbens@2499
   452
 * Direction is handled by condition internals instead of a direction member.
bobbens@2499
   453
 *
bobbens@2497
   454
 * The struct handles the following effects:
bobbens@2499
   455
 *   - SDL_HAPTIC_SPRING: Effect based on axes position.
bobbens@2499
   456
 *   - SDL_HAPTIC_DAMPER: Effect based on axes velocity.
bobbens@2499
   457
 *   - SDL_HAPTIC_INERTIA: Effect based on axes acceleration.
bobbens@2499
   458
 *   - SDL_HAPTIC_FRICTION: Effect based on axes movement.
bobbens@2497
   459
 *
bobbens@2497
   460
 * \sa SDL_HAPTIC_SPRING
bobbens@2497
   461
 * \sa SDL_HAPTIC_DAMPER
bobbens@2497
   462
 * \sa SDL_HAPTIC_INERTIA
bobbens@2497
   463
 * \sa SDL_HAPTIC_FRICTION
bobbens@2497
   464
 * \sa SDL_HapticEffect
bobbens@2497
   465
 */
bobbens@2497
   466
typedef struct SDL_HapticCondition {
bobbens@2497
   467
   /* Header */
bobbens@2497
   468
   Uint16 type; /**< SDL_HAPTIC_{SPRING,DAMPER,INERTIA,FRICTION} */
bobbens@2497
   469
bobbens@2497
   470
   /* Replay */
bobbens@2497
   471
   Uint16 length; /**< Duration of the effect. */
bobbens@2497
   472
   Uint16 delay; /**< Delay before starting the effect. */
bobbens@2497
   473
bobbens@2497
   474
   /* Trigger */
bobbens@2497
   475
   Uint16 button; /**< Button that triggers the effect. */
bobbens@2497
   476
   Uint16 interval; /**< How soon it can be triggered again after button. */
bobbens@2497
   477
bobbens@2497
   478
   /* Condition */
bobbens@2497
   479
   Uint16 right_sat; /**< Level when joystick is to the right. */
bobbens@2497
   480
   Uint16 left_sat; /**< Level when joystick is to the left. */
bobbens@2497
   481
   Sint16 right_coeff; /**< How fast to increase the force towards the right. */
bobbens@2497
   482
   Sint16 left_coeff; /**< How fast to increase the force towards the left. */
bobbens@2497
   483
   Uint16 deadband; /**< Size of the dead zone. */
bobbens@2497
   484
   Sint16 center; /**< Position of the dead zone. */
bobbens@2497
   485
} SDL_HapticCondition;
bobbens@2497
   486
/**
bobbens@2497
   487
 * \struct SDL_HapticRamp
bobbens@2497
   488
 *
bobbens@2497
   489
 * \brief A structure containing a template for a Ramp effect.
bobbens@2497
   490
 *
bobbens@2497
   491
 * This struct is exclusively for the SDL_HAPTIC_RAMP effect.
bobbens@2497
   492
 *
bobbens@2497
   493
 * \sa SDL_HAPTIC_RAMP
bobbens@2497
   494
 * \sa SDL_HapticEffect
bobbens@2497
   495
 */
bobbens@2497
   496
typedef struct SDL_HapticRamp {
bobbens@2497
   497
   /* Header */
bobbens@2497
   498
   Uint16 type; /**< SDL_HAPTIC_RAMP */
bobbens@2499
   499
   SDL_HapticDirection direction; /**< Direction of the effect. */
bobbens@2497
   500
bobbens@2497
   501
   /* Replay */
bobbens@2497
   502
   Uint16 length; /**< Duration of the effect. */
bobbens@2497
   503
   Uint16 delay; /**< Delay before starting the effect. */
bobbens@2497
   504
bobbens@2497
   505
   /* Trigger */
bobbens@2497
   506
   Uint16 button; /**< Button that triggers the effect. */
bobbens@2497
   507
   Uint16 interval; /**< How soon it can be triggered again after button. */
bobbens@2497
   508
bobbens@2497
   509
   /* Ramp */
bobbens@2497
   510
   Sint16 start; /**< Beginning strength level. */
bobbens@2497
   511
   Sint16 end; /**< Ending strength level. */
bobbens@2497
   512
bobbens@2497
   513
   /* Envelope */
bobbens@2497
   514
   Uint16 attack_length; /**< Duration of the attack. */
bobbens@2497
   515
   Uint16 attack_level; /**< Level at the start of the attack. */
bobbens@2497
   516
   Uint16 fade_length; /**< Duration of the fade. */
bobbens@2497
   517
   Uint16 fade_level; /**< Level at the end of the fade. */
bobbens@2497
   518
} SDL_HapticRamp;
bobbens@2498
   519
/**
bobbens@2497
   520
 * \union SDL_HapticEffect
bobbens@2497
   521
 *
bobbens@2497
   522
 * \brief The generic template for any haptic effect.
bobbens@2497
   523
 *
bobbens@2499
   524
 * All values max at 32767 (0x7FFF).  Signed values also can be negative.
bobbens@2481
   525
 * Time values unless specified otherwise are in milliseconds.
bobbens@2481
   526
 *
bobbens@2481
   527
 * Common parts:
bobbens@2499
   528
 * \code
bobbens@2499
   529
 * // Replay - All effects have this
bobbens@2499
   530
 * Uint16 length;        // Duration of effect (ms).
bobbens@2499
   531
 * Uint16 delay;         // Delay before starting effect.
bobbens@2499
   532
 *
bobbens@2499
   533
 * // Trigger - All effects have this
bobbens@2499
   534
 * Uint16 button;        // Button that triggers effect.
bobbens@2499
   535
 * Uint16 interval;      // How soon before effect can be triggered again.
bobbens@2499
   536
 *
bobbens@2499
   537
 * // Envelope - Not all effects have this
bobbens@2499
   538
 * Uint16 attack_length; // Duration of the attack (ms).
bobbens@2499
   539
 * Uint16 attack_level;  // Level at the start of the attack.
bobbens@2499
   540
 * Uint16 fade_length;   // Duration of the fade out (ms).
bobbens@2499
   541
 * Uint16 fade_level;    // Level at the end of the fade.
bobbens@2499
   542
 * \endcode
bobbens@2499
   543
 *
bobbens@2499
   544
 *
bobbens@2499
   545
 * Here we have an example of an effect evolution in time:
bobbens@2499
   546
 *
bobbens@2499
   547
 * \code
bobbens@2499
   548
 * Strength
bobbens@2499
   549
 * ^
bobbens@2499
   550
 * |
bobbens@2499
   551
 * | effect strength -->  _________________
bobbens@2499
   552
 * |                     /                 \
bobbens@2499
   553
 * |                    /                   \
bobbens@2499
   554
 * |                   /                     \
bobbens@2499
   555
 * |                  /                       \ 
bobbens@2499
   556
 * | attack_level --> |                        \
bobbens@2499
   557
 * |                  |                        |  <---  fade_level
bobbens@2499
   558
 * |
bobbens@2499
   559
 * +--------------------------------------------------> Time
bobbens@2499
   560
 *                    [--]                 [---]
bobbens@2499
   561
 *                    attack_length        fade_length
bobbens@2481
   562
 * 
bobbens@2499
   563
 * [------------------][-----------------------]
bobbens@2499
   564
 * delay               length
bobbens@2499
   565
 * \endcode
bobbens@2497
   566
 *
bobbens@2497
   567
 * \sa SDL_HapticConstant
bobbens@2497
   568
 * \sa SDL_HapticPeriodic
bobbens@2497
   569
 * \sa SDL_HapticCondition
bobbens@2499
   570
 * \sa SDL_HapticRamp
bobbens@2481
   571
 */
bobbens@2477
   572
typedef union SDL_HapticEffect {
bobbens@2477
   573
   /* Common for all force feedback effects */
bobbens@2499
   574
   Uint16 type; /**< Effect type. */
bobbens@2499
   575
   SDL_HapticConstant constant; /**< Constant effect. */
bobbens@2499
   576
   SDL_HapticPeriodic periodic; /**< Periodic effect. */
bobbens@2499
   577
   SDL_HapticCondition condition[2]; /**< Condition effect, one for each axis. */
bobbens@2499
   578
   SDL_HapticRamp ramp; /**< Ramp effect. */
bobbens@2477
   579
} SDL_HapticEffect;
bobbens@2477
   580
bobbens@2472
   581
bobbens@2472
   582
/* Function prototypes */
bobbens@2498
   583
/**
bobbens@2497
   584
 * \fn int SDL_NumHaptics(void)
bobbens@2497
   585
 *
bobbens@2497
   586
 * \brief Count the number of joysticks attached to the system.
bobbens@2497
   587
 *
bobbens@2497
   588
 *    \return Number of haptic devices detected on the system.
bobbens@2472
   589
 */
bobbens@2472
   590
extern DECLSPEC int SDLCALL SDL_NumHaptics(void);
bobbens@2472
   591
bobbens@2498
   592
/**
bobbens@2497
   593
 * \fn const char * SDL_HapticName(int device_index)
bobbens@2497
   594
 *
bobbens@2497
   595
 * \brief Get the implementation dependent name of a Haptic device.
bobbens@2472
   596
 * This can be called before any joysticks are opened.
bobbens@2472
   597
 * If no name can be found, this function returns NULL.
bobbens@2497
   598
 *
bobbens@2497
   599
 *    \param device_index Index of the device to get it's name.
bobbens@2497
   600
 *    \return Name of the device or NULL on error.
bobbens@2497
   601
 *
bobbens@2497
   602
 * \sa SDL_NumHaptics
bobbens@2472
   603
 */
bobbens@2472
   604
extern DECLSPEC const char *SDLCALL SDL_HapticName(int device_index);
bobbens@2472
   605
bobbens@2498
   606
/**
bobbens@2499
   607
 * \fn SDL_Haptic * SDL_HapticOpen(int device_index)
bobbens@2497
   608
 *
bobbens@2497
   609
 * \brief Opens a Haptic device for usage - the index passed as an
bobbens@2476
   610
 * argument refers to the N'th Haptic device on this system.
bobbens@2476
   611
 *
bobbens@2476
   612
 * This function returns a Haptic device identifier, or Null
bobbens@2476
   613
 * if an error occurred.
bobbens@2497
   614
 *
bobbens@2497
   615
 *    \param device_index Index of the device to open.
bobbens@2497
   616
 *    \return Device identifier or NULL on error.
bobbens@2497
   617
 *
bobbens@2497
   618
 * \sa SDL_HapticOpenFromJoystick
bobbens@2497
   619
 * \sa SDL_HapticClose
bobbens@2476
   620
 */
bobbens@2476
   621
extern DECLSPEC SDL_Haptic * SDL_HapticOpen(int device_index);
bobbens@2476
   622
bobbens@2498
   623
/**
bobbens@2498
   624
 * \fn int SDL_JoystickIsHaptic(SDL_Joystick * joystick)
bobbens@2489
   625
 *
bobbens@2497
   626
 * \brief Checks to see if a joystick has haptic features.
bobbens@2497
   627
 *
bobbens@2497
   628
 *    \param joystick Joystick to test for haptic capabilities.
bobbens@2497
   629
 *    \return SDL_TRUE if the joystick is haptic, SDL_FALSE if it isn't
bobbens@2497
   630
 *            or -1 if an error ocurred.
bobbens@2497
   631
 *
bobbens@2497
   632
 * \sa SDL_HapticOpenFromJoystick
bobbens@2489
   633
 */
bobbens@2489
   634
extern DECLSPEC int SDL_JoystickIsHaptic(SDL_Joystick * joystick);
bobbens@2489
   635
bobbens@2498
   636
/**
bobbens@2497
   637
 * \fn SDL_Haptic * SDL_HapticOpenFromJoystick(SDL_Joystick * joystick)
bobbens@2489
   638
 *
bobbens@2497
   639
 * \brief Opens a Haptic device for usage from a Joystick device.  Still has
bobbens@2497
   640
 * to be closed seperately to the joystick.
bobbens@2497
   641
 *
bobbens@2497
   642
 *    \param joystick Joystick to create a haptic device from.
bobbens@2497
   643
 *    \return A valid haptic device identifier on success or NULL on error.
bobbens@2497
   644
 *
bobbens@2497
   645
 * \sa SDL_HapticOpen
bobbens@2497
   646
 * \sa SDL_HapticClose
bobbens@2489
   647
 */
bobbens@2489
   648
extern DECLSPEC SDL_Haptic * SDL_HapticOpenFromJoystick(SDL_Joystick * joystick);
bobbens@2489
   649
bobbens@2498
   650
/**
bobbens@2497
   651
 * \fn void SDL_HapticClose(SDL_Haptic * haptic)
bobbens@2497
   652
 *
bobbens@2497
   653
 * \brief Closes a Haptic device previously opened with SDL_HapticOpen.
bobbens@2497
   654
 *
bobbens@2497
   655
 *    \param haptic Haptic device to close.
bobbens@2476
   656
 */
bobbens@2476
   657
extern DECLSPEC void SDL_HapticClose(SDL_Haptic * haptic);
bobbens@2476
   658
bobbens@2498
   659
/**
bobbens@2497
   660
 * \fn int SDL_HapticNumEffects(SDL_Haptic * haptic)
bobbens@2497
   661
 *
bobbens@2497
   662
 * \brief Returns the number of effects a haptic device can store.
bobbens@2497
   663
 *
bobbens@2497
   664
 *    \param haptic The haptic device to query effect max.
bobbens@2497
   665
 *    \return The number of effects the haptic device can store or
bobbens@2497
   666
 *            -1 on error.
bobbens@2497
   667
 *
bobbens@2497
   668
 * \sa SDL_HapticQuery
bobbens@2478
   669
 */
bobbens@2478
   670
extern DECLSPEC int SDL_HapticNumEffects(SDL_Haptic * haptic);
bobbens@2478
   671
bobbens@2498
   672
/**
bobbens@2499
   673
 * \fn unsigned int SDL_HapticQuery(SDL_Haptic * haptic)
bobbens@2478
   674
 *
bobbens@2497
   675
 * \brief Gets the haptic devices supported features in bitwise matter.
bobbens@2497
   676
 *
bobbens@2497
   677
 * Example: 
bobbens@2497
   678
 * \code
bobbens@2497
   679
 * if (SDL_HapticQueryEffects(haptic) & SDL_HAPTIC_CONSTANT) {
bobbens@2497
   680
 *    printf("We have constant haptic effect!");
bobbens@2497
   681
 * }
bobbens@2497
   682
 * \endcode
bobbens@2497
   683
 *    
bobbens@2497
   684
 *
bobbens@2497
   685
 *    \param haptic The haptic device to query.
bobbens@2497
   686
 *    \return Haptic features in bitwise manner (OR'd).
bobbens@2497
   687
 *
bobbens@2497
   688
 * \sa SDL_HapticNumEffects
bobbens@2497
   689
 * \sa SDL_HapticEffectSupported
bobbens@2478
   690
 */
bobbens@2497
   691
extern DECLSPEC unsigned int SDL_HapticQuery(SDL_Haptic * haptic);
bobbens@2478
   692
bobbens@2498
   693
/**
bobbens@2499
   694
 * \fn int SDL_HapticEffectSupported(SDL_Haptic * haptic, SDL_HapticEffect * effect)
bobbens@2486
   695
 *
bobbens@2497
   696
 * \brief Checks to see if effect is supported by haptic.
bobbens@2497
   697
 *
bobbens@2497
   698
 *    \param haptic Haptic device to check on.
bobbens@2497
   699
 *    \param effect Effect to check to see if it is supported.
bobbens@2497
   700
 *    \return SDL_TRUE if effect is supported, SDL_FALSE if it isn't or 
bobbens@2497
   701
 *            -1 on error.
bobbens@2497
   702
 * 
bobbens@2497
   703
 * \sa SDL_HapticQuery
bobbens@2497
   704
 * \sa SDL_HapticNewEffect
bobbens@2486
   705
 */
bobbens@2486
   706
extern DECLSPEC int SDL_HapticEffectSupported(SDL_Haptic * haptic, SDL_HapticEffect * effect);
bobbens@2486
   707
bobbens@2498
   708
/**
bobbens@2497
   709
 * \fn int SDL_HapticNewEffect(SDL_Haptic * haptic, SDL_HapticEffect * effect)
bobbens@2483
   710
 *
bobbens@2497
   711
 * \brief Creates a new haptic effect on the device.
bobbens@2497
   712
 *
bobbens@2497
   713
 *    \param haptic Haptic device to create the effect on.
bobbens@2497
   714
 *    \param effect Properties of the effect to create.
bobbens@2497
   715
 *    \return The id of the effect on success or -1 on error.
bobbens@2497
   716
 *
bobbens@2497
   717
 * \sa SDL_HapticUpdateEffect
bobbens@2497
   718
 * \sa SDL_HapticRunEffect
bobbens@2497
   719
 * \sa SDL_HapticDestroyEffect
bobbens@2477
   720
 */
bobbens@2477
   721
extern DECLSPEC int SDL_HapticNewEffect(SDL_Haptic * haptic, SDL_HapticEffect * effect);
bobbens@2477
   722
bobbens@2498
   723
/**
bobbens@2497
   724
 * \fn int SDL_HapticUpdateEffect(SDL_Haptic * haptic, int effect, SDL_HapticEffect * data)
bobbens@2497
   725
 *
bobbens@2497
   726
 * \brief Updates an effect.  Can be used dynamically, although behaviour when
bobbens@2488
   727
 * dynamically changing direction may be strange.  Specifically the effect
bobbens@2488
   728
 * may reupload itself and start playing from the start.  You cannot change
bobbens@2488
   729
 * the type either when running UpdateEffect.
bobbens@2488
   730
 *
bobbens@2497
   731
 *    \param haptic Haptic device that has the effect.
bobbens@2497
   732
 *    \param effect Effect to update.
bobbens@2497
   733
 *    \param data New effect properties to use.
bobbens@2497
   734
 *    \return The id of the effect on success or -1 on error.
bobbens@2497
   735
 *
bobbens@2497
   736
 * \sa SDL_HapticNewEffect
bobbens@2497
   737
 * \sa SDL_HapticRunEffect
bobbens@2497
   738
 * \sa SDL_HapticDestroyEffect
bobbens@2488
   739
 */
bobbens@2488
   740
extern DECLSPEC int SDL_HapticUpdateEffect(SDL_Haptic * haptic, int effect, SDL_HapticEffect * data);
bobbens@2488
   741
bobbens@2498
   742
/**
bobbens@2499
   743
 * \fn int SDL_HapticRunEffect(SDL_Haptic * haptic, int effect)
bobbens@2483
   744
 *
bobbens@2497
   745
 * \brief Runs the haptic effect on it's assosciated haptic device.
bobbens@2497
   746
 *
bobbens@2497
   747
 *    \param haptic Haptic device to run the effect on.
bobbens@2497
   748
 *    \param effect Identifier of the haptic effect to run.
bobbens@2497
   749
 *    \return 0 on success or -1 on error.
bobbens@2497
   750
 *
bobbens@2497
   751
 * \sa SDL_HapticStopEffect
bobbens@2497
   752
 * \sa SDL_HapticDestroyEffect
bobbens@2497
   753
 * \sa SDL_HapticGetEffectStatus
bobbens@2477
   754
 */
bobbens@2477
   755
extern DECLSPEC int SDL_HapticRunEffect(SDL_Haptic * haptic, int effect);
bobbens@2477
   756
bobbens@2498
   757
/**
bobbens@2497
   758
 * \fn int SDL_HapticStopEffect(SDL_Haptic * haptic, int effect)
bobbens@2485
   759
 *
bobbens@2497
   760
 * \brief Stops the haptic effect on it's assosciated haptic device.
bobbens@2497
   761
 *
bobbens@2497
   762
 *    \param haptic Haptic device to stop the effect on.
bobbens@2499
   763
 *    \param effect Identifier of the effect to stop.
bobbens@2497
   764
 *    \return 0 on success or -1 on error.
bobbens@2497
   765
 *
bobbens@2497
   766
 * \sa SDL_HapticRunEffect
bobbens@2497
   767
 * \sa SDL_HapticDestroyEffect
bobbens@2485
   768
 */
bobbens@2485
   769
extern DECLSPEC int SDL_HapticStopEffect(SDL_Haptic * haptic, int effect);
bobbens@2485
   770
bobbens@2498
   771
/**
bobbens@2497
   772
 * \fn void SDL_HapticDestroyEffect(SDL_Haptic * haptic, int effect)
bobbens@2497
   773
 *
bobbens@2497
   774
 * \brief Destroys a haptic effect on the device.  This will stop the effect
bobbens@2497
   775
 * if it's running.  Effects are automatically destroyed when the device is
bobbens@2497
   776
 * closed.
bobbens@2497
   777
 *
bobbens@2497
   778
 *    \param haptic Device to destroy the effect on.
bobbens@2497
   779
 *    \param effect Identifier of the effect to destroy.
bobbens@2497
   780
 * 
bobbens@2497
   781
 * \sa SDL_HapticNewEffect
bobbens@2477
   782
 */
bobbens@2477
   783
extern DECLSPEC void SDL_HapticDestroyEffect(SDL_Haptic * haptic, int effect);
bobbens@2477
   784
bobbens@2498
   785
/**
bobbens@2497
   786
 * \fn int SDL_HapticGetEffectStatus(SDL_Haptic *haptic, int effect)
bobbens@2495
   787
 *
bobbens@2497
   788
 * \brief Gets the status of the current effect on the haptic device.
bobbens@2497
   789
 *
bobbens@2497
   790
 * Device must support the SDL_HAPTIC_STATUS feature.
bobbens@2497
   791
 *
bobbens@2497
   792
 *    \param haptic Haptic device to query the effect status on.
bobbens@2497
   793
 *    \param effect Identifier of the effect to query it's status.
bobbens@2497
   794
 *    \return 0 if it isn't playing, SDL_HAPTIC_PLAYING if it is playing
bobbens@2497
   795
 *            or -1 on error.
bobbens@2497
   796
 *
bobbens@2497
   797
 * \sa SDL_HapticRunEffect
bobbens@2497
   798
 * \sa SDL_HapticStopEffect
bobbens@2495
   799
 */
bobbens@2495
   800
extern DECLSPEC int SDL_HapticGetEffectStatus(SDL_Haptic *haptic, int effect);
bobbens@2495
   801
bobbens@2498
   802
/**
bobbens@2497
   803
 * \fn int SDL_HapticSetGain(SDL_Haptic * haptic, int gain)
bobbens@2483
   804
 *
bobbens@2497
   805
 * \brief Sets the global gain of the device.  Gain should be between 0 and 100.
bobbens@2497
   806
 *
bobbens@2497
   807
 * Device must support the SDL_HAPTIC_GAIN feature.
bobbens@2497
   808
 *
bobbens@2497
   809
 *    \param haptic Haptic device to set the gain on.
bobbens@2497
   810
 *    \param gain Value to set the gain to, should be between 0 and 100.
bobbens@2497
   811
 *    \return 0 on success or -1 on error.
bobbens@2497
   812
 *
bobbens@2497
   813
 * \sa SDL_HapticQuery
bobbens@2483
   814
 */
bobbens@2483
   815
extern DECLSPEC int SDL_HapticSetGain(SDL_Haptic * haptic, int gain);
bobbens@2483
   816
bobbens@2498
   817
/**
bobbens@2497
   818
 * \fn int SDL_HapticSetAutocenter(SDL_Haptic * haptic, int autocenter)
bobbens@2497
   819
 *
bobbens@2497
   820
 * \brief Sets the global autocenter of the device.  Autocenter should be between
bobbens@2484
   821
 * 0 and 100.  Setting it to 0 will disable autocentering.
bobbens@2484
   822
 *
bobbens@2497
   823
 * Device must support the SDL_HAPTIC_AUTOCENTER feature.
bobbens@2497
   824
 *
bobbens@2497
   825
 *    \param haptic Haptic device to set autocentering on.
bobbens@2497
   826
 *    \param autocenter Value to set autocenter to, 0 disables autocentering.
bobbens@2497
   827
 *    \return 0 on success or -1 on error.
bobbens@2497
   828
 *
bobbens@2497
   829
 * \sa SDL_HapticQuery
bobbens@2484
   830
 */
bobbens@2484
   831
extern DECLSPEC int SDL_HapticSetAutocenter(SDL_Haptic * haptic, int autocenter);
bobbens@2484
   832
bobbens@2472
   833
bobbens@2472
   834
/* Ends C function definitions when using C++ */
bobbens@2472
   835
#ifdef __cplusplus
bobbens@2472
   836
/* *INDENT-OFF* */
bobbens@2472
   837
}
bobbens@2472
   838
/* *INDENT-ON* */
bobbens@2472
   839
#endif
bobbens@2472
   840
#include "close_code.h"
bobbens@2472
   841
bobbens@2472
   842
#endif /* _SDL_haptic_h */
bobbens@2472
   843
bobbens@2472
   844
/* vi: set ts=4 sw=4 expandtab: */
bobbens@2472
   845
bobbens@2472
   846