From 9f602a938d7a9e17c9bbc328057f55ecc0a26aba Mon Sep 17 00:00:00 2001 From: Brad Hefta-Gaub Date: Sun, 21 Feb 2016 12:42:02 -0800 Subject: [PATCH 1/2] don't move mouse on reset sensors --- interface/src/Application.cpp | 8 -------- 1 file changed, 8 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 7c1fd9279b..64cd586e13 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -3906,16 +3906,8 @@ void Application::resetSensors(bool andReload) { DependencyManager::get()->reset(); DependencyManager::get()->reset(); DependencyManager::get()->reset(); - getActiveDisplayPlugin()->resetSensors(); - - QScreen* currentScreen = _window->windowHandle()->screen(); - QWindow* mainWindow = _window->windowHandle(); - QPoint windowCenter = mainWindow->geometry().center(); - _glWidget->cursor().setPos(currentScreen, windowCenter); - getMyAvatar()->reset(andReload); - QMetaObject::invokeMethod(DependencyManager::get().data(), "reset", Qt::QueuedConnection); } From cbe80bffd679ca6ba211fee45c03cf0bc53f3070 Mon Sep 17 00:00:00 2001 From: Brad Hefta-Gaub Date: Sun, 21 Feb 2016 12:57:14 -0800 Subject: [PATCH 2/2] go into away mode if you the HMD loses mouse capture --- examples/away.js | 12 ++++++++++++ interface/src/ui/ApplicationCompositor.h | 5 ++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/examples/away.js b/examples/away.js index 861c642b8d..18a3fddfce 100644 --- a/examples/away.js +++ b/examples/away.js @@ -132,6 +132,7 @@ function maybeGoActive(event) { } } var wasHmdActive = false; +var wasMouseCaptured = false; function maybeGoAway() { if (HMD.active !== wasHmdActive) { wasHmdActive = !wasHmdActive; @@ -139,6 +140,17 @@ function maybeGoAway() { goAway(); } } + + // If the mouse has gone from captured, to non-captured state, + // then it likely means the person is still in the HMD, but has + // tabbed away from the application (meaning they don't have mouse + // control) and they likely want to go into an away state + if (Reticle.mouseCaptured !== wasMouseCaptured) { + wasMouseCaptured = !wasMouseCaptured; + if (!wasMouseCaptured) { + goAway(); + } + } } Script.update.connect(maybeGoAway); diff --git a/interface/src/ui/ApplicationCompositor.h b/interface/src/ui/ApplicationCompositor.h index 94244e5586..32a30c6fc6 100644 --- a/interface/src/ui/ApplicationCompositor.h +++ b/interface/src/ui/ApplicationCompositor.h @@ -101,9 +101,9 @@ public: void handleLeaveEvent(); QPointF getMouseEventPosition(QMouseEvent* event); + bool shouldCaptureMouse() const; private: - bool shouldCaptureMouse() const; void displayOverlayTextureStereo(RenderArgs* renderArgs, float aspectRatio, float fov); void bindCursorTexture(gpu::Batch& batch, uint8_t cursorId = 0); @@ -162,10 +162,13 @@ class ReticleInterface : public QObject { Q_PROPERTY(bool visible READ getVisible WRITE setVisible) Q_PROPERTY(float depth READ getDepth WRITE setDepth) Q_PROPERTY(glm::vec2 maximumPosition READ getMaximumPosition) + Q_PROPERTY(bool mouseCaptured READ isMouseCaptured) public: ReticleInterface(ApplicationCompositor* outer) : QObject(outer), _compositor(outer) {} + Q_INVOKABLE bool isMouseCaptured() { return _compositor->shouldCaptureMouse(); } + Q_INVOKABLE bool getVisible() { return _compositor->getReticleVisible(); } Q_INVOKABLE void setVisible(bool visible) { _compositor->setReticleVisible(visible); }