slouken@0
|
1 |
/*
|
slouken@0
|
2 |
SDL - Simple DirectMedia Layer
|
slouken@1312
|
3 |
Copyright (C) 1997-2006 Sam Lantinga
|
slouken@0
|
4 |
|
slouken@0
|
5 |
This library is free software; you can redistribute it and/or
|
slouken@1312
|
6 |
modify it under the terms of the GNU Lesser General Public
|
slouken@0
|
7 |
License as published by the Free Software Foundation; either
|
slouken@1312
|
8 |
version 2.1 of the License, or (at your option) any later version.
|
slouken@0
|
9 |
|
slouken@0
|
10 |
This library is distributed in the hope that it will be useful,
|
slouken@0
|
11 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
slouken@0
|
12 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
slouken@1312
|
13 |
Lesser General Public License for more details.
|
slouken@0
|
14 |
|
slouken@1312
|
15 |
You should have received a copy of the GNU Lesser General Public
|
slouken@1312
|
16 |
License along with this library; if not, write to the Free Software
|
slouken@1312
|
17 |
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
slouken@0
|
18 |
|
slouken@0
|
19 |
Sam Lantinga
|
slouken@251
|
20 |
slouken@libsdl.org
|
slouken@0
|
21 |
*/
|
slouken@0
|
22 |
|
slouken@1895
|
23 |
/**
|
slouken@1895
|
24 |
* \file SDL_mouse.h
|
slouken@1895
|
25 |
*
|
slouken@1895
|
26 |
* Include file for SDL mouse event handling
|
slouken@1895
|
27 |
*/
|
slouken@0
|
28 |
|
slouken@0
|
29 |
#ifndef _SDL_mouse_h
|
slouken@0
|
30 |
#define _SDL_mouse_h
|
slouken@0
|
31 |
|
slouken@1356
|
32 |
#include "SDL_stdinc.h"
|
slouken@1358
|
33 |
#include "SDL_error.h"
|
slouken@0
|
34 |
#include "SDL_video.h"
|
slouken@0
|
35 |
|
slouken@0
|
36 |
#include "begin_code.h"
|
slouken@0
|
37 |
/* Set up for C function definitions, even when using C++ */
|
slouken@0
|
38 |
#ifdef __cplusplus
|
slouken@1895
|
39 |
/* *INDENT-OFF* */
|
slouken@0
|
40 |
extern "C" {
|
slouken@1895
|
41 |
/* *INDENT-ON* */
|
slouken@0
|
42 |
#endif
|
slouken@0
|
43 |
|
slouken@1895
|
44 |
typedef struct SDL_Cursor SDL_Cursor; /* Implementation dependent */
|
slouken@0
|
45 |
|
slouken@0
|
46 |
/* Function prototypes */
|
slouken@1895
|
47 |
|
slouken@1895
|
48 |
/**
|
slouken@1895
|
49 |
* \fn int SDL_GetNumMice(void)
|
slouken@1895
|
50 |
*
|
slouken@1895
|
51 |
* \brief Get the number of mouse input devices available.
|
slouken@1895
|
52 |
*
|
slouken@1895
|
53 |
* \sa SDL_SelectMouse()
|
slouken@1895
|
54 |
*/
|
slouken@1895
|
55 |
extern DECLSPEC int SDLCALL SDL_GetNumMice(void);
|
slouken@1895
|
56 |
|
slouken@1895
|
57 |
/**
|
slouken@1895
|
58 |
* \fn int SDL_SelectMouse(int index)
|
slouken@1895
|
59 |
*
|
slouken@1895
|
60 |
* \brief Set the index of the currently selected mouse.
|
slouken@1895
|
61 |
*
|
slouken@1895
|
62 |
* \return The index of the previously selected mouse.
|
slouken@1895
|
63 |
*
|
slouken@1895
|
64 |
* \note You can query the currently selected mouse by passing an index of -1.
|
slouken@1895
|
65 |
*
|
slouken@1895
|
66 |
* \sa SDL_GetNumMice()
|
slouken@1895
|
67 |
*/
|
slouken@1895
|
68 |
extern DECLSPEC int SDLCALL SDL_SelectMouse(int index);
|
slouken@1895
|
69 |
|
slouken@1895
|
70 |
/**
|
slouken@1895
|
71 |
* \fn SDL_WindowID SDL_GetMouseFocusWindow(void)
|
slouken@1895
|
72 |
*
|
slouken@1895
|
73 |
* \brief Get the window which currently has focus for the currently selected mouse.
|
slouken@1895
|
74 |
*/
|
slouken@1895
|
75 |
extern DECLSPEC SDL_WindowID SDLCALL SDL_GetMouseFocusWindow(void);
|
slouken@1895
|
76 |
|
slouken@1895
|
77 |
/**
|
slouken@1895
|
78 |
* \fn int SDL_SetRelativeMouseMode(SDL_bool enabled)
|
slouken@1895
|
79 |
*
|
slouken@1895
|
80 |
* \brief Set relative mouse mode for the currently selected mouse.
|
slouken@1895
|
81 |
*
|
slouken@1895
|
82 |
* \param enabled Whether or not to enable relative mode
|
slouken@1895
|
83 |
*
|
slouken@1895
|
84 |
* \return 0 on success, or -1 if relative mode is not supported.
|
slouken@1895
|
85 |
*
|
slouken@1895
|
86 |
* While the mouse is in relative mode, the cursor is hidden, and the
|
slouken@1895
|
87 |
* driver will try to report continuous motion in the current window.
|
slouken@1895
|
88 |
* Only relative motion events will be delivered, the mouse position
|
slouken@1895
|
89 |
* will not change.
|
slouken@1895
|
90 |
*
|
slouken@1895
|
91 |
* \note This function will flush any pending mouse motion.
|
slouken@1895
|
92 |
*
|
slouken@1895
|
93 |
* \sa SDL_GetRelativeMouseMode()
|
slouken@1895
|
94 |
*/
|
slouken@1895
|
95 |
extern DECLSPEC int SDLCALL SDL_SetRelativeMouseMode(SDL_bool enabled);
|
slouken@1895
|
96 |
|
slouken@1895
|
97 |
/**
|
slouken@1895
|
98 |
* \fn SDL_bool SDL_GetRelativeMouseMode()
|
slouken@1895
|
99 |
*
|
slouken@1895
|
100 |
* \brief Query whether relative mouse mode is enabled for the currently selected mouse.
|
slouken@1895
|
101 |
*
|
slouken@1895
|
102 |
* \sa SDL_SetRelativeMouseMode()
|
slouken@1895
|
103 |
*/
|
slouken@1895
|
104 |
extern DECLSPEC SDL_bool SDLCALL SDL_GetRelativeMouseMode();
|
slouken@1895
|
105 |
|
slouken@1895
|
106 |
/**
|
slouken@1895
|
107 |
* \fn Uint8 SDL_GetMouseState(int *x, int *y)
|
slouken@1895
|
108 |
*
|
slouken@1895
|
109 |
* \brief Retrieve the current state of the currently selected mouse.
|
slouken@1895
|
110 |
*
|
slouken@0
|
111 |
* The current button state is returned as a button bitmask, which can
|
slouken@0
|
112 |
* be tested using the SDL_BUTTON(X) macros, and x and y are set to the
|
slouken@1895
|
113 |
* mouse cursor position relative to the focus window for the currently
|
slouken@1895
|
114 |
* selected mouse. You can pass NULL for either x or y.
|
slouken@0
|
115 |
*/
|
slouken@337
|
116 |
extern DECLSPEC Uint8 SDLCALL SDL_GetMouseState(int *x, int *y);
|
slouken@0
|
117 |
|
slouken@1895
|
118 |
/**
|
slouken@1895
|
119 |
* \fn Uint8 SDL_GetRelativeMouseState(int *x, int *y)
|
slouken@1895
|
120 |
*
|
slouken@1895
|
121 |
* \brief Retrieve the state of the currently selected mouse.
|
slouken@1895
|
122 |
*
|
slouken@0
|
123 |
* The current button state is returned as a button bitmask, which can
|
slouken@0
|
124 |
* be tested using the SDL_BUTTON(X) macros, and x and y are set to the
|
slouken@0
|
125 |
* mouse deltas since the last call to SDL_GetRelativeMouseState().
|
slouken@0
|
126 |
*/
|
slouken@337
|
127 |
extern DECLSPEC Uint8 SDLCALL SDL_GetRelativeMouseState(int *x, int *y);
|
slouken@0
|
128 |
|
slouken@1895
|
129 |
/**
|
slouken@1895
|
130 |
* \fn void SDL_WarpMouseInWindow(SDL_WindowID windowID, int x, int y)
|
slouken@1895
|
131 |
*
|
slouken@1895
|
132 |
* \brief Moves the currently selected mouse to the given position within the window.
|
slouken@1895
|
133 |
*
|
slouken@1895
|
134 |
* \param windowID The window to move the mouse into, or 0 for the current mouse focus
|
slouken@1895
|
135 |
* \param x The x coordinate within the window
|
slouken@1895
|
136 |
* \param y The y coordinate within the window
|
slouken@1895
|
137 |
*
|
slouken@1895
|
138 |
* \note This function generates a mouse motion event
|
slouken@0
|
139 |
*/
|
slouken@1895
|
140 |
extern DECLSPEC void SDLCALL SDL_WarpMouseInWindow(SDL_WindowID windowID,
|
slouken@1895
|
141 |
int x, int y);
|
slouken@0
|
142 |
|
slouken@1895
|
143 |
/**
|
slouken@1895
|
144 |
* \fn SDL_Cursor *SDL_CreateCursor (const Uint8 * data, const Uint8 * mask, int w, int h, int hot_x, int hot_y)
|
slouken@1895
|
145 |
*
|
slouken@1895
|
146 |
* \brief Create a cursor for the currently selected mouse, using the
|
slouken@1895
|
147 |
* specified bitmap data and mask (in MSB format).
|
slouken@1895
|
148 |
*
|
slouken@0
|
149 |
* The cursor width must be a multiple of 8 bits.
|
slouken@0
|
150 |
*
|
slouken@0
|
151 |
* The cursor is created in black and white according to the following:
|
slouken@0
|
152 |
* data mask resulting pixel on screen
|
slouken@0
|
153 |
* 0 1 White
|
slouken@0
|
154 |
* 1 1 Black
|
slouken@0
|
155 |
* 0 0 Transparent
|
slouken@0
|
156 |
* 1 0 Inverted color if possible, black if not.
|
slouken@0
|
157 |
*
|
slouken@1895
|
158 |
* \sa SDL_FreeCursor()
|
slouken@0
|
159 |
*/
|
slouken@1895
|
160 |
extern DECLSPEC SDL_Cursor *SDLCALL SDL_CreateCursor(const Uint8 * data,
|
slouken@1895
|
161 |
const Uint8 * mask,
|
slouken@1895
|
162 |
int w, int h, int hot_x,
|
slouken@1895
|
163 |
int hot_y);
|
slouken@0
|
164 |
|
slouken@1895
|
165 |
/**
|
slouken@1895
|
166 |
* \fn void SDL_SetCursor(SDL_Cursor * cursor)
|
slouken@1895
|
167 |
*
|
slouken@1895
|
168 |
* \brief Set the active cursor for the currently selected mouse.
|
slouken@1895
|
169 |
*
|
slouken@1895
|
170 |
* \note The cursor must have been created for the selected mouse.
|
slouken@0
|
171 |
*/
|
slouken@1895
|
172 |
extern DECLSPEC void SDLCALL SDL_SetCursor(SDL_Cursor * cursor);
|
slouken@0
|
173 |
|
slouken@1895
|
174 |
/**
|
slouken@1895
|
175 |
* \fn SDL_Cursor *SDL_GetCursor(void)
|
slouken@1895
|
176 |
*
|
slouken@1895
|
177 |
* \brief Return the active cursor for the currently selected mouse.
|
slouken@0
|
178 |
*/
|
slouken@1895
|
179 |
extern DECLSPEC SDL_Cursor *SDLCALL SDL_GetCursor(void);
|
slouken@0
|
180 |
|
slouken@1895
|
181 |
/**
|
slouken@1895
|
182 |
* \fn void SDL_FreeCursor(SDL_Cursor * cursor)
|
slouken@1895
|
183 |
*
|
slouken@1895
|
184 |
* \brief Frees a cursor created with SDL_CreateCursor().
|
slouken@1895
|
185 |
*
|
slouken@1895
|
186 |
* \sa SDL_CreateCursor()
|
slouken@1895
|
187 |
*/
|
slouken@1895
|
188 |
extern DECLSPEC void SDLCALL SDL_FreeCursor(SDL_Cursor * cursor);
|
slouken@1895
|
189 |
|
slouken@1895
|
190 |
/**
|
slouken@1895
|
191 |
* \fn int SDL_ShowCursor(int toggle)
|
slouken@1895
|
192 |
*
|
slouken@1895
|
193 |
* \brief Toggle whether or not the cursor is shown for the currently selected mouse.
|
slouken@1895
|
194 |
*
|
slouken@1895
|
195 |
* \param toggle 1 to show the cursor, 0 to hide it, -1 to query the current state.
|
slouken@1895
|
196 |
*
|
slouken@1895
|
197 |
* \return 1 if the cursor is shown, or 0 if the cursor is hidden.
|
slouken@0
|
198 |
*/
|
slouken@337
|
199 |
extern DECLSPEC int SDLCALL SDL_ShowCursor(int toggle);
|
slouken@0
|
200 |
|
slouken@0
|
201 |
/* Used as a mask when testing buttons in buttonstate
|
slouken@0
|
202 |
Button 1: Left mouse button
|
slouken@0
|
203 |
Button 2: Middle mouse button
|
slouken@0
|
204 |
Button 3: Right mouse button
|
slouken@0
|
205 |
*/
|
slouken@1330
|
206 |
#define SDL_BUTTON(X) (1 << ((X)-1))
|
slouken@0
|
207 |
#define SDL_BUTTON_LEFT 1
|
slouken@0
|
208 |
#define SDL_BUTTON_MIDDLE 2
|
slouken@0
|
209 |
#define SDL_BUTTON_RIGHT 3
|
slouken@0
|
210 |
#define SDL_BUTTON_LMASK SDL_BUTTON(SDL_BUTTON_LEFT)
|
slouken@0
|
211 |
#define SDL_BUTTON_MMASK SDL_BUTTON(SDL_BUTTON_MIDDLE)
|
slouken@0
|
212 |
#define SDL_BUTTON_RMASK SDL_BUTTON(SDL_BUTTON_RIGHT)
|
slouken@0
|
213 |
|
slouken@0
|
214 |
|
slouken@0
|
215 |
/* Ends C function definitions when using C++ */
|
slouken@0
|
216 |
#ifdef __cplusplus
|
slouken@1895
|
217 |
/* *INDENT-OFF* */
|
slouken@0
|
218 |
}
|
slouken@1895
|
219 |
/* *INDENT-ON* */
|
slouken@0
|
220 |
#endif
|
slouken@0
|
221 |
#include "close_code.h"
|
slouken@0
|
222 |
|
slouken@0
|
223 |
#endif /* _SDL_mouse_h */
|
slouken@1895
|
224 |
|
slouken@1895
|
225 |
/* vi: set ts=4 sw=4 expandtab: */
|