include/SDL_haptic.h
author Edgar Simo <bobbens@gmail.com>
Thu, 10 Jul 2008 17:54:08 +0000
branchgsoc2008_force_feedback
changeset 2517 37c13c12c878
parent 2515 030fc4375e63
child 2519 af9df9662807
permissions -rw-r--r--
Broke API by introducing iterations to SDL_HapticRunEffects().
Fixed minor issues.
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@2517
    73
 *    SDL_HapticRunEffect( haptic, effect_id, 1 );
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@2517
   266
/*
bobbens@2517
   267
 * Misc defines.
bobbens@2517
   268
 */
bobbens@2517
   269
/**
bobbens@2517
   270
 * \def SDL_HAPTIC_INFINITY
bobbens@2517
   271
 *
bobbens@2517
   272
 * \brief Used to play a device an infinite number of times.
bobbens@2517
   273
 *
bobbens@2517
   274
 * \sa SDL_HapticRunEffect
bobbens@2517
   275
 */
bobbens@2517
   276
#define SDL_HAPTIC_INFINITY   -1
bobbens@2517
   277
bobbens@2517
   278
bobbens@2499
   279
/**
bobbens@2499
   280
 * \struct SDL_HapticDirection
bobbens@2499
   281
 *
bobbens@2499
   282
 * \brief Structure that represents a haptic direction.
bobbens@2499
   283
 *
bobbens@2499
   284
 * Directions can be specified by:
bobbens@2504
   285
 *   - SDL_HAPTIC_POLAR : Specified by polar coordinates.
bobbens@2504
   286
 *   - SDL_HAPTIC_CARTESIAN : Specified by cartesian coordinates.
bobbens@2499
   287
 *
bobbens@2499
   288
 * Cardinal directions of the haptic device are relative to the positioning
bobbens@2499
   289
 *  of the device.  North is considered to be away from the user.
bobbens@2499
   290
 *
bobbens@2499
   291
 * The following diagram represents the cardinal directions:
bobbens@2499
   292
 * \code
bobbens@2499
   293
 *            .--.
bobbens@2499
   294
 *            |__| .-------.
bobbens@2499
   295
 *            |=.| |.-----.|
bobbens@2499
   296
 *            |--| ||     ||
bobbens@2499
   297
 *            |  | |'-----'|
bobbens@2499
   298
 *            |__|~')_____('
bobbens@2499
   299
 *              [ COMPUTER ]
bobbens@2499
   300
 *
bobbens@2499
   301
 *
bobbens@2499
   302
 *                  North (-1)
bobbens@2499
   303
 *                    ^
bobbens@2499
   304
 *                    |
bobbens@2499
   305
 *                    |
bobbens@2502
   306
 * (1)  West <----[ HAPTIC ]----> East (-1)
bobbens@2499
   307
 *                    |
bobbens@2499
   308
 *                    |
bobbens@2499
   309
 *                    v
bobbens@2499
   310
 *                  South (1)
bobbens@2499
   311
 *
bobbens@2499
   312
 *
bobbens@2499
   313
 *                 [ USER ]
bobbens@2499
   314
 *                   \|||/
bobbens@2499
   315
 *                   (o o)
bobbens@2499
   316
 *             ---ooO-(_)-Ooo---
bobbens@2499
   317
 * \endcode
bobbens@2499
   318
 *
bobbens@2499
   319
 * If type is SDL_HAPTIC_POLAR, direction is encoded by hundredths of a 
bobbens@2499
   320
 *  degree starting north and turning clockwise.  The cardinal directions would be:
bobbens@2499
   321
 *   - North: 0 (0 degrees)
bobbens@2511
   322
 *   - East: 9000 (90 degrees)
bobbens@2499
   323
 *   - South: 18000 (180 degrees)
bobbens@2511
   324
 *   - West: 27000 (270 degrees)
bobbens@2499
   325
 *
bobbens@2499
   326
 * If type is SDL_HAPTIC_CARTESIAN, direction is encoded by position.
bobbens@2499
   327
 *  The cardinal directions would be:
bobbens@2499
   328
 *   - North:  0,-1
bobbens@2511
   329
 *   - East:  -1, 0
bobbens@2499
   330
 *   - South:  0, 1
bobbens@2511
   331
 *   - West:   1, 0
bobbens@2499
   332
 *
bobbens@2499
   333
 *
bobbens@2499
   334
 * Example:
bobbens@2499
   335
 * \code
bobbens@2499
   336
 * SDL_HapticDirection direction;
bobbens@2499
   337
 *
bobbens@2499
   338
 * direction.type = SDL_HAPTIC_POLAR; // We'll be using polar direction encoding.
bobbens@2511
   339
 * direction.dir = 18000; // Force comes from the south meaning the user will
bobbens@2499
   340
 *                         // have to pull the stick to counteract.
bobbens@2499
   341
 * \endcode
bobbens@2499
   342
 *
bobbens@2499
   343
 * \sa SDL_HAPTIC_POLAR
bobbens@2499
   344
 * \sa SDL_HAPTIC_CARTESIAN
bobbens@2499
   345
 * \sa SDL_HapticEffect
bobbens@2499
   346
 */
bobbens@2499
   347
typedef struct SDL_HapticDirection {
bobbens@2499
   348
   Uint8 type; /**< The type of encoding. */
bobbens@2499
   349
   Uint16 dir[2]; /**< The encoded direction. */
bobbens@2499
   350
} SDL_HapticDirection;
bobbens@2499
   351
bobbens@2499
   352
bobbens@2497
   353
/**
bobbens@2497
   354
 * \struct SDL_HapticConstant
bobbens@2497
   355
 *
bobbens@2497
   356
 * \brief A structure containing a template for a Constant effect.
bobbens@2497
   357
 *
bobbens@2497
   358
 * The struct is exclusive to the SDL_HAPTIC_CONSTANT effect.
bobbens@2497
   359
 *
bobbens@2504
   360
 * A constant effect applies a constant force in the specified direction
bobbens@2504
   361
 *  to the joystick.
bobbens@2504
   362
 *
bobbens@2497
   363
 * \sa SDL_HAPTIC_CONSTANT
bobbens@2497
   364
 * \sa SDL_HapticEffect
bobbens@2497
   365
 */
bobbens@2497
   366
typedef struct SDL_HapticConstant {
bobbens@2497
   367
   /* Header */
bobbens@2497
   368
   Uint16 type; /**< SDL_HAPTIC_CONSTANT */
bobbens@2499
   369
   SDL_HapticDirection direction; /**< Direction of the effect. */
bobbens@2497
   370
bobbens@2497
   371
   /* Replay */
bobbens@2497
   372
   Uint16 length; /**< Duration of the effect. */
bobbens@2497
   373
   Uint16 delay; /**< Delay before starting the effect. */
bobbens@2497
   374
bobbens@2497
   375
   /* Trigger */
bobbens@2497
   376
   Uint16 button; /**< Button that triggers the effect. */
bobbens@2497
   377
   Uint16 interval; /**< How soon it can be triggered again after button. */
bobbens@2497
   378
bobbens@2497
   379
   /* Constant */
bobbens@2497
   380
   Sint16 level; /**< Strength of the constant effect. */
bobbens@2497
   381
bobbens@2497
   382
   /* Envelope */
bobbens@2497
   383
   Uint16 attack_length; /**< Duration of the attack. */
bobbens@2497
   384
   Uint16 attack_level; /**< Level at the start of the attack. */
bobbens@2497
   385
   Uint16 fade_length; /**< Duration of the fade. */
bobbens@2497
   386
   Uint16 fade_level; /**< Level at the end of the fade. */
bobbens@2497
   387
} SDL_HapticConstant;
bobbens@2497
   388
/**
bobbens@2497
   389
 * \struct SDL_HapticPeriodic
bobbens@2497
   390
 *
bobbens@2497
   391
 * \brief A structure containing a template for a Periodic effect.
bobbens@2497
   392
 *
bobbens@2497
   393
 * The struct handles the following effects:
bobbens@2497
   394
 *   - SDL_HAPTIC_SINE
bobbens@2497
   395
 *   - SDL_HAPTIC_SQUARE
bobbens@2497
   396
 *   - SDL_HAPTIC_TRIANGLE
bobbens@2497
   397
 *   - SDL_HAPTIC_SAWTOOTHUP
bobbens@2497
   398
 *   - SDL_HAPTIC_SAWTOOTHDOWN
bobbens@2497
   399
 *
bobbens@2504
   400
 * A periodic effect consists in a wave-shaped effect that repeats itself
bobbens@2504
   401
 *  over time.  The type determines the shape of the wave and the parameters
bobbens@2504
   402
 *  determine the dimensions of the wave.
bobbens@2504
   403
 *
bobbens@2499
   404
 * Examples:
bobbens@2499
   405
 * \code
bobbens@2499
   406
 * SDL_HAPTIC_SINE
bobbens@2499
   407
 *   __      __      __      __
bobbens@2499
   408
 *  /  \    /  \    /  \    /
bobbens@2499
   409
 * /    \__/    \__/    \__/
bobbens@2499
   410
 *
bobbens@2499
   411
 * SDL_HAPTIC_SQUARE
bobbens@2499
   412
 *  __    __    __    __    __
bobbens@2499
   413
 * |  |  |  |  |  |  |  |  |  |
bobbens@2499
   414
 * |  |__|  |__|  |__|  |__|  |
bobbens@2499
   415
 *
bobbens@2499
   416
 * SDL_HAPTIC_TRIANGLE
bobbens@2499
   417
 *   /\    /\    /\    /\    /\
bobbens@2499
   418
 *  /  \  /  \  /  \  /  \  /
bobbens@2499
   419
 * /    \/    \/    \/    \/
bobbens@2499
   420
 *
bobbens@2499
   421
 * SDL_HAPTIC_SAWTOOTHUP
bobbens@2504
   422
 *   /|  /|  /|  /|  /|  /|  /|
bobbens@2504
   423
 *  / | / | / | / | / | / | / |
bobbens@2504
   424
 * /  |/  |/  |/  |/  |/  |/  |
bobbens@2499
   425
 *
bobbens@2499
   426
 * SDL_HAPTIC_SAWTOOTHDOWN
bobbens@2504
   427
 * \  |\  |\  |\  |\  |\  |\  |
bobbens@2504
   428
 *  \ | \ | \ | \ | \ | \ | \ |
bobbens@2504
   429
 *   \|  \|  \|  \|  \|  \|  \|
bobbens@2499
   430
 * \endcode
bobbens@2499
   431
 *
bobbens@2497
   432
 * \sa SDL_HAPTIC_SINE
bobbens@2497
   433
 * \sa SDL_HAPTIC_SQUARE
bobbens@2497
   434
 * \sa SDL_HAPTIC_TRIANGLE
bobbens@2497
   435
 * \sa SDL_HAPTIC_SAWTOOTHUP
bobbens@2504
   436
 * \sa SDL_HAPTIC_SAWTOOTHDOWN
bobbens@2497
   437
 * \sa SDL_HapticEffect
bobbens@2497
   438
 */
bobbens@2497
   439
typedef struct SDL_HapticPeriodic {
bobbens@2497
   440
   /* Header */
bobbens@2504
   441
   Uint16 type; /**< SDL_HAPTIC_SINE, SDL_HAPTIC_SQUARE,
bobbens@2504
   442
                     SDL_HAPTIC_TRIANGLE, SDL_HAPTIC_SAWTOOTHUP or
bobbens@2504
   443
                     SDL_HAPTIC_SAWTOOTHDOWN */
bobbens@2499
   444
   SDL_HapticDirection direction; /**< Direction of the effect. */
bobbens@2497
   445
bobbens@2497
   446
   /* Replay */
bobbens@2497
   447
   Uint16 length; /**< Duration of the effect. */
bobbens@2497
   448
   Uint16 delay; /**< Delay before starting the effect. */
bobbens@2497
   449
bobbens@2497
   450
   /* Trigger */
bobbens@2497
   451
   Uint16 button; /**< Button that triggers the effect. */
bobbens@2497
   452
   Uint16 interval; /**< How soon it can be triggered again after button. */
bobbens@2497
   453
bobbens@2497
   454
   /* Periodic */
bobbens@2497
   455
   Uint16 period; /**< Period of the wave. */
bobbens@2497
   456
   Sint16 magnitude; /**< Peak value. */
bobbens@2497
   457
   Sint16 offset; /**< Mean value of the wave. */
bobbens@2497
   458
   Uint16 phase; /**< Horizontal shift. */
bobbens@2497
   459
bobbens@2497
   460
   /* Envelope */
bobbens@2497
   461
   Uint16 attack_length; /**< Duration of the attack. */
bobbens@2497
   462
   Uint16 attack_level; /**< Level at the start of the attack. */
bobbens@2497
   463
   Uint16 fade_length; /**< Duration of the fade. */
bobbens@2497
   464
   Uint16 fade_level; /**< Level at the end of the fade. */
bobbens@2497
   465
} SDL_HapticPeriodic;
bobbens@2497
   466
/**
bobbens@2497
   467
 * \struct SDL_HapticCondition
bobbens@2497
   468
 *
bobbens@2497
   469
 * \brief A structure containing a template for a Condition effect.
bobbens@2497
   470
 *
bobbens@2497
   471
 * The struct handles the following effects:
bobbens@2499
   472
 *   - SDL_HAPTIC_SPRING: Effect based on axes position.
bobbens@2499
   473
 *   - SDL_HAPTIC_DAMPER: Effect based on axes velocity.
bobbens@2499
   474
 *   - SDL_HAPTIC_INERTIA: Effect based on axes acceleration.
bobbens@2499
   475
 *   - SDL_HAPTIC_FRICTION: Effect based on axes movement.
bobbens@2497
   476
 *
bobbens@2504
   477
 * Direction is handled by condition internals instead of a direction member.
bobbens@2504
   478
 *  The condition effect specific members have two parameters.  The first
bobbens@2504
   479
 *  refers to the X axis, the second refers to the Y axis.  The right terms
bobbens@2504
   480
 *  refer to the positive side of the axis and the left terms refer to the
bobbens@2504
   481
 *  negative side of the axis.  Please refer to the SDL_HapticDirection 
bobbens@2504
   482
 *  diagram for which side is positive and which is negative.
bobbens@2504
   483
 *
bobbens@2500
   484
 * \sa SDL_HapticDirection
bobbens@2497
   485
 * \sa SDL_HAPTIC_SPRING
bobbens@2497
   486
 * \sa SDL_HAPTIC_DAMPER
bobbens@2497
   487
 * \sa SDL_HAPTIC_INERTIA
bobbens@2497
   488
 * \sa SDL_HAPTIC_FRICTION
bobbens@2497
   489
 * \sa SDL_HapticEffect
bobbens@2497
   490
 */
bobbens@2497
   491
typedef struct SDL_HapticCondition {
bobbens@2497
   492
   /* Header */
bobbens@2504
   493
   Uint16 type; /**< SDL_HAPTIC_SPRING, SDL_HAPTIC_DAMPER,
bobbens@2504
   494
                     SDL_HAPTIC_INERTIA or SDL_HAPTIC_FRICTION */
bobbens@2497
   495
bobbens@2497
   496
   /* Replay */
bobbens@2497
   497
   Uint16 length; /**< Duration of the effect. */
bobbens@2497
   498
   Uint16 delay; /**< Delay before starting the effect. */
bobbens@2497
   499
bobbens@2497
   500
   /* Trigger */
bobbens@2497
   501
   Uint16 button; /**< Button that triggers the effect. */
bobbens@2497
   502
   Uint16 interval; /**< How soon it can be triggered again after button. */
bobbens@2497
   503
bobbens@2497
   504
   /* Condition */
bobbens@2504
   505
   Uint16 right_sat[2]; /**< Level when joystick is to the positive side. */
bobbens@2504
   506
   Uint16 left_sat[2]; /**< Level when joystick is to the negative side. */
bobbens@2504
   507
   Sint16 right_coeff[2]; /**< How fast to increase the force towards the positive side. */
bobbens@2504
   508
   Sint16 left_coeff[2]; /**< How fast to increase the force towards the negative side. */
bobbens@2500
   509
   Uint16 deadband[2]; /**< Size of the dead zone. */
bobbens@2500
   510
   Sint16 center[2]; /**< Position of the dead zone. */
bobbens@2497
   511
} SDL_HapticCondition;
bobbens@2497
   512
/**
bobbens@2497
   513
 * \struct SDL_HapticRamp
bobbens@2497
   514
 *
bobbens@2497
   515
 * \brief A structure containing a template for a Ramp effect.
bobbens@2497
   516
 *
bobbens@2497
   517
 * This struct is exclusively for the SDL_HAPTIC_RAMP effect.
bobbens@2497
   518
 *
bobbens@2504
   519
 * The ramp effect starts at start strength and ends at end strength.
bobbens@2504
   520
 *  It augments in linear fashion.  If you use attack and fade with a ramp
bobbens@2504
   521
 *  they effects get added to the ramp effect making the effect become
bobbens@2504
   522
 *  quadratic instead of linear.
bobbens@2504
   523
 *
bobbens@2497
   524
 * \sa SDL_HAPTIC_RAMP
bobbens@2497
   525
 * \sa SDL_HapticEffect
bobbens@2497
   526
 */
bobbens@2497
   527
typedef struct SDL_HapticRamp {
bobbens@2497
   528
   /* Header */
bobbens@2497
   529
   Uint16 type; /**< SDL_HAPTIC_RAMP */
bobbens@2499
   530
   SDL_HapticDirection direction; /**< Direction of the effect. */
bobbens@2497
   531
bobbens@2497
   532
   /* Replay */
bobbens@2497
   533
   Uint16 length; /**< Duration of the effect. */
bobbens@2497
   534
   Uint16 delay; /**< Delay before starting the effect. */
bobbens@2497
   535
bobbens@2497
   536
   /* Trigger */
bobbens@2497
   537
   Uint16 button; /**< Button that triggers the effect. */
bobbens@2497
   538
   Uint16 interval; /**< How soon it can be triggered again after button. */
bobbens@2497
   539
bobbens@2497
   540
   /* Ramp */
bobbens@2497
   541
   Sint16 start; /**< Beginning strength level. */
bobbens@2497
   542
   Sint16 end; /**< Ending strength level. */
bobbens@2497
   543
bobbens@2497
   544
   /* Envelope */
bobbens@2497
   545
   Uint16 attack_length; /**< Duration of the attack. */
bobbens@2497
   546
   Uint16 attack_level; /**< Level at the start of the attack. */
bobbens@2497
   547
   Uint16 fade_length; /**< Duration of the fade. */
bobbens@2497
   548
   Uint16 fade_level; /**< Level at the end of the fade. */
bobbens@2497
   549
} SDL_HapticRamp;
bobbens@2498
   550
/**
bobbens@2497
   551
 * \union SDL_HapticEffect
bobbens@2497
   552
 *
bobbens@2497
   553
 * \brief The generic template for any haptic effect.
bobbens@2497
   554
 *
bobbens@2499
   555
 * All values max at 32767 (0x7FFF).  Signed values also can be negative.
bobbens@2504
   556
 *  Time values unless specified otherwise are in milliseconds.
bobbens@2481
   557
 *
bobbens@2481
   558
 * Common parts:
bobbens@2499
   559
 * \code
bobbens@2499
   560
 * // Replay - All effects have this
bobbens@2499
   561
 * Uint16 length;        // Duration of effect (ms).
bobbens@2499
   562
 * Uint16 delay;         // Delay before starting effect.
bobbens@2499
   563
 *
bobbens@2499
   564
 * // Trigger - All effects have this
bobbens@2499
   565
 * Uint16 button;        // Button that triggers effect.
bobbens@2499
   566
 * Uint16 interval;      // How soon before effect can be triggered again.
bobbens@2499
   567
 *
bobbens@2504
   568
 * // Envelope - All effects except condition effects have this
bobbens@2499
   569
 * Uint16 attack_length; // Duration of the attack (ms).
bobbens@2499
   570
 * Uint16 attack_level;  // Level at the start of the attack.
bobbens@2499
   571
 * Uint16 fade_length;   // Duration of the fade out (ms).
bobbens@2499
   572
 * Uint16 fade_level;    // Level at the end of the fade.
bobbens@2499
   573
 * \endcode
bobbens@2499
   574
 *
bobbens@2499
   575
 *
bobbens@2504
   576
 * Here we have an example of a constant effect evolution in time:
bobbens@2499
   577
 *
bobbens@2499
   578
 * \code
bobbens@2499
   579
 * Strength
bobbens@2499
   580
 * ^
bobbens@2499
   581
 * |
bobbens@2504
   582
 * |    effect level -->  _________________
bobbens@2499
   583
 * |                     /                 \
bobbens@2499
   584
 * |                    /                   \
bobbens@2499
   585
 * |                   /                     \
bobbens@2499
   586
 * |                  /                       \ 
bobbens@2499
   587
 * | attack_level --> |                        \
bobbens@2499
   588
 * |                  |                        |  <---  fade_level
bobbens@2499
   589
 * |
bobbens@2499
   590
 * +--------------------------------------------------> Time
bobbens@2499
   591
 *                    [--]                 [---]
bobbens@2499
   592
 *                    attack_length        fade_length
bobbens@2481
   593
 * 
bobbens@2499
   594
 * [------------------][-----------------------]
bobbens@2499
   595
 * delay               length
bobbens@2499
   596
 * \endcode
bobbens@2497
   597
 *
bobbens@2504
   598
 * Note either the attack_level or the fade_level may be above the actual
bobbens@2504
   599
 *  effect level.
bobbens@2504
   600
 *
bobbens@2497
   601
 * \sa SDL_HapticConstant
bobbens@2497
   602
 * \sa SDL_HapticPeriodic
bobbens@2497
   603
 * \sa SDL_HapticCondition
bobbens@2499
   604
 * \sa SDL_HapticRamp
bobbens@2481
   605
 */
bobbens@2477
   606
typedef union SDL_HapticEffect {
bobbens@2477
   607
   /* Common for all force feedback effects */
bobbens@2499
   608
   Uint16 type; /**< Effect type. */
bobbens@2499
   609
   SDL_HapticConstant constant; /**< Constant effect. */
bobbens@2499
   610
   SDL_HapticPeriodic periodic; /**< Periodic effect. */
bobbens@2500
   611
   SDL_HapticCondition condition; /**< Condition effect. */
bobbens@2499
   612
   SDL_HapticRamp ramp; /**< Ramp effect. */
bobbens@2477
   613
} SDL_HapticEffect;
bobbens@2477
   614
bobbens@2472
   615
bobbens@2472
   616
/* Function prototypes */
bobbens@2498
   617
/**
bobbens@2497
   618
 * \fn int SDL_NumHaptics(void)
bobbens@2497
   619
 *
bobbens@2497
   620
 * \brief Count the number of joysticks attached to the system.
bobbens@2497
   621
 *
bobbens@2497
   622
 *    \return Number of haptic devices detected on the system.
bobbens@2472
   623
 */
bobbens@2472
   624
extern DECLSPEC int SDLCALL SDL_NumHaptics(void);
bobbens@2472
   625
bobbens@2498
   626
/**
bobbens@2497
   627
 * \fn const char * SDL_HapticName(int device_index)
bobbens@2497
   628
 *
bobbens@2497
   629
 * \brief Get the implementation dependent name of a Haptic device.
bobbens@2472
   630
 * This can be called before any joysticks are opened.
bobbens@2472
   631
 * If no name can be found, this function returns NULL.
bobbens@2497
   632
 *
bobbens@2497
   633
 *    \param device_index Index of the device to get it's name.
bobbens@2497
   634
 *    \return Name of the device or NULL on error.
bobbens@2497
   635
 *
bobbens@2497
   636
 * \sa SDL_NumHaptics
bobbens@2472
   637
 */
bobbens@2472
   638
extern DECLSPEC const char *SDLCALL SDL_HapticName(int device_index);
bobbens@2472
   639
bobbens@2498
   640
/**
bobbens@2499
   641
 * \fn SDL_Haptic * SDL_HapticOpen(int device_index)
bobbens@2497
   642
 *
bobbens@2497
   643
 * \brief Opens a Haptic device for usage - the index passed as an
bobbens@2476
   644
 * argument refers to the N'th Haptic device on this system.
bobbens@2476
   645
 *
bobbens@2507
   646
 * When opening a haptic device, it's gain will be set to maximum and
bobbens@2507
   647
 *  autocenter will be disabled.  To modify these values use
bobbens@2507
   648
 *  SDL_HapticSetGain and SDL_HapticSetAutocenter
bobbens@2497
   649
 *
bobbens@2497
   650
 *    \param device_index Index of the device to open.
bobbens@2497
   651
 *    \return Device identifier or NULL on error.
bobbens@2497
   652
 *
bobbens@2505
   653
 * \sa SDL_HapticIndex
bobbens@2512
   654
 * \sa SDL_HapticOpenFromMouse
bobbens@2497
   655
 * \sa SDL_HapticOpenFromJoystick
bobbens@2497
   656
 * \sa SDL_HapticClose
bobbens@2507
   657
 * \sa SDL_HapticSetGain
bobbens@2507
   658
 * \sa SDL_HapticSetAutocenter
bobbens@2476
   659
 */
bobbens@2476
   660
extern DECLSPEC SDL_Haptic * SDL_HapticOpen(int device_index);
bobbens@2476
   661
bobbens@2506
   662
/**
bobbens@2506
   663
 * \fn int SDL_HapticOpened(int device_index)
bobbens@2506
   664
 *
bobbens@2506
   665
 * \brief Checks if the haptic device at index has been opened.
bobbens@2506
   666
 *
bobbens@2506
   667
 *    \param device_index Index to check to see if it has been opened.
bobbens@2506
   668
 *    \return 1 if it has been opened or 0 if it hasn't.
bobbens@2506
   669
 * 
bobbens@2506
   670
 * \sa SDL_HapticOpen
bobbens@2506
   671
 * \sa SDL_HapticIndex
bobbens@2506
   672
 */
bobbens@2506
   673
extern DECLSPEC int SDL_HapticOpened(int device_index);
bobbens@2505
   674
bobbens@2505
   675
/**
bobbens@2505
   676
 * \fn int SDL_HapticIndex(SDL_Haptic * haptic)
bobbens@2505
   677
 *
bobbens@2505
   678
 * \brief Gets the index of a haptic device.
bobbens@2505
   679
 *
bobbens@2505
   680
 *    \param haptic Haptic device to get the index of.
bobbens@2505
   681
 *    \return The index of the haptic device or -1 on error.
bobbens@2505
   682
 *
bobbens@2505
   683
 * \sa SDL_HapticOpen
bobbens@2506
   684
 * \sa SDL_HapticOpened
bobbens@2505
   685
 */
bobbens@2505
   686
extern DECLSPEC int SDL_HapticIndex(SDL_Haptic * haptic);
bobbens@2505
   687
bobbens@2498
   688
/**
bobbens@2512
   689
 * \fn int SDL_MouseIsHaptic(void)
bobbens@2512
   690
 *
bobbens@2512
   691
 * \brief Gets whether or not the current mouse has haptic capabilities.
bobbens@2512
   692
 *
bobbens@2512
   693
 *    \return SDL_TRUE if the mouse is haptic, SDL_FALSE if it isn't.
bobbens@2512
   694
 *
bobbens@2512
   695
 * \sa SDL_HapticOpenFromMouse
bobbens@2512
   696
 */
bobbens@2517
   697
extern DECLSPEC int SDL_MouseIsHaptic(void);
bobbens@2512
   698
bobbens@2512
   699
/**
bobbens@2512
   700
 * \fn SDL_Haptic * SDL_HapticOpenFromMouse(void)
bobbens@2512
   701
 *
bobbens@2512
   702
 * \brief Tries to open a haptic device from the current mouse.
bobbens@2512
   703
 *
bobbens@2512
   704
 *    \return The haptic device identifier or NULL on error.
bobbens@2512
   705
 *
bobbens@2512
   706
 * \sa SDL_MouseIsHaptic
bobbens@2512
   707
 * \sa SDL_HapticOpen
bobbens@2512
   708
 */
bobbens@2512
   709
extern DECLSPEC SDL_Haptic * SDL_HapticOpenFromMouse(void);
bobbens@2512
   710
bobbens@2512
   711
/**
bobbens@2498
   712
 * \fn int SDL_JoystickIsHaptic(SDL_Joystick * joystick)
bobbens@2489
   713
 *
bobbens@2497
   714
 * \brief Checks to see if a joystick has haptic features.
bobbens@2497
   715
 *
bobbens@2497
   716
 *    \param joystick Joystick to test for haptic capabilities.
bobbens@2497
   717
 *    \return SDL_TRUE if the joystick is haptic, SDL_FALSE if it isn't
bobbens@2497
   718
 *            or -1 if an error ocurred.
bobbens@2497
   719
 *
bobbens@2497
   720
 * \sa SDL_HapticOpenFromJoystick
bobbens@2489
   721
 */
bobbens@2489
   722
extern DECLSPEC int SDL_JoystickIsHaptic(SDL_Joystick * joystick);
bobbens@2489
   723
bobbens@2498
   724
/**
bobbens@2497
   725
 * \fn SDL_Haptic * SDL_HapticOpenFromJoystick(SDL_Joystick * joystick)
bobbens@2489
   726
 *
bobbens@2497
   727
 * \brief Opens a Haptic device for usage from a Joystick device.  Still has
bobbens@2497
   728
 * to be closed seperately to the joystick.
bobbens@2497
   729
 *
bobbens@2497
   730
 *    \param joystick Joystick to create a haptic device from.
bobbens@2497
   731
 *    \return A valid haptic device identifier on success or NULL on error.
bobbens@2497
   732
 *
bobbens@2497
   733
 * \sa SDL_HapticOpen
bobbens@2497
   734
 * \sa SDL_HapticClose
bobbens@2489
   735
 */
bobbens@2489
   736
extern DECLSPEC SDL_Haptic * SDL_HapticOpenFromJoystick(SDL_Joystick * joystick);
bobbens@2489
   737
bobbens@2498
   738
/**
bobbens@2497
   739
 * \fn void SDL_HapticClose(SDL_Haptic * haptic)
bobbens@2497
   740
 *
bobbens@2497
   741
 * \brief Closes a Haptic device previously opened with SDL_HapticOpen.
bobbens@2497
   742
 *
bobbens@2497
   743
 *    \param haptic Haptic device to close.
bobbens@2476
   744
 */
bobbens@2476
   745
extern DECLSPEC void SDL_HapticClose(SDL_Haptic * haptic);
bobbens@2476
   746
bobbens@2498
   747
/**
bobbens@2497
   748
 * \fn int SDL_HapticNumEffects(SDL_Haptic * haptic)
bobbens@2497
   749
 *
bobbens@2497
   750
 * \brief Returns the number of effects a haptic device can store.
bobbens@2497
   751
 *
bobbens@2497
   752
 *    \param haptic The haptic device to query effect max.
bobbens@2497
   753
 *    \return The number of effects the haptic device can store or
bobbens@2497
   754
 *            -1 on error.
bobbens@2497
   755
 *
bobbens@2515
   756
 * \sa SDL_HapticNumEffectsPlaying
bobbens@2497
   757
 * \sa SDL_HapticQuery
bobbens@2478
   758
 */
bobbens@2478
   759
extern DECLSPEC int SDL_HapticNumEffects(SDL_Haptic * haptic);
bobbens@2478
   760
bobbens@2498
   761
/**
bobbens@2515
   762
 * \fn int SDL_HapticNumEffectsPlaying(SDL_Haptic * haptic)
bobbens@2515
   763
 *
bobbens@2515
   764
 * \brief Returns the number of effects a haptic device can play at the same time.
bobbens@2515
   765
 *
bobbens@2515
   766
 *    \param haptic The haptic device to query maximum playing effect.s
bobbens@2515
   767
 *    \return The number of effects the haptic device can play at the same time
bobbens@2515
   768
 *            or -1 on error.
bobbens@2515
   769
 *
bobbens@2515
   770
 * \sa SDL_HapticNumEffects
bobbens@2515
   771
 * \sa SDL_HapticQuery
bobbens@2515
   772
 */
bobbens@2515
   773
extern DECLSPEC int SDL_HapticNumEffectsPlaying(SDL_Haptic * haptic);
bobbens@2515
   774
bobbens@2515
   775
/**
bobbens@2499
   776
 * \fn unsigned int SDL_HapticQuery(SDL_Haptic * haptic)
bobbens@2478
   777
 *
bobbens@2497
   778
 * \brief Gets the haptic devices supported features in bitwise matter.
bobbens@2497
   779
 *
bobbens@2497
   780
 * Example: 
bobbens@2497
   781
 * \code
bobbens@2497
   782
 * if (SDL_HapticQueryEffects(haptic) & SDL_HAPTIC_CONSTANT) {
bobbens@2497
   783
 *    printf("We have constant haptic effect!");
bobbens@2497
   784
 * }
bobbens@2497
   785
 * \endcode
bobbens@2497
   786
 *    
bobbens@2497
   787
 *
bobbens@2497
   788
 *    \param haptic The haptic device to query.
bobbens@2497
   789
 *    \return Haptic features in bitwise manner (OR'd).
bobbens@2497
   790
 *
bobbens@2497
   791
 * \sa SDL_HapticNumEffects
bobbens@2497
   792
 * \sa SDL_HapticEffectSupported
bobbens@2478
   793
 */
bobbens@2497
   794
extern DECLSPEC unsigned int SDL_HapticQuery(SDL_Haptic * haptic);
bobbens@2478
   795
bobbens@2498
   796
/**
bobbens@2499
   797
 * \fn int SDL_HapticEffectSupported(SDL_Haptic * haptic, SDL_HapticEffect * effect)
bobbens@2486
   798
 *
bobbens@2497
   799
 * \brief Checks to see if effect is supported by haptic.
bobbens@2497
   800
 *
bobbens@2497
   801
 *    \param haptic Haptic device to check on.
bobbens@2497
   802
 *    \param effect Effect to check to see if it is supported.
bobbens@2497
   803
 *    \return SDL_TRUE if effect is supported, SDL_FALSE if it isn't or 
bobbens@2497
   804
 *            -1 on error.
bobbens@2497
   805
 * 
bobbens@2497
   806
 * \sa SDL_HapticQuery
bobbens@2497
   807
 * \sa SDL_HapticNewEffect
bobbens@2486
   808
 */
bobbens@2486
   809
extern DECLSPEC int SDL_HapticEffectSupported(SDL_Haptic * haptic, SDL_HapticEffect * effect);
bobbens@2486
   810
bobbens@2498
   811
/**
bobbens@2497
   812
 * \fn int SDL_HapticNewEffect(SDL_Haptic * haptic, SDL_HapticEffect * effect)
bobbens@2483
   813
 *
bobbens@2497
   814
 * \brief Creates a new haptic effect on the device.
bobbens@2497
   815
 *
bobbens@2497
   816
 *    \param haptic Haptic device to create the effect on.
bobbens@2497
   817
 *    \param effect Properties of the effect to create.
bobbens@2497
   818
 *    \return The id of the effect on success or -1 on error.
bobbens@2497
   819
 *
bobbens@2497
   820
 * \sa SDL_HapticUpdateEffect
bobbens@2497
   821
 * \sa SDL_HapticRunEffect
bobbens@2497
   822
 * \sa SDL_HapticDestroyEffect
bobbens@2477
   823
 */
bobbens@2477
   824
extern DECLSPEC int SDL_HapticNewEffect(SDL_Haptic * haptic, SDL_HapticEffect * effect);
bobbens@2477
   825
bobbens@2498
   826
/**
bobbens@2497
   827
 * \fn int SDL_HapticUpdateEffect(SDL_Haptic * haptic, int effect, SDL_HapticEffect * data)
bobbens@2497
   828
 *
bobbens@2497
   829
 * \brief Updates an effect.  Can be used dynamically, although behaviour when
bobbens@2488
   830
 * dynamically changing direction may be strange.  Specifically the effect
bobbens@2488
   831
 * may reupload itself and start playing from the start.  You cannot change
bobbens@2488
   832
 * the type either when running UpdateEffect.
bobbens@2488
   833
 *
bobbens@2497
   834
 *    \param haptic Haptic device that has the effect.
bobbens@2497
   835
 *    \param effect Effect to update.
bobbens@2497
   836
 *    \param data New effect properties to use.
bobbens@2497
   837
 *    \return The id of the effect on success or -1 on error.
bobbens@2497
   838
 *
bobbens@2497
   839
 * \sa SDL_HapticNewEffect
bobbens@2497
   840
 * \sa SDL_HapticRunEffect
bobbens@2497
   841
 * \sa SDL_HapticDestroyEffect
bobbens@2488
   842
 */
bobbens@2488
   843
extern DECLSPEC int SDL_HapticUpdateEffect(SDL_Haptic * haptic, int effect, SDL_HapticEffect * data);
bobbens@2488
   844
bobbens@2498
   845
/**
bobbens@2517
   846
 * \fn int SDL_HapticRunEffect(SDL_Haptic * haptic, int effect, int iterations)
bobbens@2483
   847
 *
bobbens@2497
   848
 * \brief Runs the haptic effect on it's assosciated haptic device.
bobbens@2497
   849
 *
bobbens@2497
   850
 *    \param haptic Haptic device to run the effect on.
bobbens@2497
   851
 *    \param effect Identifier of the haptic effect to run.
bobbens@2517
   852
 *    \param iterations Number of iterations to run the effect. Use
bobbens@2517
   853
 *           SDL_HAPTIC_INFINITY for infinity.
bobbens@2497
   854
 *    \return 0 on success or -1 on error.
bobbens@2497
   855
 *
bobbens@2497
   856
 * \sa SDL_HapticStopEffect
bobbens@2497
   857
 * \sa SDL_HapticDestroyEffect
bobbens@2497
   858
 * \sa SDL_HapticGetEffectStatus
bobbens@2477
   859
 */
bobbens@2517
   860
extern DECLSPEC int SDL_HapticRunEffect(SDL_Haptic * haptic, int effect, int iterations);
bobbens@2477
   861
bobbens@2498
   862
/**
bobbens@2497
   863
 * \fn int SDL_HapticStopEffect(SDL_Haptic * haptic, int effect)
bobbens@2485
   864
 *
bobbens@2497
   865
 * \brief Stops the haptic effect on it's assosciated haptic device.
bobbens@2497
   866
 *
bobbens@2497
   867
 *    \param haptic Haptic device to stop the effect on.
bobbens@2499
   868
 *    \param effect Identifier of the effect to stop.
bobbens@2497
   869
 *    \return 0 on success or -1 on error.
bobbens@2497
   870
 *
bobbens@2497
   871
 * \sa SDL_HapticRunEffect
bobbens@2497
   872
 * \sa SDL_HapticDestroyEffect
bobbens@2485
   873
 */
bobbens@2485
   874
extern DECLSPEC int SDL_HapticStopEffect(SDL_Haptic * haptic, int effect);
bobbens@2485
   875
bobbens@2498
   876
/**
bobbens@2497
   877
 * \fn void SDL_HapticDestroyEffect(SDL_Haptic * haptic, int effect)
bobbens@2497
   878
 *
bobbens@2497
   879
 * \brief Destroys a haptic effect on the device.  This will stop the effect
bobbens@2497
   880
 * if it's running.  Effects are automatically destroyed when the device is
bobbens@2497
   881
 * closed.
bobbens@2497
   882
 *
bobbens@2497
   883
 *    \param haptic Device to destroy the effect on.
bobbens@2497
   884
 *    \param effect Identifier of the effect to destroy.
bobbens@2497
   885
 * 
bobbens@2497
   886
 * \sa SDL_HapticNewEffect
bobbens@2477
   887
 */
bobbens@2477
   888
extern DECLSPEC void SDL_HapticDestroyEffect(SDL_Haptic * haptic, int effect);
bobbens@2477
   889
bobbens@2498
   890
/**
bobbens@2497
   891
 * \fn int SDL_HapticGetEffectStatus(SDL_Haptic *haptic, int effect)
bobbens@2495
   892
 *
bobbens@2497
   893
 * \brief Gets the status of the current effect on the haptic device.
bobbens@2497
   894
 *
bobbens@2497
   895
 * Device must support the SDL_HAPTIC_STATUS feature.
bobbens@2497
   896
 *
bobbens@2497
   897
 *    \param haptic Haptic device to query the effect status on.
bobbens@2497
   898
 *    \param effect Identifier of the effect to query it's status.
bobbens@2497
   899
 *    \return 0 if it isn't playing, SDL_HAPTIC_PLAYING if it is playing
bobbens@2497
   900
 *            or -1 on error.
bobbens@2497
   901
 *
bobbens@2497
   902
 * \sa SDL_HapticRunEffect
bobbens@2497
   903
 * \sa SDL_HapticStopEffect
bobbens@2495
   904
 */
bobbens@2495
   905
extern DECLSPEC int SDL_HapticGetEffectStatus(SDL_Haptic *haptic, int effect);
bobbens@2495
   906
bobbens@2498
   907
/**
bobbens@2497
   908
 * \fn int SDL_HapticSetGain(SDL_Haptic * haptic, int gain)
bobbens@2483
   909
 *
bobbens@2497
   910
 * \brief Sets the global gain of the device.  Gain should be between 0 and 100.
bobbens@2497
   911
 *
bobbens@2497
   912
 * Device must support the SDL_HAPTIC_GAIN feature.
bobbens@2497
   913
 *
bobbens@2507
   914
 * The user may specify the maxmimum gain by setting the environment variable
bobbens@2507
   915
 *  SDL_HAPTIC_GAIN_MAX which should be between 0 and 100.  All calls to
bobbens@2507
   916
 *  SDL_HapticSetGain will scale linearly using SDL_HAPTIC_GAIN_MAX as the
bobbens@2507
   917
 *  maximum.
bobbens@2507
   918
 *
bobbens@2497
   919
 *    \param haptic Haptic device to set the gain on.
bobbens@2497
   920
 *    \param gain Value to set the gain to, should be between 0 and 100.
bobbens@2497
   921
 *    \return 0 on success or -1 on error.
bobbens@2497
   922
 *
bobbens@2497
   923
 * \sa SDL_HapticQuery
bobbens@2483
   924
 */
bobbens@2483
   925
extern DECLSPEC int SDL_HapticSetGain(SDL_Haptic * haptic, int gain);
bobbens@2483
   926
bobbens@2498
   927
/**
bobbens@2497
   928
 * \fn int SDL_HapticSetAutocenter(SDL_Haptic * haptic, int autocenter)
bobbens@2497
   929
 *
bobbens@2497
   930
 * \brief Sets the global autocenter of the device.  Autocenter should be between
bobbens@2484
   931
 * 0 and 100.  Setting it to 0 will disable autocentering.
bobbens@2484
   932
 *
bobbens@2497
   933
 * Device must support the SDL_HAPTIC_AUTOCENTER feature.
bobbens@2497
   934
 *
bobbens@2497
   935
 *    \param haptic Haptic device to set autocentering on.
bobbens@2497
   936
 *    \param autocenter Value to set autocenter to, 0 disables autocentering.
bobbens@2497
   937
 *    \return 0 on success or -1 on error.
bobbens@2497
   938
 *
bobbens@2497
   939
 * \sa SDL_HapticQuery
bobbens@2484
   940
 */
bobbens@2484
   941
extern DECLSPEC int SDL_HapticSetAutocenter(SDL_Haptic * haptic, int autocenter);
bobbens@2484
   942
bobbens@2472
   943
bobbens@2472
   944
/* Ends C function definitions when using C++ */
bobbens@2472
   945
#ifdef __cplusplus
bobbens@2472
   946
/* *INDENT-OFF* */
bobbens@2472
   947
}
bobbens@2472
   948
/* *INDENT-ON* */
bobbens@2472
   949
#endif
bobbens@2472
   950
#include "close_code.h"
bobbens@2472
   951
bobbens@2472
   952
#endif /* _SDL_haptic_h */
bobbens@2472
   953
bobbens@2472
   954
/* vi: set ts=4 sw=4 expandtab: */
bobbens@2472
   955
bobbens@2472
   956