include/SDL_haptic.h
author Edgar Simo <bobbens@gmail.com>
Mon, 30 Jun 2008 17:28:34 +0000
branchgsoc2008_force_feedback
changeset 2478 4fd783e0f34b
parent 2477 97f75ea43a93
child 2480 b883974445fc
permissions -rw-r--r--
Added query functions for haptic devices.
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
/**
bobbens@2472
    24
 * \file SDL_haptic.h
bobbens@2472
    25
 *
bobbens@2472
    26
 * Include file for SDL haptic subsystem
bobbens@2472
    27
 */
bobbens@2472
    28
bobbens@2472
    29
#ifndef _SDL_haptic_h
bobbens@2472
    30
#define _SDL_haptic_h
bobbens@2472
    31
bobbens@2472
    32
#include "SDL_stdinc.h"
bobbens@2472
    33
#include "SDL_error.h"
bobbens@2472
    34
bobbens@2472
    35
#include "begin_code.h"
bobbens@2472
    36
/* Set up for C function definitions, even when using C++ */
bobbens@2472
    37
#ifdef __cplusplus
bobbens@2472
    38
/* *INDENT-OFF* */
bobbens@2472
    39
extern "C" {
bobbens@2472
    40
   /* *INDENT-ON* */                                                         
bobbens@2472
    41
#endif
bobbens@2472
    42
bobbens@2472
    43
/* The haptic structure used to identify an SDL haptic */
bobbens@2472
    44
struct _SDL_Haptic;                                                     
bobbens@2472
    45
typedef struct _SDL_Haptic SDL_Haptic;
bobbens@2472
    46
bobbens@2472
    47
bobbens@2472
    48
/* Different effects that can be generated */
bobbens@2472
    49
#define SDL_HAPTIC_CONSTANT   (1<<0)
bobbens@2472
    50
#define SDL_HAPTIC_PERIODIC   (1<<1)
bobbens@2472
    51
#define SDL_HAPTIC_RAMP       (1<<2)
bobbens@2472
    52
#define SDL_HAPTIC_SPRING     (1<<3)
bobbens@2472
    53
#define SDL_HAPTIC_FRICTION   (1<<4)
bobbens@2472
    54
#define SDL_HAPTIC_DAMPER     (1<<5)
bobbens@2472
    55
#define SDL_HAPTIC_RUMBLE     (1<<6)
bobbens@2472
    56
#define SDL_HAPTIC_INERTIA    (1<<7)
bobbens@2472
    57
#define SDL_HAPTIC_GAIN       (1<<8)
bobbens@2472
    58
#define SDL_HAPTIC_AUTOCENTER (1<<9)
bobbens@2472
    59
bobbens@2477
    60
typedef struct SDL_HapticConstant {
bobbens@2477
    61
   /* Header */
bobbens@2477
    62
   Uint16 type;
bobbens@2477
    63
   Uint16 length;
bobbens@2477
    64
   Uint16 delay;
bobbens@2477
    65
   Uint16 direction;
bobbens@2477
    66
} SDL_HapticConstant;
bobbens@2477
    67
bobbens@2477
    68
typedef union SDL_HapticEffect {
bobbens@2477
    69
   /* Common for all force feedback effects */
bobbens@2477
    70
   Uint16 type; /* Effect type */
bobbens@2477
    71
   SDL_HapticConstant constant; /* Constant effect */
bobbens@2477
    72
} SDL_HapticEffect;
bobbens@2477
    73
bobbens@2472
    74
bobbens@2472
    75
/* Function prototypes */
bobbens@2472
    76
/*
bobbens@2472
    77
 * Count the number of joysticks attached to the system
bobbens@2472
    78
 */
bobbens@2472
    79
extern DECLSPEC int SDLCALL SDL_NumHaptics(void);
bobbens@2472
    80
bobbens@2472
    81
/*
bobbens@2476
    82
 * Get the implementation dependent name of a Haptic device.
bobbens@2472
    83
 * This can be called before any joysticks are opened.
bobbens@2472
    84
 * If no name can be found, this function returns NULL.
bobbens@2472
    85
 */
bobbens@2472
    86
extern DECLSPEC const char *SDLCALL SDL_HapticName(int device_index);
bobbens@2472
    87
bobbens@2476
    88
/*
bobbens@2476
    89
 * Opens a Haptic device for usage - the index passed as an
bobbens@2476
    90
 * argument refers to the N'th Haptic device on this system.
bobbens@2476
    91
 *
bobbens@2476
    92
 * This function returns a Haptic device identifier, or Null
bobbens@2476
    93
 * if an error occurred.
bobbens@2476
    94
 */
bobbens@2476
    95
extern DECLSPEC SDL_Haptic * SDL_HapticOpen(int device_index);
bobbens@2476
    96
bobbens@2476
    97
/* 
bobbens@2476
    98
 * Closes a Haptic device previously opened with SDL_HapticOpen.
bobbens@2476
    99
 */
bobbens@2476
   100
extern DECLSPEC void SDL_HapticClose(SDL_Haptic * haptic);
bobbens@2476
   101
bobbens@2477
   102
/*
bobbens@2478
   103
 * Returns the number of effects a haptic device can store.
bobbens@2478
   104
 */
bobbens@2478
   105
extern DECLSPEC int SDL_HapticNumEffects(SDL_Haptic * haptic);
bobbens@2478
   106
bobbens@2478
   107
/*
bobbens@2478
   108
 * Returns the supported effects.  Individual effects can be queried by
bobbens@2478
   109
 * bitwise operators.
bobbens@2478
   110
 *
bobbens@2478
   111
 * Example:  (SDL_HapticQueryEffects(haptic) & SDL_HAPTIC_CONSTANT)
bobbens@2478
   112
 */
bobbens@2478
   113
extern DECLSPEC unsigned int SDL_HapticQueryEffects(SDL_Haptic * haptic);
bobbens@2478
   114
bobbens@2478
   115
/*
bobbens@2477
   116
 * Creates a new haptic effect on the device.
bobbens@2477
   117
 */
bobbens@2477
   118
extern DECLSPEC int SDL_HapticNewEffect(SDL_Haptic * haptic, SDL_HapticEffect * effect);
bobbens@2477
   119
bobbens@2477
   120
/*
bobbens@2477
   121
 * Runs the haptic effect on it's assosciated haptic device.
bobbens@2477
   122
 */
bobbens@2477
   123
extern DECLSPEC int SDL_HapticRunEffect(SDL_Haptic * haptic, int effect);
bobbens@2477
   124
bobbens@2477
   125
/*
bobbens@2477
   126
 * Destroys a haptic effect on the device.
bobbens@2477
   127
 */
bobbens@2477
   128
extern DECLSPEC void SDL_HapticDestroyEffect(SDL_Haptic * haptic, int effect);
bobbens@2477
   129
bobbens@2472
   130
bobbens@2472
   131
/* Ends C function definitions when using C++ */
bobbens@2472
   132
#ifdef __cplusplus
bobbens@2472
   133
/* *INDENT-OFF* */
bobbens@2472
   134
}
bobbens@2472
   135
/* *INDENT-ON* */
bobbens@2472
   136
#endif
bobbens@2472
   137
#include "close_code.h"
bobbens@2472
   138
bobbens@2472
   139
#endif /* _SDL_haptic_h */
bobbens@2472
   140
bobbens@2472
   141
/* vi: set ts=4 sw=4 expandtab: */
bobbens@2472
   142
bobbens@2472
   143