10#include <SDL_stbimage.h>
31 return SDL_HasMouse();
36 SDL_SetWindowMouseGrab(m_window, grabbed);
41 SDL_WarpMouseInWindow(m_window, x, y);
58 m_cursor = SDL_CreateSystemCursor(cursor);
61 SDL_SetCursor(m_cursor);
75 auto& fs = entt::locator<VirtualFileSystem>::value();
77 auto data = fs.read_binary(cursor);
80 auto surface = STBIMG_LoadFromMemory(data.data(),
static_cast<int>(data.size()));
83 m_cursor = SDL_CreateColorCursor(surface, hotspot.x, hotspot.y);
86 SDL_SetCursor(m_cursor);
98 SDL_DestroySurface(surface);
110 SDL_SetCursor(SDL_GetDefaultCursor());
#define GALAXY_LOG(level, msg,...)
void set_cursor_system(const SDL_SystemCursor cursor) noexcept
Set cursor to a system cursor.
Mouse() noexcept
Constructor.
~Mouse() noexcept
Destructor.
void destroy_cursor() noexcept
Destroy any existing cursor.
void hide_cursor() const noexcept
Hide cursor.
void restore_cursor() noexcept
Set the cursor back to default.
void set_mouse_grab(const bool grabbed) const noexcept
Toggle mouse grab.
void show_cursor() const noexcept
Show cursor.
SDL_Cursor * m_cursor
Holds data for a custom cursor.
bool has_mouse() const noexcept
Check if there is a mouse connected.
void set_cursor_custom(const std::string &cursor, const glm::ivec2 &hotspot) noexcept
Set custom cursor texture.
void warp_mouse(const float x, const float y) const noexcept
Move the mouse cursor to the given position within the window.