include/SDL_joystick.h
author Sam Lantinga <slouken@libsdl.org>
Wed, 12 Jan 2011 15:42:26 -0800
changeset 4986 8431f59485d0
parent 3697 f7b03b6838cb
child 5262 b530ef003506
permissions -rw-r--r--
Renderer didn't advertise texture format SDL_PIXELFORMAT_ABGR8888
slouken@0
     1
/*
slouken@0
     2
    SDL - Simple DirectMedia Layer
slouken@3697
     3
    Copyright (C) 1997-2010 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@1895
    23
/**
slouken@3407
    24
 *  \file SDL_joystick.h
slouken@3407
    25
 *  
slouken@3407
    26
 *  Include file for SDL joystick event handling
slouken@1895
    27
 */
slouken@0
    28
slouken@0
    29
#ifndef _SDL_joystick_h
slouken@0
    30
#define _SDL_joystick_h
slouken@0
    31
slouken@1356
    32
#include "SDL_stdinc.h"
slouken@1358
    33
#include "SDL_error.h"
slouken@0
    34
slouken@0
    35
#include "begin_code.h"
slouken@0
    36
/* Set up for C function definitions, even when using C++ */
slouken@0
    37
#ifdef __cplusplus
slouken@1895
    38
/* *INDENT-OFF* */
slouken@0
    39
extern "C" {
slouken@1895
    40
/* *INDENT-ON* */
slouken@0
    41
#endif
slouken@0
    42
slouken@3407
    43
/**
slouken@3407
    44
 *  \file SDL_joystick.h
slouken@3407
    45
 *
slouken@3407
    46
 *  In order to use these functions, SDL_Init() must have been called
slouken@3407
    47
 *  with the ::SDL_INIT_JOYSTICK flag.  This causes SDL to scan the system
slouken@3407
    48
 *  for joysticks, and load appropriate drivers.
slouken@3407
    49
 */
slouken@0
    50
slouken@0
    51
/* The joystick structure used to identify an SDL joystick */
slouken@0
    52
struct _SDL_Joystick;
slouken@0
    53
typedef struct _SDL_Joystick SDL_Joystick;
slouken@0
    54
slouken@0
    55
slouken@0
    56
/* Function prototypes */
slouken@3407
    57
/**
slouken@3407
    58
 *  Count the number of joysticks attached to the system
slouken@0
    59
 */
slouken@337
    60
extern DECLSPEC int SDLCALL SDL_NumJoysticks(void);
slouken@0
    61
slouken@3407
    62
/**
slouken@3407
    63
 *  Get the implementation dependent name of a joystick.
slouken@3407
    64
 *  This can be called before any joysticks are opened.
slouken@3407
    65
 *  If no name can be found, this function returns NULL.
slouken@0
    66
 */
slouken@1895
    67
extern DECLSPEC const char *SDLCALL SDL_JoystickName(int device_index);
slouken@0
    68
slouken@3407
    69
/**
slouken@3407
    70
 *  Open a joystick for use.  
slouken@3407
    71
 *  The index passed as an argument refers tothe N'th joystick on the system.  
slouken@3407
    72
 *  This index is the value which will identify this joystick in future joystick
slouken@3407
    73
 *  events.
slouken@3407
    74
 *  
slouken@3407
    75
 *  \return A joystick identifier, or NULL if an error occurred.
slouken@0
    76
 */
slouken@1895
    77
extern DECLSPEC SDL_Joystick *SDLCALL SDL_JoystickOpen(int device_index);
slouken@0
    78
slouken@3407
    79
/**
slouken@3407
    80
 *  Returns 1 if the joystick has been opened, or 0 if it has not.
slouken@0
    81
 */
slouken@337
    82
extern DECLSPEC int SDLCALL SDL_JoystickOpened(int device_index);
slouken@0
    83
slouken@3407
    84
/**
slouken@3407
    85
 *  Get the device index of an opened joystick.
slouken@0
    86
 */
slouken@1895
    87
extern DECLSPEC int SDLCALL SDL_JoystickIndex(SDL_Joystick * joystick);
slouken@0
    88
slouken@3407
    89
/**
slouken@3407
    90
 *  Get the number of general axis controls on a joystick.
slouken@0
    91
 */
slouken@1895
    92
extern DECLSPEC int SDLCALL SDL_JoystickNumAxes(SDL_Joystick * joystick);
slouken@0
    93
slouken@3407
    94
/**
slouken@3407
    95
 *  Get the number of trackballs on a joystick.
slouken@3407
    96
 *  
slouken@3407
    97
 *  Joystick trackballs have only relative motion events associated
slouken@3407
    98
 *  with them and their state cannot be polled.
slouken@0
    99
 */
slouken@1895
   100
extern DECLSPEC int SDLCALL SDL_JoystickNumBalls(SDL_Joystick * joystick);
slouken@0
   101
slouken@3407
   102
/**
slouken@3407
   103
 *  Get the number of POV hats on a joystick.
slouken@0
   104
 */
slouken@1895
   105
extern DECLSPEC int SDLCALL SDL_JoystickNumHats(SDL_Joystick * joystick);
slouken@0
   106
slouken@3407
   107
/**
slouken@3407
   108
 *  Get the number of buttons on a joystick.
slouken@0
   109
 */
slouken@1895
   110
extern DECLSPEC int SDLCALL SDL_JoystickNumButtons(SDL_Joystick * joystick);
slouken@0
   111
slouken@3407
   112
/**
slouken@3407
   113
 *  Update the current state of the open joysticks.
slouken@3407
   114
 *  
slouken@3407
   115
 *  This is called automatically by the event loop if any joystick
slouken@3407
   116
 *  events are enabled.
slouken@0
   117
 */
slouken@337
   118
extern DECLSPEC void SDLCALL SDL_JoystickUpdate(void);
slouken@0
   119
slouken@3407
   120
/**
slouken@3407
   121
 *  Enable/disable joystick event polling.
slouken@3407
   122
 *  
slouken@3407
   123
 *  If joystick events are disabled, you must call SDL_JoystickUpdate()
slouken@3407
   124
 *  yourself and check the state of the joystick when you want joystick
slouken@3407
   125
 *  information.
slouken@3407
   126
 *  
slouken@3407
   127
 *  The state can be one of ::SDL_QUERY, ::SDL_ENABLE or ::SDL_IGNORE.
slouken@0
   128
 */
slouken@337
   129
extern DECLSPEC int SDLCALL SDL_JoystickEventState(int state);
slouken@0
   130
slouken@3407
   131
/**
slouken@3407
   132
 *  Get the current state of an axis control on a joystick.
slouken@3407
   133
 *  
slouken@3407
   134
 *  The state is a value ranging from -32768 to 32767.
slouken@3407
   135
 *  
slouken@3407
   136
 *  The axis indices start at index 0.
slouken@0
   137
 */
slouken@1895
   138
extern DECLSPEC Sint16 SDLCALL SDL_JoystickGetAxis(SDL_Joystick * joystick,
slouken@1895
   139
                                                   int axis);
slouken@0
   140
slouken@3407
   141
/**
slouken@3407
   142
 *  \name Hat positions
slouken@0
   143
 */
slouken@3407
   144
/*@{*/
slouken@0
   145
#define SDL_HAT_CENTERED	0x00
slouken@0
   146
#define SDL_HAT_UP		0x01
slouken@0
   147
#define SDL_HAT_RIGHT		0x02
slouken@0
   148
#define SDL_HAT_DOWN		0x04
slouken@0
   149
#define SDL_HAT_LEFT		0x08
slouken@0
   150
#define SDL_HAT_RIGHTUP		(SDL_HAT_RIGHT|SDL_HAT_UP)
slouken@0
   151
#define SDL_HAT_RIGHTDOWN	(SDL_HAT_RIGHT|SDL_HAT_DOWN)
slouken@0
   152
#define SDL_HAT_LEFTUP		(SDL_HAT_LEFT|SDL_HAT_UP)
slouken@0
   153
#define SDL_HAT_LEFTDOWN	(SDL_HAT_LEFT|SDL_HAT_DOWN)
slouken@3407
   154
/*@}*/
slouken@3407
   155
slouken@3407
   156
/**
slouken@3407
   157
 *  Get the current state of a POV hat on a joystick.
slouken@3407
   158
 *
slouken@3407
   159
 *  The hat indices start at index 0.
slouken@3407
   160
 *  
slouken@3407
   161
 *  \return The return value is one of the following positions:
slouken@3407
   162
 *           - ::SDL_HAT_CENTERED
slouken@3407
   163
 *           - ::SDL_HAT_UP
slouken@3407
   164
 *           - ::SDL_HAT_RIGHT
slouken@3407
   165
 *           - ::SDL_HAT_DOWN
slouken@3407
   166
 *           - ::SDL_HAT_LEFT
slouken@3407
   167
 *           - ::SDL_HAT_RIGHTUP
slouken@3407
   168
 *           - ::SDL_HAT_RIGHTDOWN
slouken@3407
   169
 *           - ::SDL_HAT_LEFTUP
slouken@3407
   170
 *           - ::SDL_HAT_LEFTDOWN
slouken@0
   171
 */
slouken@1895
   172
extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetHat(SDL_Joystick * joystick,
slouken@1895
   173
                                                 int hat);
slouken@0
   174
slouken@3407
   175
/**
slouken@3407
   176
 *  Get the ball axis change since the last poll.
slouken@3407
   177
 *  
slouken@3407
   178
 *  \return 0, or -1 if you passed it invalid parameters.
slouken@3407
   179
 *  
slouken@3407
   180
 *  The ball indices start at index 0.
slouken@0
   181
 */
slouken@1895
   182
extern DECLSPEC int SDLCALL SDL_JoystickGetBall(SDL_Joystick * joystick,
slouken@1895
   183
                                                int ball, int *dx, int *dy);
slouken@0
   184
slouken@3407
   185
/**
slouken@3407
   186
 *  Get the current state of a button on a joystick.
slouken@3407
   187
 *  
slouken@3407
   188
 *  The button indices start at index 0.
slouken@0
   189
 */
slouken@1895
   190
extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetButton(SDL_Joystick * joystick,
slouken@1895
   191
                                                    int button);
slouken@0
   192
slouken@3407
   193
/**
slouken@3407
   194
 *  Close a joystick previously opened with SDL_JoystickOpen().
slouken@0
   195
 */
slouken@1895
   196
extern DECLSPEC void SDLCALL SDL_JoystickClose(SDL_Joystick * joystick);
slouken@0
   197
slouken@0
   198
slouken@0
   199
/* Ends C function definitions when using C++ */
slouken@0
   200
#ifdef __cplusplus
slouken@1895
   201
/* *INDENT-OFF* */
slouken@0
   202
}
slouken@1895
   203
/* *INDENT-ON* */
slouken@0
   204
#endif
slouken@0
   205
#include "close_code.h"
slouken@0
   206
slouken@0
   207
#endif /* _SDL_joystick_h */
slouken@1895
   208
slouken@1895
   209
/* vi: set ts=4 sw=4 expandtab: */