4#include <SDL3/SDL_mouse.h>
5#include "SDL3pp_stdinc.h"
6#include "SDL3pp_video.h"
82 SDL_SYSTEM_CURSOR_DEFAULT;
85 SDL_SYSTEM_CURSOR_TEXT;
93 SDL_SYSTEM_CURSOR_CROSSHAIR;
101 SDL_SYSTEM_CURSOR_NWSE_RESIZE;
105 SDL_SYSTEM_CURSOR_NESW_RESIZE;
109 SDL_SYSTEM_CURSOR_EW_RESIZE;
112 SDL_SYSTEM_CURSOR_NS_RESIZE;
123 SDL_SYSTEM_CURSOR_NOT_ALLOWED;
137 SDL_SYSTEM_CURSOR_N_RESIZE;
140 SDL_SYSTEM_CURSOR_NE_RESIZE;
144 SDL_SYSTEM_CURSOR_E_RESIZE;
147 SDL_SYSTEM_CURSOR_SE_RESIZE;
151 SDL_SYSTEM_CURSOR_S_RESIZE;
154 SDL_SYSTEM_CURSOR_SW_RESIZE;
158 SDL_SYSTEM_CURSOR_W_RESIZE;
204 static void reset(SDL_Cursor* resource) { SDL_DestroyCursor(resource); }
259 const SDL_Point& size,
260 const SDL_Point& hot)
263 CheckError(SDL_CreateCursor(data, mask, size.x, size.y, hot.x, hot.y)));
296 CheckError(SDL_CreateColorCursor(surface.
get(), hot.x, hot.y)));
389 SDL_MOUSEWHEEL_NORMAL;
392 SDL_MOUSEWHEEL_FLIPPED;
419 return SDL_BUTTON_MASK(button);
492 return CheckError(SDL_GetMouseNameForID(instance_id));
539 return SDL_GetMouseState(x, y);
579 return SDL_GetGlobalMouseState(x, y);
617 return SDL_GetRelativeMouseState(x, y);
642 SDL_WarpMouseInWindow(
get(), x, y);
713 return SDL_GetWindowRelativeMouseMode(
get());
Base class for SDL memory allocated array wrap.
Definition SDL3pp_ownPtr.h:43
RESOURCE release()
Returns reference and reset this.
Definition SDL3pp_resource.h:178
Implement shared ownership for a resource.
Definition SDL3pp_resource.h:283
Implement unique ownership for a resource.
Definition SDL3pp_resource.h:226
constexpr ResourceUnique(std::nullptr_t=nullptr)
Default constructor.
Definition SDL3pp_resource.h:231
void reset()
Resets the value, destroying the resource if not nullptr.
Definition SDL3pp_resource.h:265
A dumb pointer to resource.
Definition SDL3pp_resource.h:197
constexpr ResourceUnsafe()=default
Default constructor.
Implement weak ownership for a resource.
Definition SDL3pp_resource.h:328
A SDL managed resource.
Definition SDL3pp_resource.h:29
constexpr Resource(T resource={})
Constructs from the underlying resource.
Definition SDL3pp_resource.h:37
constexpr T get() const
Return contained resource;.
Definition SDL3pp_resource.h:76
constexpr void CheckError(bool result)
Check and throw if returned value from SDL is an error.
Definition SDL3pp_error.h:206
void WarpMouse(float x, float y)
Move the mouse cursor to the given position within the window.
Definition SDL3pp_mouse.h:640
constexpr SystemCursor SYSTEM_CURSOR_MOVE
Four pointed arrow pointing north, south, east, and west.
Definition SDL3pp_mouse.h:117
constexpr SystemCursor SYSTEM_CURSOR_POINTER
Pointer that indicates a link.
Definition SDL3pp_mouse.h:128
constexpr MouseWheelDirection MOUSEWHEEL_NORMAL
The scroll direction is normal.
Definition SDL3pp_mouse.h:388
SDL_SystemCursor SystemCursor
Cursor types for Cursor.CreateSystem().
Definition SDL3pp_mouse.h:79
constexpr SystemCursor SYSTEM_CURSOR_SE_RESIZE
Window resize bottom-right.
Definition SDL3pp_mouse.h:146
constexpr MouseButton BUTTON_RIGHT
Right button.
Definition SDL3pp_mouse.h:375
CursorShared share()
Move this cursor into a CursorShared.
Definition SDL3pp_mouse.h:338
constexpr SystemCursor SYSTEM_CURSOR_W_RESIZE
Window resize left. May be EW_RESIZE.
Definition SDL3pp_mouse.h:157
constexpr MouseButton BUTTON_MIDDLE
Middle button.
Definition SDL3pp_mouse.h:373
CursorRef GetCursor()
Get the active cursor.
Definition SDL3pp_mouse.h:802
constexpr SystemCursor SYSTEM_CURSOR_NESW_RESIZE
Double arrow pointing northeast and southwest.
Definition SDL3pp_mouse.h:104
constexpr MouseWheelDirection MOUSEWHEEL_FLIPPED
The scroll direction is flipped / natural.
Definition SDL3pp_mouse.h:391
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:615
constexpr MouseButtonFlags ButtonMask(MouseButton button)
Convert a button index to a button mask.
Definition SDL3pp_mouse.h:417
void CaptureMouse(bool enabled)
Capture the mouse and to track input outside an SDL window.
Definition SDL3pp_mouse.h:761
Uint32 MouseButtonFlags
A bitmask of pressed mouse buttons, as reported by GetMouseState, etc.
Definition SDL3pp_mouse.h:409
constexpr SystemCursor SYSTEM_CURSOR_NW_RESIZE
Window resize top-left.
Definition SDL3pp_mouse.h:134
void WarpMouse(float x, float y)
Move the mouse to the given position in global screen space.
Definition SDL3pp_mouse.h:666
constexpr SystemCursor SYSTEM_CURSOR_CROSSHAIR
Crosshair.
Definition SDL3pp_mouse.h:92
bool GetRelativeMouseMode() const
Query whether relative mouse mode is enabled for a window.
Definition SDL3pp_mouse.h:711
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:577
constexpr SystemCursor SYSTEM_CURSOR_NWSE_RESIZE
Double arrow pointing northwest and southeast.
Definition SDL3pp_mouse.h:100
constexpr SystemCursor SYSTEM_CURSOR_E_RESIZE
Window resize right. May be EW_RESIZE.
Definition SDL3pp_mouse.h:143
constexpr MouseButton BUTTON_X1
X1 button.
Definition SDL3pp_mouse.h:377
constexpr SystemCursor SYSTEM_CURSOR_NS_RESIZE
Double arrow pointing north and south.
Definition SDL3pp_mouse.h:111
const char * GetMouseNameForID(MouseID instance_id)
Get the name of a mouse.
Definition SDL3pp_mouse.h:490
constexpr SystemCursor SYSTEM_CURSOR_COUNT
COUNT.
Definition SDL3pp_mouse.h:160
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:172
void SetRelativeMouseMode(bool enabled)
Set relative mouse mode for a window.
Definition SDL3pp_mouse.h:695
constexpr MouseButtonFlags BUTTON_RMASK
Right button mask.
Definition SDL3pp_mouse.h:428
constexpr SystemCursor SYSTEM_CURSOR_NOT_ALLOWED
Not permitted.
Definition SDL3pp_mouse.h:122
constexpr MouseButton BUTTON_LEFT
Left button.
Definition SDL3pp_mouse.h:371
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:537
constexpr MouseButtonFlags BUTTON_LMASK
Left button mask.
Definition SDL3pp_mouse.h:422
constexpr MouseButtonFlags BUTTON_X2MASK
X2 button mask.
Definition SDL3pp_mouse.h:434
constexpr SystemCursor SYSTEM_CURSOR_WAIT
Wait.
Definition SDL3pp_mouse.h:90
Uint8 MouseButton
Represents a button index.
Definition SDL3pp_mouse.h:369
constexpr SystemCursor SYSTEM_CURSOR_SW_RESIZE
Window resize bottom-left.
Definition SDL3pp_mouse.h:153
constexpr SystemCursor SYSTEM_CURSOR_NE_RESIZE
Window resize top-right.
Definition SDL3pp_mouse.h:139
constexpr SystemCursor SYSTEM_CURSOR_DEFAULT
Default cursor. Usually an arrow.
Definition SDL3pp_mouse.h:81
constexpr MouseButtonFlags BUTTON_X1MASK
X1 button mask.
Definition SDL3pp_mouse.h:431
constexpr SystemCursor SYSTEM_CURSOR_EW_RESIZE
Double arrow pointing west and east.
Definition SDL3pp_mouse.h:108
CursorRef GetDefaultCursor()
Get the default cursor.
Definition SDL3pp_mouse.h:817
WindowRef GetMouseFocus()
Get the window which currently has mouse focus.
Definition SDL3pp_mouse.h:504
bool CursorVisible()
Return whether the cursor is currently being shown.
Definition SDL3pp_mouse.h:863
constexpr MouseButtonFlags BUTTON_MMASK
Middle button mask.
Definition SDL3pp_mouse.h:425
constexpr SystemCursor SYSTEM_CURSOR_N_RESIZE
Window resize top. May be NS_RESIZE.
Definition SDL3pp_mouse.h:136
constexpr SystemCursor SYSTEM_CURSOR_S_RESIZE
Window resize bottom. May be NS_RESIZE.
Definition SDL3pp_mouse.h:150
SDL_MouseWheelDirection MouseWheelDirection
Scroll direction types for the Scroll event.
Definition SDL3pp_mouse.h:386
void SetCursor(CursorRef cursor)
Set the active cursor.
Definition SDL3pp_mouse.h:783
ResourceShared< Cursor > CursorShared
Handle to a shared cursor.
Definition SDL3pp_mouse.h:62
OwnArray< MouseID > GetMice()
Get a list of currently connected mice.
Definition SDL3pp_mouse.h:468
constexpr SystemCursor SYSTEM_CURSOR_TEXT
Text selection. Usually an I-beam.
Definition SDL3pp_mouse.h:84
void HideCursor()
Hide the cursor.
Definition SDL3pp_mouse.h:848
constexpr MouseButton BUTTON_X2
X2 button.
Definition SDL3pp_mouse.h:379
void ShowCursor()
Show the cursor.
Definition SDL3pp_mouse.h:834
constexpr SystemCursor SYSTEM_CURSOR_PROGRESS
Program is busy but still interactive.
Definition SDL3pp_mouse.h:98
bool HasMouse()
Return whether a mouse is currently connected.
Definition SDL3pp_mouse.h:448
the main namespace where all SDL3pp public functions and types live
Definition SDL3pp_assert.h:7
The structure used to identify an SDL cursor.
Definition SDL3pp_mouse.h:186
static void reset(SDL_Cursor *resource)
Free a previously-created cursor.
Definition SDL3pp_mouse.h:204
Unsafe Handle to cursor.
Definition SDL3pp_mouse.h:353
constexpr CursorUnsafe(Cursor &&other)
Constructs CursorUnsafe from Cursor.
Definition SDL3pp_mouse.h:359
Handle to an owned cursor.
Definition SDL3pp_mouse.h:215
void Destroy()
Free a previously-created cursor.
Definition SDL3pp_mouse.h:329
static Cursor Create(const Uint8 *data, const Uint8 *mask, const SDL_Point &size, const SDL_Point &hot)
Create a cursor using the specified bitmap data and mask (in MSB format).
Definition SDL3pp_mouse.h:257
static Cursor CreateColor(SurfaceRef surface, const SDL_Point &hot)
Create a color cursor.
Definition SDL3pp_mouse.h:293
static Cursor CreateSystem(SystemCursor id)
Create a system cursor.
Definition SDL3pp_mouse.h:312
A collection of pixels used in software blitting.
Definition SDL3pp_surface.h:153
Represents a handle to a window.
Definition SDL3pp_video.h:860