From 68edb442d3e982bd30e8576138032ed2e7d9e956 Mon Sep 17 00:00:00 2001 From: andreja6 Date: Mon, 23 Apr 2018 17:53:41 -0700 Subject: [PATCH] Mouse now stays where you left it --- main.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/main.cpp b/main.cpp index b45f50b..4ec5ce6 100644 --- a/main.cpp +++ b/main.cpp @@ -57,6 +57,7 @@ static bool backwards = false; static bool left = false; static bool right = false; Vector3 cameraPos = Vector3(0,2,10); +Vector2 oldMouse = Vector2(0,0); float moveRate = 0.5; /** This simple demo applet uses the debug mode as the regular @@ -457,6 +458,7 @@ void Demo::onUserInput(UserInput* ui) { } if(ui->keyPressed(SDL_RIGHT_MOUSE_KEY)) { + oldMouse = ui->getMouseXY(); showMouse = false; app->window()->setRelativeMousePosition(app->window()->width()/2, app->window()->height()/2); mouseMovedBeginMotion = true; @@ -464,6 +466,7 @@ void Demo::onUserInput(UserInput* ui) { } else if(ui->keyReleased(SDL_RIGHT_MOUSE_KEY)) { + ui->setMouseXY(oldMouse); showMouse = true; app->debugController.setActive(false); }