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