src/haptic/SDL_syshaptic.h
author Edgar Simo <bobbens@gmail.com>
Wed, 02 Jul 2008 10:26:35 +0000
branchgsoc2008_force_feedback
changeset 2491 10bc7aaf5114
parent 2488 8e2bdbccf7ff
child 2495 66c02abeef0e
permissions -rw-r--r--
Commented SDL_syshaptic.h.
Removed SDL_haptic_c.h (no private functions).
Fixed bug with SDL_HapticFromJoystick().
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@2477
    28
struct haptic_effect
bobbens@2477
    29
{
bobbens@2477
    30
   SDL_HapticEffect effect; /* The current event */
bobbens@2477
    31
   struct haptic_hweffect *hweffect; /* The hardware behind the event */
bobbens@2477
    32
};
bobbens@2477
    33
bobbens@2477
    34
/*
bobbens@2477
    35
 * The real SDL_Haptic event.
bobbens@2477
    36
 */
bobbens@2472
    37
struct _SDL_Haptic
bobbens@2472
    38
{  
bobbens@2477
    39
   Uint8 index; /* Stores index it is attached to */
bobbens@2477
    40
   const char* name; /* Stores the name of the device */
bobbens@2472
    41
bobbens@2477
    42
   struct haptic_effect *effects; /* Allocated effects */
bobbens@2477
    43
   int neffects; /* Maximum amount of effects */
bobbens@2477
    44
   unsigned int supported; /* Supported effects */
bobbens@2472
    45
bobbens@2477
    46
   struct haptic_hwdata *hwdata; /* Driver dependent */
bobbens@2477
    47
   int ref_count; /* Count for multiple opens */
bobbens@2472
    48
};
bobbens@2472
    49
bobbens@2491
    50
/* 
bobbens@2491
    51
 * Scans the system for haptic devices.
bobbens@2491
    52
 *
bobbens@2491
    53
 * Returns 0 on success, -1 on error.
bobbens@2491
    54
 */
bobbens@2472
    55
extern int SDL_SYS_HapticInit(void);
bobbens@2491
    56
bobbens@2491
    57
/*
bobbens@2491
    58
 * Gets the device dependent name of the haptic device
bobbens@2491
    59
 */
bobbens@2475
    60
extern const char * SDL_SYS_HapticName(int index);
bobbens@2491
    61
bobbens@2491
    62
/*
bobbens@2491
    63
 * Opens the haptic device for usage.  The haptic device should have
bobbens@2491
    64
 * the index value set previously.
bobbens@2491
    65
 *
bobbens@2491
    66
 * Returns 0 on success, -1 on error.
bobbens@2491
    67
 */
bobbens@2475
    68
extern int SDL_SYS_HapticOpen(SDL_Haptic * haptic);
bobbens@2491
    69
bobbens@2491
    70
/*
bobbens@2491
    71
 * Checks to see if the joystick has haptic capabilities.
bobbens@2491
    72
 *
bobbens@2491
    73
 * Returns >0 if haptic capabilities are detected, 0 if haptic
bobbens@2491
    74
 * capabilities aren't detected and -1 on error.
bobbens@2491
    75
 */
bobbens@2491
    76
extern int SDL_JoystickIsHaptic(SDL_Joystick * joystick);
bobbens@2491
    77
bobbens@2491
    78
/*
bobbens@2491
    79
 * Opens the haptic device for usage using the same device as
bobbens@2491
    80
 * the joystick.
bobbens@2491
    81
 *
bobbens@2491
    82
 * Returns 0 on success, -1 on error.
bobbens@2491
    83
 */
bobbens@2491
    84
extern int SDL_SYS_HapticOpenFromJoystick(SDL_Haptic * haptic,
bobbens@2491
    85
                                          SDL_Joystick * joystick);
bobbens@2491
    86
bobbens@2491
    87
/*
bobbens@2491
    88
 * Checks to see if haptic device and joystick device are the same.
bobbens@2491
    89
 *
bobbens@2491
    90
 * Returns 1 if they are the same, 0 if they aren't.
bobbens@2491
    91
 */
bobbens@2491
    92
extern int SDL_SYS_JoystickSameHaptic(SDL_Haptic * haptic,
bobbens@2491
    93
                                      SDL_Joystick * joystick);
bobbens@2491
    94
bobbens@2491
    95
/*
bobbens@2491
    96
 * Closes a haptic device after usage.
bobbens@2491
    97
 */
bobbens@2475
    98
extern void SDL_SYS_HapticClose(SDL_Haptic * haptic);
bobbens@2491
    99
bobbens@2491
   100
/*
bobbens@2491
   101
 * Performs a cleanup on the haptic subsystem.
bobbens@2491
   102
 */
bobbens@2475
   103
extern void SDL_SYS_HapticQuit(void);
bobbens@2491
   104
bobbens@2491
   105
/*
bobbens@2491
   106
 * Creates a new haptic effect on the haptic device using base
bobbens@2491
   107
 * as a template for the effect.
bobbens@2491
   108
 *
bobbens@2491
   109
 * Returns 0 on success, -1 on error.
bobbens@2491
   110
 */
bobbens@2479
   111
extern int SDL_SYS_HapticNewEffect(SDL_Haptic * haptic,
bobbens@2491
   112
                                 struct haptic_effect * effect,
bobbens@2491
   113
                                 SDL_HapticEffect * base);
bobbens@2491
   114
bobbens@2491
   115
/*
bobbens@2491
   116
 * Updates the haptic effect on the haptic device using data
bobbens@2491
   117
 * as a template.
bobbens@2491
   118
 *
bobbens@2491
   119
 * Returns 0 on success, -1 on error.
bobbens@2491
   120
 */
bobbens@2488
   121
extern int SDL_SYS_HapticUpdateEffect(SDL_Haptic * haptic,
bobbens@2491
   122
                                      struct haptic_effect * effect,
bobbens@2491
   123
                                      SDL_HapticEffect * data);
bobbens@2491
   124
bobbens@2491
   125
/*
bobbens@2491
   126
 * Runs the effect on the haptic device.
bobbens@2491
   127
 *
bobbens@2491
   128
 * Returns 0 on success, -1 on error.
bobbens@2491
   129
 */
bobbens@2479
   130
extern int SDL_SYS_HapticRunEffect(SDL_Haptic * haptic,
bobbens@2491
   131
                                   struct haptic_effect * effect);
bobbens@2491
   132
bobbens@2491
   133
/*
bobbens@2491
   134
 * Stops the effect on the haptic device.
bobbens@2491
   135
 *
bobbens@2491
   136
 * Returns 0 on success, -1 on error.
bobbens@2491
   137
 */
bobbens@2485
   138
extern int SDL_SYS_HapticStopEffect(SDL_Haptic * haptic,
bobbens@2491
   139
                                    struct haptic_effect * effect);
bobbens@2491
   140
bobbens@2491
   141
/*
bobbens@2491
   142
 * Cleanups up the effect on the haptic device.
bobbens@2491
   143
 */
bobbens@2479
   144
extern void SDL_SYS_HapticDestroyEffect(SDL_Haptic * haptic,
bobbens@2491
   145
                                        struct haptic_effect * effect);
bobbens@2491
   146
bobbens@2491
   147
/*
bobbens@2491
   148
 * Sets the global gain of the haptic device.
bobbens@2491
   149
 *
bobbens@2491
   150
 * Returns 0 on success, -1 on error.
bobbens@2491
   151
 */
bobbens@2483
   152
extern int SDL_SYS_HapticSetGain(SDL_Haptic * haptic, int gain);
bobbens@2491
   153
bobbens@2491
   154
/*
bobbens@2491
   155
 * Sets the autocenter feature of the haptic device.
bobbens@2491
   156
 *
bobbens@2491
   157
 * Returns 0 on success, -1 on error.
bobbens@2491
   158
 */
bobbens@2491
   159
extern int SDL_SYS_HapticSetAutocenter(SDL_Haptic * haptic,
bobbens@2491
   160
                                       int autocenter);
bobbens@2472
   161
bobbens@2479
   162