Ability to make cursor invisible again (both OS-cursor and oculus rectile) and js-interface to cursorVisible boolean
Showing the changes to interface/src/Application.cpp (1 of 5 files). Show all
Unified · Split
| @@ -230,6 +230,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 229 unmodified lines | |||
| 230 | _touchAvgX(0.0f), | 230 | _touchAvgX(0.0f), |
| 231 | _touchAvgY(0.0f), | 231 | _touchAvgY(0.0f), |
| 232 | _isTouchPressed(false), | 232 | _isTouchPressed(false), |
| 233 | _cursorVisible(true), | ||
| 233 | _mousePressed(false), | 234 | _mousePressed(false), |
| 234 | _enableProcessOctreeThread(true), | 235 | _enableProcessOctreeThread(true), |
| 235 | _octreeProcessor(), | 236 | _octreeProcessor(), |
| @@ -1480,6 +1481,8 @@ void Application::setEnableVRMode(bool enableVRMode) { · 1244 unmodified lines | |||
| 1480 | 1481 | ||
| 1481 | auto glCanvas = DependencyManager::get<GLCanvas>(); | 1482 | auto glCanvas = DependencyManager::get<GLCanvas>(); |
| 1482 | resizeGL(glCanvas->getDeviceWidth(), glCanvas->getDeviceHeight()); | 1483 | resizeGL(glCanvas->getDeviceWidth(), glCanvas->getDeviceHeight()); |
| 1484 | |||
| 1485 | updateCursorVisibility(); | ||
| 1483 | } | 1486 | } |
| 1484 | 1487 | ||
| 1485 | void Application::setLowVelocityFilter(bool lowVelocityFilter) { | 1488 | void Application::setLowVelocityFilter(bool lowVelocityFilter) { |
| @@ -1947,35 +1950,22 @@ void Application::updateCursor(float deltaTime) { · 461 unmodified lines | |||
| 1947 | 1950 | ||
| 1948 | static QPoint lastMousePos = QPoint(); | 1951 | static QPoint lastMousePos = QPoint(); |
| 1949 | _lastMouseMove = (lastMousePos == QCursor::pos()) ? _lastMouseMove : usecTimestampNow(); | 1952 | _lastMouseMove = (lastMousePos == QCursor::pos()) ? _lastMouseMove : usecTimestampNow(); |
| 1950 | bool hideMouse = false; | ||
| 1951 | bool underMouse = QGuiApplication::topLevelAt(QCursor::pos()) == | ||
| 1952 | Application::getInstance()->getWindow()->windowHandle(); | ||
| 1953 | |||
| 1954 | static const int HIDE_CURSOR_TIMEOUT = 3 * USECS_PER_SECOND; // 3 second | ||
| 1955 | int elapsed = usecTimestampNow() - _lastMouseMove; | ||
| 1956 | if ((elapsed > HIDE_CURSOR_TIMEOUT) || | ||
| 1957 | (OculusManager::isConnected() && Menu::getInstance()->isOptionChecked(MenuOption::EnableVRMode))) { | ||
| 1958 | hideMouse = underMouse; | ||
| 1959 | } | ||
| 1960 | |||
| 1961 | setCursorVisible(!hideMouse); | ||
| 1962 | lastMousePos = QCursor::pos(); | 1953 | lastMousePos = QCursor::pos(); |
| 1963 | } | 1954 | } |
| 1964 | 1955 | ||
| 1965 | void Application::setCursorVisible(bool visible) { | 1956 | void Application::updateCursorVisibility() { |
| 1966 | if (visible) { | 1957 | if (!_cursorVisible || Menu::getInstance()->isOptionChecked(MenuOption::EnableVRMode)) { |
| 1967 | if (overrideCursor() != NULL) { | 1958 | DependencyManager::get<GLCanvas>()->setCursor(Qt::BlankCursor); |
| 1968 | restoreOverrideCursor(); | ||
| 1969 | } | ||
| 1970 | } else { | 1959 | } else { |
| 1971 | if (overrideCursor() != NULL) { | 1960 | DependencyManager::get<GLCanvas>()->unsetCursor(); |
| 1972 | changeOverrideCursor(Qt::BlankCursor); | ||
| 1973 | } else { | ||
| 1974 | setOverrideCursor(Qt::BlankCursor); | ||
| 1975 | } | ||
| 1976 | } | 1961 | } |
| 1977 | } | 1962 | } |
| 1978 | 1963 | ||
| 1964 | void Application::setCursorVisible(bool visible) { | ||
| 1965 | _cursorVisible = visible; | ||
| 1966 | updateCursorVisibility(); | ||
| 1967 | } | ||
| 1968 | |||
| 1979 | void Application::update(float deltaTime) { | 1969 | void Application::update(float deltaTime) { |
| 1980 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); | 1970 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); |
| 1981 | PerformanceWarning warn(showWarnings, "Application::update()"); | 1971 | PerformanceWarning warn(showWarnings, "Application::update()"); |