SDL standard library
Embed:
(wiki syntax)
Show/hide line numbers
SDL_mouse.h
Go to the documentation of this file.
00001 /* 00002 Simple DirectMedia Layer 00003 Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org> 00004 00005 This software is provided 'as-is', without any express or implied 00006 warranty. In no event will the authors be held liable for any damages 00007 arising from the use of this software. 00008 00009 Permission is granted to anyone to use this software for any purpose, 00010 including commercial applications, and to alter it and redistribute it 00011 freely, subject to the following restrictions: 00012 00013 1. The origin of this software must not be misrepresented; you must not 00014 claim that you wrote the original software. If you use this software 00015 in a product, an acknowledgment in the product documentation would be 00016 appreciated but is not required. 00017 2. Altered source versions must be plainly marked as such, and must not be 00018 misrepresented as being the original software. 00019 3. This notice may not be removed or altered from any source distribution. 00020 */ 00021 00022 /** 00023 * \file SDL_mouse.h 00024 * 00025 * Include file for SDL mouse event handling. 00026 */ 00027 00028 #ifndef _SDL_mouse_h 00029 #define _SDL_mouse_h 00030 00031 #include "SDL_stdinc.h" 00032 #include "SDL_error.h" 00033 #include "SDL_video.h" 00034 00035 #include "begin_code.h" 00036 /* Set up for C function definitions, even when using C++ */ 00037 #ifdef __cplusplus 00038 extern "C" { 00039 #endif 00040 00041 typedef struct SDL_Cursor SDL_Cursor; /* Implementation dependent */ 00042 00043 /** 00044 * \brief Cursor types for SDL_CreateSystemCursor. 00045 */ 00046 typedef enum 00047 { 00048 SDL_SYSTEM_CURSOR_ARROW, /**< Arrow */ 00049 SDL_SYSTEM_CURSOR_IBEAM, /**< I-beam */ 00050 SDL_SYSTEM_CURSOR_WAIT, /**< Wait */ 00051 SDL_SYSTEM_CURSOR_CROSSHAIR, /**< Crosshair */ 00052 SDL_SYSTEM_CURSOR_WAITARROW, /**< Small wait cursor (or Wait if not available) */ 00053 SDL_SYSTEM_CURSOR_SIZENWSE, /**< Double arrow pointing northwest and southeast */ 00054 SDL_SYSTEM_CURSOR_SIZENESW, /**< Double arrow pointing northeast and southwest */ 00055 SDL_SYSTEM_CURSOR_SIZEWE, /**< Double arrow pointing west and east */ 00056 SDL_SYSTEM_CURSOR_SIZENS, /**< Double arrow pointing north and south */ 00057 SDL_SYSTEM_CURSOR_SIZEALL, /**< Four pointed arrow pointing north, south, east, and west */ 00058 SDL_SYSTEM_CURSOR_NO, /**< Slashed circle or crossbones */ 00059 SDL_SYSTEM_CURSOR_HAND, /**< Hand */ 00060 SDL_NUM_SYSTEM_CURSORS 00061 } SDL_SystemCursor; 00062 00063 /* Function prototypes */ 00064 00065 /** 00066 * \brief Get the window which currently has mouse focus. 00067 */ 00068 extern DECLSPEC SDL_Window * SDLCALL SDL_GetMouseFocus(void); 00069 00070 /** 00071 * \brief Retrieve the current state of the mouse. 00072 * 00073 * The current button state is returned as a button bitmask, which can 00074 * be tested using the SDL_BUTTON(X) macros, and x and y are set to the 00075 * mouse cursor position relative to the focus window for the currently 00076 * selected mouse. You can pass NULL for either x or y. 00077 */ 00078 extern DECLSPEC Uint32 SDLCALL SDL_GetMouseState(int *x, int *y); 00079 00080 /** 00081 * \brief Retrieve the relative state of the mouse. 00082 * 00083 * The current button state is returned as a button bitmask, which can 00084 * be tested using the SDL_BUTTON(X) macros, and x and y are set to the 00085 * mouse deltas since the last call to SDL_GetRelativeMouseState(). 00086 */ 00087 extern DECLSPEC Uint32 SDLCALL SDL_GetRelativeMouseState(int *x, int *y); 00088 00089 /** 00090 * \brief Moves the mouse to the given position within the window. 00091 * 00092 * \param window The window to move the mouse into, or NULL for the current mouse focus 00093 * \param x The x coordinate within the window 00094 * \param y The y coordinate within the window 00095 * 00096 * \note This function generates a mouse motion event 00097 */ 00098 extern DECLSPEC void SDLCALL SDL_WarpMouseInWindow(SDL_Window * window, 00099 int x, int y); 00100 00101 /** 00102 * \brief Set relative mouse mode. 00103 * 00104 * \param enabled Whether or not to enable relative mode 00105 * 00106 * \return 0 on success, or -1 if relative mode is not supported. 00107 * 00108 * While the mouse is in relative mode, the cursor is hidden, and the 00109 * driver will try to report continuous motion in the current window. 00110 * Only relative motion events will be delivered, the mouse position 00111 * will not change. 00112 * 00113 * \note This function will flush any pending mouse motion. 00114 * 00115 * \sa SDL_GetRelativeMouseMode() 00116 */ 00117 extern DECLSPEC int SDLCALL SDL_SetRelativeMouseMode(SDL_bool enabled); 00118 00119 /** 00120 * \brief Query whether relative mouse mode is enabled. 00121 * 00122 * \sa SDL_SetRelativeMouseMode() 00123 */ 00124 extern DECLSPEC SDL_bool SDLCALL SDL_GetRelativeMouseMode(void); 00125 00126 /** 00127 * \brief Create a cursor, using the specified bitmap data and 00128 * mask (in MSB format). 00129 * 00130 * The cursor width must be a multiple of 8 bits. 00131 * 00132 * The cursor is created in black and white according to the following: 00133 * <table> 00134 * <tr><td> data </td><td> mask </td><td> resulting pixel on screen </td></tr> 00135 * <tr><td> 0 </td><td> 1 </td><td> White </td></tr> 00136 * <tr><td> 1 </td><td> 1 </td><td> Black </td></tr> 00137 * <tr><td> 0 </td><td> 0 </td><td> Transparent </td></tr> 00138 * <tr><td> 1 </td><td> 0 </td><td> Inverted color if possible, black 00139 * if not. </td></tr> 00140 * </table> 00141 * 00142 * \sa SDL_FreeCursor() 00143 */ 00144 extern DECLSPEC SDL_Cursor *SDLCALL SDL_CreateCursor(const Uint8 * data, 00145 const Uint8 * mask, 00146 int w, int h, int hot_x, 00147 int hot_y); 00148 00149 /** 00150 * \brief Create a color cursor. 00151 * 00152 * \sa SDL_FreeCursor() 00153 */ 00154 extern DECLSPEC SDL_Cursor *SDLCALL SDL_CreateColorCursor(SDL_Surface *surface, 00155 int hot_x, 00156 int hot_y); 00157 00158 /** 00159 * \brief Create a system cursor. 00160 * 00161 * \sa SDL_FreeCursor() 00162 */ 00163 extern DECLSPEC SDL_Cursor *SDLCALL SDL_CreateSystemCursor(SDL_SystemCursor id); 00164 00165 /** 00166 * \brief Set the active cursor. 00167 */ 00168 extern DECLSPEC void SDLCALL SDL_SetCursor(SDL_Cursor * cursor); 00169 00170 /** 00171 * \brief Return the active cursor. 00172 */ 00173 extern DECLSPEC SDL_Cursor *SDLCALL SDL_GetCursor(void); 00174 00175 /** 00176 * \brief Return the default cursor. 00177 */ 00178 extern DECLSPEC SDL_Cursor *SDLCALL SDL_GetDefaultCursor(void); 00179 00180 /** 00181 * \brief Frees a cursor created with SDL_CreateCursor(). 00182 * 00183 * \sa SDL_CreateCursor() 00184 */ 00185 extern DECLSPEC void SDLCALL SDL_FreeCursor(SDL_Cursor * cursor); 00186 00187 /** 00188 * \brief Toggle whether or not the cursor is shown. 00189 * 00190 * \param toggle 1 to show the cursor, 0 to hide it, -1 to query the current 00191 * state. 00192 * 00193 * \return 1 if the cursor is shown, or 0 if the cursor is hidden. 00194 */ 00195 extern DECLSPEC int SDLCALL SDL_ShowCursor(int toggle); 00196 00197 /** 00198 * Used as a mask when testing buttons in buttonstate. 00199 * - Button 1: Left mouse button 00200 * - Button 2: Middle mouse button 00201 * - Button 3: Right mouse button 00202 */ 00203 #define SDL_BUTTON(X) (1 << ((X)-1)) 00204 #define SDL_BUTTON_LEFT 1 00205 #define SDL_BUTTON_MIDDLE 2 00206 #define SDL_BUTTON_RIGHT 3 00207 #define SDL_BUTTON_X1 4 00208 #define SDL_BUTTON_X2 5 00209 #define SDL_BUTTON_LMASK SDL_BUTTON(SDL_BUTTON_LEFT) 00210 #define SDL_BUTTON_MMASK SDL_BUTTON(SDL_BUTTON_MIDDLE) 00211 #define SDL_BUTTON_RMASK SDL_BUTTON(SDL_BUTTON_RIGHT) 00212 #define SDL_BUTTON_X1MASK SDL_BUTTON(SDL_BUTTON_X1) 00213 #define SDL_BUTTON_X2MASK SDL_BUTTON(SDL_BUTTON_X2) 00214 00215 00216 /* Ends C function definitions when using C++ */ 00217 #ifdef __cplusplus 00218 } 00219 #endif 00220 #include "close_code.h" 00221 00222 #endif /* _SDL_mouse_h */ 00223 00224 /* vi: set ts=4 sw=4 expandtab: */
Generated on Tue Jul 12 2022 13:56:24 by 1.7.2