include/SDL_joystick.h
branchSDL-1.3
changeset 1668 4da1ee79c9af
parent 1662 782fd950bd46
equal deleted inserted replaced
1667:1fddae038bc8 1668:4da1ee79c9af
    52 
    52 
    53 /* Function prototypes */
    53 /* Function prototypes */
    54 /*
    54 /*
    55  * Count the number of joysticks attached to the system
    55  * Count the number of joysticks attached to the system
    56  */
    56  */
    57 extern DECLSPEC int SDLCALL SDL_NumJoysticks (void);
    57 extern DECLSPEC int SDLCALL SDL_NumJoysticks(void);
    58 
    58 
    59 /*
    59 /*
    60  * Get the implementation dependent name of a joystick.
    60  * Get the implementation dependent name of a joystick.
    61  * This can be called before any joysticks are opened.
    61  * This can be called before any joysticks are opened.
    62  * If no name can be found, this function returns NULL.
    62  * If no name can be found, this function returns NULL.
    63  */
    63  */
    64 extern DECLSPEC const char *SDLCALL SDL_JoystickName (int device_index);
    64 extern DECLSPEC const char *SDLCALL SDL_JoystickName(int device_index);
    65 
    65 
    66 /*
    66 /*
    67  * Open a joystick for use - the index passed as an argument refers to
    67  * Open a joystick for use - the index passed as an argument refers to
    68  * the N'th joystick on the system.  This index is the value which will
    68  * the N'th joystick on the system.  This index is the value which will
    69  * identify this joystick in future joystick events.
    69  * identify this joystick in future joystick events.
    70  *
    70  *
    71  * This function returns a joystick identifier, or NULL if an error occurred.
    71  * This function returns a joystick identifier, or NULL if an error occurred.
    72  */
    72  */
    73 extern DECLSPEC SDL_Joystick *SDLCALL SDL_JoystickOpen (int device_index);
    73 extern DECLSPEC SDL_Joystick *SDLCALL SDL_JoystickOpen(int device_index);
    74 
    74 
    75 /*
    75 /*
    76  * Returns 1 if the joystick has been opened, or 0 if it has not.
    76  * Returns 1 if the joystick has been opened, or 0 if it has not.
    77  */
    77  */
    78 extern DECLSPEC int SDLCALL SDL_JoystickOpened (int device_index);
    78 extern DECLSPEC int SDLCALL SDL_JoystickOpened(int device_index);
    79 
    79 
    80 /*
    80 /*
    81  * Get the device index of an opened joystick.
    81  * Get the device index of an opened joystick.
    82  */
    82  */
    83 extern DECLSPEC int SDLCALL SDL_JoystickIndex (SDL_Joystick * joystick);
    83 extern DECLSPEC int SDLCALL SDL_JoystickIndex(SDL_Joystick * joystick);
    84 
    84 
    85 /*
    85 /*
    86  * Get the number of general axis controls on a joystick
    86  * Get the number of general axis controls on a joystick
    87  */
    87  */
    88 extern DECLSPEC int SDLCALL SDL_JoystickNumAxes (SDL_Joystick * joystick);
    88 extern DECLSPEC int SDLCALL SDL_JoystickNumAxes(SDL_Joystick * joystick);
    89 
    89 
    90 /*
    90 /*
    91  * Get the number of trackballs on a joystick
    91  * Get the number of trackballs on a joystick
    92  * Joystick trackballs have only relative motion events associated
    92  * Joystick trackballs have only relative motion events associated
    93  * with them and their state cannot be polled.
    93  * with them and their state cannot be polled.
    94  */
    94  */
    95 extern DECLSPEC int SDLCALL SDL_JoystickNumBalls (SDL_Joystick * joystick);
    95 extern DECLSPEC int SDLCALL SDL_JoystickNumBalls(SDL_Joystick * joystick);
    96 
    96 
    97 /*
    97 /*
    98  * Get the number of POV hats on a joystick
    98  * Get the number of POV hats on a joystick
    99  */
    99  */
   100 extern DECLSPEC int SDLCALL SDL_JoystickNumHats (SDL_Joystick * joystick);
   100 extern DECLSPEC int SDLCALL SDL_JoystickNumHats(SDL_Joystick * joystick);
   101 
   101 
   102 /*
   102 /*
   103  * Get the number of buttons on a joystick
   103  * Get the number of buttons on a joystick
   104  */
   104  */
   105 extern DECLSPEC int SDLCALL SDL_JoystickNumButtons (SDL_Joystick * joystick);
   105 extern DECLSPEC int SDLCALL SDL_JoystickNumButtons(SDL_Joystick * joystick);
   106 
   106 
   107 /*
   107 /*
   108  * Update the current state of the open joysticks.
   108  * Update the current state of the open joysticks.
   109  * This is called automatically by the event loop if any joystick
   109  * This is called automatically by the event loop if any joystick
   110  * events are enabled.
   110  * events are enabled.
   111  */
   111  */
   112 extern DECLSPEC void SDLCALL SDL_JoystickUpdate (void);
   112 extern DECLSPEC void SDLCALL SDL_JoystickUpdate(void);
   113 
   113 
   114 /*
   114 /*
   115  * Enable/disable joystick event polling.
   115  * Enable/disable joystick event polling.
   116  * If joystick events are disabled, you must call SDL_JoystickUpdate()
   116  * If joystick events are disabled, you must call SDL_JoystickUpdate()
   117  * yourself and check the state of the joystick when you want joystick
   117  * yourself and check the state of the joystick when you want joystick
   118  * information.
   118  * information.
   119  * The state can be one of SDL_QUERY, SDL_ENABLE or SDL_IGNORE.
   119  * The state can be one of SDL_QUERY, SDL_ENABLE or SDL_IGNORE.
   120  */
   120  */
   121 extern DECLSPEC int SDLCALL SDL_JoystickEventState (int state);
   121 extern DECLSPEC int SDLCALL SDL_JoystickEventState(int state);
   122 
   122 
   123 /*
   123 /*
   124  * Get the current state of an axis control on a joystick
   124  * Get the current state of an axis control on a joystick
   125  * The state is a value ranging from -32768 to 32767.
   125  * The state is a value ranging from -32768 to 32767.
   126  * The axis indices start at index 0.
   126  * The axis indices start at index 0.
   127  */
   127  */
   128 extern DECLSPEC Sint16 SDLCALL SDL_JoystickGetAxis (SDL_Joystick * joystick,
   128 extern DECLSPEC Sint16 SDLCALL SDL_JoystickGetAxis(SDL_Joystick * joystick,
   129                                                     int axis);
   129                                                    int axis);
   130 
   130 
   131 /*
   131 /*
   132  * Get the current state of a POV hat on a joystick
   132  * Get the current state of a POV hat on a joystick
   133  * The return value is one of the following positions:
   133  * The return value is one of the following positions:
   134  */
   134  */
   142 #define SDL_HAT_LEFTUP		(SDL_HAT_LEFT|SDL_HAT_UP)
   142 #define SDL_HAT_LEFTUP		(SDL_HAT_LEFT|SDL_HAT_UP)
   143 #define SDL_HAT_LEFTDOWN	(SDL_HAT_LEFT|SDL_HAT_DOWN)
   143 #define SDL_HAT_LEFTDOWN	(SDL_HAT_LEFT|SDL_HAT_DOWN)
   144 /*
   144 /*
   145  * The hat indices start at index 0.
   145  * The hat indices start at index 0.
   146  */
   146  */
   147 extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetHat (SDL_Joystick * joystick,
   147 extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetHat(SDL_Joystick * joystick,
   148                                                   int hat);
   148                                                  int hat);
   149 
   149 
   150 /*
   150 /*
   151  * Get the ball axis change since the last poll
   151  * Get the ball axis change since the last poll
   152  * This returns 0, or -1 if you passed it invalid parameters.
   152  * This returns 0, or -1 if you passed it invalid parameters.
   153  * The ball indices start at index 0.
   153  * The ball indices start at index 0.
   154  */
   154  */
   155 extern DECLSPEC int SDLCALL SDL_JoystickGetBall (SDL_Joystick * joystick,
   155 extern DECLSPEC int SDLCALL SDL_JoystickGetBall(SDL_Joystick * joystick,
   156                                                  int ball, int *dx, int *dy);
   156                                                 int ball, int *dx, int *dy);
   157 
   157 
   158 /*
   158 /*
   159  * Get the current state of a button on a joystick
   159  * Get the current state of a button on a joystick
   160  * The button indices start at index 0.
   160  * The button indices start at index 0.
   161  */
   161  */
   162 extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetButton (SDL_Joystick * joystick,
   162 extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetButton(SDL_Joystick * joystick,
   163                                                      int button);
   163                                                     int button);
   164 
   164 
   165 /*
   165 /*
   166  * Close a joystick previously opened with SDL_JoystickOpen()
   166  * Close a joystick previously opened with SDL_JoystickOpen()
   167  */
   167  */
   168 extern DECLSPEC void SDLCALL SDL_JoystickClose (SDL_Joystick * joystick);
   168 extern DECLSPEC void SDLCALL SDL_JoystickClose(SDL_Joystick * joystick);
   169 
   169 
   170 
   170 
   171 /* Ends C function definitions when using C++ */
   171 /* Ends C function definitions when using C++ */
   172 #ifdef __cplusplus
   172 #ifdef __cplusplus
   173 /* *INDENT-OFF* */
   173 /* *INDENT-OFF* */