SDL Library

Dependents:   H261_decoder

Committer:
miruga27
Date:
Thu Sep 22 00:03:09 2016 +0000
Revision:
0:7fb6877b5d7c
SDL

Who changed what in which revision?

UserRevisionLine numberNew contents of line
miruga27 0:7fb6877b5d7c 1 /*
miruga27 0:7fb6877b5d7c 2 Simple DirectMedia Layer
miruga27 0:7fb6877b5d7c 3 Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
miruga27 0:7fb6877b5d7c 4
miruga27 0:7fb6877b5d7c 5 This software is provided 'as-is', without any express or implied
miruga27 0:7fb6877b5d7c 6 warranty. In no event will the authors be held liable for any damages
miruga27 0:7fb6877b5d7c 7 arising from the use of this software.
miruga27 0:7fb6877b5d7c 8
miruga27 0:7fb6877b5d7c 9 Permission is granted to anyone to use this software for any purpose,
miruga27 0:7fb6877b5d7c 10 including commercial applications, and to alter it and redistribute it
miruga27 0:7fb6877b5d7c 11 freely, subject to the following restrictions:
miruga27 0:7fb6877b5d7c 12
miruga27 0:7fb6877b5d7c 13 1. The origin of this software must not be misrepresented; you must not
miruga27 0:7fb6877b5d7c 14 claim that you wrote the original software. If you use this software
miruga27 0:7fb6877b5d7c 15 in a product, an acknowledgment in the product documentation would be
miruga27 0:7fb6877b5d7c 16 appreciated but is not required.
miruga27 0:7fb6877b5d7c 17 2. Altered source versions must be plainly marked as such, and must not be
miruga27 0:7fb6877b5d7c 18 misrepresented as being the original software.
miruga27 0:7fb6877b5d7c 19 3. This notice may not be removed or altered from any source distribution.
miruga27 0:7fb6877b5d7c 20 */
miruga27 0:7fb6877b5d7c 21
miruga27 0:7fb6877b5d7c 22 /**
miruga27 0:7fb6877b5d7c 23 * \file SDL_mouse.h
miruga27 0:7fb6877b5d7c 24 *
miruga27 0:7fb6877b5d7c 25 * Include file for SDL mouse event handling.
miruga27 0:7fb6877b5d7c 26 */
miruga27 0:7fb6877b5d7c 27
miruga27 0:7fb6877b5d7c 28 #ifndef _SDL_mouse_h
miruga27 0:7fb6877b5d7c 29 #define _SDL_mouse_h
miruga27 0:7fb6877b5d7c 30
miruga27 0:7fb6877b5d7c 31 #include "SDL_stdinc.h"
miruga27 0:7fb6877b5d7c 32 #include "SDL_error.h"
miruga27 0:7fb6877b5d7c 33 #include "SDL_video.h"
miruga27 0:7fb6877b5d7c 34
miruga27 0:7fb6877b5d7c 35 #include "begin_code.h"
miruga27 0:7fb6877b5d7c 36 /* Set up for C function definitions, even when using C++ */
miruga27 0:7fb6877b5d7c 37 #ifdef __cplusplus
miruga27 0:7fb6877b5d7c 38 extern "C" {
miruga27 0:7fb6877b5d7c 39 #endif
miruga27 0:7fb6877b5d7c 40
miruga27 0:7fb6877b5d7c 41 typedef struct SDL_Cursor SDL_Cursor; /* Implementation dependent */
miruga27 0:7fb6877b5d7c 42
miruga27 0:7fb6877b5d7c 43 /**
miruga27 0:7fb6877b5d7c 44 * \brief Cursor types for SDL_CreateSystemCursor.
miruga27 0:7fb6877b5d7c 45 */
miruga27 0:7fb6877b5d7c 46 typedef enum
miruga27 0:7fb6877b5d7c 47 {
miruga27 0:7fb6877b5d7c 48 SDL_SYSTEM_CURSOR_ARROW, /**< Arrow */
miruga27 0:7fb6877b5d7c 49 SDL_SYSTEM_CURSOR_IBEAM, /**< I-beam */
miruga27 0:7fb6877b5d7c 50 SDL_SYSTEM_CURSOR_WAIT, /**< Wait */
miruga27 0:7fb6877b5d7c 51 SDL_SYSTEM_CURSOR_CROSSHAIR, /**< Crosshair */
miruga27 0:7fb6877b5d7c 52 SDL_SYSTEM_CURSOR_WAITARROW, /**< Small wait cursor (or Wait if not available) */
miruga27 0:7fb6877b5d7c 53 SDL_SYSTEM_CURSOR_SIZENWSE, /**< Double arrow pointing northwest and southeast */
miruga27 0:7fb6877b5d7c 54 SDL_SYSTEM_CURSOR_SIZENESW, /**< Double arrow pointing northeast and southwest */
miruga27 0:7fb6877b5d7c 55 SDL_SYSTEM_CURSOR_SIZEWE, /**< Double arrow pointing west and east */
miruga27 0:7fb6877b5d7c 56 SDL_SYSTEM_CURSOR_SIZENS, /**< Double arrow pointing north and south */
miruga27 0:7fb6877b5d7c 57 SDL_SYSTEM_CURSOR_SIZEALL, /**< Four pointed arrow pointing north, south, east, and west */
miruga27 0:7fb6877b5d7c 58 SDL_SYSTEM_CURSOR_NO, /**< Slashed circle or crossbones */
miruga27 0:7fb6877b5d7c 59 SDL_SYSTEM_CURSOR_HAND, /**< Hand */
miruga27 0:7fb6877b5d7c 60 SDL_NUM_SYSTEM_CURSORS
miruga27 0:7fb6877b5d7c 61 } SDL_SystemCursor;
miruga27 0:7fb6877b5d7c 62
miruga27 0:7fb6877b5d7c 63 /* Function prototypes */
miruga27 0:7fb6877b5d7c 64
miruga27 0:7fb6877b5d7c 65 /**
miruga27 0:7fb6877b5d7c 66 * \brief Get the window which currently has mouse focus.
miruga27 0:7fb6877b5d7c 67 */
miruga27 0:7fb6877b5d7c 68 extern DECLSPEC SDL_Window * SDLCALL SDL_GetMouseFocus(void);
miruga27 0:7fb6877b5d7c 69
miruga27 0:7fb6877b5d7c 70 /**
miruga27 0:7fb6877b5d7c 71 * \brief Retrieve the current state of the mouse.
miruga27 0:7fb6877b5d7c 72 *
miruga27 0:7fb6877b5d7c 73 * The current button state is returned as a button bitmask, which can
miruga27 0:7fb6877b5d7c 74 * be tested using the SDL_BUTTON(X) macros, and x and y are set to the
miruga27 0:7fb6877b5d7c 75 * mouse cursor position relative to the focus window for the currently
miruga27 0:7fb6877b5d7c 76 * selected mouse. You can pass NULL for either x or y.
miruga27 0:7fb6877b5d7c 77 */
miruga27 0:7fb6877b5d7c 78 extern DECLSPEC Uint32 SDLCALL SDL_GetMouseState(int *x, int *y);
miruga27 0:7fb6877b5d7c 79
miruga27 0:7fb6877b5d7c 80 /**
miruga27 0:7fb6877b5d7c 81 * \brief Retrieve the relative state of the mouse.
miruga27 0:7fb6877b5d7c 82 *
miruga27 0:7fb6877b5d7c 83 * The current button state is returned as a button bitmask, which can
miruga27 0:7fb6877b5d7c 84 * be tested using the SDL_BUTTON(X) macros, and x and y are set to the
miruga27 0:7fb6877b5d7c 85 * mouse deltas since the last call to SDL_GetRelativeMouseState().
miruga27 0:7fb6877b5d7c 86 */
miruga27 0:7fb6877b5d7c 87 extern DECLSPEC Uint32 SDLCALL SDL_GetRelativeMouseState(int *x, int *y);
miruga27 0:7fb6877b5d7c 88
miruga27 0:7fb6877b5d7c 89 /**
miruga27 0:7fb6877b5d7c 90 * \brief Moves the mouse to the given position within the window.
miruga27 0:7fb6877b5d7c 91 *
miruga27 0:7fb6877b5d7c 92 * \param window The window to move the mouse into, or NULL for the current mouse focus
miruga27 0:7fb6877b5d7c 93 * \param x The x coordinate within the window
miruga27 0:7fb6877b5d7c 94 * \param y The y coordinate within the window
miruga27 0:7fb6877b5d7c 95 *
miruga27 0:7fb6877b5d7c 96 * \note This function generates a mouse motion event
miruga27 0:7fb6877b5d7c 97 */
miruga27 0:7fb6877b5d7c 98 extern DECLSPEC void SDLCALL SDL_WarpMouseInWindow(SDL_Window * window,
miruga27 0:7fb6877b5d7c 99 int x, int y);
miruga27 0:7fb6877b5d7c 100
miruga27 0:7fb6877b5d7c 101 /**
miruga27 0:7fb6877b5d7c 102 * \brief Set relative mouse mode.
miruga27 0:7fb6877b5d7c 103 *
miruga27 0:7fb6877b5d7c 104 * \param enabled Whether or not to enable relative mode
miruga27 0:7fb6877b5d7c 105 *
miruga27 0:7fb6877b5d7c 106 * \return 0 on success, or -1 if relative mode is not supported.
miruga27 0:7fb6877b5d7c 107 *
miruga27 0:7fb6877b5d7c 108 * While the mouse is in relative mode, the cursor is hidden, and the
miruga27 0:7fb6877b5d7c 109 * driver will try to report continuous motion in the current window.
miruga27 0:7fb6877b5d7c 110 * Only relative motion events will be delivered, the mouse position
miruga27 0:7fb6877b5d7c 111 * will not change.
miruga27 0:7fb6877b5d7c 112 *
miruga27 0:7fb6877b5d7c 113 * \note This function will flush any pending mouse motion.
miruga27 0:7fb6877b5d7c 114 *
miruga27 0:7fb6877b5d7c 115 * \sa SDL_GetRelativeMouseMode()
miruga27 0:7fb6877b5d7c 116 */
miruga27 0:7fb6877b5d7c 117 extern DECLSPEC int SDLCALL SDL_SetRelativeMouseMode(SDL_bool enabled);
miruga27 0:7fb6877b5d7c 118
miruga27 0:7fb6877b5d7c 119 /**
miruga27 0:7fb6877b5d7c 120 * \brief Query whether relative mouse mode is enabled.
miruga27 0:7fb6877b5d7c 121 *
miruga27 0:7fb6877b5d7c 122 * \sa SDL_SetRelativeMouseMode()
miruga27 0:7fb6877b5d7c 123 */
miruga27 0:7fb6877b5d7c 124 extern DECLSPEC SDL_bool SDLCALL SDL_GetRelativeMouseMode(void);
miruga27 0:7fb6877b5d7c 125
miruga27 0:7fb6877b5d7c 126 /**
miruga27 0:7fb6877b5d7c 127 * \brief Create a cursor, using the specified bitmap data and
miruga27 0:7fb6877b5d7c 128 * mask (in MSB format).
miruga27 0:7fb6877b5d7c 129 *
miruga27 0:7fb6877b5d7c 130 * The cursor width must be a multiple of 8 bits.
miruga27 0:7fb6877b5d7c 131 *
miruga27 0:7fb6877b5d7c 132 * The cursor is created in black and white according to the following:
miruga27 0:7fb6877b5d7c 133 * <table>
miruga27 0:7fb6877b5d7c 134 * <tr><td> data </td><td> mask </td><td> resulting pixel on screen </td></tr>
miruga27 0:7fb6877b5d7c 135 * <tr><td> 0 </td><td> 1 </td><td> White </td></tr>
miruga27 0:7fb6877b5d7c 136 * <tr><td> 1 </td><td> 1 </td><td> Black </td></tr>
miruga27 0:7fb6877b5d7c 137 * <tr><td> 0 </td><td> 0 </td><td> Transparent </td></tr>
miruga27 0:7fb6877b5d7c 138 * <tr><td> 1 </td><td> 0 </td><td> Inverted color if possible, black
miruga27 0:7fb6877b5d7c 139 * if not. </td></tr>
miruga27 0:7fb6877b5d7c 140 * </table>
miruga27 0:7fb6877b5d7c 141 *
miruga27 0:7fb6877b5d7c 142 * \sa SDL_FreeCursor()
miruga27 0:7fb6877b5d7c 143 */
miruga27 0:7fb6877b5d7c 144 extern DECLSPEC SDL_Cursor *SDLCALL SDL_CreateCursor(const Uint8 * data,
miruga27 0:7fb6877b5d7c 145 const Uint8 * mask,
miruga27 0:7fb6877b5d7c 146 int w, int h, int hot_x,
miruga27 0:7fb6877b5d7c 147 int hot_y);
miruga27 0:7fb6877b5d7c 148
miruga27 0:7fb6877b5d7c 149 /**
miruga27 0:7fb6877b5d7c 150 * \brief Create a color cursor.
miruga27 0:7fb6877b5d7c 151 *
miruga27 0:7fb6877b5d7c 152 * \sa SDL_FreeCursor()
miruga27 0:7fb6877b5d7c 153 */
miruga27 0:7fb6877b5d7c 154 extern DECLSPEC SDL_Cursor *SDLCALL SDL_CreateColorCursor(SDL_Surface *surface,
miruga27 0:7fb6877b5d7c 155 int hot_x,
miruga27 0:7fb6877b5d7c 156 int hot_y);
miruga27 0:7fb6877b5d7c 157
miruga27 0:7fb6877b5d7c 158 /**
miruga27 0:7fb6877b5d7c 159 * \brief Create a system cursor.
miruga27 0:7fb6877b5d7c 160 *
miruga27 0:7fb6877b5d7c 161 * \sa SDL_FreeCursor()
miruga27 0:7fb6877b5d7c 162 */
miruga27 0:7fb6877b5d7c 163 extern DECLSPEC SDL_Cursor *SDLCALL SDL_CreateSystemCursor(SDL_SystemCursor id);
miruga27 0:7fb6877b5d7c 164
miruga27 0:7fb6877b5d7c 165 /**
miruga27 0:7fb6877b5d7c 166 * \brief Set the active cursor.
miruga27 0:7fb6877b5d7c 167 */
miruga27 0:7fb6877b5d7c 168 extern DECLSPEC void SDLCALL SDL_SetCursor(SDL_Cursor * cursor);
miruga27 0:7fb6877b5d7c 169
miruga27 0:7fb6877b5d7c 170 /**
miruga27 0:7fb6877b5d7c 171 * \brief Return the active cursor.
miruga27 0:7fb6877b5d7c 172 */
miruga27 0:7fb6877b5d7c 173 extern DECLSPEC SDL_Cursor *SDLCALL SDL_GetCursor(void);
miruga27 0:7fb6877b5d7c 174
miruga27 0:7fb6877b5d7c 175 /**
miruga27 0:7fb6877b5d7c 176 * \brief Return the default cursor.
miruga27 0:7fb6877b5d7c 177 */
miruga27 0:7fb6877b5d7c 178 extern DECLSPEC SDL_Cursor *SDLCALL SDL_GetDefaultCursor(void);
miruga27 0:7fb6877b5d7c 179
miruga27 0:7fb6877b5d7c 180 /**
miruga27 0:7fb6877b5d7c 181 * \brief Frees a cursor created with SDL_CreateCursor().
miruga27 0:7fb6877b5d7c 182 *
miruga27 0:7fb6877b5d7c 183 * \sa SDL_CreateCursor()
miruga27 0:7fb6877b5d7c 184 */
miruga27 0:7fb6877b5d7c 185 extern DECLSPEC void SDLCALL SDL_FreeCursor(SDL_Cursor * cursor);
miruga27 0:7fb6877b5d7c 186
miruga27 0:7fb6877b5d7c 187 /**
miruga27 0:7fb6877b5d7c 188 * \brief Toggle whether or not the cursor is shown.
miruga27 0:7fb6877b5d7c 189 *
miruga27 0:7fb6877b5d7c 190 * \param toggle 1 to show the cursor, 0 to hide it, -1 to query the current
miruga27 0:7fb6877b5d7c 191 * state.
miruga27 0:7fb6877b5d7c 192 *
miruga27 0:7fb6877b5d7c 193 * \return 1 if the cursor is shown, or 0 if the cursor is hidden.
miruga27 0:7fb6877b5d7c 194 */
miruga27 0:7fb6877b5d7c 195 extern DECLSPEC int SDLCALL SDL_ShowCursor(int toggle);
miruga27 0:7fb6877b5d7c 196
miruga27 0:7fb6877b5d7c 197 /**
miruga27 0:7fb6877b5d7c 198 * Used as a mask when testing buttons in buttonstate.
miruga27 0:7fb6877b5d7c 199 * - Button 1: Left mouse button
miruga27 0:7fb6877b5d7c 200 * - Button 2: Middle mouse button
miruga27 0:7fb6877b5d7c 201 * - Button 3: Right mouse button
miruga27 0:7fb6877b5d7c 202 */
miruga27 0:7fb6877b5d7c 203 #define SDL_BUTTON(X) (1 << ((X)-1))
miruga27 0:7fb6877b5d7c 204 #define SDL_BUTTON_LEFT 1
miruga27 0:7fb6877b5d7c 205 #define SDL_BUTTON_MIDDLE 2
miruga27 0:7fb6877b5d7c 206 #define SDL_BUTTON_RIGHT 3
miruga27 0:7fb6877b5d7c 207 #define SDL_BUTTON_X1 4
miruga27 0:7fb6877b5d7c 208 #define SDL_BUTTON_X2 5
miruga27 0:7fb6877b5d7c 209 #define SDL_BUTTON_LMASK SDL_BUTTON(SDL_BUTTON_LEFT)
miruga27 0:7fb6877b5d7c 210 #define SDL_BUTTON_MMASK SDL_BUTTON(SDL_BUTTON_MIDDLE)
miruga27 0:7fb6877b5d7c 211 #define SDL_BUTTON_RMASK SDL_BUTTON(SDL_BUTTON_RIGHT)
miruga27 0:7fb6877b5d7c 212 #define SDL_BUTTON_X1MASK SDL_BUTTON(SDL_BUTTON_X1)
miruga27 0:7fb6877b5d7c 213 #define SDL_BUTTON_X2MASK SDL_BUTTON(SDL_BUTTON_X2)
miruga27 0:7fb6877b5d7c 214
miruga27 0:7fb6877b5d7c 215
miruga27 0:7fb6877b5d7c 216 /* Ends C function definitions when using C++ */
miruga27 0:7fb6877b5d7c 217 #ifdef __cplusplus
miruga27 0:7fb6877b5d7c 218 }
miruga27 0:7fb6877b5d7c 219 #endif
miruga27 0:7fb6877b5d7c 220 #include "close_code.h"
miruga27 0:7fb6877b5d7c 221
miruga27 0:7fb6877b5d7c 222 #endif /* _SDL_mouse_h */
miruga27 0:7fb6877b5d7c 223
miruga27 0:7fb6877b5d7c 224 /* vi: set ts=4 sw=4 expandtab: */