SDL  2.0
SDL_mouse_c.h
Go to the documentation of this file.
1 /*
2  Simple DirectMedia Layer
3  Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
4 
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.
8 
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:
12 
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.
20 */
21 #include "../SDL_internal.h"
22 
23 #ifndef SDL_mouse_c_h_
24 #define SDL_mouse_c_h_
25 
26 #include "SDL_mouse.h"
27 
29 
30 struct SDL_Cursor
31 {
32  struct SDL_Cursor *next;
33  void *driverdata;
34 };
35 
36 typedef struct
37 {
38  int last_x, last_y;
42 
43 typedef struct
44 {
45  /* Create a cursor from a surface */
46  SDL_Cursor *(*CreateCursor) (SDL_Surface * surface, int hot_x, int hot_y);
47 
48  /* Create a system cursor */
49  SDL_Cursor *(*CreateSystemCursor) (SDL_SystemCursor id);
50 
51  /* Show the specified cursor, or hide if cursor is NULL */
52  int (*ShowCursor) (SDL_Cursor * cursor);
53 
54  /* This is called when a mouse motion event occurs */
55  void (*MoveCursor) (SDL_Cursor * cursor);
56 
57  /* Free a window manager cursor */
58  void (*FreeCursor) (SDL_Cursor * cursor);
59 
60  /* Warp the mouse to (x,y) within a window */
61  void (*WarpMouse) (SDL_Window * window, int x, int y);
62 
63  /* Warp the mouse to (x,y) in screen space */
64  int (*WarpMouseGlobal) (int x, int y);
65 
66  /* Set relative mode */
67  int (*SetRelativeMouseMode) (SDL_bool enabled);
68 
69  /* Set mouse capture */
70  int (*CaptureMouse) (SDL_Window * window);
71 
72  /* Get absolute mouse coordinates. (x) and (y) are never NULL and set to zero before call. */
73  Uint32 (*GetGlobalMouseState) (int *x, int *y);
74 
75  /* Data common to all mice */
78  int x;
79  int y;
80  int xdelta;
81  int ydelta;
82  int last_x, last_y; /* the last reported x and y coordinates */
97  SDL_bool was_touch_mouse_events; /* Was a touch-mouse event pending? */
98 
99  /* Data for double-click tracking */
102 
107 
108  /* Driver-dependent data. */
109  void *driverdata;
110 } SDL_Mouse;
111 
112 
113 /* Initialize the mouse subsystem */
114 extern int SDL_MouseInit(void);
115 
116 /* Get the mouse state structure */
117 SDL_Mouse *SDL_GetMouse(void);
118 
119 /* Set the default mouse cursor */
120 extern void SDL_SetDefaultCursor(SDL_Cursor * cursor);
121 
122 /* Set the mouse focus window */
123 extern void SDL_SetMouseFocus(SDL_Window * window);
124 
125 /* Send a mouse motion event */
126 extern int SDL_SendMouseMotion(SDL_Window * window, SDL_MouseID mouseID, int relative, int x, int y);
127 
128 /* Send a mouse button event */
130 
131 /* Send a mouse button event with a click count */
132 extern int SDL_SendMouseButtonClicks(SDL_Window * window, SDL_MouseID mouseID, Uint8 state, Uint8 button, int clicks);
133 
134 /* Send a mouse wheel event */
135 extern int SDL_SendMouseWheel(SDL_Window * window, SDL_MouseID mouseID, float x, float y, SDL_MouseWheelDirection direction);
136 
137 /* Shutdown the mouse subsystem */
138 extern void SDL_MouseQuit(void);
139 
140 #endif /* SDL_mouse_c_h_ */
141 
142 /* vi: set ts=4 sw=4 expandtab: */
Uint32
uint32_t Uint32
Definition: SDL_stdinc.h:203
SDL_Mouse::buttonstate
Uint32 buttonstate
Definition: SDL_mouse_c.h:85
SDL_MouseQuit
void SDL_MouseQuit(void)
Definition: SDL_mouse.c:654
SDL_Surface
A collection of pixels used in software blitting.
Definition: SDL_surface.h:70
SDL_Cursor
Definition: SDL_mouse_c.h:30
SDL_mouse.h
SDL_Mouse::scale_accum_y
float scale_accum_y
Definition: SDL_mouse_c.h:92
SDL_Mouse::cursors
SDL_Cursor * cursors
Definition: SDL_mouse_c.h:103
surface
EGLSurface surface
Definition: eglext.h:248
SDL_Mouse::scale_accum_x
float scale_accum_x
Definition: SDL_mouse_c.h:91
SDL_Mouse::touch_mouse_events
SDL_bool touch_mouse_events
Definition: SDL_mouse_c.h:95
SDL_MouseClickState
Definition: SDL_mouse_c.h:36
SDL_Mouse::double_click_radius
int double_click_radius
Definition: SDL_mouse_c.h:94
SDL_Mouse::normal_speed_scale
float normal_speed_scale
Definition: SDL_mouse_c.h:89
SDL_Mouse::accumulated_wheel_x
float accumulated_wheel_x
Definition: SDL_mouse_c.h:83
SDL_Mouse::y
int y
Definition: SDL_mouse_c.h:79
SDL_Mouse::driverdata
void * driverdata
Definition: SDL_mouse_c.h:109
SDL_Cursor::driverdata
void * driverdata
Definition: SDL_mouse_c.h:33
SDL_MouseID
Uint32 SDL_MouseID
Definition: SDL_mouse_c.h:28
SDL_Window
The type used to identify a window.
Definition: SDL_sysvideo.h:74
SDL_SendMouseButtonClicks
int SDL_SendMouseButtonClicks(SDL_Window *window, SDL_MouseID mouseID, Uint8 state, Uint8 button, int clicks)
Definition: SDL_mouse.c:587
SDL_Mouse::mouse_touch_events
SDL_bool mouse_touch_events
Definition: SDL_mouse_c.h:96
SDL_SendMouseMotion
int SDL_SendMouseMotion(SDL_Window *window, SDL_MouseID mouseID, int relative, int x, int y)
Definition: SDL_mouse.c:293
SDL_Mouse::was_touch_mouse_events
SDL_bool was_touch_mouse_events
Definition: SDL_mouse_c.h:97
SDL_Mouse::ydelta
int ydelta
Definition: SDL_mouse_c.h:81
SDL_Mouse::relative_mode
SDL_bool relative_mode
Definition: SDL_mouse_c.h:87
x
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
window
EGLSurface EGLNativeWindowType * window
Definition: eglext.h:1025
SDL_MouseClickState::click_count
Uint8 click_count
Definition: SDL_mouse_c.h:40
SDL_Mouse::relative_speed_scale
float relative_speed_scale
Definition: SDL_mouse_c.h:90
SDL_MouseClickState::last_timestamp
Uint32 last_timestamp
Definition: SDL_mouse_c.h:39
SDL_Mouse::def_cursor
SDL_Cursor * def_cursor
Definition: SDL_mouse_c.h:104
SDL_SendMouseButton
int SDL_SendMouseButton(SDL_Window *window, SDL_MouseID mouseID, Uint8 state, Uint8 button)
Definition: SDL_mouse.c:594
SDL_Cursor::next
struct SDL_Cursor * next
Definition: SDL_mouse_c.h:32
SDL_SystemCursor
SDL_SystemCursor
Cursor types for SDL_CreateSystemCursor().
Definition: SDL_mouse.h:46
SDL_SetMouseFocus
void SDL_SetMouseFocus(SDL_Window *window)
Definition: SDL_mouse.c:203
SDL_Mouse
Definition: SDL_mouse_c.h:43
SDL_GetMouse
SDL_Mouse * SDL_GetMouse(void)
Definition: SDL_mouse.c:170
SDL_Mouse::relative_mode_warp
SDL_bool relative_mode_warp
Definition: SDL_mouse_c.h:88
hot_x
int uint32_t uint32_t uint32_t uint32_t uint32_t int drmModeModeInfoPtr mode int uint32_t uint32_t uint32_t uint32_t int32_t hot_x
Definition: SDL_kmsdrmsym.h:57
SDL_Mouse::focus
SDL_Window * focus
Definition: SDL_mouse_c.h:77
SDL_Mouse::accumulated_wheel_y
float accumulated_wheel_y
Definition: SDL_mouse_c.h:84
cursor
SDL_Cursor * cursor
Definition: testwm2.c:40
y
GLint GLint GLint GLint GLint GLint y
Definition: SDL_opengl.h:1574
SDL_Mouse::num_clickstates
int num_clickstates
Definition: SDL_mouse_c.h:100
id
GLuint id
Definition: SDL_opengl_glext.h:531
SDL_Mouse::xdelta
int xdelta
Definition: SDL_mouse_c.h:80
SDL_Mouse::last_y
int last_y
Definition: SDL_mouse_c.h:82
SDL_Mouse::x
int x
Definition: SDL_mouse_c.h:78
SDL_Mouse::clickstate
SDL_MouseClickState * clickstate
Definition: SDL_mouse_c.h:101
SDL_Mouse::has_position
SDL_bool has_position
Definition: SDL_mouse_c.h:86
SDL_SendMouseWheel
int SDL_SendMouseWheel(SDL_Window *window, SDL_MouseID mouseID, float x, float y, SDL_MouseWheelDirection direction)
Definition: SDL_mouse.c:600
SDL_Mouse::mouseID
SDL_MouseID mouseID
Definition: SDL_mouse_c.h:76
SDL_MouseInit
int SDL_MouseInit(void)
Definition: SDL_mouse.c:127
enabled
GLenum GLenum GLsizei const GLuint GLboolean enabled
Definition: SDL_opengl_glext.h:2482
SDL_MouseWheelDirection
SDL_MouseWheelDirection
Scroll direction types for the Scroll event.
Definition: SDL_mouse.h:66
void
const SDL_PRINTF_FORMAT_STRING char int const SDL_PRINTF_FORMAT_STRING char int const SDL_PRINTF_FORMAT_STRING char int const SDL_PRINTF_FORMAT_STRING char const char const SDL_SCANF_FORMAT_STRING char return SDL_ThreadFunction const char void return Uint32 return Uint32 void
Definition: SDL_dynapi_procs.h:89
SDL_MouseClickState::last_y
int last_y
Definition: SDL_mouse_c.h:38
state
struct xkb_state * state
Definition: SDL_waylandsym.h:114
SDL_Mouse::double_click_time
Uint32 double_click_time
Definition: SDL_mouse_c.h:93
button
SDL_Texture * button
Definition: testgamecontroller.c:67
SDL_Mouse::cur_cursor
SDL_Cursor * cur_cursor
Definition: SDL_mouse_c.h:105
SDL_bool
SDL_bool
Definition: SDL_stdinc.h:161
SDL_Mouse::cursor_shown
SDL_bool cursor_shown
Definition: SDL_mouse_c.h:106
SDL_SetDefaultCursor
void SDL_SetDefaultCursor(SDL_Cursor *cursor)
Definition: SDL_mouse.c:159
Uint8
uint8_t Uint8
Definition: SDL_stdinc.h:179