diff options
| -rw-r--r-- | backends/graphics/opengl/opengl-graphics.cpp | 58 | ||||
| -rw-r--r-- | backends/graphics/opengl/opengl-graphics.h | 10 | ||||
| -rw-r--r-- | backends/graphics/openglsdl/openglsdl-graphics.cpp | 48 | ||||
| -rw-r--r-- | backends/graphics/openglsdl/openglsdl-graphics.h | 4 | 
4 files changed, 63 insertions, 57 deletions
| diff --git a/backends/graphics/opengl/opengl-graphics.cpp b/backends/graphics/opengl/opengl-graphics.cpp index 9a2efe3eec..6bd790237a 100644 --- a/backends/graphics/opengl/opengl-graphics.cpp +++ b/backends/graphics/opengl/opengl-graphics.cpp @@ -540,13 +540,53 @@ bool OpenGLGraphicsManager::showMouse(bool visible) {  	return last;  } -void OpenGLGraphicsManager::setMousePos(int x, int y) { -	_cursorState.x = x; -	_cursorState.y = y; -} -  void OpenGLGraphicsManager::warpMouse(int x, int y) { -	setMousePos(x, y); +	int scaledX = x; +	int scaledY = y; + +	int16 currentX = _cursorState.x; +	int16 currentY = _cursorState.y; + +	adjustMousePosition(currentX, currentY); + +	// Do not adjust the real screen position, when the current game / overlay +	// coordinates match the requested coordinates. This avoids a slight +	// movement which might occur otherwise when the mouse is at a subpixel +	// position. +	if (x == currentX && y == currentY) +		return; + +	if (_videoMode.mode == OpenGL::GFX_NORMAL) { +		if (_videoMode.hardwareWidth != _videoMode.overlayWidth) +			scaledX = scaledX * _videoMode.hardwareWidth / _videoMode.overlayWidth; +		if (_videoMode.hardwareHeight != _videoMode.overlayHeight) +			scaledY = scaledY * _videoMode.hardwareHeight / _videoMode.overlayHeight; + +		if (!_overlayVisible) { +			scaledX *= _videoMode.scaleFactor; +			scaledY *= _videoMode.scaleFactor; +		} +	} else { +		if (_overlayVisible) { +			if (_displayWidth != _videoMode.overlayWidth) +				scaledX = scaledX * _displayWidth / _videoMode.overlayWidth; +			if (_displayHeight != _videoMode.overlayHeight) +				scaledY = scaledY * _displayHeight / _videoMode.overlayHeight; +		} else { +			if (_displayWidth != _videoMode.screenWidth) +				scaledX = scaledX * _displayWidth / _videoMode.screenWidth; +			if (_displayHeight != _videoMode.screenHeight) +				scaledY = scaledY * _displayHeight / _videoMode.screenHeight; +		} + +		scaledX += _displayX; +		scaledY += _displayY; +	} + +	setInternalMousePosition(scaledX, scaledY); + +	_cursorState.x = scaledX; +	_cursorState.y = scaledY;  }  void OpenGLGraphicsManager::setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int cursorTargetScale, const Graphics::PixelFormat *format) { @@ -1249,8 +1289,10 @@ void OpenGLGraphicsManager::adjustMousePosition(int16 &x, int16 &y) {  bool OpenGLGraphicsManager::notifyEvent(const Common::Event &event) {  	switch (event.type) {  	case Common::EVENT_MOUSEMOVE: -		if (!event.synthetic) -			setMousePos(event.mouse.x, event.mouse.y); +		if (!event.synthetic) { +			_cursorState.x = event.mouse.x; +			_cursorState.y = event.mouse.y; +		}  	case Common::EVENT_LBUTTONDOWN:  	case Common::EVENT_RBUTTONDOWN:  	case Common::EVENT_WHEELUP: diff --git a/backends/graphics/opengl/opengl-graphics.h b/backends/graphics/opengl/opengl-graphics.h index b4084e8e41..d048c91593 100644 --- a/backends/graphics/opengl/opengl-graphics.h +++ b/backends/graphics/opengl/opengl-graphics.h @@ -272,6 +272,15 @@ protected:  	virtual void refreshCursor();  	virtual void refreshCursorScale(); + +	/** +	 * Set up the mouse position for the (event) system. +	 * +	 * @param x X coordinate in native coordinates. +	 * @param y Y coordinate in native coordinates. +	 */ +	virtual void setInternalMousePosition(int x, int y) = 0; +  	/**  	 * Adjusts hardware screen coordinates to either overlay or game screen  	 * coordinates depending on whether the overlay is visible or not. @@ -280,7 +289,6 @@ protected:  	 * @param y Y coordinate of the mouse position.  	 */  	virtual void adjustMousePosition(int16 &x, int16 &y); -	virtual void setMousePos(int x, int y);  	//  	// Misc diff --git a/backends/graphics/openglsdl/openglsdl-graphics.cpp b/backends/graphics/openglsdl/openglsdl-graphics.cpp index cbc152a4a3..0c7e53950c 100644 --- a/backends/graphics/openglsdl/openglsdl-graphics.cpp +++ b/backends/graphics/openglsdl/openglsdl-graphics.cpp @@ -192,52 +192,8 @@ void OpenGLSdlGraphicsManager::detectSupportedFormats() {  #endif -void OpenGLSdlGraphicsManager::warpMouse(int x, int y) { -	int scaledX = x; -	int scaledY = y; - -	int16 currentX = _cursorState.x; -	int16 currentY = _cursorState.y; - -	adjustMousePosition(currentX, currentY); - -	// Do not adjust the real screen position, when the current game / overlay -	// coordinates match the requested coordinates. This avoids a slight -	// movement which might occur otherwise when the mouse is at a subpixel -	// position. -	if (x == currentX && y == currentY) -		return; - -	if (_videoMode.mode == OpenGL::GFX_NORMAL) { -		if (_videoMode.hardwareWidth != _videoMode.overlayWidth) -			scaledX = scaledX * _videoMode.hardwareWidth / _videoMode.overlayWidth; -		if (_videoMode.hardwareHeight != _videoMode.overlayHeight) -			scaledY = scaledY * _videoMode.hardwareHeight / _videoMode.overlayHeight; - -		if (!_overlayVisible) { -			scaledX *= _videoMode.scaleFactor; -			scaledY *= _videoMode.scaleFactor; -		} -	} else { -		if (_overlayVisible) { -			if (_displayWidth != _videoMode.overlayWidth) -				scaledX = scaledX * _displayWidth / _videoMode.overlayWidth; -			if (_displayHeight != _videoMode.overlayHeight) -				scaledY = scaledY * _displayHeight / _videoMode.overlayHeight; -		} else { -			if (_displayWidth != _videoMode.screenWidth) -				scaledX = scaledX * _displayWidth / _videoMode.screenWidth; -			if (_displayHeight != _videoMode.screenHeight) -				scaledY = scaledY * _displayHeight / _videoMode.screenHeight; -		} - -		scaledX += _displayX; -		scaledY += _displayY; -	} - -	SDL_WarpMouse(scaledX, scaledY); - -	setMousePos(scaledX, scaledY); +void OpenGLSdlGraphicsManager::setInternalMousePosition(int x, int y) { +	SDL_WarpMouse(x, y);  }  void OpenGLSdlGraphicsManager::updateScreen() { diff --git a/backends/graphics/openglsdl/openglsdl-graphics.h b/backends/graphics/openglsdl/openglsdl-graphics.h index d39c0814de..309301c25a 100644 --- a/backends/graphics/openglsdl/openglsdl-graphics.h +++ b/backends/graphics/openglsdl/openglsdl-graphics.h @@ -48,8 +48,6 @@ public:  	virtual Common::List<Graphics::PixelFormat> getSupportedFormats() const;  #endif -	virtual void warpMouse(int x, int y); -  	virtual bool notifyEvent(const Common::Event &event);  	virtual void updateScreen(); @@ -86,6 +84,8 @@ protected:  	 */  	virtual bool setupFullscreenMode(); +	virtual void setInternalMousePosition(int x, int y); +  	int _lastFullscreenModeWidth;  	int _lastFullscreenModeHeight;  	int _desktopWidth; | 
