SDL standard library

Dependents:   H261_encoder

Committer:
miruga27
Date:
Wed Sep 07 18:46:53 2016 +0000
Revision:
0:dda4f4550403
7/09/2016;

Who changed what in which revision?

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