src/haptic/SDL_syshaptic.h
author Ryan C. Gordon <icculus@icculus.org>
Mon, 21 May 2018 12:00:21 -0400
changeset 11994 8e094f91ddab
parent 11811 5d94cb6b24d3
child 12503 806492103856
permissions -rw-r--r--
thread: fixed compiler warnings on non-Linux systems that use pthread.

(static function rtkit_setpriority was unused, moved it in with rest of
__LINUX__ section.)
slouken@2713
     1
/*
slouken@5535
     2
  Simple DirectMedia Layer
slouken@11811
     3
  Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
slouken@2713
     4
slouken@5535
     5
  This software is provided 'as-is', without any express or implied
slouken@5535
     6
  warranty.  In no event will the authors be held liable for any damages
slouken@5535
     7
  arising from the use of this software.
slouken@2713
     8
slouken@5535
     9
  Permission is granted to anyone to use this software for any purpose,
slouken@5535
    10
  including commercial applications, and to alter it and redistribute it
slouken@5535
    11
  freely, subject to the following restrictions:
slouken@2713
    12
slouken@5535
    13
  1. The origin of this software must not be misrepresented; you must not
slouken@5535
    14
     claim that you wrote the original software. If you use this software
slouken@5535
    15
     in a product, an acknowledgment in the product documentation would be
slouken@5535
    16
     appreciated but is not required.
slouken@5535
    17
  2. Altered source versions must be plainly marked as such, and must not be
slouken@5535
    18
     misrepresented as being the original software.
slouken@5535
    19
  3. This notice may not be removed or altered from any source distribution.
slouken@2713
    20
*/
slouken@2713
    21
icculus@8093
    22
#include "../SDL_internal.h"
slouken@2713
    23
slouken@10638
    24
#ifndef SDL_syshaptic_h_
slouken@10638
    25
#define SDL_syshaptic_h_
slouken@8976
    26
slouken@2713
    27
#include "SDL_haptic.h"
slouken@2713
    28
slouken@2713
    29
slouken@2713
    30
struct haptic_effect
slouken@2713
    31
{
slouken@2713
    32
    SDL_HapticEffect effect;    /* The current event */
slouken@2713
    33
    struct haptic_hweffect *hweffect;   /* The hardware behind the event */
slouken@2713
    34
};
slouken@2713
    35
slouken@2713
    36
/*
slouken@2713
    37
 * The real SDL_Haptic struct.
slouken@2713
    38
 */
slouken@2713
    39
struct _SDL_Haptic
slouken@2713
    40
{
slouken@2713
    41
    Uint8 index;                /* Stores index it is attached to */
slouken@2713
    42
slouken@2713
    43
    struct haptic_effect *effects;      /* Allocated effects */
slouken@2713
    44
    int neffects;               /* Maximum amount of effects */
slouken@2713
    45
    int nplaying;               /* Maximum amount of effects to play at the same time */
slouken@2713
    46
    unsigned int supported;     /* Supported effects */
slouken@2713
    47
    int naxes;                  /* Number of axes on the device. */
slouken@2713
    48
slouken@2713
    49
    struct haptic_hwdata *hwdata;       /* Driver dependent */
slouken@2713
    50
    int ref_count;              /* Count for multiple opens */
slouken@5360
    51
slouken@5360
    52
    int rumble_id;              /* ID of rumble effect for simple rumble API. */
slouken@5360
    53
    SDL_HapticEffect rumble_effect; /* Rumble effect. */
urkle@8170
    54
    struct _SDL_Haptic *next; /* pointer to next haptic we have allocated */
slouken@2713
    55
};
slouken@2713
    56
slouken@7191
    57
/*
slouken@2713
    58
 * Scans the system for haptic devices.
slouken@2713
    59
 *
philipp@7220
    60
 * Returns number of devices on success, -1 on error.
slouken@2713
    61
 */
slouken@2713
    62
extern int SDL_SYS_HapticInit(void);
slouken@2713
    63
urkle@8170
    64
/* Function to return the number of haptic devices plugged in right now */
slouken@10609
    65
extern int SDL_SYS_NumHaptics(void);
urkle@8170
    66
slouken@2713
    67
/*
slouken@2713
    68
 * Gets the device dependent name of the haptic device
slouken@2713
    69
 */
slouken@2713
    70
extern const char *SDL_SYS_HapticName(int index);
slouken@2713
    71
slouken@2713
    72
/*
slouken@2713
    73
 * Opens the haptic device for usage.  The haptic device should have
slouken@2713
    74
 * the index value set previously.
slouken@2713
    75
 *
slouken@2713
    76
 * Returns 0 on success, -1 on error.
slouken@2713
    77
 */
slouken@2713
    78
extern int SDL_SYS_HapticOpen(SDL_Haptic * haptic);
slouken@2713
    79
slouken@2713
    80
/*
slouken@2713
    81
 * Returns the index of the haptic core pointer or -1 if none is found.
slouken@2713
    82
 */
slouken@2713
    83
int SDL_SYS_HapticMouse(void);
slouken@2713
    84
slouken@2713
    85
/*
slouken@2713
    86
 * Checks to see if the joystick has haptic capabilities.
slouken@2713
    87
 *
slouken@2713
    88
 * Returns >0 if haptic capabilities are detected, 0 if haptic
slouken@2713
    89
 * capabilities aren't detected and -1 on error.
slouken@2713
    90
 */
slouken@2713
    91
extern int SDL_SYS_JoystickIsHaptic(SDL_Joystick * joystick);
slouken@2713
    92
slouken@2713
    93
/*
slouken@2713
    94
 * Opens the haptic device for usage using the same device as
slouken@2713
    95
 * the joystick.
slouken@2713
    96
 *
slouken@2713
    97
 * Returns 0 on success, -1 on error.
slouken@2713
    98
 */
slouken@2713
    99
extern int SDL_SYS_HapticOpenFromJoystick(SDL_Haptic * haptic,
slouken@2713
   100
                                          SDL_Joystick * joystick);
slouken@2713
   101
/*
slouken@2713
   102
 * Checks to see if haptic device and joystick device are the same.
slouken@2713
   103
 *
slouken@2713
   104
 * Returns 1 if they are the same, 0 if they aren't.
slouken@2713
   105
 */
slouken@2713
   106
extern int SDL_SYS_JoystickSameHaptic(SDL_Haptic * haptic,
slouken@2713
   107
                                      SDL_Joystick * joystick);
slouken@2713
   108
slouken@2713
   109
/*
slouken@2713
   110
 * Closes a haptic device after usage.
slouken@2713
   111
 */
slouken@2713
   112
extern void SDL_SYS_HapticClose(SDL_Haptic * haptic);
slouken@2713
   113
slouken@2713
   114
/*
slouken@2713
   115
 * Performs a cleanup on the haptic subsystem.
slouken@2713
   116
 */
slouken@2713
   117
extern void SDL_SYS_HapticQuit(void);
slouken@2713
   118
slouken@2713
   119
/*
slouken@2713
   120
 * Creates a new haptic effect on the haptic device using base
slouken@2713
   121
 * as a template for the effect.
slouken@2713
   122
 *
slouken@2713
   123
 * Returns 0 on success, -1 on error.
slouken@2713
   124
 */
slouken@2713
   125
extern int SDL_SYS_HapticNewEffect(SDL_Haptic * haptic,
slouken@2713
   126
                                   struct haptic_effect *effect,
slouken@2713
   127
                                   SDL_HapticEffect * base);
slouken@2713
   128
slouken@2713
   129
/*
slouken@2713
   130
 * Updates the haptic effect on the haptic device using data
slouken@2713
   131
 * as a template.
slouken@2713
   132
 *
slouken@2713
   133
 * Returns 0 on success, -1 on error.
slouken@2713
   134
 */
slouken@2713
   135
extern int SDL_SYS_HapticUpdateEffect(SDL_Haptic * haptic,
slouken@2713
   136
                                      struct haptic_effect *effect,
slouken@2713
   137
                                      SDL_HapticEffect * data);
slouken@2713
   138
slouken@2713
   139
/*
slouken@2713
   140
 * Runs the effect on the haptic device.
slouken@2713
   141
 *
slouken@2713
   142
 * Returns 0 on success, -1 on error.
slouken@2713
   143
 */
slouken@2713
   144
extern int SDL_SYS_HapticRunEffect(SDL_Haptic * haptic,
slouken@2713
   145
                                   struct haptic_effect *effect,
slouken@2713
   146
                                   Uint32 iterations);
slouken@2713
   147
slouken@2713
   148
/*
slouken@2713
   149
 * Stops the effect on the haptic device.
slouken@2713
   150
 *
slouken@2713
   151
 * Returns 0 on success, -1 on error.
slouken@2713
   152
 */
slouken@2713
   153
extern int SDL_SYS_HapticStopEffect(SDL_Haptic * haptic,
slouken@2713
   154
                                    struct haptic_effect *effect);
slouken@2713
   155
slouken@2713
   156
/*
slouken@2713
   157
 * Cleanups up the effect on the haptic device.
slouken@2713
   158
 */
slouken@2713
   159
extern void SDL_SYS_HapticDestroyEffect(SDL_Haptic * haptic,
slouken@2713
   160
                                        struct haptic_effect *effect);
slouken@2713
   161
slouken@2713
   162
/*
slouken@2713
   163
 * Queries the device for the status of effect.
slouken@2713
   164
 *
slouken@2713
   165
 * Returns 0 if device is stopped, >0 if device is playing and
slouken@2713
   166
 * -1 on error.
slouken@2713
   167
 */
slouken@2713
   168
extern int SDL_SYS_HapticGetEffectStatus(SDL_Haptic * haptic,
slouken@2713
   169
                                         struct haptic_effect *effect);
slouken@2713
   170
slouken@2713
   171
/*
slouken@2713
   172
 * Sets the global gain of the haptic device.
slouken@2713
   173
 *
slouken@2713
   174
 * Returns 0 on success, -1 on error.
slouken@2713
   175
 */
slouken@2713
   176
extern int SDL_SYS_HapticSetGain(SDL_Haptic * haptic, int gain);
slouken@2713
   177
slouken@2713
   178
/*
slouken@2713
   179
 * Sets the autocenter feature of the haptic device.
slouken@2713
   180
 *
slouken@2713
   181
 * Returns 0 on success, -1 on error.
slouken@2713
   182
 */
slouken@2713
   183
extern int SDL_SYS_HapticSetAutocenter(SDL_Haptic * haptic, int autocenter);
slouken@2713
   184
slouken@2713
   185
/*
slouken@2713
   186
 * Pauses the haptic device.
slouken@2713
   187
 *
slouken@2713
   188
 * Returns 0 on success, -1 on error.
slouken@2713
   189
 */
slouken@2713
   190
extern int SDL_SYS_HapticPause(SDL_Haptic * haptic);
slouken@2713
   191
slouken@2713
   192
/*
slouken@2713
   193
 * Unpauses the haptic device.
slouken@2713
   194
 *
slouken@2713
   195
 * Returns 0 on success, -1 on error.
slouken@2713
   196
 */
slouken@2713
   197
extern int SDL_SYS_HapticUnpause(SDL_Haptic * haptic);
slouken@2713
   198
slouken@2713
   199
/*
slouken@2713
   200
 * Stops all the currently playing haptic effects on the device.
slouken@2713
   201
 *
slouken@2713
   202
 * Returns 0 on success, -1 on error.
slouken@2713
   203
 */
slouken@2713
   204
extern int SDL_SYS_HapticStopAll(SDL_Haptic * haptic);
icculus@8176
   205
slouken@10638
   206
#endif /* SDL_syshaptic_h_ */
slouken@8976
   207
icculus@8176
   208
/* vi: set ts=4 sw=4 expandtab: */