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