4#include <SDL3/SDL_mouse.h>
5#include "SDL3pp_stdinc.h"
6#include "SDL3pp_video.h"
74 constexpr explicit operator bool()
const {
return !!
value; }
91 SDL_SYSTEM_CURSOR_DEFAULT;
94 SDL_SYSTEM_CURSOR_TEXT;
100 SDL_SYSTEM_CURSOR_CROSSHAIR;
106 SDL_SYSTEM_CURSOR_NWSE_RESIZE;
110 SDL_SYSTEM_CURSOR_NESW_RESIZE;
114 SDL_SYSTEM_CURSOR_EW_RESIZE;
117 SDL_SYSTEM_CURSOR_NS_RESIZE;
124 SDL_SYSTEM_CURSOR_NOT_ALLOWED;
136 SDL_SYSTEM_CURSOR_N_RESIZE;
139 SDL_SYSTEM_CURSOR_NE_RESIZE;
142 SDL_SYSTEM_CURSOR_E_RESIZE;
145 SDL_SYSTEM_CURSOR_SE_RESIZE;
149 SDL_SYSTEM_CURSOR_S_RESIZE;
152 SDL_SYSTEM_CURSOR_SW_RESIZE;
156 SDL_SYSTEM_CURSOR_W_RESIZE;
187 constexpr Cursor(std::nullptr_t =
nullptr) noexcept
200 : m_resource(resource)
266 CheckError(SDL_CreateCursor(data, mask, size.x, size.y, hot.x, hot.y)))
302 : m_resource(
CheckError(SDL_CreateColorCursor(surface, hot.x, hot.y)))
320 : m_resource(
CheckError(SDL_CreateSystemCursor(id)))
330 std::swap(m_resource, other.m_resource);
346 m_resource =
nullptr;
354 constexpr explicit operator bool() const noexcept {
return !!m_resource; }
357 constexpr operator CursorParam() const noexcept {
return {m_resource}; }
439 SDL_MOUSEWHEEL_NORMAL;
442 SDL_MOUSEWHEEL_FLIPPED;
444#if SDL_VERSION_ATLEAST(3, 4, 0)
501 return SDL_BUTTON_MASK(button);
504#if SDL_VERSION_ATLEAST(3, 4, 0)
636 return SDL_GetMouseNameForID(instance_id);
683 return SDL_GetMouseState(x, y);
723 return SDL_GetGlobalMouseState(x, y);
761 return SDL_GetRelativeMouseState(x, y);
766 SDL_WarpMouseInWindow(m_resource, p.x, p.y);
794#if SDL_VERSION_ATLEAST(3, 4, 0)
814 CheckError(SDL_SetRelativeMouseTransform(callback, userdata));
840 CheckError(SDL_SetWindowRelativeMouseMode(m_resource, enabled));
845 return SDL_GetWindowRelativeMouseMode(m_resource);
944 return Cursor(data, mask, size, hot);
979 return Cursor(surface, hot);
982#if SDL_VERSION_ATLEAST(3, 4, 0)
1034 SDL_CreateAnimatedCursor(frames, frame_count, hot_x, hot_y));
The structure used to identify an SDL cursor.
Definition: SDL3pp_mouse.h:182
constexpr Cursor & operator=(Cursor &&other) noexcept
Assignment operator.
Definition: SDL3pp_mouse.h:328
constexpr CursorRaw get() const noexcept
Retrieves underlying CursorRaw.
Definition: SDL3pp_mouse.h:340
Cursor(SystemCursor id)
Create a system cursor.
Definition: SDL3pp_mouse.h:319
constexpr Cursor(Cursor &&other) noexcept
Move constructor.
Definition: SDL3pp_mouse.h:210
constexpr CursorRaw release() noexcept
Retrieves underlying CursorRaw and clear this.
Definition: SDL3pp_mouse.h:343
constexpr auto operator<=>(const Cursor &other) const noexcept=default
Comparison.
constexpr Cursor(const Cursor &other) noexcept=default
Copy constructor.
Cursor(SurfaceParam surface, const PointRaw &hot)
Create a color cursor.
Definition: SDL3pp_mouse.h:301
constexpr Cursor & operator=(const Cursor &other) noexcept=default
Assignment operator.
constexpr Cursor(const CursorRaw resource) noexcept
Constructs from CursorParam.
Definition: SDL3pp_mouse.h:199
Cursor(const Uint8 *data, const Uint8 *mask, const PointRaw &size, const PointRaw &hot)
Create a cursor using the specified bitmap data and mask (in MSB format).
Definition: SDL3pp_mouse.h:261
constexpr Cursor(std::nullptr_t=nullptr) noexcept
Default ctor.
Definition: SDL3pp_mouse.h:187
~Cursor()
Destructor.
Definition: SDL3pp_mouse.h:325
Base class for SDL memory allocated array wrap.
Definition: SDL3pp_ownPtr.h:44
constexpr void CheckError(bool result)
Check and throw if returned value from SDL is an error.
Definition: SDL3pp_error.h:197
Cursor CreateCursor(const Uint8 *data, const Uint8 *mask, const PointRaw &size, const PointRaw &hot)
Create a cursor using the specified bitmap data and mask (in MSB format).
Definition: SDL3pp_mouse.h:939
constexpr SystemCursor SYSTEM_CURSOR_MOVE
Four pointed arrow pointing north, south, east, and west.
Definition: SDL3pp_mouse.h:120
bool GetRelativeMouseMode() const
Query whether relative mouse mode is enabled for a window.
Definition: SDL3pp_mouse.h:843
void SetRelativeMouseTransform(MouseMotionTransformCallback callback, void *userdata)
Set a user-defined function by which to transform relative mouse inputs.
Definition: SDL3pp_mouse.h:811
constexpr SystemCursor SYSTEM_CURSOR_POINTER
Pointer that indicates a link. Usually a pointing hand.
Definition: SDL3pp_mouse.h:127
constexpr MouseWheelDirection MOUSEWHEEL_NORMAL
The scroll direction is normal.
Definition: SDL3pp_mouse.h:438
SDL_SystemCursor SystemCursor
Cursor types for Cursor.Cursor().
Definition: SDL3pp_mouse.h:88
constexpr SystemCursor SYSTEM_CURSOR_SE_RESIZE
Window resize bottom-right.
Definition: SDL3pp_mouse.h:144
constexpr MouseButton BUTTON_RIGHT
Right button.
Definition: SDL3pp_mouse.h:465
constexpr SystemCursor SYSTEM_CURSOR_W_RESIZE
Window resize left. May be EW_RESIZE.
Definition: SDL3pp_mouse.h:155
constexpr MouseButton BUTTON_MIDDLE
Middle button.
Definition: SDL3pp_mouse.h:463
CursorRef GetCursor()
Get the active cursor.
Definition: SDL3pp_mouse.h:1089
void Destroy()
Free a previously-created cursor.
Definition: SDL3pp_mouse.h:1129
void DestroyCursor(CursorRaw cursor)
Free a previously-created cursor.
Definition: SDL3pp_mouse.h:1127
constexpr SystemCursor SYSTEM_CURSOR_NESW_RESIZE
Double arrow pointing northeast and southwest.
Definition: SDL3pp_mouse.h:109
constexpr MouseWheelDirection MOUSEWHEEL_FLIPPED
The scroll direction is flipped / natural.
Definition: SDL3pp_mouse.h:441
MouseButtonFlags GetRelativeMouseState(float *x, float *y)
Query SDL's cache for the synchronous mouse button state and accumulated mouse delta since last call.
Definition: SDL3pp_mouse.h:759
constexpr MouseButtonFlags ButtonMask(MouseButton button)
Returns mask for button.
Definition: SDL3pp_mouse.h:499
void CaptureMouse(bool enabled)
Capture the mouse and to track input outside an SDL window.
Definition: SDL3pp_mouse.h:892
Cursor CreateSystemCursor(SystemCursor id)
Create a system cursor.
Definition: SDL3pp_mouse.h:1052
Uint32 MouseButtonFlags
A bitmask of pressed mouse buttons, as reported by GetMouseState, etc.
Definition: SDL3pp_mouse.h:486
constexpr SystemCursor SYSTEM_CURSOR_NW_RESIZE
Window resize top-left.
Definition: SDL3pp_mouse.h:133
constexpr SystemCursor SYSTEM_CURSOR_CROSSHAIR
Crosshair.
Definition: SDL3pp_mouse.h:99
void WarpMouse(const FPointRaw &p)
Move the mouse to the given position in global screen space.
Definition: SDL3pp_mouse.h:789
MouseButtonFlags GetGlobalMouseState(float *x, float *y)
Query the platform for the asynchronous mouse button state and the desktop-relative platform-cursor p...
Definition: SDL3pp_mouse.h:721
constexpr SystemCursor SYSTEM_CURSOR_NWSE_RESIZE
Double arrow pointing northwest and southeast.
Definition: SDL3pp_mouse.h:105
constexpr SystemCursor SYSTEM_CURSOR_E_RESIZE
Window resize right. May be EW_RESIZE.
Definition: SDL3pp_mouse.h:141
constexpr MouseButton BUTTON_X1
X1 button.
Definition: SDL3pp_mouse.h:467
constexpr SystemCursor SYSTEM_CURSOR_NS_RESIZE
Double arrow pointing north and south.
Definition: SDL3pp_mouse.h:116
const char * GetMouseNameForID(MouseID instance_id)
Get the name of a mouse.
Definition: SDL3pp_mouse.h:634
constexpr SystemCursor SYSTEM_CURSOR_COUNT
COUNT.
Definition: SDL3pp_mouse.h:158
SDL_MouseID MouseID
This is a unique ID for a mouse for the time it is connected to the system, and is never reused for t...
Definition: SDL3pp_mouse.h:170
constexpr MouseButtonFlags BUTTON_RMASK
RMASK.
Definition: SDL3pp_mouse.h:492
constexpr SystemCursor SYSTEM_CURSOR_NOT_ALLOWED
Not permitted. Usually a slashed circle or crossbones.
Definition: SDL3pp_mouse.h:123
void Set()
Set the active cursor.
Definition: SDL3pp_mouse.h:1073
constexpr MouseButton BUTTON_LEFT
Left button.
Definition: SDL3pp_mouse.h:461
MouseButtonFlags GetMouseState(float *x, float *y)
Query SDL's cache for the synchronous mouse button state and the window-relative SDL-cursor position.
Definition: SDL3pp_mouse.h:681
constexpr MouseButtonFlags BUTTON_LMASK
LMASK.
Definition: SDL3pp_mouse.h:488
constexpr MouseButtonFlags BUTTON_X2MASK
X2MASK.
Definition: SDL3pp_mouse.h:496
void SetRelativeMouseMode(bool enabled)
Set relative mouse mode for a window.
Definition: SDL3pp_mouse.h:838
constexpr SystemCursor SYSTEM_CURSOR_WAIT
Wait. Usually an hourglass or watch or spinning ball.
Definition: SDL3pp_mouse.h:97
Uint8 MouseButton
Represents a button index.
Definition: SDL3pp_mouse.h:459
constexpr SystemCursor SYSTEM_CURSOR_SW_RESIZE
Window resize bottom-left.
Definition: SDL3pp_mouse.h:151
void WarpMouse(const FPointRaw &p)
Move the mouse cursor to the given position within the window.
Definition: SDL3pp_mouse.h:764
void SetCursor(CursorParam cursor)
Set the active cursor.
Definition: SDL3pp_mouse.h:1071
constexpr SystemCursor SYSTEM_CURSOR_NE_RESIZE
Window resize top-right. May be NESW_RESIZE.
Definition: SDL3pp_mouse.h:138
void(SDLCALL *)(void *userdata, Uint64 timestamp, WindowRaw window, MouseID mouseID, float *x, float *y) MouseMotionTransformCallback
A callback used to transform mouse motion delta from raw values.
Definition: SDL3pp_mouse.h:541
constexpr SystemCursor SYSTEM_CURSOR_DEFAULT
Default cursor. Usually an arrow.
Definition: SDL3pp_mouse.h:90
constexpr MouseButtonFlags BUTTON_X1MASK
X1MASK.
Definition: SDL3pp_mouse.h:494
SDL_Cursor * CursorRaw
Alias to raw representation for Cursor.
Definition: SDL3pp_mouse.h:51
constexpr SystemCursor SYSTEM_CURSOR_EW_RESIZE
Double arrow pointing west and east.
Definition: SDL3pp_mouse.h:113
SDL_CursorFrameInfo CursorFrameInfo
Animated cursor frame info.
Definition: SDL3pp_mouse.h:451
CursorRef GetDefaultCursor()
Get the default cursor.
Definition: SDL3pp_mouse.h:1105
WindowRef GetMouseFocus()
Get the window which currently has mouse focus.
Definition: SDL3pp_mouse.h:648
bool CursorVisible()
Return whether the cursor is currently being shown.
Definition: SDL3pp_mouse.h:1172
constexpr MouseButtonFlags BUTTON_MMASK
MMASK.
Definition: SDL3pp_mouse.h:490
constexpr SystemCursor SYSTEM_CURSOR_N_RESIZE
Window resize top. May be NS_RESIZE.
Definition: SDL3pp_mouse.h:135
Cursor CreateColorCursor(SurfaceParam surface, const PointRaw &hot)
Create a color cursor.
Definition: SDL3pp_mouse.h:977
constexpr SystemCursor SYSTEM_CURSOR_S_RESIZE
Window resize bottom. May be NS_RESIZE.
Definition: SDL3pp_mouse.h:148
SDL_MouseWheelDirection MouseWheelDirection
Scroll direction types for the Scroll event.
Definition: SDL3pp_mouse.h:436
OwnArray< MouseID > GetMice()
Get a list of currently connected mice.
Definition: SDL3pp_mouse.h:612
constexpr SystemCursor SYSTEM_CURSOR_TEXT
Text selection. Usually an I-beam.
Definition: SDL3pp_mouse.h:93
void HideCursor()
Hide the cursor.
Definition: SDL3pp_mouse.h:1157
constexpr MouseButton BUTTON_X2
X2 button.
Definition: SDL3pp_mouse.h:469
void ShowCursor()
Show the cursor.
Definition: SDL3pp_mouse.h:1143
constexpr SystemCursor SYSTEM_CURSOR_PROGRESS
Program is busy but still interactive. Usually it's WAIT with an arrow.
Definition: SDL3pp_mouse.h:103
bool HasMouse()
Return whether a mouse is currently connected.
Definition: SDL3pp_mouse.h:593
SDL_FPoint FPointRaw
Alias to raw representation for FPoint.
Definition: SDL3pp_rect.h:28
SDL_Point PointRaw
Alias to raw representation for Point.
Definition: SDL3pp_rect.h:22
Cursor CreateAnimatedCursor(AnimationParam anim, const PointRaw &hotspot)
Create an animated cursor from an animation.
Definition: SDL3pp_image.h:3745
::Uint32 Uint32
An unsigned 32-bit integer type.
Definition: SDL3pp_stdinc.h:341
::Uint64 Uint64
An unsigned 64-bit integer type.
Definition: SDL3pp_stdinc.h:371
::Uint8 Uint8
An unsigned 8-bit integer type.
Definition: SDL3pp_stdinc.h:289
SDL_Window * WindowRaw
Alias to raw representation for Window.
Definition: SDL3pp_video.h:47
Main include header for the SDL3pp library.
Safely wrap Cursor for non owning parameters.
Definition: SDL3pp_mouse.h:58
CursorRaw value
parameter's CursorRaw
Definition: SDL3pp_mouse.h:59
constexpr auto operator<=>(const CursorParam &other) const =default
Comparison.
constexpr CursorParam(std::nullptr_t=nullptr)
Constructs null/invalid.
Definition: SDL3pp_mouse.h:68
constexpr CursorParam(CursorRaw value)
Constructs from CursorRaw.
Definition: SDL3pp_mouse.h:62
Semi-safe reference for Cursor.
Definition: SDL3pp_mouse.h:397
constexpr CursorRef(const CursorRef &other) noexcept=default
Copy constructor.
CursorRef(CursorRaw resource) noexcept
Constructs from CursorParam.
Definition: SDL3pp_mouse.h:419
~CursorRef()
Destructor.
Definition: SDL3pp_mouse.h:428
CursorRef(CursorParam resource) noexcept
Constructs from CursorParam.
Definition: SDL3pp_mouse.h:407
Definition: SDL3pp_callbackWrapper.h:169
Safely wrap Surface for non owning parameters.
Definition: SDL3pp_surface.h:53
Semi-safe reference for Window.
Definition: SDL3pp_video.h:3169