10#include <SDL_stbimage.h>
32 return SDL_HasMouse();
37 SDL_SetWindowMouseGrab(m_window, grabbed);
42 SDL_WarpMouseInWindow(m_window, x, y);
59 m_cursor = SDL_CreateSystemCursor(cursor);
62 SDL_SetCursor(m_cursor);
76 auto& fs = entt::locator<VirtualFileSystem>::value();
78 auto data = fs.read_binary(cursor);
81 auto surface = STBIMG_LoadFromMemory(data.data(),
static_cast<int>(data.size()));
84 m_cursor = SDL_CreateColorCursor(surface, hotspot.x, hotspot.y);
87 SDL_SetCursor(m_cursor);
99 SDL_DestroySurface(surface);
111 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.
Allows you to bind a base class to the window.