mirror of
https://github.com/lubosz/overte.git
synced 2025-04-24 00:13:53 +02:00
go into away mode if you the HMD loses mouse capture
This commit is contained in:
parent
9f602a938d
commit
cbe80bffd6
2 changed files with 16 additions and 1 deletions
|
@ -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);
|
||||
|
|
|
@ -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); }
|
||||
|
||||
|
|
Loading…
Reference in a new issue