allow hydra mouse to know the correct size of screen to target

This commit is contained in:
Brad Hefta-Gaub 2016-02-18 22:30:31 -08:00
parent dd8e5fd199
commit d1e1067e5a
3 changed files with 25 additions and 6 deletions

View file

@ -53,8 +53,9 @@ Script.update.connect(function(deltaTime) {
var poseLeft = Controller.getPoseValue(Controller.Standard.LeftHand);
// NOTE: hack for now
var screenSizeX = 1920;
var screenSizeY = 1080;
var screenSize = Reticle.maximumPosition;
var screenSizeX = screenSize.x;
var screenSizeY = screenSize.y;
var rotatedRight = Vec3.multiplyQbyV(poseRight.rotation, Vec3.UNIT_NEG_Y);
var rotatedLeft = Vec3.multiplyQbyV(poseLeft.rotation, Vec3.UNIT_NEG_Y);

View file

@ -401,6 +401,18 @@ void ApplicationCompositor::setReticlePosition(glm::vec2 position, bool sendFake
}
}
#include <QDesktopWidget>
glm::vec2 ApplicationCompositor::getReticleMaximumPosition() const {
glm::vec2 result;
if (qApp->isHMDMode()) {
result = glm::vec2(VIRTUAL_SCREEN_SIZE_X, VIRTUAL_SCREEN_SIZE_Y);
} else {
QRect rec = QApplication::desktop()->screenGeometry();
result = glm::vec2(rec.right(), rec.bottom());
}
return result;
}
// FIXME - this probably is hella buggy and probably doesn't work correctly
// we should kill it asap.
@ -571,7 +583,7 @@ glm::vec2 ApplicationCompositor::screenToSpherical(const glm::vec2& screenPos) {
}
glm::vec2 ApplicationCompositor::sphericalToScreen(const glm::vec2& sphericalPos) {
glm::uvec2 screenSize { VIRTUAL_SCREEN_SIZE_X, VIRTUAL_SCREEN_SIZE_Y }; // = qApp->getCanvasSize();
glm::uvec2 screenSize { VIRTUAL_SCREEN_SIZE_X, VIRTUAL_SCREEN_SIZE_Y };
glm::vec2 result = sphericalPos;
result.x *= -1.0f;
result /= MOUSE_RANGE;

View file

@ -96,6 +96,8 @@ public:
Q_INVOKABLE glm::vec2 getReticlePosition();
Q_INVOKABLE void setReticlePosition(glm::vec2 position, bool sendFakeEvent = true);
Q_INVOKABLE glm::vec2 getReticleMaximumPosition() const;
ReticleInterface* getReticleInterface() { return _reticleInterface; }
/// return value - true means the caller should not process the event further
@ -160,9 +162,11 @@ private:
// Scripting interface available to control the Reticle
class ReticleInterface : public QObject {
Q_OBJECT
Q_PROPERTY(glm::vec2 position READ getPosition WRITE setPosition)
Q_PROPERTY(bool visible READ getVisible WRITE setVisible)
Q_PROPERTY(float depth READ getDepth WRITE setDepth)
Q_PROPERTY(glm::vec2 position READ getPosition WRITE setPosition)
Q_PROPERTY(bool visible READ getVisible WRITE setVisible)
Q_PROPERTY(float depth READ getDepth WRITE setDepth)
Q_PROPERTY(glm::vec2 maximumPosition READ getMaximumPosition)
public:
ReticleInterface(ApplicationCompositor* outer) : QObject(outer), _compositor(outer) {}
@ -174,6 +178,8 @@ public:
Q_INVOKABLE glm::vec2 getPosition() { return _compositor->getReticlePosition(); }
Q_INVOKABLE void setPosition(glm::vec2 position) { _compositor->setReticlePosition(position); }
Q_INVOKABLE glm::vec2 getMaximumPosition() { return _compositor->getReticleMaximumPosition(); }
private:
ApplicationCompositor* _compositor;
};