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