Skip to content

Commit

Permalink
TINSEL: Clip mouse position to be within the screen (bug #3613765)
Browse files Browse the repository at this point in the history
The mouse cursor warping code via the keyboard allows the cursor to go
outside the screen. We now limit the cursor's position to always stay
within the screen
  • Loading branch information
bluegr committed Jun 20, 2013
1 parent 125b146 commit 468274a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion engines/tinsel/tinsel.h
Expand Up @@ -226,7 +226,11 @@ class TinselEngine : public Engine {
Graphics::Surface &screen() { return _screenSurface; }

Common::Point getMousePosition() const { return _mousePos; }
void setMousePosition(const Common::Point &pt) {
void setMousePosition(Common::Point pt) {
// Clip mouse position to be within the screen coordinates
pt.x = CLIP<int16>(pt.x, 0, SCREEN_WIDTH - 1);
pt.y = CLIP<int16>(pt.y, 0, SCREEN_HEIGHT - 1);

int yOffset = TinselV2 ? (g_system->getHeight() - _screenSurface.h) / 2 : 0;
g_system->warpMouse(pt.x, pt.y + yOffset);
_mousePos = pt;
Expand Down

0 comments on commit 468274a

Please sign in to comment.