src/haptic/SDL_syshaptic.h
author Edgar Simo <bobbens@gmail.com>
Thu, 17 Jul 2008 11:47:48 +0000
branchgsoc2008_force_feedback
changeset 2523 366d84fdf8d1
parent 2519 af9df9662807
child 2524 1a55848ce198
permissions -rw-r--r--
Haptic subsystem handles haptic axes now.
Support for SDL_HAPTIC_SPHERICAL on linux.
More error checking.
Improved documentation.
Added missing SDLCALLs to SDL_haptic.h.
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
#include "SDL_config.h"
bobbens@2472
    24
bobbens@2472
    25
#include "SDL_haptic.h"
bobbens@2472
    26
bobbens@2472
    27
bobbens@2512
    28
/*
bobbens@2512
    29
 * Number of haptic devices on the system.
bobbens@2512
    30
 */
bobbens@2512
    31
extern Uint8 SDL_numhaptics;
bobbens@2512
    32
bobbens@2512
    33
bobbens@2477
    34
struct haptic_effect
bobbens@2477
    35
{
bobbens@2477
    36
   SDL_HapticEffect effect; /* The current event */
bobbens@2477
    37
   struct haptic_hweffect *hweffect; /* The hardware behind the event */
bobbens@2477
    38
};
bobbens@2477
    39
bobbens@2477
    40
/*
bobbens@2517
    41
 * The real SDL_Haptic struct.
bobbens@2477
    42
 */
bobbens@2472
    43
struct _SDL_Haptic
bobbens@2472
    44
{  
bobbens@2477
    45
   Uint8 index; /* Stores index it is attached to */
bobbens@2477
    46
   const char* name; /* Stores the name of the device */
bobbens@2472
    47
bobbens@2477
    48
   struct haptic_effect *effects; /* Allocated effects */
bobbens@2477
    49
   int neffects; /* Maximum amount of effects */
bobbens@2515
    50
   int nplaying; /* Maximum amount of effects to play at the same time */
bobbens@2477
    51
   unsigned int supported; /* Supported effects */
bobbens@2523
    52
   int naxes; /* Number of axes on the device. */
bobbens@2472
    53
bobbens@2477
    54
   struct haptic_hwdata *hwdata; /* Driver dependent */
bobbens@2477
    55
   int ref_count; /* Count for multiple opens */
bobbens@2472
    56
};
bobbens@2472
    57
bobbens@2491
    58
/* 
bobbens@2491
    59
 * Scans the system for haptic devices.
bobbens@2491
    60
 *
bobbens@2491
    61
 * Returns 0 on success, -1 on error.
bobbens@2491
    62
 */
bobbens@2472
    63
extern int SDL_SYS_HapticInit(void);
bobbens@2491
    64
bobbens@2491
    65
/*
bobbens@2491
    66
 * Gets the device dependent name of the haptic device
bobbens@2491
    67
 */
bobbens@2475
    68
extern const char * SDL_SYS_HapticName(int index);
bobbens@2491
    69
bobbens@2491
    70
/*
bobbens@2491
    71
 * Opens the haptic device for usage.  The haptic device should have
bobbens@2491
    72
 * the index value set previously.
bobbens@2491
    73
 *
bobbens@2491
    74
 * Returns 0 on success, -1 on error.
bobbens@2491
    75
 */
bobbens@2475
    76
extern int SDL_SYS_HapticOpen(SDL_Haptic * haptic);
bobbens@2491
    77
bobbens@2491
    78
/*
bobbens@2512
    79
 * Returns the index of the haptic core pointer or -1 if none is found.
bobbens@2512
    80
 */
bobbens@2512
    81
int SDL_SYS_HapticMouse(void);
bobbens@2512
    82
bobbens@2512
    83
/*
bobbens@2491
    84
 * Checks to see if the joystick has haptic capabilities.
bobbens@2491
    85
 *
bobbens@2491
    86
 * Returns >0 if haptic capabilities are detected, 0 if haptic
bobbens@2491
    87
 * capabilities aren't detected and -1 on error.
bobbens@2491
    88
 */
bobbens@2491
    89
extern int SDL_JoystickIsHaptic(SDL_Joystick * joystick);
bobbens@2491
    90
bobbens@2491
    91
/*
bobbens@2491
    92
 * Opens the haptic device for usage using the same device as
bobbens@2491
    93
 * the joystick.
bobbens@2491
    94
 *
bobbens@2491
    95
 * Returns 0 on success, -1 on error.
bobbens@2491
    96
 */
bobbens@2491
    97
extern int SDL_SYS_HapticOpenFromJoystick(SDL_Haptic * haptic,
bobbens@2491
    98
                                          SDL_Joystick * joystick);
bobbens@2491
    99
/*
bobbens@2491
   100
 * Checks to see if haptic device and joystick device are the same.
bobbens@2491
   101
 *
bobbens@2491
   102
 * Returns 1 if they are the same, 0 if they aren't.
bobbens@2491
   103
 */
bobbens@2491
   104
extern int SDL_SYS_JoystickSameHaptic(SDL_Haptic * haptic,
bobbens@2491
   105
                                      SDL_Joystick * joystick);
bobbens@2491
   106
bobbens@2491
   107
/*
bobbens@2491
   108
 * Closes a haptic device after usage.
bobbens@2491
   109
 */
bobbens@2475
   110
extern void SDL_SYS_HapticClose(SDL_Haptic * haptic);
bobbens@2491
   111
bobbens@2491
   112
/*
bobbens@2491
   113
 * Performs a cleanup on the haptic subsystem.
bobbens@2491
   114
 */
bobbens@2475
   115
extern void SDL_SYS_HapticQuit(void);
bobbens@2491
   116
bobbens@2491
   117
/*
bobbens@2491
   118
 * Creates a new haptic effect on the haptic device using base
bobbens@2491
   119
 * as a template for the effect.
bobbens@2491
   120
 *
bobbens@2491
   121
 * Returns 0 on success, -1 on error.
bobbens@2491
   122
 */
bobbens@2479
   123
extern int SDL_SYS_HapticNewEffect(SDL_Haptic * haptic,
bobbens@2491
   124
                                 struct haptic_effect * effect,
bobbens@2491
   125
                                 SDL_HapticEffect * base);
bobbens@2491
   126
bobbens@2491
   127
/*
bobbens@2491
   128
 * Updates the haptic effect on the haptic device using data
bobbens@2491
   129
 * as a template.
bobbens@2491
   130
 *
bobbens@2491
   131
 * Returns 0 on success, -1 on error.
bobbens@2491
   132
 */
bobbens@2488
   133
extern int SDL_SYS_HapticUpdateEffect(SDL_Haptic * haptic,
bobbens@2491
   134
                                      struct haptic_effect * effect,
bobbens@2491
   135
                                      SDL_HapticEffect * data);
bobbens@2491
   136
bobbens@2491
   137
/*
bobbens@2491
   138
 * Runs the effect on the haptic device.
bobbens@2491
   139
 *
bobbens@2491
   140
 * Returns 0 on success, -1 on error.
bobbens@2491
   141
 */
bobbens@2479
   142
extern int SDL_SYS_HapticRunEffect(SDL_Haptic * haptic,
bobbens@2517
   143
                                   struct haptic_effect * effect,
bobbens@2519
   144
                                   Uint32 iterations);
bobbens@2491
   145
bobbens@2491
   146
/*
bobbens@2491
   147
 * Stops the effect on the haptic device.
bobbens@2491
   148
 *
bobbens@2491
   149
 * Returns 0 on success, -1 on error.
bobbens@2491
   150
 */
bobbens@2485
   151
extern int SDL_SYS_HapticStopEffect(SDL_Haptic * haptic,
bobbens@2491
   152
                                    struct haptic_effect * effect);
bobbens@2491
   153
bobbens@2491
   154
/*
bobbens@2491
   155
 * Cleanups up the effect on the haptic device.
bobbens@2491
   156
 */
bobbens@2479
   157
extern void SDL_SYS_HapticDestroyEffect(SDL_Haptic * haptic,
bobbens@2491
   158
                                        struct haptic_effect * effect);
bobbens@2491
   159
bobbens@2491
   160
/*
bobbens@2495
   161
 * Queries the device for the status of effect.
bobbens@2495
   162
 *
bobbens@2495
   163
 * Returns 0 if device is stopped, >0 if device is playing and
bobbens@2495
   164
 * -1 on error.
bobbens@2495
   165
 */
bobbens@2495
   166
extern int SDL_SYS_HapticGetEffectStatus(SDL_Haptic * haptic,
bobbens@2495
   167
                                         struct haptic_effect * effect);
bobbens@2495
   168
bobbens@2495
   169
/*
bobbens@2491
   170
 * Sets the global gain of the haptic device.
bobbens@2491
   171
 *
bobbens@2491
   172
 * Returns 0 on success, -1 on error.
bobbens@2491
   173
 */
bobbens@2483
   174
extern int SDL_SYS_HapticSetGain(SDL_Haptic * haptic, int gain);
bobbens@2472
   175
bobbens@2491
   176
/*
bobbens@2491
   177
 * Sets the autocenter feature of the haptic device.
bobbens@2491
   178
 *
bobbens@2491
   179
 * Returns 0 on success, -1 on error.
bobbens@2491
   180
 */
bobbens@2491
   181
extern int SDL_SYS_HapticSetAutocenter(SDL_Haptic * haptic,
bobbens@2491
   182
                                       int autocenter);
bobbens@2479
   183
bobbens@2491
   184