include/SDL_mouse.h
changeset 7191 75360622e65f
parent 7104 4e4ca313000c
child 8149 681eb46b8ac4
equal deleted inserted replaced
7190:11612d544fcd 7191:75360622e65f
    19   3. This notice may not be removed or altered from any source distribution.
    19   3. This notice may not be removed or altered from any source distribution.
    20 */
    20 */
    21 
    21 
    22 /**
    22 /**
    23  *  \file SDL_mouse.h
    23  *  \file SDL_mouse.h
    24  *  
    24  *
    25  *  Include file for SDL mouse event handling.
    25  *  Include file for SDL mouse event handling.
    26  */
    26  */
    27 
    27 
    28 #ifndef _SDL_mouse_h
    28 #ifndef _SDL_mouse_h
    29 #define _SDL_mouse_h
    29 #define _SDL_mouse_h
    33 #include "SDL_video.h"
    33 #include "SDL_video.h"
    34 
    34 
    35 #include "begin_code.h"
    35 #include "begin_code.h"
    36 /* Set up for C function definitions, even when using C++ */
    36 /* Set up for C function definitions, even when using C++ */
    37 #ifdef __cplusplus
    37 #ifdef __cplusplus
    38 /* *INDENT-OFF* */
       
    39 extern "C" {
    38 extern "C" {
    40 /* *INDENT-ON* */
       
    41 #endif
    39 #endif
    42 
    40 
    43 typedef struct SDL_Cursor SDL_Cursor;   /* Implementation dependent */
    41 typedef struct SDL_Cursor SDL_Cursor;   /* Implementation dependent */
    44 
    42 
    45 /**
    43 /**
    69  */
    67  */
    70 extern DECLSPEC SDL_Window * SDLCALL SDL_GetMouseFocus(void);
    68 extern DECLSPEC SDL_Window * SDLCALL SDL_GetMouseFocus(void);
    71 
    69 
    72 /**
    70 /**
    73  *  \brief Retrieve the current state of the mouse.
    71  *  \brief Retrieve the current state of the mouse.
    74  *  
    72  *
    75  *  The current button state is returned as a button bitmask, which can
    73  *  The current button state is returned as a button bitmask, which can
    76  *  be tested using the SDL_BUTTON(X) macros, and x and y are set to the
    74  *  be tested using the SDL_BUTTON(X) macros, and x and y are set to the
    77  *  mouse cursor position relative to the focus window for the currently
    75  *  mouse cursor position relative to the focus window for the currently
    78  *  selected mouse.  You can pass NULL for either x or y.
    76  *  selected mouse.  You can pass NULL for either x or y.
    79  */
    77  */
    88  */
    86  */
    89 extern DECLSPEC Uint32 SDLCALL SDL_GetRelativeMouseState(int *x, int *y);
    87 extern DECLSPEC Uint32 SDLCALL SDL_GetRelativeMouseState(int *x, int *y);
    90 
    88 
    91 /**
    89 /**
    92  *  \brief Moves the mouse to the given position within the window.
    90  *  \brief Moves the mouse to the given position within the window.
    93  *  
    91  *
    94  *  \param window The window to move the mouse into, or NULL for the current mouse focus
    92  *  \param window The window to move the mouse into, or NULL for the current mouse focus
    95  *  \param x The x coordinate within the window
    93  *  \param x The x coordinate within the window
    96  *  \param y The y coordinate within the window
    94  *  \param y The y coordinate within the window
    97  *  
    95  *
    98  *  \note This function generates a mouse motion event
    96  *  \note This function generates a mouse motion event
    99  */
    97  */
   100 extern DECLSPEC void SDLCALL SDL_WarpMouseInWindow(SDL_Window * window,
    98 extern DECLSPEC void SDLCALL SDL_WarpMouseInWindow(SDL_Window * window,
   101                                                    int x, int y);
    99                                                    int x, int y);
   102 
   100 
   103 /**
   101 /**
   104  *  \brief Set relative mouse mode.
   102  *  \brief Set relative mouse mode.
   105  *  
   103  *
   106  *  \param enabled Whether or not to enable relative mode
   104  *  \param enabled Whether or not to enable relative mode
   107  *
   105  *
   108  *  \return 0 on success, or -1 if relative mode is not supported.
   106  *  \return 0 on success, or -1 if relative mode is not supported.
   109  *  
   107  *
   110  *  While the mouse is in relative mode, the cursor is hidden, and the
   108  *  While the mouse is in relative mode, the cursor is hidden, and the
   111  *  driver will try to report continuous motion in the current window.
   109  *  driver will try to report continuous motion in the current window.
   112  *  Only relative motion events will be delivered, the mouse position
   110  *  Only relative motion events will be delivered, the mouse position
   113  *  will not change.
   111  *  will not change.
   114  *  
   112  *
   115  *  \note This function will flush any pending mouse motion.
   113  *  \note This function will flush any pending mouse motion.
   116  *  
   114  *
   117  *  \sa SDL_GetRelativeMouseMode()
   115  *  \sa SDL_GetRelativeMouseMode()
   118  */
   116  */
   119 extern DECLSPEC int SDLCALL SDL_SetRelativeMouseMode(SDL_bool enabled);
   117 extern DECLSPEC int SDLCALL SDL_SetRelativeMouseMode(SDL_bool enabled);
   120 
   118 
   121 /**
   119 /**
   122  *  \brief Query whether relative mouse mode is enabled.
   120  *  \brief Query whether relative mouse mode is enabled.
   123  *  
   121  *
   124  *  \sa SDL_SetRelativeMouseMode()
   122  *  \sa SDL_SetRelativeMouseMode()
   125  */
   123  */
   126 extern DECLSPEC SDL_bool SDLCALL SDL_GetRelativeMouseMode(void);
   124 extern DECLSPEC SDL_bool SDLCALL SDL_GetRelativeMouseMode(void);
   127 
   125 
   128 /**
   126 /**
   129  *  \brief Create a cursor, using the specified bitmap data and
   127  *  \brief Create a cursor, using the specified bitmap data and
   130  *         mask (in MSB format).
   128  *         mask (in MSB format).
   131  *  
   129  *
   132  *  The cursor width must be a multiple of 8 bits.
   130  *  The cursor width must be a multiple of 8 bits.
   133  *  
   131  *
   134  *  The cursor is created in black and white according to the following:
   132  *  The cursor is created in black and white according to the following:
   135  *  <table>
   133  *  <table>
   136  *  <tr><td> data </td><td> mask </td><td> resulting pixel on screen </td></tr>
   134  *  <tr><td> data </td><td> mask </td><td> resulting pixel on screen </td></tr>
   137  *  <tr><td>  0   </td><td>  1   </td><td> White </td></tr>
   135  *  <tr><td>  0   </td><td>  1   </td><td> White </td></tr>
   138  *  <tr><td>  1   </td><td>  1   </td><td> Black </td></tr>
   136  *  <tr><td>  1   </td><td>  1   </td><td> Black </td></tr>
   139  *  <tr><td>  0   </td><td>  0   </td><td> Transparent </td></tr>
   137  *  <tr><td>  0   </td><td>  0   </td><td> Transparent </td></tr>
   140  *  <tr><td>  1   </td><td>  0   </td><td> Inverted color if possible, black 
   138  *  <tr><td>  1   </td><td>  0   </td><td> Inverted color if possible, black
   141  *                                         if not. </td></tr>
   139  *                                         if not. </td></tr>
   142  *  </table>
   140  *  </table>
   143  *  
   141  *
   144  *  \sa SDL_FreeCursor()
   142  *  \sa SDL_FreeCursor()
   145  */
   143  */
   146 extern DECLSPEC SDL_Cursor *SDLCALL SDL_CreateCursor(const Uint8 * data,
   144 extern DECLSPEC SDL_Cursor *SDLCALL SDL_CreateCursor(const Uint8 * data,
   147                                                      const Uint8 * mask,
   145                                                      const Uint8 * mask,
   148                                                      int w, int h, int hot_x,
   146                                                      int w, int h, int hot_x,
   149                                                      int hot_y);
   147                                                      int hot_y);
   150 
   148 
   151 /**
   149 /**
   152  *  \brief Create a color cursor.
   150  *  \brief Create a color cursor.
   153  *  
   151  *
   154  *  \sa SDL_FreeCursor()
   152  *  \sa SDL_FreeCursor()
   155  */
   153  */
   156 extern DECLSPEC SDL_Cursor *SDLCALL SDL_CreateColorCursor(SDL_Surface *surface,
   154 extern DECLSPEC SDL_Cursor *SDLCALL SDL_CreateColorCursor(SDL_Surface *surface,
   157                                                           int hot_x,
   155                                                           int hot_x,
   158                                                           int hot_y);
   156                                                           int hot_y);
   179  */
   177  */
   180 extern DECLSPEC SDL_Cursor *SDLCALL SDL_GetDefaultCursor(void);
   178 extern DECLSPEC SDL_Cursor *SDLCALL SDL_GetDefaultCursor(void);
   181 
   179 
   182 /**
   180 /**
   183  *  \brief Frees a cursor created with SDL_CreateCursor().
   181  *  \brief Frees a cursor created with SDL_CreateCursor().
   184  *  
   182  *
   185  *  \sa SDL_CreateCursor()
   183  *  \sa SDL_CreateCursor()
   186  */
   184  */
   187 extern DECLSPEC void SDLCALL SDL_FreeCursor(SDL_Cursor * cursor);
   185 extern DECLSPEC void SDLCALL SDL_FreeCursor(SDL_Cursor * cursor);
   188 
   186 
   189 /**
   187 /**
   190  *  \brief Toggle whether or not the cursor is shown.
   188  *  \brief Toggle whether or not the cursor is shown.
   191  *  
   189  *
   192  *  \param toggle 1 to show the cursor, 0 to hide it, -1 to query the current 
   190  *  \param toggle 1 to show the cursor, 0 to hide it, -1 to query the current
   193  *                state.
   191  *                state.
   194  *  
   192  *
   195  *  \return 1 if the cursor is shown, or 0 if the cursor is hidden.
   193  *  \return 1 if the cursor is shown, or 0 if the cursor is hidden.
   196  */
   194  */
   197 extern DECLSPEC int SDLCALL SDL_ShowCursor(int toggle);
   195 extern DECLSPEC int SDLCALL SDL_ShowCursor(int toggle);
   198 
   196 
   199 /**
   197 /**
   200  *  Used as a mask when testing buttons in buttonstate.
   198  *  Used as a mask when testing buttons in buttonstate.
   201  *   - Button 1:  Left mouse button
   199  *   - Button 1:  Left mouse button
   202  *   - Button 2:  Middle mouse button
   200  *   - Button 2:  Middle mouse button
   203  *   - Button 3:  Right mouse button
   201  *   - Button 3:  Right mouse button
   204  */
   202  */
   205 #define SDL_BUTTON(X)		(1 << ((X)-1))
   203 #define SDL_BUTTON(X)       (1 << ((X)-1))
   206 #define SDL_BUTTON_LEFT		1
   204 #define SDL_BUTTON_LEFT     1
   207 #define SDL_BUTTON_MIDDLE	2
   205 #define SDL_BUTTON_MIDDLE   2
   208 #define SDL_BUTTON_RIGHT	3
   206 #define SDL_BUTTON_RIGHT    3
   209 #define SDL_BUTTON_X1		4
   207 #define SDL_BUTTON_X1       4
   210 #define SDL_BUTTON_X2		5
   208 #define SDL_BUTTON_X2       5
   211 #define SDL_BUTTON_LMASK	SDL_BUTTON(SDL_BUTTON_LEFT)
   209 #define SDL_BUTTON_LMASK    SDL_BUTTON(SDL_BUTTON_LEFT)
   212 #define SDL_BUTTON_MMASK	SDL_BUTTON(SDL_BUTTON_MIDDLE)
   210 #define SDL_BUTTON_MMASK    SDL_BUTTON(SDL_BUTTON_MIDDLE)
   213 #define SDL_BUTTON_RMASK	SDL_BUTTON(SDL_BUTTON_RIGHT)
   211 #define SDL_BUTTON_RMASK    SDL_BUTTON(SDL_BUTTON_RIGHT)
   214 #define SDL_BUTTON_X1MASK	SDL_BUTTON(SDL_BUTTON_X1)
   212 #define SDL_BUTTON_X1MASK   SDL_BUTTON(SDL_BUTTON_X1)
   215 #define SDL_BUTTON_X2MASK	SDL_BUTTON(SDL_BUTTON_X2)
   213 #define SDL_BUTTON_X2MASK   SDL_BUTTON(SDL_BUTTON_X2)
   216 
   214 
   217 
   215 
   218 /* Ends C function definitions when using C++ */
   216 /* Ends C function definitions when using C++ */
   219 #ifdef __cplusplus
   217 #ifdef __cplusplus
   220 /* *INDENT-OFF* */
       
   221 }
   218 }
   222 /* *INDENT-ON* */
       
   223 #endif
   219 #endif
   224 #include "close_code.h"
   220 #include "close_code.h"
   225 
   221 
   226 #endif /* _SDL_mouse_h */
   222 #endif /* _SDL_mouse_h */
   227 
   223