2
Simple DirectMedia Layer
3
Copyright (C) 1997-2011 Sam Lantinga <slouken@libsdl.org>
5
This software is provided 'as-is', without any express or implied
6
warranty. In no event will the authors be held liable for any damages
7
arising from the use of this software.
9
Permission is granted to anyone to use this software for any purpose,
10
including commercial applications, and to alter it and redistribute it
11
freely, subject to the following restrictions:
13
1. The origin of this software must not be misrepresented; you must not
14
claim that you wrote the original software. If you use this software
15
in a product, an acknowledgment in the product documentation would be
16
appreciated but is not required.
17
2. Altered source versions must be plainly marked as such, and must not be
18
misrepresented as being the original software.
19
3. This notice may not be removed or altered from any source distribution.
25
* Include file for SDL mouse event handling.
27
* Please note that this ONLY discusses "mice" with the notion of the
28
* desktop GUI. You (usually) have one system cursor, and the OS hides
29
* the hardware details from you. If you plug in 10 mice, all ten move that
30
* one cursor. For many applications and games, this is perfect, and this
31
* API has served hundreds of SDL programs well since its birth.
33
* It's not the whole picture, though. If you want more lowlevel control,
34
* SDL offers a different API, that gives you visibility into each input
35
* device, multi-touch interfaces, etc.
37
* Those two APIs are incompatible, and you usually should not use both
38
* at the same time. But for legacy purposes, this API refers to a "mouse"
39
* when it actually means the system pointer and not a physical mouse.
41
* The other API is in SDL_input.h
47
#include "SDL_stdinc.h"
48
#include "SDL_error.h"
49
#include "SDL_video.h"
51
#include "begin_code.h"
52
/* Set up for C function definitions, even when using C++ */
59
typedef struct SDL_Cursor SDL_Cursor; /* Implementation dependent */
62
/* Function prototypes */
65
* \brief Get the window which currently has mouse focus.
67
extern DECLSPEC SDL_Window * SDLCALL SDL_GetMouseFocus(void);
70
* \brief Retrieve the current state of the mouse.
72
* The current button state is returned as a button bitmask, which can
73
* be tested using the SDL_BUTTON(X) macros, and x and y are set to the
74
* mouse cursor position relative to the focus window for the currently
75
* selected mouse. You can pass NULL for either x or y.
77
extern DECLSPEC Uint8 SDLCALL SDL_GetMouseState(int *x, int *y);
80
* \brief Retrieve the relative state of the mouse.
82
* The current button state is returned as a button bitmask, which can
83
* be tested using the SDL_BUTTON(X) macros, and x and y are set to the
84
* mouse deltas since the last call to SDL_GetRelativeMouseState().
86
extern DECLSPEC Uint8 SDLCALL SDL_GetRelativeMouseState(int *x, int *y);
89
* \brief Moves the mouse to the given position within the window.
91
* \param window The window to move the mouse into, or NULL for the current mouse focus
92
* \param x The x coordinate within the window
93
* \param y The y coordinate within the window
95
* \note This function generates a mouse motion event
97
extern DECLSPEC void SDLCALL SDL_WarpMouseInWindow(SDL_Window * window,
101
* \brief Set relative mouse mode.
103
* \param enabled Whether or not to enable relative mode
105
* \return 0 on success, or -1 if relative mode is not supported.
107
* While the mouse is in relative mode, the cursor is hidden, and the
108
* driver will try to report continuous motion in the current window.
109
* Only relative motion events will be delivered, the mouse position
112
* \note This function will flush any pending mouse motion.
114
* \sa SDL_GetRelativeMouseMode()
116
extern DECLSPEC int SDLCALL SDL_SetRelativeMouseMode(SDL_bool enabled);
119
* \brief Query whether relative mouse mode is enabled.
121
* \sa SDL_SetRelativeMouseMode()
123
extern DECLSPEC SDL_bool SDLCALL SDL_GetRelativeMouseMode(void);
126
* \brief Create a cursor, using the specified bitmap data and
127
* mask (in MSB format).
129
* The cursor width must be a multiple of 8 bits.
131
* The cursor is created in black and white according to the following:
133
* <tr><td> data </td><td> mask </td><td> resulting pixel on screen </td></tr>
134
* <tr><td> 0 </td><td> 1 </td><td> White </td></tr>
135
* <tr><td> 1 </td><td> 1 </td><td> Black </td></tr>
136
* <tr><td> 0 </td><td> 0 </td><td> Transparent </td></tr>
137
* <tr><td> 1 </td><td> 0 </td><td> Inverted color if possible, black
141
* \sa SDL_FreeCursor()
143
extern DECLSPEC SDL_Cursor *SDLCALL SDL_CreateCursor(const Uint8 * data,
145
int w, int h, int hot_x,
149
* \brief Create a color cursor.
151
* \sa SDL_FreeCursor()
153
extern DECLSPEC SDL_Cursor *SDLCALL SDL_CreateColorCursor(SDL_Surface *surface,
158
* \brief Set the active cursor.
160
extern DECLSPEC void SDLCALL SDL_SetCursor(SDL_Cursor * cursor);
163
* \brief Return the active cursor.
165
extern DECLSPEC SDL_Cursor *SDLCALL SDL_GetCursor(void);
168
* \brief Frees a cursor created with SDL_CreateCursor().
170
* \sa SDL_CreateCursor()
172
extern DECLSPEC void SDLCALL SDL_FreeCursor(SDL_Cursor * cursor);
175
* \brief Toggle whether or not the cursor is shown.
177
* \param toggle 1 to show the cursor, 0 to hide it, -1 to query the current
180
* \return 1 if the cursor is shown, or 0 if the cursor is hidden.
182
extern DECLSPEC int SDLCALL SDL_ShowCursor(int toggle);
185
* Used as a mask when testing buttons in buttonstate.
186
* - Button 1: Left mouse button
187
* - Button 2: Middle mouse button
188
* - Button 3: Right mouse button
190
#define SDL_BUTTON(X) (1 << ((X)-1))
191
#define SDL_BUTTON_LEFT 1
192
#define SDL_BUTTON_MIDDLE 2
193
#define SDL_BUTTON_RIGHT 3
194
#define SDL_BUTTON_X1 4
195
#define SDL_BUTTON_X2 5
196
#define SDL_BUTTON_LMASK SDL_BUTTON(SDL_BUTTON_LEFT)
197
#define SDL_BUTTON_MMASK SDL_BUTTON(SDL_BUTTON_MIDDLE)
198
#define SDL_BUTTON_RMASK SDL_BUTTON(SDL_BUTTON_RIGHT)
199
#define SDL_BUTTON_X1MASK SDL_BUTTON(SDL_BUTTON_X1)
200
#define SDL_BUTTON_X2MASK SDL_BUTTON(SDL_BUTTON_X2)
203
/* Ends C function definitions when using C++ */
209
#include "close_code.h"
211
#endif /* _SDL_mouse_h */
213
/* vi: set ts=4 sw=4 expandtab: */