14 if (SDL_SetRelativeMouseMode(enabled ? SDL_TRUE : SDL_FALSE) < 0)
15 throw Exception(
"SDL_SetRelativeMouseMode");
21 return SDL_GetRelativeMouseMode() == SDL_TRUE;
27 SDL_WarpMouseInWindow(window.
ptr(), position.x, position.y);
33 SDL_WarpMouseGlobal(position.x, position.y);
44 Cursor(SDL_SystemCursor
id) : cursor_(SDL_CreateSystemCursor(id))
48 throw Exception(
"SDL_CreateSystemCursor");
54 : cursor_(SDL_CreateCursor(data, mask, size.x, size.y, hot.x, hot.y))
64 : cursor_(SDL_CreateColorCursor(surface.ptr(), hot.x, hot.y))
75 if (cursor_) SDL_FreeCursor(cursor_);
80 if (cursor_ != other.cursor_)
83 other.cursor_ =
nullptr;
93 if (cursor_) SDL_SetCursor(cursor_);
99 const auto value = SDL_ShowCursor(SDL_ENABLE);
101 if (value != SDL_ENABLE)
110 const auto value = SDL_ShowCursor(SDL_DISABLE);
112 if (value != SDL_DISABLE)
121 const auto value = SDL_ShowCursor(SDL_QUERY);
128 return value == SDL_ENABLE;
Cursor(SDL_SystemCursor id)
Construct a system cursor.
void warp_global(Vec2i const &position)
Wrap at this global and absolute position.
Generic templated 2D vector class.
Cursor(const uint8_t *data, const uint8_t *mask, Vec2i const &size, Vec2i const &hot)
Construct a cursor from MSB bitmap data.
static void hide()
Set the cursor as invisible.
SDL_Cursor * cursor_
SDL pointer.
bool get_relative()
Get if the mouse is in relative mode.
~Cursor()
Free the cursor.
Cursor(Cursor &&other) noexcept
Cursor(Surface const &surface, Vec2i const &hot)
Create cursor from a SDL_Surface.
Cursor & operator=(Cursor &&other) noexcept
Represent an SDL_Surface.
SDL_Window * ptr() const
Getter for the raw SDL2 window pointer.
static bool visible()
Return true or false if the cursor is curently visible or not.
void set_relative(bool enabled)
Namespace containing everything that has to do with mouse management Set the mose in relative mode...
static void show()
Set the cursor as visible.
Define to deactivate exception support.
void warp_in_window(Window const &window, Vec2i const &position)
Wrap inside the given windows.