include/SDL_joystick.h
changeset 0 74212992fb08
child 251 b8688cfdc232
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/include/SDL_joystick.h	Thu Apr 26 16:45:43 2001 +0000
     1.3 @@ -0,0 +1,171 @@
     1.4 +/*
     1.5 +    SDL - Simple DirectMedia Layer
     1.6 +    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
     1.7 +
     1.8 +    This library is free software; you can redistribute it and/or
     1.9 +    modify it under the terms of the GNU Library General Public
    1.10 +    License as published by the Free Software Foundation; either
    1.11 +    version 2 of the License, or (at your option) any later version.
    1.12 +
    1.13 +    This library is distributed in the hope that it will be useful,
    1.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    1.16 +    Library General Public License for more details.
    1.17 +
    1.18 +    You should have received a copy of the GNU Library General Public
    1.19 +    License along with this library; if not, write to the Free
    1.20 +    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    1.21 +
    1.22 +    Sam Lantinga
    1.23 +    slouken@devolution.com
    1.24 +*/
    1.25 +
    1.26 +#ifdef SAVE_RCSID
    1.27 +static char rcsid =
    1.28 + "@(#) $Id$";
    1.29 +#endif
    1.30 +
    1.31 +/* Include file for SDL joystick event handling */
    1.32 +
    1.33 +#ifndef _SDL_joystick_h
    1.34 +#define _SDL_joystick_h
    1.35 +
    1.36 +#include "SDL_types.h"
    1.37 +
    1.38 +#include "begin_code.h"
    1.39 +/* Set up for C function definitions, even when using C++ */
    1.40 +#ifdef __cplusplus
    1.41 +extern "C" {
    1.42 +#endif
    1.43 +
    1.44 +/* In order to use these functions, SDL_Init() must have been called
    1.45 +   with the SDL_INIT_JOYSTICK flag.  This causes SDL to scan the system
    1.46 +   for joysticks, and load appropriate drivers.
    1.47 +*/
    1.48 +
    1.49 +/* The joystick structure used to identify an SDL joystick */
    1.50 +struct _SDL_Joystick;
    1.51 +typedef struct _SDL_Joystick SDL_Joystick;
    1.52 +
    1.53 +
    1.54 +/* Function prototypes */
    1.55 +/*
    1.56 + * Count the number of joysticks attached to the system
    1.57 + */
    1.58 +extern DECLSPEC int SDL_NumJoysticks(void);
    1.59 +
    1.60 +/*
    1.61 + * Get the implementation dependent name of a joystick.
    1.62 + * This can be called before any joysticks are opened.
    1.63 + * If no name can be found, this function returns NULL.
    1.64 + */
    1.65 +extern DECLSPEC const char *SDL_JoystickName(int device_index);
    1.66 +
    1.67 +/*
    1.68 + * Open a joystick for use - the index passed as an argument refers to
    1.69 + * the N'th joystick on the system.  This index is the value which will
    1.70 + * identify this joystick in future joystick events.
    1.71 + *
    1.72 + * This function returns a joystick identifier, or NULL if an error occurred.
    1.73 + */
    1.74 +extern DECLSPEC SDL_Joystick *SDL_JoystickOpen(int device_index);
    1.75 +
    1.76 +/*
    1.77 + * Returns 1 if the joystick has been opened, or 0 if it has not.
    1.78 + */
    1.79 +extern DECLSPEC int SDL_JoystickOpened(int device_index);
    1.80 +
    1.81 +/*
    1.82 + * Get the device index of an opened joystick.
    1.83 + */
    1.84 +extern DECLSPEC int SDL_JoystickIndex(SDL_Joystick *joystick);
    1.85 +
    1.86 +/*
    1.87 + * Get the number of general axis controls on a joystick
    1.88 + */
    1.89 +extern DECLSPEC int SDL_JoystickNumAxes(SDL_Joystick *joystick);
    1.90 +
    1.91 +/*
    1.92 + * Get the number of trackballs on a joystick
    1.93 + * Joystick trackballs have only relative motion events associated
    1.94 + * with them and their state cannot be polled.
    1.95 + */
    1.96 +extern DECLSPEC int SDL_JoystickNumBalls(SDL_Joystick *joystick);
    1.97 +
    1.98 +/*
    1.99 + * Get the number of POV hats on a joystick
   1.100 + */
   1.101 +extern DECLSPEC int SDL_JoystickNumHats(SDL_Joystick *joystick);
   1.102 +
   1.103 +/*
   1.104 + * Get the number of buttons on a joystick
   1.105 + */
   1.106 +extern DECLSPEC int SDL_JoystickNumButtons(SDL_Joystick *joystick);
   1.107 +
   1.108 +/*
   1.109 + * Update the current state of the open joysticks.
   1.110 + * This is called automatically by the event loop if any joystick
   1.111 + * events are enabled.
   1.112 + */
   1.113 +extern DECLSPEC void SDL_JoystickUpdate(void);
   1.114 +
   1.115 +/*
   1.116 + * Enable/disable joystick event polling.
   1.117 + * If joystick events are disabled, you must call SDL_JoystickUpdate()
   1.118 + * yourself and check the state of the joystick when you want joystick
   1.119 + * information.
   1.120 + * The state can be one of SDL_QUERY, SDL_ENABLE or SDL_IGNORE.
   1.121 + */
   1.122 +extern DECLSPEC int SDL_JoystickEventState(int state);
   1.123 +
   1.124 +/*
   1.125 + * Get the current state of an axis control on a joystick
   1.126 + * The state is a value ranging from -32768 to 32767.
   1.127 + * The axis indices start at index 0.
   1.128 + */
   1.129 +extern DECLSPEC Sint16 SDL_JoystickGetAxis(SDL_Joystick *joystick, int axis);
   1.130 +
   1.131 +/*
   1.132 + * Get the current state of a POV hat on a joystick
   1.133 + * The return value is one of the following positions:
   1.134 + */
   1.135 +#define SDL_HAT_CENTERED	0x00
   1.136 +#define SDL_HAT_UP		0x01
   1.137 +#define SDL_HAT_RIGHT		0x02
   1.138 +#define SDL_HAT_DOWN		0x04
   1.139 +#define SDL_HAT_LEFT		0x08
   1.140 +#define SDL_HAT_RIGHTUP		(SDL_HAT_RIGHT|SDL_HAT_UP)
   1.141 +#define SDL_HAT_RIGHTDOWN	(SDL_HAT_RIGHT|SDL_HAT_DOWN)
   1.142 +#define SDL_HAT_LEFTUP		(SDL_HAT_LEFT|SDL_HAT_UP)
   1.143 +#define SDL_HAT_LEFTDOWN	(SDL_HAT_LEFT|SDL_HAT_DOWN)
   1.144 +/*
   1.145 + * The hat indices start at index 0.
   1.146 + */
   1.147 +extern DECLSPEC Uint8 SDL_JoystickGetHat(SDL_Joystick *joystick, int hat);
   1.148 +
   1.149 +/*
   1.150 + * Get the ball axis change since the last poll
   1.151 + * This returns 0, or -1 if you passed it invalid parameters.
   1.152 + * The ball indices start at index 0.
   1.153 + */
   1.154 +extern DECLSPEC int SDL_JoystickGetBall(SDL_Joystick *joystick, int ball, int *dx, int *dy);
   1.155 +
   1.156 +/*
   1.157 + * Get the current state of a button on a joystick
   1.158 + * The button indices start at index 0.
   1.159 + */
   1.160 +extern DECLSPEC Uint8 SDL_JoystickGetButton(SDL_Joystick *joystick, int button);
   1.161 +
   1.162 +/*
   1.163 + * Close a joystick previously opened with SDL_JoystickOpen()
   1.164 + */
   1.165 +extern DECLSPEC void SDL_JoystickClose(SDL_Joystick *joystick);
   1.166 +
   1.167 +
   1.168 +/* Ends C function definitions when using C++ */
   1.169 +#ifdef __cplusplus
   1.170 +}
   1.171 +#endif
   1.172 +#include "close_code.h"
   1.173 +
   1.174 +#endif /* _SDL_joystick_h */