slouken@0: /* slouken@5535: Simple DirectMedia Layer slouken@8149: Copyright (C) 1997-2014 Sam Lantinga slouken@0: slouken@5535: This software is provided 'as-is', without any express or implied slouken@5535: warranty. In no event will the authors be held liable for any damages slouken@5535: arising from the use of this software. slouken@0: slouken@5535: Permission is granted to anyone to use this software for any purpose, slouken@5535: including commercial applications, and to alter it and redistribute it slouken@5535: freely, subject to the following restrictions: slouken@0: slouken@5535: 1. The origin of this software must not be misrepresented; you must not slouken@5535: claim that you wrote the original software. If you use this software slouken@5535: in a product, an acknowledgment in the product documentation would be slouken@5535: appreciated but is not required. slouken@5535: 2. Altered source versions must be plainly marked as such, and must not be slouken@5535: misrepresented as being the original software. slouken@5535: 3. This notice may not be removed or altered from any source distribution. slouken@0: */ slouken@0: slouken@1895: /** slouken@3407: * \file SDL_mouse.h slouken@7191: * slouken@3407: * Include file for SDL mouse event handling. slouken@1895: */ slouken@0: slouken@0: #ifndef _SDL_mouse_h slouken@0: #define _SDL_mouse_h slouken@0: slouken@1356: #include "SDL_stdinc.h" slouken@1358: #include "SDL_error.h" slouken@0: #include "SDL_video.h" slouken@0: slouken@0: #include "begin_code.h" slouken@0: /* Set up for C function definitions, even when using C++ */ slouken@0: #ifdef __cplusplus slouken@0: extern "C" { slouken@0: #endif slouken@0: slouken@1895: typedef struct SDL_Cursor SDL_Cursor; /* Implementation dependent */ slouken@0: mikesart@6675: /** mikesart@6675: * \brief Cursor types for SDL_CreateSystemCursor. mikesart@6675: */ mikesart@6675: typedef enum mikesart@6675: { icculus@7067: SDL_SYSTEM_CURSOR_ARROW, /**< Arrow */ icculus@7067: SDL_SYSTEM_CURSOR_IBEAM, /**< I-beam */ icculus@7067: SDL_SYSTEM_CURSOR_WAIT, /**< Wait */ icculus@7067: SDL_SYSTEM_CURSOR_CROSSHAIR, /**< Crosshair */ icculus@7067: SDL_SYSTEM_CURSOR_WAITARROW, /**< Small wait cursor (or Wait if not available) */ icculus@7067: SDL_SYSTEM_CURSOR_SIZENWSE, /**< Double arrow pointing northwest and southeast */ icculus@7067: SDL_SYSTEM_CURSOR_SIZENESW, /**< Double arrow pointing northeast and southwest */ icculus@7067: SDL_SYSTEM_CURSOR_SIZEWE, /**< Double arrow pointing west and east */ icculus@7067: SDL_SYSTEM_CURSOR_SIZENS, /**< Double arrow pointing north and south */ icculus@7067: SDL_SYSTEM_CURSOR_SIZEALL, /**< Four pointed arrow pointing north, south, east, and west */ icculus@7067: SDL_SYSTEM_CURSOR_NO, /**< Slashed circle or crossbones */ icculus@7067: SDL_SYSTEM_CURSOR_HAND, /**< Hand */ slouken@6677: SDL_NUM_SYSTEM_CURSORS mikesart@6675: } SDL_SystemCursor; slouken@4465: slouken@0: /* Function prototypes */ slouken@1895: slouken@1895: /** slouken@4465: * \brief Get the window which currently has mouse focus. slouken@1895: */ slouken@4465: extern DECLSPEC SDL_Window * SDLCALL SDL_GetMouseFocus(void); slouken@1895: slouken@1895: /** slouken@4465: * \brief Retrieve the current state of the mouse. slouken@7191: * slouken@4465: * The current button state is returned as a button bitmask, which can slouken@4465: * be tested using the SDL_BUTTON(X) macros, and x and y are set to the slouken@4465: * mouse cursor position relative to the focus window for the currently slouken@4465: * selected mouse. You can pass NULL for either x or y. kazeuser@2718: */ slouken@6673: extern DECLSPEC Uint32 SDLCALL SDL_GetMouseState(int *x, int *y); kazeuser@2718: kazeuser@2718: /** slouken@4465: * \brief Retrieve the relative state of the mouse. slouken@4465: * slouken@4465: * The current button state is returned as a button bitmask, which can slouken@4465: * be tested using the SDL_BUTTON(X) macros, and x and y are set to the slouken@4465: * mouse deltas since the last call to SDL_GetRelativeMouseState(). slouken@1895: */ slouken@6673: extern DECLSPEC Uint32 SDLCALL SDL_GetRelativeMouseState(int *x, int *y); slouken@1895: slouken@1895: /** slouken@4465: * \brief Moves the mouse to the given position within the window. slouken@7191: * slouken@4465: * \param window The window to move the mouse into, or NULL for the current mouse focus slouken@4465: * \param x The x coordinate within the window slouken@4465: * \param y The y coordinate within the window slouken@7191: * slouken@4465: * \note This function generates a mouse motion event slouken@1895: */ slouken@4465: extern DECLSPEC void SDLCALL SDL_WarpMouseInWindow(SDL_Window * window, slouken@4465: int x, int y); slouken@1895: slouken@1895: /** slouken@4465: * \brief Set relative mouse mode. slouken@7191: * slouken@3407: * \param enabled Whether or not to enable relative mode slouken@4465: * slouken@3407: * \return 0 on success, or -1 if relative mode is not supported. slouken@7191: * slouken@3407: * While the mouse is in relative mode, the cursor is hidden, and the slouken@3407: * driver will try to report continuous motion in the current window. slouken@3407: * Only relative motion events will be delivered, the mouse position slouken@3407: * will not change. slouken@7191: * slouken@3407: * \note This function will flush any pending mouse motion. slouken@7191: * slouken@3407: * \sa SDL_GetRelativeMouseMode() slouken@1895: */ slouken@4465: extern DECLSPEC int SDLCALL SDL_SetRelativeMouseMode(SDL_bool enabled); slouken@1895: slouken@1895: /** icculus@8927: * \brief Capture the mouse, to track input outside an SDL window. icculus@8927: * icculus@8927: * \param enabled Whether or not to enable capturing icculus@8927: * icculus@8927: * Capturing enables your app to obtain mouse events globally, instead of icculus@8927: * just within your window. Not all video targets support this function. icculus@8927: * When capturing is enabled, the current window will get all mouse events, icculus@8927: * but unlike relative mode, no change is made to the cursor and it is icculus@8927: * not restrained to your window. icculus@8927: * icculus@8927: * This function may also deny mouse input to other windows--both those in icculus@8927: * your application and others on the system--so you should use this icculus@8927: * function sparingly, and in small bursts. For example, you might want to icculus@8927: * track the mouse while the user is dragging something, until the user icculus@8927: * releases a mouse button. It is not recommended that you capture the mouse icculus@8927: * for long periods of time, such as the entire time your app is running. icculus@8927: * icculus@8927: * While captured, mouse events still report coordinates relative to the icculus@8927: * current (foreground) window, but those coordinates may be outside the icculus@8927: * bounds of the window (including negative values). Capturing is only icculus@8927: * allowed for the foreground window. If the window loses focus while icculus@8927: * capturing, the capture will be disabled automatically. icculus@8927: * icculus@8927: * While capturing is enabled, the current window will have the icculus@8927: * SDL_WINDOW_MOUSE_CAPTURE flag set. icculus@8927: * icculus@8927: * \return 0 on success, or -1 if not supported. icculus@8927: */ icculus@8927: extern DECLSPEC int SDLCALL SDL_CaptureMouse(SDL_bool enabled); icculus@8927: icculus@8927: /** slouken@4465: * \brief Query whether relative mouse mode is enabled. slouken@7191: * slouken@3407: * \sa SDL_SetRelativeMouseMode() slouken@1895: */ slouken@4465: extern DECLSPEC SDL_bool SDLCALL SDL_GetRelativeMouseMode(void); slouken@1895: slouken@1895: /** slouken@4465: * \brief Create a cursor, using the specified bitmap data and slouken@4465: * mask (in MSB format). slouken@7191: * slouken@3407: * The cursor width must be a multiple of 8 bits. slouken@7191: * slouken@3407: * The cursor is created in black and white according to the following: slouken@3407: * slouken@3407: * slouken@3407: * slouken@3407: * slouken@3407: * slouken@7191: * slouken@3407: *
data mask resulting pixel on screen
0 1 White
1 1 Black
0 0 Transparent
1 0 Inverted color if possible, black slouken@4465: * if not.
slouken@7191: * slouken@3407: * \sa SDL_FreeCursor() slouken@0: */ slouken@1895: extern DECLSPEC SDL_Cursor *SDLCALL SDL_CreateCursor(const Uint8 * data, slouken@1895: const Uint8 * mask, slouken@1895: int w, int h, int hot_x, slouken@1895: int hot_y); slouken@0: slouken@1895: /** slouken@5473: * \brief Create a color cursor. slouken@7191: * slouken@5473: * \sa SDL_FreeCursor() slouken@5473: */ slouken@5473: extern DECLSPEC SDL_Cursor *SDLCALL SDL_CreateColorCursor(SDL_Surface *surface, slouken@5473: int hot_x, slouken@5473: int hot_y); slouken@5473: slouken@5473: /** mikesart@6675: * \brief Create a system cursor. mikesart@6675: * mikesart@6675: * \sa SDL_FreeCursor() mikesart@6675: */ mikesart@6675: extern DECLSPEC SDL_Cursor *SDLCALL SDL_CreateSystemCursor(SDL_SystemCursor id); mikesart@6675: mikesart@6675: /** slouken@4465: * \brief Set the active cursor. slouken@0: */ slouken@1895: extern DECLSPEC void SDLCALL SDL_SetCursor(SDL_Cursor * cursor); slouken@0: slouken@1895: /** slouken@4465: * \brief Return the active cursor. slouken@0: */ slouken@1895: extern DECLSPEC SDL_Cursor *SDLCALL SDL_GetCursor(void); slouken@0: slouken@1895: /** jorgen@7104: * \brief Return the default cursor. jorgen@7104: */ jorgen@7104: extern DECLSPEC SDL_Cursor *SDLCALL SDL_GetDefaultCursor(void); jorgen@7104: jorgen@7104: /** slouken@3407: * \brief Frees a cursor created with SDL_CreateCursor(). slouken@7191: * slouken@3407: * \sa SDL_CreateCursor() slouken@0: */ slouken@1895: extern DECLSPEC void SDLCALL SDL_FreeCursor(SDL_Cursor * cursor); slouken@0: slouken@1895: /** slouken@4465: * \brief Toggle whether or not the cursor is shown. slouken@7191: * slouken@7191: * \param toggle 1 to show the cursor, 0 to hide it, -1 to query the current slouken@3407: * state. slouken@7191: * slouken@3407: * \return 1 if the cursor is shown, or 0 if the cursor is hidden. slouken@0: */ slouken@337: extern DECLSPEC int SDLCALL SDL_ShowCursor(int toggle); slouken@0: kazeuser@2718: /** slouken@3407: * Used as a mask when testing buttons in buttonstate. slouken@3407: * - Button 1: Left mouse button slouken@3407: * - Button 2: Middle mouse button slouken@3407: * - Button 3: Right mouse button slouken@3407: */ slouken@7191: #define SDL_BUTTON(X) (1 << ((X)-1)) slouken@7191: #define SDL_BUTTON_LEFT 1 slouken@7191: #define SDL_BUTTON_MIDDLE 2 slouken@7191: #define SDL_BUTTON_RIGHT 3 slouken@7191: #define SDL_BUTTON_X1 4 slouken@7191: #define SDL_BUTTON_X2 5 slouken@7191: #define SDL_BUTTON_LMASK SDL_BUTTON(SDL_BUTTON_LEFT) slouken@7191: #define SDL_BUTTON_MMASK SDL_BUTTON(SDL_BUTTON_MIDDLE) slouken@7191: #define SDL_BUTTON_RMASK SDL_BUTTON(SDL_BUTTON_RIGHT) slouken@7191: #define SDL_BUTTON_X1MASK SDL_BUTTON(SDL_BUTTON_X1) slouken@7191: #define SDL_BUTTON_X2MASK SDL_BUTTON(SDL_BUTTON_X2) slouken@0: slouken@0: slouken@0: /* Ends C function definitions when using C++ */ slouken@0: #ifdef __cplusplus slouken@0: } slouken@0: #endif slouken@0: #include "close_code.h" slouken@0: slouken@0: #endif /* _SDL_mouse_h */ slouken@1895: slouken@1895: /* vi: set ts=4 sw=4 expandtab: */