Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

253 lines
8.0 KiB

  1. /*
  2. Simple DirectMedia Layer
  3. Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
  4. This software is provided 'as-is', without any express or implied
  5. warranty. In no event will the authors be held liable for any damages
  6. arising from the use of this software.
  7. Permission is granted to anyone to use this software for any purpose,
  8. including commercial applications, and to alter it and redistribute it
  9. freely, subject to the following restrictions:
  10. 1. The origin of this software must not be misrepresented; you must not
  11. claim that you wrote the original software. If you use this software
  12. in a product, an acknowledgment in the product documentation would be
  13. appreciated but is not required.
  14. 2. Altered source versions must be plainly marked as such, and must not be
  15. misrepresented as being the original software.
  16. 3. This notice may not be removed or altered from any source distribution.
  17. */
  18. /**
  19. * \file SDL_joystick.h
  20. *
  21. * Include file for SDL joystick event handling
  22. *
  23. * The term "device_index" identifies currently plugged in joystick devices between 0 and SDL_NumJoysticks, with the exact joystick
  24. * behind a device_index changing as joysticks are plugged and unplugged.
  25. *
  26. * The term "instance_id" is the current instantiation of a joystick device in the system, if the joystick is removed and then re-inserted
  27. * then it will get a new instance_id, instance_id's are monotonically increasing identifiers of a joystick plugged in.
  28. *
  29. * The term JoystickGUID is a stable 128-bit identifier for a joystick device that does not change over time, it identifies class of
  30. * the device (a X360 wired controller for example). This identifier is platform dependent.
  31. *
  32. *
  33. */
  34. #ifndef _SDL_joystick_h
  35. #define _SDL_joystick_h
  36. #include "SDL_stdinc.h"
  37. #include "SDL_error.h"
  38. #include "begin_code.h"
  39. /* Set up for C function definitions, even when using C++ */
  40. #ifdef __cplusplus
  41. extern "C" {
  42. #endif
  43. /**
  44. * \file SDL_joystick.h
  45. *
  46. * In order to use these functions, SDL_Init() must have been called
  47. * with the ::SDL_INIT_JOYSTICK flag. This causes SDL to scan the system
  48. * for joysticks, and load appropriate drivers.
  49. *
  50. * If you would like to receive joystick updates while the application
  51. * is in the background, you should set the following hint before calling
  52. * SDL_Init(): SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS
  53. */
  54. /* The joystick structure used to identify an SDL joystick */
  55. struct _SDL_Joystick;
  56. typedef struct _SDL_Joystick SDL_Joystick;
  57. /* A structure that encodes the stable unique id for a joystick device */
  58. typedef struct {
  59. Uint8 data[16];
  60. } SDL_JoystickGUID;
  61. typedef Sint32 SDL_JoystickID;
  62. /* Function prototypes */
  63. /**
  64. * Count the number of joysticks attached to the system right now
  65. */
  66. extern DECLSPEC int SDLCALL SDL_NumJoysticks(void);
  67. /**
  68. * Get the implementation dependent name of a joystick.
  69. * This can be called before any joysticks are opened.
  70. * If no name can be found, this function returns NULL.
  71. */
  72. extern DECLSPEC const char *SDLCALL SDL_JoystickNameForIndex(int device_index);
  73. /**
  74. * Open a joystick for use.
  75. * The index passed as an argument refers tothe N'th joystick on the system.
  76. * This index is the value which will identify this joystick in future joystick
  77. * events.
  78. *
  79. * \return A joystick identifier, or NULL if an error occurred.
  80. */
  81. extern DECLSPEC SDL_Joystick *SDLCALL SDL_JoystickOpen(int device_index);
  82. /**
  83. * Return the name for this currently opened joystick.
  84. * If no name can be found, this function returns NULL.
  85. */
  86. extern DECLSPEC const char *SDLCALL SDL_JoystickName(SDL_Joystick * joystick);
  87. /**
  88. * Return the GUID for the joystick at this index
  89. */
  90. extern DECLSPEC SDL_JoystickGUID SDLCALL SDL_JoystickGetDeviceGUID(int device_index);
  91. /**
  92. * Return the GUID for this opened joystick
  93. */
  94. extern DECLSPEC SDL_JoystickGUID SDLCALL SDL_JoystickGetGUID(SDL_Joystick * joystick);
  95. /**
  96. * Return a string representation for this guid. pszGUID must point to at least 33 bytes
  97. * (32 for the string plus a NULL terminator).
  98. */
  99. extern DECLSPEC void SDLCALL SDL_JoystickGetGUIDString(SDL_JoystickGUID guid, char *pszGUID, int cbGUID);
  100. /**
  101. * convert a string into a joystick formatted guid
  102. */
  103. extern DECLSPEC SDL_JoystickGUID SDLCALL SDL_JoystickGetGUIDFromString(const char *pchGUID);
  104. /**
  105. * Returns SDL_TRUE if the joystick has been opened and currently connected, or SDL_FALSE if it has not.
  106. */
  107. extern DECLSPEC SDL_bool SDLCALL SDL_JoystickGetAttached(SDL_Joystick * joystick);
  108. /**
  109. * Get the instance ID of an opened joystick or -1 if the joystick is invalid.
  110. */
  111. extern DECLSPEC SDL_JoystickID SDLCALL SDL_JoystickInstanceID(SDL_Joystick * joystick);
  112. /**
  113. * Get the number of general axis controls on a joystick.
  114. */
  115. extern DECLSPEC int SDLCALL SDL_JoystickNumAxes(SDL_Joystick * joystick);
  116. /**
  117. * Get the number of trackballs on a joystick.
  118. *
  119. * Joystick trackballs have only relative motion events associated
  120. * with them and their state cannot be polled.
  121. */
  122. extern DECLSPEC int SDLCALL SDL_JoystickNumBalls(SDL_Joystick * joystick);
  123. /**
  124. * Get the number of POV hats on a joystick.
  125. */
  126. extern DECLSPEC int SDLCALL SDL_JoystickNumHats(SDL_Joystick * joystick);
  127. /**
  128. * Get the number of buttons on a joystick.
  129. */
  130. extern DECLSPEC int SDLCALL SDL_JoystickNumButtons(SDL_Joystick * joystick);
  131. /**
  132. * Update the current state of the open joysticks.
  133. *
  134. * This is called automatically by the event loop if any joystick
  135. * events are enabled.
  136. */
  137. extern DECLSPEC void SDLCALL SDL_JoystickUpdate(void);
  138. /**
  139. * Enable/disable joystick event polling.
  140. *
  141. * If joystick events are disabled, you must call SDL_JoystickUpdate()
  142. * yourself and check the state of the joystick when you want joystick
  143. * information.
  144. *
  145. * The state can be one of ::SDL_QUERY, ::SDL_ENABLE or ::SDL_IGNORE.
  146. */
  147. extern DECLSPEC int SDLCALL SDL_JoystickEventState(int state);
  148. /**
  149. * Get the current state of an axis control on a joystick.
  150. *
  151. * The state is a value ranging from -32768 to 32767.
  152. *
  153. * The axis indices start at index 0.
  154. */
  155. extern DECLSPEC Sint16 SDLCALL SDL_JoystickGetAxis(SDL_Joystick * joystick,
  156. int axis);
  157. /**
  158. * \name Hat positions
  159. */
  160. /* @{ */
  161. #define SDL_HAT_CENTERED 0x00
  162. #define SDL_HAT_UP 0x01
  163. #define SDL_HAT_RIGHT 0x02
  164. #define SDL_HAT_DOWN 0x04
  165. #define SDL_HAT_LEFT 0x08
  166. #define SDL_HAT_RIGHTUP (SDL_HAT_RIGHT|SDL_HAT_UP)
  167. #define SDL_HAT_RIGHTDOWN (SDL_HAT_RIGHT|SDL_HAT_DOWN)
  168. #define SDL_HAT_LEFTUP (SDL_HAT_LEFT|SDL_HAT_UP)
  169. #define SDL_HAT_LEFTDOWN (SDL_HAT_LEFT|SDL_HAT_DOWN)
  170. /* @} */
  171. /**
  172. * Get the current state of a POV hat on a joystick.
  173. *
  174. * The hat indices start at index 0.
  175. *
  176. * \return The return value is one of the following positions:
  177. * - ::SDL_HAT_CENTERED
  178. * - ::SDL_HAT_UP
  179. * - ::SDL_HAT_RIGHT
  180. * - ::SDL_HAT_DOWN
  181. * - ::SDL_HAT_LEFT
  182. * - ::SDL_HAT_RIGHTUP
  183. * - ::SDL_HAT_RIGHTDOWN
  184. * - ::SDL_HAT_LEFTUP
  185. * - ::SDL_HAT_LEFTDOWN
  186. */
  187. extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetHat(SDL_Joystick * joystick,
  188. int hat);
  189. /**
  190. * Get the ball axis change since the last poll.
  191. *
  192. * \return 0, or -1 if you passed it invalid parameters.
  193. *
  194. * The ball indices start at index 0.
  195. */
  196. extern DECLSPEC int SDLCALL SDL_JoystickGetBall(SDL_Joystick * joystick,
  197. int ball, int *dx, int *dy);
  198. /**
  199. * Get the current state of a button on a joystick.
  200. *
  201. * The button indices start at index 0.
  202. */
  203. extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetButton(SDL_Joystick * joystick,
  204. int button);
  205. /**
  206. * Close a joystick previously opened with SDL_JoystickOpen().
  207. */
  208. extern DECLSPEC void SDLCALL SDL_JoystickClose(SDL_Joystick * joystick);
  209. /* Ends C function definitions when using C++ */
  210. #ifdef __cplusplus
  211. }
  212. #endif
  213. #include "close_code.h"
  214. #endif /* _SDL_joystick_h */
  215. /* vi: set ts=4 sw=4 expandtab: */