include/SDL_joystick.h
author Sam Lantinga <slouken@libsdl.org>
Fri, 10 Feb 2006 06:48:43 +0000
changeset 1358 c71e05b4dc2e
parent 1356 67114343400d
child 1662 782fd950bd46
child 1895 c121d94672cb
child 4159 a1b03ba2fcd0
permissions -rw-r--r--
More header massaging... works great on Windows. ;-)
slouken@0
     1
/*
slouken@0
     2
    SDL - Simple DirectMedia Layer
slouken@1312
     3
    Copyright (C) 1997-2006 Sam Lantinga
slouken@0
     4
slouken@0
     5
    This library is free software; you can redistribute it and/or
slouken@1312
     6
    modify it under the terms of the GNU Lesser General Public
slouken@0
     7
    License as published by the Free Software Foundation; either
slouken@1312
     8
    version 2.1 of the License, or (at your option) any later version.
slouken@0
     9
slouken@0
    10
    This library is distributed in the hope that it will be useful,
slouken@0
    11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
slouken@0
    12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
slouken@1312
    13
    Lesser General Public License for more details.
slouken@0
    14
slouken@1312
    15
    You should have received a copy of the GNU Lesser General Public
slouken@1312
    16
    License along with this library; if not, write to the Free Software
slouken@1312
    17
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
slouken@0
    18
slouken@0
    19
    Sam Lantinga
slouken@251
    20
    slouken@libsdl.org
slouken@0
    21
*/
slouken@0
    22
slouken@0
    23
/* Include file for SDL joystick event handling */
slouken@0
    24
slouken@0
    25
#ifndef _SDL_joystick_h
slouken@0
    26
#define _SDL_joystick_h
slouken@0
    27
slouken@1356
    28
#include "SDL_stdinc.h"
slouken@1358
    29
#include "SDL_error.h"
slouken@0
    30
slouken@0
    31
#include "begin_code.h"
slouken@0
    32
/* Set up for C function definitions, even when using C++ */
slouken@0
    33
#ifdef __cplusplus
slouken@0
    34
extern "C" {
slouken@0
    35
#endif
slouken@0
    36
slouken@0
    37
/* In order to use these functions, SDL_Init() must have been called
slouken@0
    38
   with the SDL_INIT_JOYSTICK flag.  This causes SDL to scan the system
slouken@0
    39
   for joysticks, and load appropriate drivers.
slouken@0
    40
*/
slouken@0
    41
slouken@0
    42
/* The joystick structure used to identify an SDL joystick */
slouken@0
    43
struct _SDL_Joystick;
slouken@0
    44
typedef struct _SDL_Joystick SDL_Joystick;
slouken@0
    45
slouken@0
    46
slouken@0
    47
/* Function prototypes */
slouken@0
    48
/*
slouken@0
    49
 * Count the number of joysticks attached to the system
slouken@0
    50
 */
slouken@337
    51
extern DECLSPEC int SDLCALL SDL_NumJoysticks(void);
slouken@0
    52
slouken@0
    53
/*
slouken@0
    54
 * Get the implementation dependent name of a joystick.
slouken@0
    55
 * This can be called before any joysticks are opened.
slouken@0
    56
 * If no name can be found, this function returns NULL.
slouken@0
    57
 */
slouken@337
    58
extern DECLSPEC const char * SDLCALL SDL_JoystickName(int device_index);
slouken@0
    59
slouken@0
    60
/*
slouken@0
    61
 * Open a joystick for use - the index passed as an argument refers to
slouken@0
    62
 * the N'th joystick on the system.  This index is the value which will
slouken@0
    63
 * identify this joystick in future joystick events.
slouken@0
    64
 *
slouken@0
    65
 * This function returns a joystick identifier, or NULL if an error occurred.
slouken@0
    66
 */
slouken@905
    67
extern DECLSPEC SDL_Joystick * SDLCALL SDL_JoystickOpen(int device_index);
slouken@0
    68
slouken@0
    69
/*
slouken@0
    70
 * Returns 1 if the joystick has been opened, or 0 if it has not.
slouken@0
    71
 */
slouken@337
    72
extern DECLSPEC int SDLCALL SDL_JoystickOpened(int device_index);
slouken@0
    73
slouken@0
    74
/*
slouken@0
    75
 * Get the device index of an opened joystick.
slouken@0
    76
 */
slouken@337
    77
extern DECLSPEC int SDLCALL SDL_JoystickIndex(SDL_Joystick *joystick);
slouken@0
    78
slouken@0
    79
/*
slouken@0
    80
 * Get the number of general axis controls on a joystick
slouken@0
    81
 */
slouken@337
    82
extern DECLSPEC int SDLCALL SDL_JoystickNumAxes(SDL_Joystick *joystick);
slouken@0
    83
slouken@0
    84
/*
slouken@0
    85
 * Get the number of trackballs on a joystick
slouken@0
    86
 * Joystick trackballs have only relative motion events associated
slouken@0
    87
 * with them and their state cannot be polled.
slouken@0
    88
 */
slouken@337
    89
extern DECLSPEC int SDLCALL SDL_JoystickNumBalls(SDL_Joystick *joystick);
slouken@0
    90
slouken@0
    91
/*
slouken@0
    92
 * Get the number of POV hats on a joystick
slouken@0
    93
 */
slouken@337
    94
extern DECLSPEC int SDLCALL SDL_JoystickNumHats(SDL_Joystick *joystick);
slouken@0
    95
slouken@0
    96
/*
slouken@0
    97
 * Get the number of buttons on a joystick
slouken@0
    98
 */
slouken@337
    99
extern DECLSPEC int SDLCALL SDL_JoystickNumButtons(SDL_Joystick *joystick);
slouken@0
   100
slouken@0
   101
/*
slouken@0
   102
 * Update the current state of the open joysticks.
slouken@0
   103
 * This is called automatically by the event loop if any joystick
slouken@0
   104
 * events are enabled.
slouken@0
   105
 */
slouken@337
   106
extern DECLSPEC void SDLCALL SDL_JoystickUpdate(void);
slouken@0
   107
slouken@0
   108
/*
slouken@0
   109
 * Enable/disable joystick event polling.
slouken@0
   110
 * If joystick events are disabled, you must call SDL_JoystickUpdate()
slouken@0
   111
 * yourself and check the state of the joystick when you want joystick
slouken@0
   112
 * information.
slouken@0
   113
 * The state can be one of SDL_QUERY, SDL_ENABLE or SDL_IGNORE.
slouken@0
   114
 */
slouken@337
   115
extern DECLSPEC int SDLCALL SDL_JoystickEventState(int state);
slouken@0
   116
slouken@0
   117
/*
slouken@0
   118
 * Get the current state of an axis control on a joystick
slouken@0
   119
 * The state is a value ranging from -32768 to 32767.
slouken@0
   120
 * The axis indices start at index 0.
slouken@0
   121
 */
slouken@337
   122
extern DECLSPEC Sint16 SDLCALL SDL_JoystickGetAxis(SDL_Joystick *joystick, int axis);
slouken@0
   123
slouken@0
   124
/*
slouken@0
   125
 * Get the current state of a POV hat on a joystick
slouken@0
   126
 * The return value is one of the following positions:
slouken@0
   127
 */
slouken@0
   128
#define SDL_HAT_CENTERED	0x00
slouken@0
   129
#define SDL_HAT_UP		0x01
slouken@0
   130
#define SDL_HAT_RIGHT		0x02
slouken@0
   131
#define SDL_HAT_DOWN		0x04
slouken@0
   132
#define SDL_HAT_LEFT		0x08
slouken@0
   133
#define SDL_HAT_RIGHTUP		(SDL_HAT_RIGHT|SDL_HAT_UP)
slouken@0
   134
#define SDL_HAT_RIGHTDOWN	(SDL_HAT_RIGHT|SDL_HAT_DOWN)
slouken@0
   135
#define SDL_HAT_LEFTUP		(SDL_HAT_LEFT|SDL_HAT_UP)
slouken@0
   136
#define SDL_HAT_LEFTDOWN	(SDL_HAT_LEFT|SDL_HAT_DOWN)
slouken@0
   137
/*
slouken@0
   138
 * The hat indices start at index 0.
slouken@0
   139
 */
slouken@337
   140
extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetHat(SDL_Joystick *joystick, int hat);
slouken@0
   141
slouken@0
   142
/*
slouken@0
   143
 * Get the ball axis change since the last poll
slouken@0
   144
 * This returns 0, or -1 if you passed it invalid parameters.
slouken@0
   145
 * The ball indices start at index 0.
slouken@0
   146
 */
slouken@337
   147
extern DECLSPEC int SDLCALL SDL_JoystickGetBall(SDL_Joystick *joystick, int ball, int *dx, int *dy);
slouken@0
   148
slouken@0
   149
/*
slouken@0
   150
 * Get the current state of a button on a joystick
slouken@0
   151
 * The button indices start at index 0.
slouken@0
   152
 */
slouken@337
   153
extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetButton(SDL_Joystick *joystick, int button);
slouken@0
   154
slouken@0
   155
/*
slouken@0
   156
 * Close a joystick previously opened with SDL_JoystickOpen()
slouken@0
   157
 */
slouken@337
   158
extern DECLSPEC void SDLCALL SDL_JoystickClose(SDL_Joystick *joystick);
slouken@0
   159
slouken@0
   160
slouken@0
   161
/* Ends C function definitions when using C++ */
slouken@0
   162
#ifdef __cplusplus
slouken@0
   163
}
slouken@0
   164
#endif
slouken@0
   165
#include "close_code.h"
slouken@0
   166
slouken@0
   167
#endif /* _SDL_joystick_h */