diff options
author | Kae <80987908+Novaenia@users.noreply.github.com> | 2024-04-19 08:52:35 +1000 |
---|---|---|
committer | Kae <80987908+Novaenia@users.noreply.github.com> | 2024-04-19 08:52:35 +1000 |
commit | d5f5fb5ddf0d4a9f0b0e6ac012121926d2fcd949 (patch) | |
tree | 5f1bca917aacc2bb22d0ac00857edb15b134add2 /source/application/StarMainApplication_sdl.cpp | |
parent | 9533c8d0a50c2e09d4880776f5ddfda2b7482c32 (diff) |
Add hardware cursor game setting
Diffstat (limited to 'source/application/StarMainApplication_sdl.cpp')
-rw-r--r-- | source/application/StarMainApplication_sdl.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/source/application/StarMainApplication_sdl.cpp b/source/application/StarMainApplication_sdl.cpp index cb631ff..277df57 100644 --- a/source/application/StarMainApplication_sdl.cpp +++ b/source/application/StarMainApplication_sdl.cpp @@ -630,6 +630,10 @@ private: SDL_WarpMouseInWindow(parent->m_sdlWindow, cursorPosition[0], cursorPosition[1]); } + void setCursorHardware(bool hardware) override { + parent->m_cursorHardware = hardware; + } + bool setCursorImage(const String& id, const ImageConstPtr& image, unsigned scale, const Vec2I& offset) override { return parent->setCursorImage(id, image, scale, offset); } @@ -828,12 +832,16 @@ private: } } - static const size_t MaximumCursorDimensions = 128; - static const size_t MaximumCursorPixelCount = MaximumCursorDimensions * MaximumCursorDimensions; + static const size_t MaxCursorSize = 128; bool setCursorImage(const String& id, const ImageConstPtr& image, unsigned scale, const Vec2I& offset) { auto imageSize = image->size().piecewiseMultiply(Vec2U::filled(scale)); - if (!scale || imageSize.max() > MaximumCursorDimensions || (size_t)(imageSize[0] * imageSize[1]) > MaximumCursorPixelCount) + if (!m_cursorHardware || !scale || imageSize.max() > MaxCursorSize || imageSize.product() > square(MaxCursorSize)) { + if (auto defaultCursor = SDL_GetDefaultCursor()) { + if (SDL_GetCursor() != defaultCursor) + SDL_SetCursor(defaultCursor); + } return m_cursorVisible = false; + } auto& entry = m_cursorCache.get(m_currentCursor = { scale, offset, id }, [&](auto const&) { auto entry = std::make_shared<CursorEntry>(); @@ -926,6 +934,7 @@ private: bool m_windowVSync = true; unsigned m_maxFrameSkip = 5; bool m_cursorVisible = true; + bool m_cursorHardware = true; bool m_acceptingTextInput = false; bool m_audioEnabled = false; bool m_quitRequested = false; |