include/SDL_haptic.h
author Edgar Simo <bobbens@gmail.com>
Sat, 19 Jul 2008 16:06:43 +0000
branchgsoc2008_force_feedback
changeset 2536 fe3ee345a5d2
parent 2535 f0ed8471497d
child 2554 2681a04c2d3d
permissions -rw-r--r--
Fixed some typos in the doxygen.
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@2536
   215
 * \brief User defined custom haptic effect.
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@2536
   265
 * \def SDL_HAPTIC_SPHERICAL
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@2526
   437
 * Phase is given by hundredth of a cyle meaning that giving the phase a value
bobbens@2526
   438
 *  of 9000 will displace it 25% of it's period.  Here are sample values:
bobbens@2526
   439
 *    -     0: No phase displacement.
bobbens@2526
   440
 *    -  9000: Displaced 25% of it's period.
bobbens@2526
   441
 *    - 18000: Displaced 50% of it's period.
bobbens@2526
   442
 *    - 27000: Displaced 75% of it's period.
bobbens@2526
   443
 *    - 36000: Displaced 100% of it's period, same as 0, but 0 is preffered.
bobbens@2526
   444
 *
bobbens@2499
   445
 * Examples:
bobbens@2499
   446
 * \code
bobbens@2499
   447
 * SDL_HAPTIC_SINE
bobbens@2499
   448
 *   __      __      __      __
bobbens@2499
   449
 *  /  \    /  \    /  \    /
bobbens@2499
   450
 * /    \__/    \__/    \__/
bobbens@2499
   451
 *
bobbens@2499
   452
 * SDL_HAPTIC_SQUARE
bobbens@2499
   453
 *  __    __    __    __    __
bobbens@2499
   454
 * |  |  |  |  |  |  |  |  |  |
bobbens@2499
   455
 * |  |__|  |__|  |__|  |__|  |
bobbens@2499
   456
 *
bobbens@2499
   457
 * SDL_HAPTIC_TRIANGLE
bobbens@2499
   458
 *   /\    /\    /\    /\    /\
bobbens@2499
   459
 *  /  \  /  \  /  \  /  \  /
bobbens@2499
   460
 * /    \/    \/    \/    \/
bobbens@2499
   461
 *
bobbens@2499
   462
 * SDL_HAPTIC_SAWTOOTHUP
bobbens@2504
   463
 *   /|  /|  /|  /|  /|  /|  /|
bobbens@2504
   464
 *  / | / | / | / | / | / | / |
bobbens@2504
   465
 * /  |/  |/  |/  |/  |/  |/  |
bobbens@2499
   466
 *
bobbens@2499
   467
 * SDL_HAPTIC_SAWTOOTHDOWN
bobbens@2504
   468
 * \  |\  |\  |\  |\  |\  |\  |
bobbens@2504
   469
 *  \ | \ | \ | \ | \ | \ | \ |
bobbens@2504
   470
 *   \|  \|  \|  \|  \|  \|  \|
bobbens@2499
   471
 * \endcode
bobbens@2499
   472
 *
bobbens@2497
   473
 * \sa SDL_HAPTIC_SINE
bobbens@2497
   474
 * \sa SDL_HAPTIC_SQUARE
bobbens@2497
   475
 * \sa SDL_HAPTIC_TRIANGLE
bobbens@2497
   476
 * \sa SDL_HAPTIC_SAWTOOTHUP
bobbens@2504
   477
 * \sa SDL_HAPTIC_SAWTOOTHDOWN
bobbens@2497
   478
 * \sa SDL_HapticEffect
bobbens@2497
   479
 */
bobbens@2497
   480
typedef struct SDL_HapticPeriodic {
bobbens@2497
   481
   /* Header */
bobbens@2504
   482
   Uint16 type; /**< SDL_HAPTIC_SINE, SDL_HAPTIC_SQUARE,
bobbens@2504
   483
                     SDL_HAPTIC_TRIANGLE, SDL_HAPTIC_SAWTOOTHUP or
bobbens@2504
   484
                     SDL_HAPTIC_SAWTOOTHDOWN */
bobbens@2499
   485
   SDL_HapticDirection direction; /**< Direction of the effect. */
bobbens@2497
   486
bobbens@2497
   487
   /* Replay */
bobbens@2519
   488
   Uint32 length; /**< Duration of the effect. */
bobbens@2497
   489
   Uint16 delay; /**< Delay before starting the effect. */
bobbens@2497
   490
bobbens@2497
   491
   /* Trigger */
bobbens@2497
   492
   Uint16 button; /**< Button that triggers the effect. */
bobbens@2497
   493
   Uint16 interval; /**< How soon it can be triggered again after button. */
bobbens@2497
   494
bobbens@2497
   495
   /* Periodic */
bobbens@2497
   496
   Uint16 period; /**< Period of the wave. */
bobbens@2497
   497
   Sint16 magnitude; /**< Peak value. */
bobbens@2497
   498
   Sint16 offset; /**< Mean value of the wave. */
bobbens@2526
   499
   Uint16 phase; /**< Horizontal shift given by hundredth of a cycle. */
bobbens@2497
   500
bobbens@2497
   501
   /* Envelope */
bobbens@2497
   502
   Uint16 attack_length; /**< Duration of the attack. */
bobbens@2497
   503
   Uint16 attack_level; /**< Level at the start of the attack. */
bobbens@2497
   504
   Uint16 fade_length; /**< Duration of the fade. */
bobbens@2497
   505
   Uint16 fade_level; /**< Level at the end of the fade. */
bobbens@2497
   506
} SDL_HapticPeriodic;
bobbens@2497
   507
/**
bobbens@2497
   508
 * \struct SDL_HapticCondition
bobbens@2497
   509
 *
bobbens@2497
   510
 * \brief A structure containing a template for a Condition effect.
bobbens@2497
   511
 *
bobbens@2497
   512
 * The struct handles the following effects:
bobbens@2499
   513
 *   - SDL_HAPTIC_SPRING: Effect based on axes position.
bobbens@2499
   514
 *   - SDL_HAPTIC_DAMPER: Effect based on axes velocity.
bobbens@2499
   515
 *   - SDL_HAPTIC_INERTIA: Effect based on axes acceleration.
bobbens@2499
   516
 *   - SDL_HAPTIC_FRICTION: Effect based on axes movement.
bobbens@2497
   517
 *
bobbens@2504
   518
 * Direction is handled by condition internals instead of a direction member.
bobbens@2525
   519
 *  The condition effect specific members have three parameters.  The first
bobbens@2525
   520
 *  refers to the X axis, the second refers to the Y axis and the third
bobbens@2525
   521
 *  refers to the Z axis.  The right terms refer to the positive side of the
bobbens@2525
   522
 *  axis and the left terms refer to the negative side of the axis.  Please 
bobbens@2525
   523
 *  refer to the SDL_HapticDirection  diagram for which side is positive and
bobbens@2525
   524
 *  which is negative.
bobbens@2504
   525
 *
bobbens@2500
   526
 * \sa SDL_HapticDirection
bobbens@2497
   527
 * \sa SDL_HAPTIC_SPRING
bobbens@2497
   528
 * \sa SDL_HAPTIC_DAMPER
bobbens@2497
   529
 * \sa SDL_HAPTIC_INERTIA
bobbens@2497
   530
 * \sa SDL_HAPTIC_FRICTION
bobbens@2497
   531
 * \sa SDL_HapticEffect
bobbens@2497
   532
 */
bobbens@2497
   533
typedef struct SDL_HapticCondition {
bobbens@2497
   534
   /* Header */
bobbens@2504
   535
   Uint16 type; /**< SDL_HAPTIC_SPRING, SDL_HAPTIC_DAMPER,
bobbens@2504
   536
                     SDL_HAPTIC_INERTIA or SDL_HAPTIC_FRICTION */
bobbens@2523
   537
   SDL_HapticDirection direction; /**< Direction of the effect - Not used ATM. */
bobbens@2497
   538
bobbens@2497
   539
   /* Replay */
bobbens@2519
   540
   Uint32 length; /**< Duration of the effect. */
bobbens@2497
   541
   Uint16 delay; /**< Delay before starting the effect. */
bobbens@2497
   542
bobbens@2497
   543
   /* Trigger */
bobbens@2497
   544
   Uint16 button; /**< Button that triggers the effect. */
bobbens@2497
   545
   Uint16 interval; /**< How soon it can be triggered again after button. */
bobbens@2497
   546
bobbens@2497
   547
   /* Condition */
bobbens@2525
   548
   Uint16 right_sat[3]; /**< Level when joystick is to the positive side. */
bobbens@2525
   549
   Uint16 left_sat[3]; /**< Level when joystick is to the negative side. */
bobbens@2525
   550
   Sint16 right_coeff[3]; /**< How fast to increase the force towards the positive side. */
bobbens@2525
   551
   Sint16 left_coeff[3]; /**< How fast to increase the force towards the negative side. */
bobbens@2525
   552
   Uint16 deadband[3]; /**< Size of the dead zone. */
bobbens@2525
   553
   Sint16 center[3]; /**< Position of the dead zone. */
bobbens@2497
   554
} SDL_HapticCondition;
bobbens@2497
   555
/**
bobbens@2497
   556
 * \struct SDL_HapticRamp
bobbens@2497
   557
 *
bobbens@2497
   558
 * \brief A structure containing a template for a Ramp effect.
bobbens@2497
   559
 *
bobbens@2497
   560
 * This struct is exclusively for the SDL_HAPTIC_RAMP effect.
bobbens@2497
   561
 *
bobbens@2504
   562
 * The ramp effect starts at start strength and ends at end strength.
bobbens@2504
   563
 *  It augments in linear fashion.  If you use attack and fade with a ramp
bobbens@2504
   564
 *  they effects get added to the ramp effect making the effect become
bobbens@2504
   565
 *  quadratic instead of linear.
bobbens@2504
   566
 *
bobbens@2497
   567
 * \sa SDL_HAPTIC_RAMP
bobbens@2497
   568
 * \sa SDL_HapticEffect
bobbens@2497
   569
 */
bobbens@2497
   570
typedef struct SDL_HapticRamp {
bobbens@2497
   571
   /* Header */
bobbens@2497
   572
   Uint16 type; /**< SDL_HAPTIC_RAMP */
bobbens@2499
   573
   SDL_HapticDirection direction; /**< Direction of the effect. */
bobbens@2497
   574
bobbens@2497
   575
   /* Replay */
bobbens@2519
   576
   Uint32 length; /**< Duration of the effect. */
bobbens@2497
   577
   Uint16 delay; /**< Delay before starting the effect. */
bobbens@2497
   578
bobbens@2497
   579
   /* Trigger */
bobbens@2497
   580
   Uint16 button; /**< Button that triggers the effect. */
bobbens@2497
   581
   Uint16 interval; /**< How soon it can be triggered again after button. */
bobbens@2497
   582
bobbens@2497
   583
   /* Ramp */
bobbens@2497
   584
   Sint16 start; /**< Beginning strength level. */
bobbens@2497
   585
   Sint16 end; /**< Ending strength level. */
bobbens@2497
   586
bobbens@2497
   587
   /* Envelope */
bobbens@2497
   588
   Uint16 attack_length; /**< Duration of the attack. */
bobbens@2497
   589
   Uint16 attack_level; /**< Level at the start of the attack. */
bobbens@2497
   590
   Uint16 fade_length; /**< Duration of the fade. */
bobbens@2497
   591
   Uint16 fade_level; /**< Level at the end of the fade. */
bobbens@2497
   592
} SDL_HapticRamp;
bobbens@2498
   593
/**
bobbens@2535
   594
 * \struct SDL_HapticCustom
bobbens@2535
   595
 *
bobbens@2535
   596
 * \brief A structure containing a template for the SDL_HAPTIC_CUSTOM effect.
bobbens@2535
   597
 *
bobbens@2535
   598
 * A custom force feedback effect is much like a periodic effect, where the
bobbens@2535
   599
 *  application can define it's exact shape.  You will have to allocate the
bobbens@2535
   600
 *  data yourself.  Data should consist of channels * samples Uint16 samples.
bobbens@2535
   601
 *
bobbens@2535
   602
 * If channels is one, the effect is rotated using the defined direction.
bobbens@2535
   603
 *  Otherwise it uses the samples in data for the different axes.
bobbens@2535
   604
 *
bobbens@2535
   605
 * \sa SDL_HAPTIC_CUSTOM
bobbens@2535
   606
 * \sa SDL_HapticEffect
bobbens@2535
   607
 */
bobbens@2535
   608
typedef struct SDL_HapticCustom {
bobbens@2535
   609
   /* Header */
bobbens@2535
   610
   Uint16 type; /**< SDL_HAPTIC_CUSTOM */
bobbens@2535
   611
   SDL_HapticDirection direction; /**< Direction of the effect. */
bobbens@2535
   612
bobbens@2535
   613
   /* Replay */
bobbens@2535
   614
   Uint32 length; /**< Duration of the effect. */
bobbens@2535
   615
   Uint16 delay; /**< Delay before starting the effect. */
bobbens@2535
   616
bobbens@2535
   617
   /* Trigger */
bobbens@2535
   618
   Uint16 button; /**< Button that triggers the effect. */
bobbens@2535
   619
   Uint16 interval; /**< How soon it can be triggered again after button. */
bobbens@2535
   620
bobbens@2535
   621
   /* Custom */
bobbens@2535
   622
   Uint8 channels; /**< Axes to use, minimum of one. */
bobbens@2535
   623
   Uint16 period; /**< Sample periods. */
bobbens@2535
   624
   Uint16 samples; /**< Amount of samples. */
bobbens@2535
   625
   Uint16 *data; /**< Should contain channels*samples items. */
bobbens@2535
   626
bobbens@2535
   627
   /* Envelope */                                                         
bobbens@2535
   628
   Uint16 attack_length; /**< Duration of the attack. */
bobbens@2535
   629
   Uint16 attack_level; /**< Level at the start of the attack. */
bobbens@2535
   630
   Uint16 fade_length; /**< Duration of the fade. */
bobbens@2535
   631
   Uint16 fade_level; /**< Level at the end of the fade. */
bobbens@2535
   632
} SDL_HapticCustom;
bobbens@2535
   633
/**
bobbens@2497
   634
 * \union SDL_HapticEffect
bobbens@2497
   635
 *
bobbens@2497
   636
 * \brief The generic template for any haptic effect.
bobbens@2497
   637
 *
bobbens@2499
   638
 * All values max at 32767 (0x7FFF).  Signed values also can be negative.
bobbens@2504
   639
 *  Time values unless specified otherwise are in milliseconds.
bobbens@2481
   640
 *
bobbens@2519
   641
 * You can also pass SDL_HAPTIC_INFINITY to length instead of a 0-32767 value.
bobbens@2519
   642
 *  Neither delay, interval, attack_length nor fade_length support 
bobbens@2526
   643
 *  SDL_HAPTIC_INFINITY.  Fade will also not be used since effect never ends.
bobbens@2519
   644
 *
bobbens@2532
   645
 * Additionally, the SDL_HAPTIC_RAMP effect does not support a duration of
bobbens@2532
   646
 *  SDL_HAPTIC_INFINITY.
bobbens@2532
   647
 *
bobbens@2481
   648
 * Common parts:
bobbens@2499
   649
 * \code
bobbens@2499
   650
 * // Replay - All effects have this
bobbens@2519
   651
 * Uint32 length;        // Duration of effect (ms).
bobbens@2499
   652
 * Uint16 delay;         // Delay before starting effect.
bobbens@2499
   653
 *
bobbens@2499
   654
 * // Trigger - All effects have this
bobbens@2499
   655
 * Uint16 button;        // Button that triggers effect.
bobbens@2499
   656
 * Uint16 interval;      // How soon before effect can be triggered again.
bobbens@2499
   657
 *
bobbens@2504
   658
 * // Envelope - All effects except condition effects have this
bobbens@2499
   659
 * Uint16 attack_length; // Duration of the attack (ms).
bobbens@2499
   660
 * Uint16 attack_level;  // Level at the start of the attack.
bobbens@2499
   661
 * Uint16 fade_length;   // Duration of the fade out (ms).
bobbens@2499
   662
 * Uint16 fade_level;    // Level at the end of the fade.
bobbens@2499
   663
 * \endcode
bobbens@2499
   664
 *
bobbens@2499
   665
 *
bobbens@2504
   666
 * Here we have an example of a constant effect evolution in time:
bobbens@2499
   667
 *
bobbens@2499
   668
 * \code
bobbens@2499
   669
 * Strength
bobbens@2499
   670
 * ^
bobbens@2499
   671
 * |
bobbens@2504
   672
 * |    effect level -->  _________________
bobbens@2499
   673
 * |                     /                 \
bobbens@2499
   674
 * |                    /                   \
bobbens@2499
   675
 * |                   /                     \
bobbens@2499
   676
 * |                  /                       \ 
bobbens@2499
   677
 * | attack_level --> |                        \
bobbens@2499
   678
 * |                  |                        |  <---  fade_level
bobbens@2499
   679
 * |
bobbens@2499
   680
 * +--------------------------------------------------> Time
bobbens@2499
   681
 *                    [--]                 [---]
bobbens@2499
   682
 *                    attack_length        fade_length
bobbens@2481
   683
 * 
bobbens@2499
   684
 * [------------------][-----------------------]
bobbens@2499
   685
 * delay               length
bobbens@2499
   686
 * \endcode
bobbens@2497
   687
 *
bobbens@2504
   688
 * Note either the attack_level or the fade_level may be above the actual
bobbens@2504
   689
 *  effect level.
bobbens@2504
   690
 *
bobbens@2497
   691
 * \sa SDL_HapticConstant
bobbens@2497
   692
 * \sa SDL_HapticPeriodic
bobbens@2497
   693
 * \sa SDL_HapticCondition
bobbens@2499
   694
 * \sa SDL_HapticRamp
bobbens@2535
   695
 * \sa SDL_HapticCustom
bobbens@2481
   696
 */
bobbens@2477
   697
typedef union SDL_HapticEffect {
bobbens@2477
   698
   /* Common for all force feedback effects */
bobbens@2499
   699
   Uint16 type; /**< Effect type. */
bobbens@2499
   700
   SDL_HapticConstant constant; /**< Constant effect. */
bobbens@2499
   701
   SDL_HapticPeriodic periodic; /**< Periodic effect. */
bobbens@2500
   702
   SDL_HapticCondition condition; /**< Condition effect. */
bobbens@2499
   703
   SDL_HapticRamp ramp; /**< Ramp effect. */
bobbens@2535
   704
   SDL_HapticCustom custom; /**< Custom effect. */
bobbens@2477
   705
} SDL_HapticEffect;
bobbens@2477
   706
bobbens@2472
   707
bobbens@2472
   708
/* Function prototypes */
bobbens@2498
   709
/**
bobbens@2497
   710
 * \fn int SDL_NumHaptics(void)
bobbens@2497
   711
 *
bobbens@2497
   712
 * \brief Count the number of joysticks attached to the system.
bobbens@2497
   713
 *
bobbens@2497
   714
 *    \return Number of haptic devices detected on the system.
bobbens@2472
   715
 */
bobbens@2472
   716
extern DECLSPEC int SDLCALL SDL_NumHaptics(void);
bobbens@2472
   717
bobbens@2498
   718
/**
bobbens@2497
   719
 * \fn const char * SDL_HapticName(int device_index)
bobbens@2497
   720
 *
bobbens@2497
   721
 * \brief Get the implementation dependent name of a Haptic device.
bobbens@2472
   722
 * This can be called before any joysticks are opened.
bobbens@2472
   723
 * If no name can be found, this function returns NULL.
bobbens@2497
   724
 *
bobbens@2497
   725
 *    \param device_index Index of the device to get it's name.
bobbens@2497
   726
 *    \return Name of the device or NULL on error.
bobbens@2497
   727
 *
bobbens@2497
   728
 * \sa SDL_NumHaptics
bobbens@2472
   729
 */
bobbens@2472
   730
extern DECLSPEC const char *SDLCALL SDL_HapticName(int device_index);
bobbens@2472
   731
bobbens@2498
   732
/**
bobbens@2499
   733
 * \fn SDL_Haptic * SDL_HapticOpen(int device_index)
bobbens@2497
   734
 *
bobbens@2497
   735
 * \brief Opens a Haptic device for usage - the index passed as an
bobbens@2476
   736
 * argument refers to the N'th Haptic device on this system.
bobbens@2476
   737
 *
bobbens@2507
   738
 * When opening a haptic device, it's gain will be set to maximum and
bobbens@2507
   739
 *  autocenter will be disabled.  To modify these values use
bobbens@2507
   740
 *  SDL_HapticSetGain and SDL_HapticSetAutocenter
bobbens@2497
   741
 *
bobbens@2497
   742
 *    \param device_index Index of the device to open.
bobbens@2497
   743
 *    \return Device identifier or NULL on error.
bobbens@2497
   744
 *
bobbens@2505
   745
 * \sa SDL_HapticIndex
bobbens@2512
   746
 * \sa SDL_HapticOpenFromMouse
bobbens@2497
   747
 * \sa SDL_HapticOpenFromJoystick
bobbens@2497
   748
 * \sa SDL_HapticClose
bobbens@2507
   749
 * \sa SDL_HapticSetGain
bobbens@2507
   750
 * \sa SDL_HapticSetAutocenter
bobbens@2476
   751
 */
bobbens@2523
   752
extern DECLSPEC SDL_Haptic *SDLCALL SDL_HapticOpen(int device_index);
bobbens@2476
   753
bobbens@2506
   754
/**
bobbens@2506
   755
 * \fn int SDL_HapticOpened(int device_index)
bobbens@2506
   756
 *
bobbens@2506
   757
 * \brief Checks if the haptic device at index has been opened.
bobbens@2506
   758
 *
bobbens@2506
   759
 *    \param device_index Index to check to see if it has been opened.
bobbens@2506
   760
 *    \return 1 if it has been opened or 0 if it hasn't.
bobbens@2506
   761
 * 
bobbens@2506
   762
 * \sa SDL_HapticOpen
bobbens@2506
   763
 * \sa SDL_HapticIndex
bobbens@2506
   764
 */
bobbens@2523
   765
extern DECLSPEC int SDLCALL SDL_HapticOpened(int device_index);
bobbens@2505
   766
bobbens@2505
   767
/**
bobbens@2505
   768
 * \fn int SDL_HapticIndex(SDL_Haptic * haptic)
bobbens@2505
   769
 *
bobbens@2505
   770
 * \brief Gets the index of a haptic device.
bobbens@2505
   771
 *
bobbens@2505
   772
 *    \param haptic Haptic device to get the index of.
bobbens@2505
   773
 *    \return The index of the haptic device or -1 on error.
bobbens@2505
   774
 *
bobbens@2505
   775
 * \sa SDL_HapticOpen
bobbens@2506
   776
 * \sa SDL_HapticOpened
bobbens@2505
   777
 */
bobbens@2523
   778
extern DECLSPEC int SDLCALL SDL_HapticIndex(SDL_Haptic * haptic);
bobbens@2505
   779
bobbens@2498
   780
/**
bobbens@2512
   781
 * \fn int SDL_MouseIsHaptic(void)
bobbens@2512
   782
 *
bobbens@2512
   783
 * \brief Gets whether or not the current mouse has haptic capabilities.
bobbens@2512
   784
 *
bobbens@2512
   785
 *    \return SDL_TRUE if the mouse is haptic, SDL_FALSE if it isn't.
bobbens@2512
   786
 *
bobbens@2512
   787
 * \sa SDL_HapticOpenFromMouse
bobbens@2512
   788
 */
bobbens@2523
   789
extern DECLSPEC int SDLCALL SDL_MouseIsHaptic(void);
bobbens@2512
   790
bobbens@2512
   791
/**
bobbens@2512
   792
 * \fn SDL_Haptic * SDL_HapticOpenFromMouse(void)
bobbens@2512
   793
 *
bobbens@2512
   794
 * \brief Tries to open a haptic device from the current mouse.
bobbens@2512
   795
 *
bobbens@2512
   796
 *    \return The haptic device identifier or NULL on error.
bobbens@2512
   797
 *
bobbens@2512
   798
 * \sa SDL_MouseIsHaptic
bobbens@2512
   799
 * \sa SDL_HapticOpen
bobbens@2512
   800
 */
bobbens@2523
   801
extern DECLSPEC SDL_Haptic *SDLCALL SDL_HapticOpenFromMouse(void);
bobbens@2512
   802
bobbens@2512
   803
/**
bobbens@2498
   804
 * \fn int SDL_JoystickIsHaptic(SDL_Joystick * joystick)
bobbens@2489
   805
 *
bobbens@2497
   806
 * \brief Checks to see if a joystick has haptic features.
bobbens@2497
   807
 *
bobbens@2497
   808
 *    \param joystick Joystick to test for haptic capabilities.
bobbens@2497
   809
 *    \return SDL_TRUE if the joystick is haptic, SDL_FALSE if it isn't
bobbens@2497
   810
 *            or -1 if an error ocurred.
bobbens@2497
   811
 *
bobbens@2497
   812
 * \sa SDL_HapticOpenFromJoystick
bobbens@2489
   813
 */
bobbens@2523
   814
extern DECLSPEC int SDLCALL SDL_JoystickIsHaptic(SDL_Joystick * joystick);
bobbens@2489
   815
bobbens@2498
   816
/**
bobbens@2497
   817
 * \fn SDL_Haptic * SDL_HapticOpenFromJoystick(SDL_Joystick * joystick)
bobbens@2489
   818
 *
bobbens@2497
   819
 * \brief Opens a Haptic device for usage from a Joystick device.  Still has
bobbens@2497
   820
 * to be closed seperately to the joystick.
bobbens@2497
   821
 *
bobbens@2497
   822
 *    \param joystick Joystick to create a haptic device from.
bobbens@2497
   823
 *    \return A valid haptic device identifier on success or NULL on error.
bobbens@2497
   824
 *
bobbens@2497
   825
 * \sa SDL_HapticOpen
bobbens@2497
   826
 * \sa SDL_HapticClose
bobbens@2489
   827
 */
bobbens@2523
   828
extern DECLSPEC SDL_Haptic *SDLCALL SDL_HapticOpenFromJoystick(SDL_Joystick * joystick);
bobbens@2489
   829
bobbens@2498
   830
/**
bobbens@2497
   831
 * \fn void SDL_HapticClose(SDL_Haptic * haptic)
bobbens@2497
   832
 *
bobbens@2497
   833
 * \brief Closes a Haptic device previously opened with SDL_HapticOpen.
bobbens@2497
   834
 *
bobbens@2497
   835
 *    \param haptic Haptic device to close.
bobbens@2476
   836
 */
bobbens@2523
   837
extern DECLSPEC void SDLCALL SDL_HapticClose(SDL_Haptic * haptic);
bobbens@2476
   838
bobbens@2498
   839
/**
bobbens@2497
   840
 * \fn int SDL_HapticNumEffects(SDL_Haptic * haptic)
bobbens@2497
   841
 *
bobbens@2497
   842
 * \brief Returns the number of effects a haptic device can store.
bobbens@2497
   843
 *
bobbens@2497
   844
 *    \param haptic The haptic device to query effect max.
bobbens@2497
   845
 *    \return The number of effects the haptic device can store or
bobbens@2497
   846
 *            -1 on error.
bobbens@2497
   847
 *
bobbens@2515
   848
 * \sa SDL_HapticNumEffectsPlaying
bobbens@2497
   849
 * \sa SDL_HapticQuery
bobbens@2478
   850
 */
bobbens@2523
   851
extern DECLSPEC int SDLCALL SDL_HapticNumEffects(SDL_Haptic * haptic);
bobbens@2478
   852
bobbens@2498
   853
/**
bobbens@2515
   854
 * \fn int SDL_HapticNumEffectsPlaying(SDL_Haptic * haptic)
bobbens@2515
   855
 *
bobbens@2515
   856
 * \brief Returns the number of effects a haptic device can play at the same time.
bobbens@2515
   857
 *
bobbens@2515
   858
 *    \param haptic The haptic device to query maximum playing effect.s
bobbens@2515
   859
 *    \return The number of effects the haptic device can play at the same time
bobbens@2515
   860
 *            or -1 on error.
bobbens@2515
   861
 *
bobbens@2515
   862
 * \sa SDL_HapticNumEffects
bobbens@2515
   863
 * \sa SDL_HapticQuery
bobbens@2515
   864
 */
bobbens@2523
   865
extern DECLSPEC int SDLCALL SDL_HapticNumEffectsPlaying(SDL_Haptic * haptic);
bobbens@2515
   866
bobbens@2515
   867
/**
bobbens@2499
   868
 * \fn unsigned int SDL_HapticQuery(SDL_Haptic * haptic)
bobbens@2478
   869
 *
bobbens@2497
   870
 * \brief Gets the haptic devices supported features in bitwise matter.
bobbens@2497
   871
 *
bobbens@2497
   872
 * Example: 
bobbens@2497
   873
 * \code
bobbens@2497
   874
 * if (SDL_HapticQueryEffects(haptic) & SDL_HAPTIC_CONSTANT) {
bobbens@2497
   875
 *    printf("We have constant haptic effect!");
bobbens@2497
   876
 * }
bobbens@2497
   877
 * \endcode
bobbens@2497
   878
 *    
bobbens@2497
   879
 *
bobbens@2497
   880
 *    \param haptic The haptic device to query.
bobbens@2497
   881
 *    \return Haptic features in bitwise manner (OR'd).
bobbens@2497
   882
 *
bobbens@2497
   883
 * \sa SDL_HapticNumEffects
bobbens@2497
   884
 * \sa SDL_HapticEffectSupported
bobbens@2478
   885
 */
bobbens@2523
   886
extern DECLSPEC unsigned int SDLCALL SDL_HapticQuery(SDL_Haptic * haptic);
bobbens@2523
   887
bobbens@2523
   888
bobbens@2523
   889
/**
bobbens@2523
   890
 * \fn int SDL_HapticNumAxes(SDL_Haptic * haptic)
bobbens@2523
   891
 *
bobbens@2523
   892
 * \brief Gets the number of haptic axes the device has.
bobbens@2523
   893
 *
bobbens@2523
   894
 * \sa SDL_HapticDirection
bobbens@2523
   895
 */
bobbens@2523
   896
extern DECLSPEC int SDLCALL SDL_HapticNumAxes(SDL_Haptic * haptic);
bobbens@2478
   897
bobbens@2498
   898
/**
bobbens@2499
   899
 * \fn int SDL_HapticEffectSupported(SDL_Haptic * haptic, SDL_HapticEffect * effect)
bobbens@2486
   900
 *
bobbens@2497
   901
 * \brief Checks to see if effect is supported by haptic.
bobbens@2497
   902
 *
bobbens@2497
   903
 *    \param haptic Haptic device to check on.
bobbens@2497
   904
 *    \param effect Effect to check to see if it is supported.
bobbens@2497
   905
 *    \return SDL_TRUE if effect is supported, SDL_FALSE if it isn't or 
bobbens@2497
   906
 *            -1 on error.
bobbens@2497
   907
 * 
bobbens@2497
   908
 * \sa SDL_HapticQuery
bobbens@2497
   909
 * \sa SDL_HapticNewEffect
bobbens@2486
   910
 */
bobbens@2523
   911
extern DECLSPEC int SDLCALL SDL_HapticEffectSupported(SDL_Haptic * haptic, SDL_HapticEffect * effect);
bobbens@2486
   912
bobbens@2498
   913
/**
bobbens@2497
   914
 * \fn int SDL_HapticNewEffect(SDL_Haptic * haptic, SDL_HapticEffect * effect)
bobbens@2483
   915
 *
bobbens@2497
   916
 * \brief Creates a new haptic effect on the device.
bobbens@2497
   917
 *
bobbens@2497
   918
 *    \param haptic Haptic device to create the effect on.
bobbens@2497
   919
 *    \param effect Properties of the effect to create.
bobbens@2497
   920
 *    \return The id of the effect on success or -1 on error.
bobbens@2497
   921
 *
bobbens@2497
   922
 * \sa SDL_HapticUpdateEffect
bobbens@2497
   923
 * \sa SDL_HapticRunEffect
bobbens@2497
   924
 * \sa SDL_HapticDestroyEffect
bobbens@2477
   925
 */
bobbens@2523
   926
extern DECLSPEC int SDLCALL SDL_HapticNewEffect(SDL_Haptic * haptic, SDL_HapticEffect * effect);
bobbens@2477
   927
bobbens@2498
   928
/**
bobbens@2497
   929
 * \fn int SDL_HapticUpdateEffect(SDL_Haptic * haptic, int effect, SDL_HapticEffect * data)
bobbens@2497
   930
 *
bobbens@2526
   931
 * \brief Updates the properties of an effect.
bobbens@2526
   932
 *
bobbens@2526
   933
 * Can be used dynamically, although behaviour when dynamically changing
bobbens@2526
   934
 * direction may be strange.  Specifically the effect may reupload itself
bobbens@2526
   935
 * and start playing from the start.  You cannot change the type either when
bobbens@2526
   936
 * running UpdateEffect.
bobbens@2488
   937
 *
bobbens@2497
   938
 *    \param haptic Haptic device that has the effect.
bobbens@2497
   939
 *    \param effect Effect to update.
bobbens@2497
   940
 *    \param data New effect properties to use.
bobbens@2497
   941
 *    \return The id of the effect on success or -1 on error.
bobbens@2497
   942
 *
bobbens@2497
   943
 * \sa SDL_HapticNewEffect
bobbens@2497
   944
 * \sa SDL_HapticRunEffect
bobbens@2497
   945
 * \sa SDL_HapticDestroyEffect
bobbens@2488
   946
 */
bobbens@2523
   947
extern DECLSPEC int SDLCALL SDL_HapticUpdateEffect(SDL_Haptic * haptic, int effect, SDL_HapticEffect * data);
bobbens@2488
   948
bobbens@2498
   949
/**
bobbens@2536
   950
 * \fn int SDL_HapticRunEffect(SDL_Haptic * haptic, int effect, Uint32 iterations)
bobbens@2483
   951
 *
bobbens@2497
   952
 * \brief Runs the haptic effect on it's assosciated haptic device.
bobbens@2497
   953
 *
bobbens@2526
   954
 * If iterations are SDL_HAPTIC_INFINITY, it'll run the effect over and over
bobbens@2526
   955
 *  repeating the envelope (attack and fade) every time.  If you only want the
bobbens@2526
   956
 *  effect to last forever, set SDL_HAPTIC_INFINITY in the effect's length
bobbens@2526
   957
 *  parameter.
bobbens@2526
   958
 *
bobbens@2497
   959
 *    \param haptic Haptic device to run the effect on.
bobbens@2497
   960
 *    \param effect Identifier of the haptic effect to run.
bobbens@2517
   961
 *    \param iterations Number of iterations to run the effect. Use
bobbens@2517
   962
 *           SDL_HAPTIC_INFINITY for infinity.
bobbens@2497
   963
 *    \return 0 on success or -1 on error.
bobbens@2497
   964
 *
bobbens@2497
   965
 * \sa SDL_HapticStopEffect
bobbens@2497
   966
 * \sa SDL_HapticDestroyEffect
bobbens@2497
   967
 * \sa SDL_HapticGetEffectStatus
bobbens@2477
   968
 */
bobbens@2523
   969
extern DECLSPEC int SDLCALL SDL_HapticRunEffect(SDL_Haptic * haptic, int effect, Uint32 iterations);
bobbens@2477
   970
bobbens@2498
   971
/**
bobbens@2497
   972
 * \fn int SDL_HapticStopEffect(SDL_Haptic * haptic, int effect)
bobbens@2485
   973
 *
bobbens@2497
   974
 * \brief Stops the haptic effect on it's assosciated haptic device.
bobbens@2497
   975
 *
bobbens@2497
   976
 *    \param haptic Haptic device to stop the effect on.
bobbens@2499
   977
 *    \param effect Identifier of the effect to stop.
bobbens@2497
   978
 *    \return 0 on success or -1 on error.
bobbens@2497
   979
 *
bobbens@2497
   980
 * \sa SDL_HapticRunEffect
bobbens@2497
   981
 * \sa SDL_HapticDestroyEffect
bobbens@2485
   982
 */
bobbens@2523
   983
extern DECLSPEC int SDLCALL SDL_HapticStopEffect(SDL_Haptic * haptic, int effect);
bobbens@2485
   984
bobbens@2498
   985
/**
bobbens@2497
   986
 * \fn void SDL_HapticDestroyEffect(SDL_Haptic * haptic, int effect)
bobbens@2497
   987
 *
bobbens@2497
   988
 * \brief Destroys a haptic effect on the device.  This will stop the effect
bobbens@2497
   989
 * if it's running.  Effects are automatically destroyed when the device is
bobbens@2497
   990
 * closed.
bobbens@2497
   991
 *
bobbens@2497
   992
 *    \param haptic Device to destroy the effect on.
bobbens@2497
   993
 *    \param effect Identifier of the effect to destroy.
bobbens@2497
   994
 * 
bobbens@2497
   995
 * \sa SDL_HapticNewEffect
bobbens@2477
   996
 */
bobbens@2523
   997
extern DECLSPEC void SDLCALL SDL_HapticDestroyEffect(SDL_Haptic * haptic, int effect);
bobbens@2477
   998
bobbens@2498
   999
/**
bobbens@2497
  1000
 * \fn int SDL_HapticGetEffectStatus(SDL_Haptic *haptic, int effect)
bobbens@2495
  1001
 *
bobbens@2497
  1002
 * \brief Gets the status of the current effect on the haptic device.
bobbens@2497
  1003
 *
bobbens@2497
  1004
 * Device must support the SDL_HAPTIC_STATUS feature.
bobbens@2497
  1005
 *
bobbens@2497
  1006
 *    \param haptic Haptic device to query the effect status on.
bobbens@2497
  1007
 *    \param effect Identifier of the effect to query it's status.
bobbens@2497
  1008
 *    \return 0 if it isn't playing, SDL_HAPTIC_PLAYING if it is playing
bobbens@2497
  1009
 *            or -1 on error.
bobbens@2497
  1010
 *
bobbens@2497
  1011
 * \sa SDL_HapticRunEffect
bobbens@2497
  1012
 * \sa SDL_HapticStopEffect
bobbens@2495
  1013
 */
bobbens@2523
  1014
extern DECLSPEC int SDLCALL SDL_HapticGetEffectStatus(SDL_Haptic *haptic, int effect);
bobbens@2495
  1015
bobbens@2498
  1016
/**
bobbens@2497
  1017
 * \fn int SDL_HapticSetGain(SDL_Haptic * haptic, int gain)
bobbens@2483
  1018
 *
bobbens@2497
  1019
 * \brief Sets the global gain of the device.  Gain should be between 0 and 100.
bobbens@2497
  1020
 *
bobbens@2497
  1021
 * Device must support the SDL_HAPTIC_GAIN feature.
bobbens@2497
  1022
 *
bobbens@2507
  1023
 * The user may specify the maxmimum gain by setting the environment variable
bobbens@2507
  1024
 *  SDL_HAPTIC_GAIN_MAX which should be between 0 and 100.  All calls to
bobbens@2507
  1025
 *  SDL_HapticSetGain will scale linearly using SDL_HAPTIC_GAIN_MAX as the
bobbens@2507
  1026
 *  maximum.
bobbens@2507
  1027
 *
bobbens@2497
  1028
 *    \param haptic Haptic device to set the gain on.
bobbens@2497
  1029
 *    \param gain Value to set the gain to, should be between 0 and 100.
bobbens@2497
  1030
 *    \return 0 on success or -1 on error.
bobbens@2497
  1031
 *
bobbens@2497
  1032
 * \sa SDL_HapticQuery
bobbens@2483
  1033
 */
bobbens@2523
  1034
extern DECLSPEC int SDLCALL SDL_HapticSetGain(SDL_Haptic * haptic, int gain);
bobbens@2483
  1035
bobbens@2498
  1036
/**
bobbens@2497
  1037
 * \fn int SDL_HapticSetAutocenter(SDL_Haptic * haptic, int autocenter)
bobbens@2497
  1038
 *
bobbens@2497
  1039
 * \brief Sets the global autocenter of the device.  Autocenter should be between
bobbens@2484
  1040
 * 0 and 100.  Setting it to 0 will disable autocentering.
bobbens@2484
  1041
 *
bobbens@2497
  1042
 * Device must support the SDL_HAPTIC_AUTOCENTER feature.
bobbens@2497
  1043
 *
bobbens@2497
  1044
 *    \param haptic Haptic device to set autocentering on.
bobbens@2497
  1045
 *    \param autocenter Value to set autocenter to, 0 disables autocentering.
bobbens@2497
  1046
 *    \return 0 on success or -1 on error.
bobbens@2497
  1047
 *
bobbens@2497
  1048
 * \sa SDL_HapticQuery
bobbens@2484
  1049
 */
bobbens@2523
  1050
extern DECLSPEC int SDLCALL SDL_HapticSetAutocenter(SDL_Haptic * haptic, int autocenter);
bobbens@2484
  1051
bobbens@2472
  1052
bobbens@2472
  1053
/* Ends C function definitions when using C++ */
bobbens@2472
  1054
#ifdef __cplusplus
bobbens@2472
  1055
/* *INDENT-OFF* */
bobbens@2472
  1056
}
bobbens@2472
  1057
/* *INDENT-ON* */
bobbens@2472
  1058
#endif
bobbens@2472
  1059
#include "close_code.h"
bobbens@2472
  1060
bobbens@2472
  1061
#endif /* _SDL_haptic_h */
bobbens@2472
  1062
bobbens@2472
  1063
/* vi: set ts=4 sw=4 expandtab: */
bobbens@2472
  1064
bobbens@2472
  1065