diff --git a/client/eventsSDL/InputSourceGameController.cpp b/client/eventsSDL/InputSourceGameController.cpp index 619d92f29..1028bba17 100644 --- a/client/eventsSDL/InputSourceGameController.cpp +++ b/client/eventsSDL/InputSourceGameController.cpp @@ -209,9 +209,11 @@ void InputSourceGameController::handleEventAxisMotion(const SDL_ControllerAxisEv void InputSourceGameController::tryToConvertCursor() { - if(CCS && CCS->curh && CCS->curh->getShowType() == Cursor::ShowType::HARDWARE) + assert(CCS); + assert(CCS->curh); + if(CCS->curh->getShowType() == Cursor::ShowType::HARDWARE) { - const Point & cursorPosition = CCS->curh->getCursorPosition(); + const Point & cursorPosition = GH.getCursorPosition(); CCS->curh->ChangeCursor(Cursor::ShowType::SOFTWARE); CCS->curh->cursorMove(cursorPosition.x, cursorPosition.y); GH.input().setCursorPosition(cursorPosition); diff --git a/client/gui/CGuiHandler.cpp b/client/gui/CGuiHandler.cpp index c1745321f..aeb1d157f 100644 --- a/client/gui/CGuiHandler.cpp +++ b/client/gui/CGuiHandler.cpp @@ -76,8 +76,8 @@ void CGuiHandler::init() windowHandlerInstance = std::make_unique(); screenHandlerInstance = std::make_unique(); renderHandlerInstance = std::make_unique(); - inputHandlerInstance = std::make_unique(); // Must be after windowHandlerInstance shortcutsHandlerInstance = std::make_unique(); + inputHandlerInstance = std::make_unique(); // Must be after windowHandlerInstance and shortcutsHandlerInstance framerateManagerInstance = std::make_unique(settings["video"]["targetfps"].Integer()); } diff --git a/client/gui/CursorHandler.cpp b/client/gui/CursorHandler.cpp index 6f264f89b..92f2823c6 100644 --- a/client/gui/CursorHandler.cpp +++ b/client/gui/CursorHandler.cpp @@ -315,8 +315,3 @@ void CursorHandler::ChangeCursor(Cursor::ShowType showType) break; } } - -const Point & CursorHandler::getCursorPosition() -{ - return cursor->getCursorPosition(); -} diff --git a/client/gui/CursorHandler.h b/client/gui/CursorHandler.h index 2c8528e91..875d1b58b 100644 --- a/client/gui/CursorHandler.h +++ b/client/gui/CursorHandler.h @@ -186,7 +186,6 @@ public: /// change cursor's positions to (x, y) void cursorMove(const int & x, const int & y); - Cursor::ShowType getShowType(); - void ChangeCursor(Cursor::ShowType showType); - const Point & getCursorPosition(); + Cursor::ShowType getShowType(); + void ChangeCursor(Cursor::ShowType showType); }; diff --git a/client/render/ICursor.h b/client/render/ICursor.h index fab509240..af9e2f1c6 100644 --- a/client/render/ICursor.h +++ b/client/render/ICursor.h @@ -24,6 +24,5 @@ public: virtual void setCursorPosition( const Point & newPos ) = 0; virtual void render() = 0; virtual void setVisible( bool on) = 0; - virtual const Point & getCursorPosition() = 0; }; diff --git a/client/render/IScreenHandler.h b/client/render/IScreenHandler.h index 96381b298..49e5cd95e 100644 --- a/client/render/IScreenHandler.h +++ b/client/render/IScreenHandler.h @@ -43,7 +43,4 @@ public: /// Window has focus virtual bool hasFocus() = 0; - - /// Get the scale value of screen - virtual void getRenderScale(float & scaleX, float & scaleY) = 0; }; diff --git a/client/renderSDL/CursorHardware.cpp b/client/renderSDL/CursorHardware.cpp index e86a16e38..a4a10f2f8 100644 --- a/client/renderSDL/CursorHardware.cpp +++ b/client/renderSDL/CursorHardware.cpp @@ -67,17 +67,6 @@ void CursorHardware::setImage(std::shared_ptr image, const Point & pivot }); } -const Point & CursorHardware::getCursorPosition() -{ - int mouseX, mouseY; - SDL_GetMouseState(&mouseX, &mouseY); - float scaleX, scaleY; - GH.screenHandler().getRenderScale(scaleX, scaleY); - pos.x = int(mouseX / scaleX); - pos.y = int(mouseY / scaleY); - return pos; -} - void CursorHardware::setCursorPosition( const Point & newPos ) { //no-op diff --git a/client/renderSDL/CursorHardware.h b/client/renderSDL/CursorHardware.h index eac1acf4b..3c5509aa2 100644 --- a/client/renderSDL/CursorHardware.h +++ b/client/renderSDL/CursorHardware.h @@ -33,6 +33,5 @@ public: void setCursorPosition( const Point & newPos ) override; void render() override; void setVisible( bool on) override; - const Point & getCursorPosition() override; }; diff --git a/client/renderSDL/CursorSoftware.cpp b/client/renderSDL/CursorSoftware.cpp index a35786759..78b9e1250 100644 --- a/client/renderSDL/CursorSoftware.cpp +++ b/client/renderSDL/CursorSoftware.cpp @@ -81,11 +81,6 @@ void CursorSoftware::setVisible(bool on) visible = on; } -const Point & CursorSoftware::getCursorPosition() -{ - return pos; -} - CursorSoftware::CursorSoftware(): cursorTexture(nullptr), cursorSurface(nullptr), diff --git a/client/renderSDL/CursorSoftware.h b/client/renderSDL/CursorSoftware.h index 18bc59f25..44080e3e2 100644 --- a/client/renderSDL/CursorSoftware.h +++ b/client/renderSDL/CursorSoftware.h @@ -40,6 +40,5 @@ public: void setCursorPosition( const Point & newPos ) override; void render() override; void setVisible( bool on) override; - const Point & getCursorPosition() override; }; diff --git a/client/renderSDL/ScreenHandler.cpp b/client/renderSDL/ScreenHandler.cpp index f197d9061..604928c49 100644 --- a/client/renderSDL/ScreenHandler.cpp +++ b/client/renderSDL/ScreenHandler.cpp @@ -582,8 +582,3 @@ bool ScreenHandler::hasFocus() ui32 flags = SDL_GetWindowFlags(mainWindow); return flags & SDL_WINDOW_INPUT_FOCUS; } - -void ScreenHandler::getRenderScale(float & scaleX, float & scaleY) -{ - SDL_RenderGetScale(mainRenderer, &scaleX, &scaleY); -} diff --git a/client/renderSDL/ScreenHandler.h b/client/renderSDL/ScreenHandler.h index b1428842c..fb3d6a334 100644 --- a/client/renderSDL/ScreenHandler.h +++ b/client/renderSDL/ScreenHandler.h @@ -89,9 +89,6 @@ public: /// Window has focus bool hasFocus() final; - /// Get the scale value of screen - void getRenderScale(float & scaleX, float & scaleY); - std::vector getSupportedResolutions() const final; std::vector getSupportedResolutions(int displayIndex) const; std::tuple getSupportedScalingRange() const final;