go into away mode if you the HMD loses mouse capture

This commit is contained in:
Brad Hefta-Gaub 2016-02-21 12:57:14 -08:00
parent 9f602a938d
commit cbe80bffd6
2 changed files with 16 additions and 1 deletions

View file

@ -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);

View file

@ -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); }