21 #include "../SDL_internal.h" 31 #include "../video/SDL_sysvideo.h" 92 printf(
"Resetting mouse\n");
107 if (mouse->
focus == window) {
117 if (mouse->
focus && !window) {
162 #ifdef SUPPORT_DRAG_OUTSIDE_WINDOW 163 if (!inWindow && !buttonstate) {
167 if (window == mouse->
focus) {
169 printf(
"Mouse left window, synthesizing move & focus lost event\n");
177 if (window != mouse->
focus) {
179 printf(
"Mouse entered window, synthesizing focus gain & move event\n");
190 if (window && !relative) {
209 int center_x = 0, center_y = 0;
213 if (x == center_x && y == center_y) {
224 x = (mouse->
last_x + xrel);
225 y = (mouse->
last_y + yrel);
232 if (!xrel && !yrel) {
234 printf(
"Mouse event didn't change state - dropped!\n");
251 int x_max = 0, y_max = 0;
258 if (mouse->
x > x_max) {
265 if (mouse->
y > y_max) {
287 event.motion.windowID = mouse->
focus ? mouse->
focus->
id : 0;
288 event.motion.which = mouseID;
290 event.motion.x = mouse->
x;
291 event.motion.y = mouse->
y;
292 event.motion.xrel = xrel;
293 event.motion.yrel = yrel;
310 int i,
count = button + 1;
387 event.button.windowID = mouse->
focus ? mouse->
focus->
id : 0;
388 event.button.which = mouseID;
389 event.button.state =
state;
390 event.button.button =
button;
391 event.button.clicks = click_count;
392 event.button.x = mouse->
x;
393 event.button.y = mouse->
y;
424 event.wheel.windowID = mouse->
focus ? mouse->
focus->
id : 0;
425 event.wheel.which = mouseID;
428 event.wheel.direction = (
Uint32)direction;
511 SDL_assert(0 &&
"This should really be implemented for every target.");
523 if (window ==
NULL) {
524 window = mouse->
focus;
527 if (window ==
NULL) {
580 if (enabled && focusWindow) {
641 if (isCaptured == enabled) {
664 int w,
int h,
int hot_x,
int hot_y)
670 Uint8 datab = 0, maskb = 0;
671 const Uint32 black = 0xFF000000;
672 const Uint32 white = 0xFFFFFFFF;
673 const Uint32 transparent = 0x00000000;
687 for (y = 0; y <
h; ++
y) {
689 for (x = 0; x <
w; ++
x) {
695 *pixel++ = (datab & 0x80) ? black : white;
697 *pixel++ = (datab & 0x80) ? black : transparent;
729 if ((hot_x < 0) || (hot_y < 0) ||
730 (hot_x >= surface->
w) || (hot_y >= surface->
h)) {
731 SDL_SetError(
"Cursor hot spot doesn't lie within cursor");
761 SDL_SetError(
"CreateSystemCursor is not currently supported");
788 for (found = mouse->
cursors; found; found = found->
next) {
789 if (found == cursor) {
794 SDL_SetError(
"Cursor not associated with the current mouse");
858 prev = curr, curr = curr->
next) {
859 if (curr == cursor) {
void SDL_SetDoubleClickTime(Uint32 interval)
void SDL_UpdateWindowGrab(SDL_Window *window)
#define SDL_ConvertSurfaceFormat
SDL_Mouse * SDL_GetMouse(void)
SDL_Cursor * SDL_GetCursor(void)
Return the active cursor.
int(* ShowCursor)(SDL_Cursor *cursor)
uint32_t Uint32
An unsigned 32-bit integer type.
static int SDL_PrivateSendMouseMotion(SDL_Window *window, SDL_MouseID mouseID, int relative, int x, int y)
SDL_Cursor * SDL_CreateColorCursor(SDL_Surface *surface, int hot_x, int hot_y)
Create a color cursor.
GLint GLint GLint GLint GLint x
SDL_bool relative_mode_warp
GLuint GLuint GLsizei count
int(* SetRelativeMouseMode)(SDL_bool enabled)
Uint32 SDL_GetMouseState(int *x, int *y)
Retrieve the current state of the mouse.
SDL_MouseClickState * clickstate
A collection of pixels used in software blitting.
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
void SDL_SetCursor(SDL_Cursor *cursor)
Set the active cursor.
Uint32(* GetGlobalMouseState)(int *x, int *y)
int SDL_WarpMouseGlobal(int x, int y)
Moves the mouse to the given position in global screen space.
int SDL_ShowCursor(int toggle)
Toggle whether or not the cursor is shown.
int SDL_SendWindowEvent(SDL_Window *window, Uint8 windowevent, int data1, int data2)
void SDL_SetMouseFocus(SDL_Window *window)
#define SDL_GetKeyboardFocus
SDL_Cursor * SDL_CreateCursor(const Uint8 *data, const Uint8 *mask, int w, int h, int hot_x, int hot_y)
Create a cursor, using the specified bitmap data and mask (in MSB format).
static int SDL_double_click_radius
int SDL_CaptureMouse(SDL_bool enabled)
Capture the mouse, to track input outside an SDL window.
void SDL_WarpMouseInWindow(SDL_Window *window, int x, int y)
Moves the mouse to the given position within the window.
int(* CaptureMouse)(SDL_Window *window)
#define SDL_GetWindowSize
static SDL_Mouse SDL_mouse
SDL_Cursor *(* CreateCursor)(SDL_Surface *surface, int hot_x, int hot_y)
SDL_Cursor * SDL_GetDefaultCursor(void)
Return the default cursor.
GLuint GLuint GLsizei GLenum type
SDL_bool SDL_GetRelativeMouseMode()
Query whether relative mouse mode is enabled.
#define SDL_GetEventState(type)
GLint GLint GLint GLint GLint GLint y
int SDL_SendMouseMotion(SDL_Window *window, SDL_MouseID mouseID, int relative, int x, int y)
Uint32 SDL_GetTicks(void)
Get the number of milliseconds since the SDL library initialization.
SDL_Cursor * SDL_CreateSystemCursor(SDL_SystemCursor id)
Create a system cursor.
uint8_t Uint8
An unsigned 8-bit integer type.
void SDL_ResetMouse(void)
SDL_SystemCursor
Cursor types for SDL_CreateSystemCursor.
static SDL_MouseClickState * GetMouseClickState(SDL_Mouse *mouse, Uint8 button)
void SDL_SetDefaultCursor(SDL_Cursor *cursor)
static SDL_bool SDL_UpdateMouseFocus(SDL_Window *window, int x, int y, Uint32 buttonstate)
int(* WarpMouseGlobal)(int x, int y)
GLenum GLenum GLsizei const GLuint GLboolean enabled
void(* FreeCursor)(SDL_Cursor *cursor)
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
#define SDL_assert(condition)
#define SDL_CreateRGBSurface
int SDL_SetRelativeMouseMode(SDL_bool enabled)
Set relative mouse mode.
The type used to identify a window.
void(* WarpMouse)(SDL_Window *window, int x, int y)
int SDL_SendMouseWheel(SDL_Window *window, SDL_MouseID mouseID, int x, int y, SDL_MouseWheelDirection direction)
GLubyte GLubyte GLubyte GLubyte w
SDL_Window * SDL_GetMouseFocus(void)
Get the window which currently has mouse focus.
void SDL_FreeCursor(SDL_Cursor *cursor)
Frees a cursor created with SDL_CreateCursor().
static Uint32 SDL_double_click_time
#define SDL_TICKS_PASSED(A, B)
Compare SDL ticks values, and return true if A has passed B.
void(* MoveCursor)(SDL_Cursor *cursor)
SDL_Cursor *(* CreateSystemCursor)(SDL_SystemCursor id)
SDL_MouseWheelDirection
Scroll direction types for the Scroll event.
int SDL_SendMouseButton(SDL_Window *window, SDL_MouseID mouseID, Uint8 state, Uint8 button)
#define SDL_Unsupported()
#define SDL_HINT_MOUSE_RELATIVE_MODE_WARP
A variable controlling whether relative mouse mode is implemented using mouse warping.
GLfloat GLfloat GLfloat GLfloat h
static SDL_bool ShouldUseRelativeModeWarp(SDL_Mouse *mouse)
Uint32 SDL_GetRelativeMouseState(int *x, int *y)
Retrieve the relative state of the mouse.
Uint32 SDL_GetGlobalMouseState(int *x, int *y)
Get the current state of the mouse, in relation to the desktop.