Atlas - SDL_mouse_c.h

Home / ext / SDL / src / events Lines: 1 | Size: 7771 bytes [Download] [Show on GitHub] [Search similar files] [Raw] [Raw (proxy)]
[FILE BEGIN]
1/* 2 Simple DirectMedia Layer 3 Copyright (C) 1997-2026 Sam Lantinga <[email protected]> 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 32typedef struct SDL_CursorData SDL_CursorData; 33 34struct SDL_Cursor; 35 36typedef struct 37{ 38 Uint64 last_update; 39 int num_frames; 40 int current_frame; 41 struct SDL_Cursor **frames; 42 Uint32 *durations; 43} SDL_CursorAnimation; 44 45struct SDL_Cursor 46{ 47 SDL_CursorAnimation *animation; 48 49 SDL_CursorData *internal; 50 51 struct SDL_Cursor *next; 52}; 53 54typedef struct 55{ 56 Uint64 last_timestamp; 57 double click_motion_x; 58 double click_motion_y; 59 Uint8 click_count; 60} SDL_MouseClickState; 61 62typedef struct 63{ 64 SDL_MouseID mouseID; 65 Uint32 buttonstate; 66 67 // Data for double-click tracking 68 int num_clickstates; 69 SDL_MouseClickState *clickstate; 70} SDL_MouseInputSource; 71 72typedef struct 73{ 74 // Create a cursor from a surface 75 SDL_Cursor *(*CreateCursor)(SDL_Surface *surface, int hot_x, int hot_y); 76 77 // Create an animated cursor from a sequence of surfaces 78 SDL_Cursor *(*CreateAnimatedCursor)(SDL_CursorFrameInfo *frames, int frame_count, int hot_x, int hot_y); 79 80 // Create a system cursor 81 SDL_Cursor *(*CreateSystemCursor)(SDL_SystemCursor id); 82 83 // Show the specified cursor, or hide if cursor is NULL 84 bool (*ShowCursor)(SDL_Cursor *cursor); 85 86 // This is called when a mouse motion event occurs 87 bool (*MoveCursor)(SDL_Cursor *cursor); 88 89 // Free a window manager cursor 90 void (*FreeCursor)(SDL_Cursor *cursor); 91 92 // Warp the mouse to (x,y) within a window 93 bool (*WarpMouse)(SDL_Window *window, float x, float y); 94 95 // Warp the mouse to (x,y) in screen space 96 bool (*WarpMouseGlobal)(float x, float y); 97 98 // Set relative mode 99 bool (*SetRelativeMouseMode)(bool enabled); 100 101 // Set mouse capture 102 bool (*CaptureMouse)(SDL_Window *window); 103 104 // Get absolute mouse coordinates. (x) and (y) are never NULL and set to zero before call. 105 SDL_MouseButtonFlags (*GetGlobalMouseState)(float *x, float *y); 106 107 // Platform-specific system mouse transform applied in relative mode 108 SDL_MouseMotionTransformCallback ApplySystemScale; 109 void *system_scale_data; 110 111 // User-defined mouse input transform applied in relative mode 112 SDL_MouseMotionTransformCallback InputTransform; 113 void *input_transform_data; 114 115 // integer mode data 116 Uint8 integer_mode_flags; // 1 to enable mouse quantization, 2 to enable wheel quantization 117 float integer_mode_residual_motion_x; 118 float integer_mode_residual_motion_y; 119 120 // Data common to all mice 121 SDL_Window *focus; 122 float x; 123 float y; 124 float x_accu; 125 float y_accu; 126 float last_x, last_y; // the last reported x and y coordinates 127 float residual_scroll_x; 128 float residual_scroll_y; 129 double click_motion_x; 130 double click_motion_y; 131 bool has_position; 132 bool relative_mode; 133 bool relative_mode_warp_motion; 134 bool relative_mode_hide_cursor; 135 bool relative_mode_center; 136 bool warp_emulation_hint; 137 bool warp_emulation_active; 138 bool warp_emulation_prohibited; 139 Uint64 last_center_warp_time_ns; 140 bool enable_normal_speed_scale; 141 float normal_speed_scale; 142 bool enable_relative_speed_scale; 143 float relative_speed_scale; 144 bool enable_relative_system_scale; 145 Uint32 double_click_time; 146 int double_click_radius; 147 bool touch_mouse_events; 148 bool mouse_touch_events; 149 bool pen_mouse_events; 150 bool pen_touch_events; 151 bool was_touch_mouse_events; // Was a touch-mouse event pending? 152 bool added_mouse_touch_device; // did we SDL_AddTouch() a virtual touch device for the mouse? 153 bool added_pen_touch_device; // did we SDL_AddTouch() a virtual touch device for pens? 154#ifdef SDL_PLATFORM_VITA 155 Uint8 vita_touch_mouse_device; 156#endif 157 bool auto_capture; 158 bool capture_desired; 159 SDL_Window *capture_window; 160 161 // Data for input source state 162 int num_sources; 163 SDL_MouseInputSource *sources; 164 165 SDL_Cursor *cursors; 166 SDL_Cursor *def_cursor; 167 SDL_Cursor *cur_cursor; 168 bool cursor_visible; 169 170 // Driver-dependent data. 171 void *internal; 172} SDL_Mouse; 173 174// Initialize the mouse subsystem, called before the main video driver is initialized 175extern bool SDL_PreInitMouse(void); 176 177// Finish initializing the mouse subsystem, called after the main video driver was initialized 178extern void SDL_PostInitMouse(void); 179 180// Return whether a device is actually a mouse 181extern bool SDL_IsMouse(Uint16 vendor, Uint16 product); 182 183// A mouse has been added to the system 184extern void SDL_AddMouse(SDL_MouseID mouseID, const char *name); 185 186// A mouse has been removed from the system 187extern void SDL_RemoveMouse(SDL_MouseID mouseID); 188 189// Get the mouse state structure 190extern SDL_Mouse *SDL_GetMouse(void); 191 192// Set the default mouse cursor 193extern void SDL_RedrawCursor(void); 194 195// Set the default mouse cursor 196extern void SDL_SetDefaultCursor(SDL_Cursor *cursor); 197 198// Get the preferred default system cursor 199extern SDL_SystemCursor SDL_GetDefaultSystemCursor(void); 200 201// Update the current cursor animation if needed 202extern void SDL_UpdateCursorAnimation(void); 203 204// Set the mouse focus window 205extern void SDL_SetMouseFocus(SDL_Window *window); 206 207// Update the mouse capture window 208extern bool SDL_UpdateMouseCapture(bool force_release); 209 210// Send a mouse motion event 211extern void SDL_SendMouseMotion(Uint64 timestamp, SDL_Window *window, SDL_MouseID mouseID, bool relative, float x, float y); 212 213// Send a mouse button event 214extern void SDL_SendMouseButton(Uint64 timestamp, SDL_Window *window, SDL_MouseID mouseID, Uint8 button, bool down); 215 216// Send a mouse button event with a click count 217extern void SDL_SendMouseButtonClicks(Uint64 timestamp, SDL_Window *window, SDL_MouseID mouseID, Uint8 button, bool down, int clicks); 218 219// Send a mouse wheel event 220extern void SDL_SendMouseWheel(Uint64 timestamp, SDL_Window *window, SDL_MouseID mouseID, float x, float y, SDL_MouseWheelDirection direction); 221 222// Warp the mouse within the window, potentially overriding relative mode 223extern void SDL_PerformWarpMouseInWindow(SDL_Window *window, float x, float y, bool ignore_relative_mode); 224 225// Relative mouse mode 226extern bool SDL_SetRelativeMouseMode(bool enabled); 227extern bool SDL_GetRelativeMouseMode(void); 228extern bool SDL_UpdateRelativeMouseMode(void); 229extern void SDL_DisableMouseWarpEmulation(void); 230 231// TODO RECONNECT: Set mouse state to "zero" 232#if 0 233extern void SDL_ResetMouse(void); 234#endif // 0 235 236// Check if mouse position is within window or captured by window 237extern bool SDL_MousePositionInWindow(SDL_Window *window, float x, float y); 238 239// Shutdown the mouse subsystem 240extern void SDL_QuitMouse(void); 241 242#endif // SDL_mouse_c_h_ 243
[FILE END]
(C) 2025 0x4248 (C) 2025 4248 Media and 4248 Systems, All part of 0x4248 See LICENCE files for more information. Not all files are by 0x4248 always check Licencing.