diff options
Diffstat (limited to 'contrib/SDL-3.2.8/src/events/SDL_mouse_c.h')
| -rw-r--r-- | contrib/SDL-3.2.8/src/events/SDL_mouse_c.h | 208 |
1 files changed, 208 insertions, 0 deletions
diff --git a/contrib/SDL-3.2.8/src/events/SDL_mouse_c.h b/contrib/SDL-3.2.8/src/events/SDL_mouse_c.h new file mode 100644 index 0000000..43cc520 --- /dev/null +++ b/contrib/SDL-3.2.8/src/events/SDL_mouse_c.h | |||
| @@ -0,0 +1,208 @@ | |||
| 1 | /* | ||
| 2 | Simple DirectMedia Layer | ||
| 3 | Copyright (C) 1997-2025 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 | // Mouse events not associated with a specific input device | ||
| 27 | #define SDL_GLOBAL_MOUSE_ID 0 | ||
| 28 | |||
| 29 | // The default mouse input device, for platforms that don't have multiple mice | ||
| 30 | #define SDL_DEFAULT_MOUSE_ID 1 | ||
| 31 | |||
| 32 | typedef struct SDL_CursorData SDL_CursorData; | ||
| 33 | |||
| 34 | struct SDL_Cursor | ||
| 35 | { | ||
| 36 | struct SDL_Cursor *next; | ||
| 37 | SDL_CursorData *internal; | ||
| 38 | }; | ||
| 39 | |||
| 40 | typedef struct | ||
| 41 | { | ||
| 42 | Uint64 last_timestamp; | ||
| 43 | double click_motion_x; | ||
| 44 | double click_motion_y; | ||
| 45 | Uint8 click_count; | ||
| 46 | } SDL_MouseClickState; | ||
| 47 | |||
| 48 | typedef struct | ||
| 49 | { | ||
| 50 | SDL_MouseID mouseID; | ||
| 51 | Uint32 buttonstate; | ||
| 52 | |||
| 53 | // Data for double-click tracking | ||
| 54 | int num_clickstates; | ||
| 55 | SDL_MouseClickState *clickstate; | ||
| 56 | } SDL_MouseInputSource; | ||
| 57 | |||
| 58 | typedef struct | ||
| 59 | { | ||
| 60 | // Create a cursor from a surface | ||
| 61 | SDL_Cursor *(*CreateCursor)(SDL_Surface *surface, int hot_x, int hot_y); | ||
| 62 | |||
| 63 | // Create a system cursor | ||
| 64 | SDL_Cursor *(*CreateSystemCursor)(SDL_SystemCursor id); | ||
| 65 | |||
| 66 | // Show the specified cursor, or hide if cursor is NULL | ||
| 67 | bool (*ShowCursor)(SDL_Cursor *cursor); | ||
| 68 | |||
| 69 | // This is called when a mouse motion event occurs | ||
| 70 | bool (*MoveCursor)(SDL_Cursor *cursor); | ||
| 71 | |||
| 72 | // Free a window manager cursor | ||
| 73 | void (*FreeCursor)(SDL_Cursor *cursor); | ||
| 74 | |||
| 75 | // Warp the mouse to (x,y) within a window | ||
| 76 | bool (*WarpMouse)(SDL_Window *window, float x, float y); | ||
| 77 | |||
| 78 | // Warp the mouse to (x,y) in screen space | ||
| 79 | bool (*WarpMouseGlobal)(float x, float y); | ||
| 80 | |||
| 81 | // Set relative mode | ||
| 82 | bool (*SetRelativeMouseMode)(bool enabled); | ||
| 83 | |||
| 84 | // Set mouse capture | ||
| 85 | bool (*CaptureMouse)(SDL_Window *window); | ||
| 86 | |||
| 87 | // Get absolute mouse coordinates. (x) and (y) are never NULL and set to zero before call. | ||
| 88 | SDL_MouseButtonFlags (*GetGlobalMouseState)(float *x, float *y); | ||
| 89 | |||
| 90 | // Platform-specific system mouse transform | ||
| 91 | void (*ApplySystemScale)(void *internal, Uint64 timestamp, SDL_Window *window, SDL_MouseID mouseID, float *x, float *y); | ||
| 92 | void *system_scale_data; | ||
| 93 | |||
| 94 | // Data common to all mice | ||
| 95 | SDL_Window *focus; | ||
| 96 | float x; | ||
| 97 | float y; | ||
| 98 | float x_accu; | ||
| 99 | float y_accu; | ||
| 100 | float last_x, last_y; // the last reported x and y coordinates | ||
| 101 | double click_motion_x; | ||
| 102 | double click_motion_y; | ||
| 103 | bool has_position; | ||
| 104 | bool relative_mode; | ||
| 105 | bool relative_mode_warp_motion; | ||
| 106 | bool relative_mode_cursor_visible; | ||
| 107 | bool relative_mode_center; | ||
| 108 | bool warp_emulation_hint; | ||
| 109 | bool warp_emulation_active; | ||
| 110 | bool warp_emulation_prohibited; | ||
| 111 | Uint64 last_center_warp_time_ns; | ||
| 112 | bool enable_normal_speed_scale; | ||
| 113 | float normal_speed_scale; | ||
| 114 | bool enable_relative_speed_scale; | ||
| 115 | float relative_speed_scale; | ||
| 116 | bool enable_relative_system_scale; | ||
| 117 | Uint32 double_click_time; | ||
| 118 | int double_click_radius; | ||
| 119 | bool touch_mouse_events; | ||
| 120 | bool mouse_touch_events; | ||
| 121 | bool pen_mouse_events; | ||
| 122 | bool pen_touch_events; | ||
| 123 | bool was_touch_mouse_events; // Was a touch-mouse event pending? | ||
| 124 | bool added_mouse_touch_device; // did we SDL_AddTouch() a virtual touch device for the mouse? | ||
| 125 | bool added_pen_touch_device; // did we SDL_AddTouch() a virtual touch device for pens? | ||
| 126 | #ifdef SDL_PLATFORM_VITA | ||
| 127 | Uint8 vita_touch_mouse_device; | ||
| 128 | #endif | ||
| 129 | bool auto_capture; | ||
| 130 | bool capture_desired; | ||
| 131 | SDL_Window *capture_window; | ||
| 132 | |||
| 133 | // Data for input source state | ||
| 134 | int num_sources; | ||
| 135 | SDL_MouseInputSource *sources; | ||
| 136 | |||
| 137 | SDL_Cursor *cursors; | ||
| 138 | SDL_Cursor *def_cursor; | ||
| 139 | SDL_Cursor *cur_cursor; | ||
| 140 | bool cursor_shown; | ||
| 141 | |||
| 142 | // Driver-dependent data. | ||
| 143 | void *internal; | ||
| 144 | } SDL_Mouse; | ||
| 145 | |||
| 146 | // Initialize the mouse subsystem, called before the main video driver is initialized | ||
| 147 | extern bool SDL_PreInitMouse(void); | ||
| 148 | |||
| 149 | // Finish initializing the mouse subsystem, called after the main video driver was initialized | ||
| 150 | extern void SDL_PostInitMouse(void); | ||
| 151 | |||
| 152 | // Return whether a device is actually a mouse | ||
| 153 | extern bool SDL_IsMouse(Uint16 vendor, Uint16 product); | ||
| 154 | |||
| 155 | // A mouse has been added to the system | ||
| 156 | extern void SDL_AddMouse(SDL_MouseID mouseID, const char *name, bool send_event); | ||
| 157 | |||
| 158 | // A mouse has been removed from the system | ||
| 159 | extern void SDL_RemoveMouse(SDL_MouseID mouseID, bool send_event); | ||
| 160 | |||
| 161 | // Get the mouse state structure | ||
| 162 | extern SDL_Mouse *SDL_GetMouse(void); | ||
| 163 | |||
| 164 | // Set the default mouse cursor | ||
| 165 | extern void SDL_SetDefaultCursor(SDL_Cursor *cursor); | ||
| 166 | |||
| 167 | // Get the preferred default system cursor | ||
| 168 | extern SDL_SystemCursor SDL_GetDefaultSystemCursor(void); | ||
| 169 | |||
| 170 | // Set the mouse focus window | ||
| 171 | extern void SDL_SetMouseFocus(SDL_Window *window); | ||
| 172 | |||
| 173 | // Update the mouse capture window | ||
| 174 | extern bool SDL_UpdateMouseCapture(bool force_release); | ||
| 175 | |||
| 176 | // Send a mouse motion event | ||
| 177 | extern void SDL_SendMouseMotion(Uint64 timestamp, SDL_Window *window, SDL_MouseID mouseID, bool relative, float x, float y); | ||
| 178 | |||
| 179 | // Send a mouse button event | ||
| 180 | extern void SDL_SendMouseButton(Uint64 timestamp, SDL_Window *window, SDL_MouseID mouseID, Uint8 button, bool down); | ||
| 181 | |||
| 182 | // Send a mouse button event with a click count | ||
| 183 | extern void SDL_SendMouseButtonClicks(Uint64 timestamp, SDL_Window *window, SDL_MouseID mouseID, Uint8 button, bool down, int clicks); | ||
| 184 | |||
| 185 | // Send a mouse wheel event | ||
| 186 | extern void SDL_SendMouseWheel(Uint64 timestamp, SDL_Window *window, SDL_MouseID mouseID, float x, float y, SDL_MouseWheelDirection direction); | ||
| 187 | |||
| 188 | // Warp the mouse within the window, potentially overriding relative mode | ||
| 189 | extern void SDL_PerformWarpMouseInWindow(SDL_Window *window, float x, float y, bool ignore_relative_mode); | ||
| 190 | |||
| 191 | // Relative mouse mode | ||
| 192 | extern bool SDL_SetRelativeMouseMode(bool enabled); | ||
| 193 | extern bool SDL_GetRelativeMouseMode(void); | ||
| 194 | extern void SDL_UpdateRelativeMouseMode(void); | ||
| 195 | extern void SDL_DisableMouseWarpEmulation(void); | ||
| 196 | |||
| 197 | // TODO RECONNECT: Set mouse state to "zero" | ||
| 198 | #if 0 | ||
| 199 | extern void SDL_ResetMouse(void); | ||
| 200 | #endif // 0 | ||
| 201 | |||
| 202 | // Check if mouse position is within window or captured by window | ||
| 203 | extern bool SDL_MousePositionInWindow(SDL_Window *window, float x, float y); | ||
| 204 | |||
| 205 | // Shutdown the mouse subsystem | ||
| 206 | extern void SDL_QuitMouse(void); | ||
| 207 | |||
| 208 | #endif // SDL_mouse_c_h_ | ||
