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