mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 12:38:27 +02:00
Use correct mouse coordinate
This commit is contained in:
parent
b197558b87
commit
43dc35d549
2 changed files with 11 additions and 11 deletions
|
@ -1128,7 +1128,8 @@ void Application::keyPressEvent(QKeyEvent* event) {
|
||||||
if (!event->isAutoRepeat()) {
|
if (!event->isAutoRepeat()) {
|
||||||
// this starts an HFActionEvent
|
// this starts an HFActionEvent
|
||||||
HFActionEvent startActionEvent(HFActionEvent::startType(),
|
HFActionEvent startActionEvent(HFActionEvent::startType(),
|
||||||
_myCamera.computeViewPickRay(0.5f, 0.5f));
|
_myCamera.computePickRay(getTrueMouseX(),
|
||||||
|
getTrueMouseY()));
|
||||||
sendEvent(this, &startActionEvent);
|
sendEvent(this, &startActionEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1219,10 +1220,11 @@ void Application::keyReleaseEvent(QKeyEvent* event) {
|
||||||
case Qt::Key_Space: {
|
case Qt::Key_Space: {
|
||||||
if (!event->isAutoRepeat()) {
|
if (!event->isAutoRepeat()) {
|
||||||
// this ends the HFActionEvent
|
// this ends the HFActionEvent
|
||||||
HFActionEvent endActionEvent(HFActionEvent::endType(), _myCamera.computeViewPickRay(0.5f, 0.5f));
|
HFActionEvent endActionEvent(HFActionEvent::endType(),
|
||||||
|
_myCamera.computePickRay(getTrueMouseX(),
|
||||||
|
getTrueMouseY()));
|
||||||
sendEvent(this, &endActionEvent);
|
sendEvent(this, &endActionEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Qt::Key_Escape: {
|
case Qt::Key_Escape: {
|
||||||
|
@ -1231,7 +1233,6 @@ void Application::keyReleaseEvent(QKeyEvent* event) {
|
||||||
HFBackEvent endBackEvent(HFBackEvent::endType());
|
HFBackEvent endBackEvent(HFBackEvent::endType());
|
||||||
sendEvent(this, &endBackEvent);
|
sendEvent(this, &endBackEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
@ -1256,7 +1257,7 @@ void Application::mouseMoveEvent(QMouseEvent* event, unsigned int deviceID) {
|
||||||
_lastMouseMove = usecTimestampNow();
|
_lastMouseMove = usecTimestampNow();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_aboutToQuit) {
|
if (_aboutToQuit) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1267,6 +1268,7 @@ void Application::mouseMoveEvent(QMouseEvent* event, unsigned int deviceID) {
|
||||||
if (_controllerScriptingInterface.isMouseCaptured()) {
|
if (_controllerScriptingInterface.isMouseCaptured()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::mousePressEvent(QMouseEvent* event, unsigned int deviceID) {
|
void Application::mousePressEvent(QMouseEvent* event, unsigned int deviceID) {
|
||||||
|
@ -2297,21 +2299,19 @@ void Application::updateCursor(float deltaTime) {
|
||||||
bool hideMouse = false;
|
bool hideMouse = false;
|
||||||
bool underMouse = _glWidget->underMouse();
|
bool underMouse = _glWidget->underMouse();
|
||||||
|
|
||||||
static const int HIDE_CURSOR_TIMEOUT = 1 * USECS_PER_SECOND; // 1 second
|
static const int HIDE_CURSOR_TIMEOUT = 3 * USECS_PER_SECOND; // 3 second
|
||||||
int elapsed = usecTimestampNow() - _lastMouseMove;
|
int elapsed = usecTimestampNow() - _lastMouseMove;
|
||||||
if ((elapsed > HIDE_CURSOR_TIMEOUT && underMouse) ||
|
if ((elapsed > HIDE_CURSOR_TIMEOUT && underMouse) ||
|
||||||
(OculusManager::isConnected() && Menu::getInstance()->isOptionChecked(MenuOption::EnableVRMode))) {
|
(OculusManager::isConnected() && Menu::getInstance()->isOptionChecked(MenuOption::EnableVRMode))) {
|
||||||
hideMouse = true;
|
hideMouse = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hideMouse != isMouseHidden()) {
|
setCursorVisible(!hideMouse);
|
||||||
setCursorVisible(!hideMouse);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::setCursorVisible(bool visible) {
|
void Application::setCursorVisible(bool visible) {
|
||||||
if (visible) {
|
if (visible) {
|
||||||
_glWidget->setCursor(Qt::ArrowCursor);
|
_glWidget->unsetCursor();
|
||||||
} else {
|
} else {
|
||||||
_glWidget->setCursor(Qt::BlankCursor);
|
_glWidget->setCursor(Qt::BlankCursor);
|
||||||
}
|
}
|
||||||
|
|
|
@ -536,7 +536,7 @@ void ApplicationOverlay::renderPointers() {
|
||||||
glm::vec2 screenPos = sphericalToScreen(glm::vec2(yaw, -pitch));
|
glm::vec2 screenPos = sphericalToScreen(glm::vec2(yaw, -pitch));
|
||||||
|
|
||||||
position = QPoint(screenPos.x, screenPos.y);
|
position = QPoint(screenPos.x, screenPos.y);
|
||||||
QCursor::setPos(application->getGLWidget()->mapToGlobal(position));
|
application->getGLWidget()->cursor().setPos(application->getGLWidget()->mapToGlobal(position));
|
||||||
}
|
}
|
||||||
|
|
||||||
_reticlePosition[MOUSE] = position;
|
_reticlePosition[MOUSE] = position;
|
||||||
|
|
Loading…
Reference in a new issue