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.

224 lines
7.3 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_mouse.h
  20. *
  21. * Include file for SDL mouse event handling.
  22. */
  23. #ifndef _SDL_mouse_h
  24. #define _SDL_mouse_h
  25. #include "SDL_stdinc.h"
  26. #include "SDL_error.h"
  27. #include "SDL_video.h"
  28. #include "begin_code.h"
  29. /* Set up for C function definitions, even when using C++ */
  30. #ifdef __cplusplus
  31. extern "C" {
  32. #endif
  33. typedef struct SDL_Cursor SDL_Cursor; /* Implementation dependent */
  34. /**
  35. * \brief Cursor types for SDL_CreateSystemCursor.
  36. */
  37. typedef enum
  38. {
  39. SDL_SYSTEM_CURSOR_ARROW, /**< Arrow */
  40. SDL_SYSTEM_CURSOR_IBEAM, /**< I-beam */
  41. SDL_SYSTEM_CURSOR_WAIT, /**< Wait */
  42. SDL_SYSTEM_CURSOR_CROSSHAIR, /**< Crosshair */
  43. SDL_SYSTEM_CURSOR_WAITARROW, /**< Small wait cursor (or Wait if not available) */
  44. SDL_SYSTEM_CURSOR_SIZENWSE, /**< Double arrow pointing northwest and southeast */
  45. SDL_SYSTEM_CURSOR_SIZENESW, /**< Double arrow pointing northeast and southwest */
  46. SDL_SYSTEM_CURSOR_SIZEWE, /**< Double arrow pointing west and east */
  47. SDL_SYSTEM_CURSOR_SIZENS, /**< Double arrow pointing north and south */
  48. SDL_SYSTEM_CURSOR_SIZEALL, /**< Four pointed arrow pointing north, south, east, and west */
  49. SDL_SYSTEM_CURSOR_NO, /**< Slashed circle or crossbones */
  50. SDL_SYSTEM_CURSOR_HAND, /**< Hand */
  51. SDL_NUM_SYSTEM_CURSORS
  52. } SDL_SystemCursor;
  53. /* Function prototypes */
  54. /**
  55. * \brief Get the window which currently has mouse focus.
  56. */
  57. extern DECLSPEC SDL_Window * SDLCALL SDL_GetMouseFocus(void);
  58. /**
  59. * \brief Retrieve the current state of the mouse.
  60. *
  61. * The current button state is returned as a button bitmask, which can
  62. * be tested using the SDL_BUTTON(X) macros, and x and y are set to the
  63. * mouse cursor position relative to the focus window for the currently
  64. * selected mouse. You can pass NULL for either x or y.
  65. */
  66. extern DECLSPEC Uint32 SDLCALL SDL_GetMouseState(int *x, int *y);
  67. /**
  68. * \brief Retrieve the relative state of the mouse.
  69. *
  70. * The current button state is returned as a button bitmask, which can
  71. * be tested using the SDL_BUTTON(X) macros, and x and y are set to the
  72. * mouse deltas since the last call to SDL_GetRelativeMouseState().
  73. */
  74. extern DECLSPEC Uint32 SDLCALL SDL_GetRelativeMouseState(int *x, int *y);
  75. /**
  76. * \brief Moves the mouse to the given position within the window.
  77. *
  78. * \param window The window to move the mouse into, or NULL for the current mouse focus
  79. * \param x The x coordinate within the window
  80. * \param y The y coordinate within the window
  81. *
  82. * \note This function generates a mouse motion event
  83. */
  84. extern DECLSPEC void SDLCALL SDL_WarpMouseInWindow(SDL_Window * window,
  85. int x, int y);
  86. /**
  87. * \brief Set relative mouse mode.
  88. *
  89. * \param enabled Whether or not to enable relative mode
  90. *
  91. * \return 0 on success, or -1 if relative mode is not supported.
  92. *
  93. * While the mouse is in relative mode, the cursor is hidden, and the
  94. * driver will try to report continuous motion in the current window.
  95. * Only relative motion events will be delivered, the mouse position
  96. * will not change.
  97. *
  98. * \note This function will flush any pending mouse motion.
  99. *
  100. * \sa SDL_GetRelativeMouseMode()
  101. */
  102. extern DECLSPEC int SDLCALL SDL_SetRelativeMouseMode(SDL_bool enabled);
  103. /**
  104. * \brief Query whether relative mouse mode is enabled.
  105. *
  106. * \sa SDL_SetRelativeMouseMode()
  107. */
  108. extern DECLSPEC SDL_bool SDLCALL SDL_GetRelativeMouseMode(void);
  109. /**
  110. * \brief Create a cursor, using the specified bitmap data and
  111. * mask (in MSB format).
  112. *
  113. * The cursor width must be a multiple of 8 bits.
  114. *
  115. * The cursor is created in black and white according to the following:
  116. * <table>
  117. * <tr><td> data </td><td> mask </td><td> resulting pixel on screen </td></tr>
  118. * <tr><td> 0 </td><td> 1 </td><td> White </td></tr>
  119. * <tr><td> 1 </td><td> 1 </td><td> Black </td></tr>
  120. * <tr><td> 0 </td><td> 0 </td><td> Transparent </td></tr>
  121. * <tr><td> 1 </td><td> 0 </td><td> Inverted color if possible, black
  122. * if not. </td></tr>
  123. * </table>
  124. *
  125. * \sa SDL_FreeCursor()
  126. */
  127. extern DECLSPEC SDL_Cursor *SDLCALL SDL_CreateCursor(const Uint8 * data,
  128. const Uint8 * mask,
  129. int w, int h, int hot_x,
  130. int hot_y);
  131. /**
  132. * \brief Create a color cursor.
  133. *
  134. * \sa SDL_FreeCursor()
  135. */
  136. extern DECLSPEC SDL_Cursor *SDLCALL SDL_CreateColorCursor(SDL_Surface *surface,
  137. int hot_x,
  138. int hot_y);
  139. /**
  140. * \brief Create a system cursor.
  141. *
  142. * \sa SDL_FreeCursor()
  143. */
  144. extern DECLSPEC SDL_Cursor *SDLCALL SDL_CreateSystemCursor(SDL_SystemCursor id);
  145. /**
  146. * \brief Set the active cursor.
  147. */
  148. extern DECLSPEC void SDLCALL SDL_SetCursor(SDL_Cursor * cursor);
  149. /**
  150. * \brief Return the active cursor.
  151. */
  152. extern DECLSPEC SDL_Cursor *SDLCALL SDL_GetCursor(void);
  153. /**
  154. * \brief Return the default cursor.
  155. */
  156. extern DECLSPEC SDL_Cursor *SDLCALL SDL_GetDefaultCursor(void);
  157. /**
  158. * \brief Frees a cursor created with SDL_CreateCursor().
  159. *
  160. * \sa SDL_CreateCursor()
  161. */
  162. extern DECLSPEC void SDLCALL SDL_FreeCursor(SDL_Cursor * cursor);
  163. /**
  164. * \brief Toggle whether or not the cursor is shown.
  165. *
  166. * \param toggle 1 to show the cursor, 0 to hide it, -1 to query the current
  167. * state.
  168. *
  169. * \return 1 if the cursor is shown, or 0 if the cursor is hidden.
  170. */
  171. extern DECLSPEC int SDLCALL SDL_ShowCursor(int toggle);
  172. /**
  173. * Used as a mask when testing buttons in buttonstate.
  174. * - Button 1: Left mouse button
  175. * - Button 2: Middle mouse button
  176. * - Button 3: Right mouse button
  177. */
  178. #define SDL_BUTTON(X) (1 << ((X)-1))
  179. #define SDL_BUTTON_LEFT 1
  180. #define SDL_BUTTON_MIDDLE 2
  181. #define SDL_BUTTON_RIGHT 3
  182. #define SDL_BUTTON_X1 4
  183. #define SDL_BUTTON_X2 5
  184. #define SDL_BUTTON_LMASK SDL_BUTTON(SDL_BUTTON_LEFT)
  185. #define SDL_BUTTON_MMASK SDL_BUTTON(SDL_BUTTON_MIDDLE)
  186. #define SDL_BUTTON_RMASK SDL_BUTTON(SDL_BUTTON_RIGHT)
  187. #define SDL_BUTTON_X1MASK SDL_BUTTON(SDL_BUTTON_X1)
  188. #define SDL_BUTTON_X2MASK SDL_BUTTON(SDL_BUTTON_X2)
  189. /* Ends C function definitions when using C++ */
  190. #ifdef __cplusplus
  191. }
  192. #endif
  193. #include "close_code.h"
  194. #endif /* _SDL_mouse_h */
  195. /* vi: set ts=4 sw=4 expandtab: */