Path: blob/master/thirdparty/sdl/events/SDL_mouse_c.h
9902 views
/*1Simple DirectMedia Layer2Copyright (C) 1997-2025 Sam Lantinga <[email protected]>34This software is provided 'as-is', without any express or implied5warranty. In no event will the authors be held liable for any damages6arising from the use of this software.78Permission is granted to anyone to use this software for any purpose,9including commercial applications, and to alter it and redistribute it10freely, subject to the following restrictions:11121. The origin of this software must not be misrepresented; you must not13claim that you wrote the original software. If you use this software14in a product, an acknowledgment in the product documentation would be15appreciated but is not required.162. Altered source versions must be plainly marked as such, and must not be17misrepresented as being the original software.183. This notice may not be removed or altered from any source distribution.19*/20#include "SDL_internal.h"2122#ifndef SDL_mouse_c_h_23#define SDL_mouse_c_h_2425// Mouse events not associated with a specific input device26#define SDL_GLOBAL_MOUSE_ID 02728// The default mouse input device, for platforms that don't have multiple mice29#define SDL_DEFAULT_MOUSE_ID 13031typedef struct SDL_CursorData SDL_CursorData;3233struct SDL_Cursor34{35struct SDL_Cursor *next;36SDL_CursorData *internal;37};3839typedef struct40{41Uint64 last_timestamp;42double click_motion_x;43double click_motion_y;44Uint8 click_count;45} SDL_MouseClickState;4647typedef struct48{49SDL_MouseID mouseID;50Uint32 buttonstate;5152// Data for double-click tracking53int num_clickstates;54SDL_MouseClickState *clickstate;55} SDL_MouseInputSource;5657typedef struct58{59// Create a cursor from a surface60SDL_Cursor *(*CreateCursor)(SDL_Surface *surface, int hot_x, int hot_y);6162// Create a system cursor63SDL_Cursor *(*CreateSystemCursor)(SDL_SystemCursor id);6465// Show the specified cursor, or hide if cursor is NULL66bool (*ShowCursor)(SDL_Cursor *cursor);6768// This is called when a mouse motion event occurs69bool (*MoveCursor)(SDL_Cursor *cursor);7071// Free a window manager cursor72void (*FreeCursor)(SDL_Cursor *cursor);7374// Warp the mouse to (x,y) within a window75bool (*WarpMouse)(SDL_Window *window, float x, float y);7677// Warp the mouse to (x,y) in screen space78bool (*WarpMouseGlobal)(float x, float y);7980// Set relative mode81bool (*SetRelativeMouseMode)(bool enabled);8283// Set mouse capture84bool (*CaptureMouse)(SDL_Window *window);8586// Get absolute mouse coordinates. (x) and (y) are never NULL and set to zero before call.87SDL_MouseButtonFlags (*GetGlobalMouseState)(float *x, float *y);8889// Platform-specific system mouse transform90void (*ApplySystemScale)(void *internal, Uint64 timestamp, SDL_Window *window, SDL_MouseID mouseID, float *x, float *y);91void *system_scale_data;9293// integer mode data94Uint8 integer_mode_flags; // 1 to enable mouse quantization, 2 to enable wheel quantization95float integer_mode_residual_motion_x;96float integer_mode_residual_motion_y;9798// Data common to all mice99SDL_Window *focus;100float x;101float y;102float x_accu;103float y_accu;104float last_x, last_y; // the last reported x and y coordinates105float residual_scroll_x;106float residual_scroll_y;107double click_motion_x;108double click_motion_y;109bool has_position;110bool relative_mode;111bool relative_mode_warp_motion;112bool relative_mode_cursor_visible;113bool relative_mode_center;114bool warp_emulation_hint;115bool warp_emulation_active;116bool warp_emulation_prohibited;117Uint64 last_center_warp_time_ns;118bool enable_normal_speed_scale;119float normal_speed_scale;120bool enable_relative_speed_scale;121float relative_speed_scale;122bool enable_relative_system_scale;123Uint32 double_click_time;124int double_click_radius;125bool touch_mouse_events;126bool mouse_touch_events;127bool pen_mouse_events;128bool pen_touch_events;129bool was_touch_mouse_events; // Was a touch-mouse event pending?130bool added_mouse_touch_device; // did we SDL_AddTouch() a virtual touch device for the mouse?131bool added_pen_touch_device; // did we SDL_AddTouch() a virtual touch device for pens?132#ifdef SDL_PLATFORM_VITA133Uint8 vita_touch_mouse_device;134#endif135bool auto_capture;136bool capture_desired;137SDL_Window *capture_window;138139// Data for input source state140int num_sources;141SDL_MouseInputSource *sources;142143SDL_Cursor *cursors;144SDL_Cursor *def_cursor;145SDL_Cursor *cur_cursor;146bool cursor_shown;147148// Driver-dependent data.149void *internal;150} SDL_Mouse;151152// Initialize the mouse subsystem, called before the main video driver is initialized153extern bool SDL_PreInitMouse(void);154155// Finish initializing the mouse subsystem, called after the main video driver was initialized156extern void SDL_PostInitMouse(void);157158// Return whether a device is actually a mouse159extern bool SDL_IsMouse(Uint16 vendor, Uint16 product);160161// A mouse has been added to the system162extern void SDL_AddMouse(SDL_MouseID mouseID, const char *name, bool send_event);163164// A mouse has been removed from the system165extern void SDL_RemoveMouse(SDL_MouseID mouseID, bool send_event);166167// Get the mouse state structure168extern SDL_Mouse *SDL_GetMouse(void);169170// Set the default mouse cursor171extern void SDL_SetDefaultCursor(SDL_Cursor *cursor);172173// Get the preferred default system cursor174extern SDL_SystemCursor SDL_GetDefaultSystemCursor(void);175176// Set the mouse focus window177extern void SDL_SetMouseFocus(SDL_Window *window);178179// Update the mouse capture window180extern bool SDL_UpdateMouseCapture(bool force_release);181182// Send a mouse motion event183extern void SDL_SendMouseMotion(Uint64 timestamp, SDL_Window *window, SDL_MouseID mouseID, bool relative, float x, float y);184185// Send a mouse button event186extern void SDL_SendMouseButton(Uint64 timestamp, SDL_Window *window, SDL_MouseID mouseID, Uint8 button, bool down);187188// Send a mouse button event with a click count189extern void SDL_SendMouseButtonClicks(Uint64 timestamp, SDL_Window *window, SDL_MouseID mouseID, Uint8 button, bool down, int clicks);190191// Send a mouse wheel event192extern void SDL_SendMouseWheel(Uint64 timestamp, SDL_Window *window, SDL_MouseID mouseID, float x, float y, SDL_MouseWheelDirection direction);193194// Warp the mouse within the window, potentially overriding relative mode195extern void SDL_PerformWarpMouseInWindow(SDL_Window *window, float x, float y, bool ignore_relative_mode);196197// Relative mouse mode198extern bool SDL_SetRelativeMouseMode(bool enabled);199extern bool SDL_GetRelativeMouseMode(void);200extern void SDL_UpdateRelativeMouseMode(void);201extern void SDL_DisableMouseWarpEmulation(void);202203// TODO RECONNECT: Set mouse state to "zero"204#if 0205extern void SDL_ResetMouse(void);206#endif // 0207208// Check if mouse position is within window or captured by window209extern bool SDL_MousePositionInWindow(SDL_Window *window, float x, float y);210211// Shutdown the mouse subsystem212extern void SDL_QuitMouse(void);213214#endif // SDL_mouse_c_h_215216217