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