Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Latest commit

 

History

History
213 lines (186 loc) · 6.95 KB

SDL_mouse.h

File metadata and controls

213 lines (186 loc) · 6.95 KB
 
Apr 26, 2001
Apr 26, 2001
1
/*
Apr 8, 2011
Apr 8, 2011
2
3
Simple DirectMedia Layer
Copyright (C) 1997-2011 Sam Lantinga <slouken@libsdl.org>
Apr 26, 2001
Apr 26, 2001
4
Apr 8, 2011
Apr 8, 2011
5
6
7
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Apr 26, 2001
Apr 26, 2001
8
Apr 8, 2011
Apr 8, 2011
9
10
11
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
Apr 26, 2001
Apr 26, 2001
12
Apr 8, 2011
Apr 8, 2011
13
14
15
16
17
18
19
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
Apr 26, 2001
Apr 26, 2001
20
21
*/
Jul 10, 2006
Jul 10, 2006
22
/**
Oct 19, 2009
Oct 19, 2009
23
24
25
* \file SDL_mouse.h
*
* Include file for SDL mouse event handling.
May 10, 2010
May 10, 2010
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
*
* Please note that this ONLY discusses "mice" with the notion of the
* desktop GUI. You (usually) have one system cursor, and the OS hides
* the hardware details from you. If you plug in 10 mice, all ten move that
* one cursor. For many applications and games, this is perfect, and this
* API has served hundreds of SDL programs well since its birth.
*
* It's not the whole picture, though. If you want more lowlevel control,
* SDL offers a different API, that gives you visibility into each input
* device, multi-touch interfaces, etc.
*
* Those two APIs are incompatible, and you usually should not use both
* at the same time. But for legacy purposes, this API refers to a "mouse"
* when it actually means the system pointer and not a physical mouse.
*
* The other API is in SDL_input.h
Jul 10, 2006
Jul 10, 2006
42
*/
Apr 26, 2001
Apr 26, 2001
43
44
45
46
#ifndef _SDL_mouse_h
#define _SDL_mouse_h
Feb 10, 2006
Feb 10, 2006
47
#include "SDL_stdinc.h"
Feb 10, 2006
Feb 10, 2006
48
#include "SDL_error.h"
Apr 26, 2001
Apr 26, 2001
49
50
51
52
53
#include "SDL_video.h"
#include "begin_code.h"
/* Set up for C function definitions, even when using C++ */
#ifdef __cplusplus
Jul 10, 2006
Jul 10, 2006
54
/* *INDENT-OFF* */
Apr 26, 2001
Apr 26, 2001
55
extern "C" {
Jul 10, 2006
Jul 10, 2006
56
/* *INDENT-ON* */
Apr 26, 2001
Apr 26, 2001
57
58
#endif
Jul 10, 2006
Jul 10, 2006
59
typedef struct SDL_Cursor SDL_Cursor; /* Implementation dependent */
Apr 26, 2001
Apr 26, 2001
60
May 10, 2010
May 10, 2010
61
Apr 26, 2001
Apr 26, 2001
62
/* Function prototypes */
Jul 10, 2006
Jul 10, 2006
63
64
/**
May 10, 2010
May 10, 2010
65
* \brief Get the window which currently has mouse focus.
Jul 10, 2006
Jul 10, 2006
66
*/
May 10, 2010
May 10, 2010
67
extern DECLSPEC SDL_Window * SDLCALL SDL_GetMouseFocus(void);
Jul 10, 2006
Jul 10, 2006
68
Aug 25, 2008
Aug 25, 2008
69
/**
May 10, 2010
May 10, 2010
70
* \brief Retrieve the current state of the mouse.
Oct 19, 2009
Oct 19, 2009
71
*
May 10, 2010
May 10, 2010
72
73
74
75
* The current button state is returned as a button bitmask, which can
* be tested using the SDL_BUTTON(X) macros, and x and y are set to the
* mouse cursor position relative to the focus window for the currently
* selected mouse. You can pass NULL for either x or y.
Aug 25, 2008
Aug 25, 2008
76
*/
May 10, 2010
May 10, 2010
77
extern DECLSPEC Uint8 SDLCALL SDL_GetMouseState(int *x, int *y);
Aug 25, 2008
Aug 25, 2008
78
Jul 10, 2006
Jul 10, 2006
79
/**
May 10, 2010
May 10, 2010
80
81
82
83
84
* \brief Retrieve the relative state of the mouse.
*
* The current button state is returned as a button bitmask, which can
* be tested using the SDL_BUTTON(X) macros, and x and y are set to the
* mouse deltas since the last call to SDL_GetRelativeMouseState().
Jul 10, 2006
Jul 10, 2006
85
*/
May 10, 2010
May 10, 2010
86
extern DECLSPEC Uint8 SDLCALL SDL_GetRelativeMouseState(int *x, int *y);
Jul 10, 2006
Jul 10, 2006
87
88
/**
May 10, 2010
May 10, 2010
89
90
91
92
93
94
95
* \brief Moves the mouse to the given position within the window.
*
* \param window The window to move the mouse into, or NULL for the current mouse focus
* \param x The x coordinate within the window
* \param y The y coordinate within the window
*
* \note This function generates a mouse motion event
Jul 10, 2006
Jul 10, 2006
96
*/
May 10, 2010
May 10, 2010
97
98
extern DECLSPEC void SDLCALL SDL_WarpMouseInWindow(SDL_Window * window,
int x, int y);
Jul 10, 2006
Jul 10, 2006
99
100
/**
May 10, 2010
May 10, 2010
101
* \brief Set relative mouse mode.
Oct 19, 2009
Oct 19, 2009
102
103
*
* \param enabled Whether or not to enable relative mode
May 10, 2010
May 10, 2010
104
*
Oct 19, 2009
Oct 19, 2009
105
106
107
108
109
110
111
112
113
114
* \return 0 on success, or -1 if relative mode is not supported.
*
* While the mouse is in relative mode, the cursor is hidden, and the
* driver will try to report continuous motion in the current window.
* Only relative motion events will be delivered, the mouse position
* will not change.
*
* \note This function will flush any pending mouse motion.
*
* \sa SDL_GetRelativeMouseMode()
Jul 10, 2006
Jul 10, 2006
115
*/
May 10, 2010
May 10, 2010
116
extern DECLSPEC int SDLCALL SDL_SetRelativeMouseMode(SDL_bool enabled);
Jul 10, 2006
Jul 10, 2006
117
118
/**
May 10, 2010
May 10, 2010
119
* \brief Query whether relative mouse mode is enabled.
Oct 19, 2009
Oct 19, 2009
120
121
*
* \sa SDL_SetRelativeMouseMode()
Jul 10, 2006
Jul 10, 2006
122
*/
May 10, 2010
May 10, 2010
123
extern DECLSPEC SDL_bool SDLCALL SDL_GetRelativeMouseMode(void);
Apr 26, 2001
Apr 26, 2001
124
Jul 10, 2006
Jul 10, 2006
125
/**
May 10, 2010
May 10, 2010
126
127
* \brief Create a cursor, using the specified bitmap data and
* mask (in MSB format).
Oct 19, 2009
Oct 19, 2009
128
129
130
131
132
133
134
135
136
137
*
* The cursor width must be a multiple of 8 bits.
*
* The cursor is created in black and white according to the following:
* <table>
* <tr><td> data </td><td> mask </td><td> resulting pixel on screen </td></tr>
* <tr><td> 0 </td><td> 1 </td><td> White </td></tr>
* <tr><td> 1 </td><td> 1 </td><td> Black </td></tr>
* <tr><td> 0 </td><td> 0 </td><td> Transparent </td></tr>
* <tr><td> 1 </td><td> 0 </td><td> Inverted color if possible, black
May 10, 2010
May 10, 2010
138
* if not. </td></tr>
Oct 19, 2009
Oct 19, 2009
139
140
141
* </table>
*
* \sa SDL_FreeCursor()
Apr 26, 2001
Apr 26, 2001
142
*/
Jul 10, 2006
Jul 10, 2006
143
144
145
146
extern DECLSPEC SDL_Cursor *SDLCALL SDL_CreateCursor(const Uint8 * data,
const Uint8 * mask,
int w, int h, int hot_x,
int hot_y);
Apr 26, 2001
Apr 26, 2001
147
Mar 11, 2011
Mar 11, 2011
148
149
150
151
152
153
154
155
156
/**
* \brief Create a color cursor.
*
* \sa SDL_FreeCursor()
*/
extern DECLSPEC SDL_Cursor *SDLCALL SDL_CreateColorCursor(SDL_Surface *surface,
int hot_x,
int hot_y);
Jul 10, 2006
Jul 10, 2006
157
/**
May 10, 2010
May 10, 2010
158
* \brief Set the active cursor.
Apr 26, 2001
Apr 26, 2001
159
*/
Jul 10, 2006
Jul 10, 2006
160
extern DECLSPEC void SDLCALL SDL_SetCursor(SDL_Cursor * cursor);
Apr 26, 2001
Apr 26, 2001
161
Jul 10, 2006
Jul 10, 2006
162
/**
May 10, 2010
May 10, 2010
163
* \brief Return the active cursor.
Apr 26, 2001
Apr 26, 2001
164
*/
Jul 10, 2006
Jul 10, 2006
165
extern DECLSPEC SDL_Cursor *SDLCALL SDL_GetCursor(void);
Apr 26, 2001
Apr 26, 2001
166
Jul 10, 2006
Jul 10, 2006
167
/**
Oct 19, 2009
Oct 19, 2009
168
169
170
* \brief Frees a cursor created with SDL_CreateCursor().
*
* \sa SDL_CreateCursor()
Apr 26, 2001
Apr 26, 2001
171
*/
Jul 10, 2006
Jul 10, 2006
172
extern DECLSPEC void SDLCALL SDL_FreeCursor(SDL_Cursor * cursor);
Apr 26, 2001
Apr 26, 2001
173
Jul 10, 2006
Jul 10, 2006
174
/**
May 10, 2010
May 10, 2010
175
* \brief Toggle whether or not the cursor is shown.
Oct 19, 2009
Oct 19, 2009
176
177
178
179
180
*
* \param toggle 1 to show the cursor, 0 to hide it, -1 to query the current
* state.
*
* \return 1 if the cursor is shown, or 0 if the cursor is hidden.
Apr 26, 2001
Apr 26, 2001
181
*/
Apr 11, 2002
Apr 11, 2002
182
extern DECLSPEC int SDLCALL SDL_ShowCursor(int toggle);
Apr 26, 2001
Apr 26, 2001
183
Oct 19, 2009
Oct 19, 2009
184
185
186
187
188
189
/**
* Used as a mask when testing buttons in buttonstate.
* - Button 1: Left mouse button
* - Button 2: Middle mouse button
* - Button 3: Right mouse button
*/
Feb 6, 2006
Feb 6, 2006
190
#define SDL_BUTTON(X) (1 << ((X)-1))
Apr 26, 2001
Apr 26, 2001
191
192
193
#define SDL_BUTTON_LEFT 1
#define SDL_BUTTON_MIDDLE 2
#define SDL_BUTTON_RIGHT 3
Dec 29, 2007
Dec 29, 2007
194
195
#define SDL_BUTTON_X1 4
#define SDL_BUTTON_X2 5
Apr 26, 2001
Apr 26, 2001
196
197
198
#define SDL_BUTTON_LMASK SDL_BUTTON(SDL_BUTTON_LEFT)
#define SDL_BUTTON_MMASK SDL_BUTTON(SDL_BUTTON_MIDDLE)
#define SDL_BUTTON_RMASK SDL_BUTTON(SDL_BUTTON_RIGHT)
Dec 29, 2007
Dec 29, 2007
199
200
#define SDL_BUTTON_X1MASK SDL_BUTTON(SDL_BUTTON_X1)
#define SDL_BUTTON_X2MASK SDL_BUTTON(SDL_BUTTON_X2)
Apr 26, 2001
Apr 26, 2001
201
202
203
204
/* Ends C function definitions when using C++ */
#ifdef __cplusplus
Jul 10, 2006
Jul 10, 2006
205
/* *INDENT-OFF* */
Apr 26, 2001
Apr 26, 2001
206
}
Jul 10, 2006
Jul 10, 2006
207
/* *INDENT-ON* */
Apr 26, 2001
Apr 26, 2001
208
209
210
211
#endif
#include "close_code.h"
#endif /* _SDL_mouse_h */
Jul 10, 2006
Jul 10, 2006
212
213
/* vi: set ts=4 sw=4 expandtab: */