mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 15:58:35 +02:00
Merge pull request #1046 from overte-org/fix/offscreen_ui_keyboard
Allow events from VR keyboard to overlay UI
This commit is contained in:
commit
a91ae5aea4
4 changed files with 32 additions and 4 deletions
|
@ -8594,6 +8594,14 @@ SharedSoundPointer Application::getSampleSound() const {
|
||||||
return _sampleSound;
|
return _sampleSound;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Application::showVRKeyboardForHudUI(bool show) {
|
||||||
|
if (show) {
|
||||||
|
DependencyManager::get<Keyboard>()->setRaised(true, true);
|
||||||
|
} else {
|
||||||
|
DependencyManager::get<Keyboard>()->setRaised(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Application::loadLODToolsDialog() {
|
void Application::loadLODToolsDialog() {
|
||||||
auto tabletScriptingInterface = DependencyManager::get<TabletScriptingInterface>();
|
auto tabletScriptingInterface = DependencyManager::get<TabletScriptingInterface>();
|
||||||
auto tablet = dynamic_cast<TabletProxy*>(tabletScriptingInterface->getTablet(SYSTEM_TABLET));
|
auto tablet = dynamic_cast<TabletProxy*>(tabletScriptingInterface->getTablet(SYSTEM_TABLET));
|
||||||
|
|
|
@ -431,6 +431,16 @@ public slots:
|
||||||
Q_INVOKABLE void loadAddAvatarBookmarkDialog() const;
|
Q_INVOKABLE void loadAddAvatarBookmarkDialog() const;
|
||||||
Q_INVOKABLE void loadAvatarBrowser() const;
|
Q_INVOKABLE void loadAvatarBrowser() const;
|
||||||
Q_INVOKABLE SharedSoundPointer getSampleSound() const;
|
Q_INVOKABLE SharedSoundPointer getSampleSound() const;
|
||||||
|
/**
|
||||||
|
* @brief Shows/hides VR keyboard input for Overlay windows
|
||||||
|
*
|
||||||
|
* This is used by QML scripts to show and hide VR keyboard. Unlike JS API Keyboard.raised = true,
|
||||||
|
* with showVRKeyboardForHudUI the input is passed to the active window on the overlay first.
|
||||||
|
*
|
||||||
|
* @param show
|
||||||
|
* If set to true, then keyboard is shown, for false it's hidden.
|
||||||
|
*/
|
||||||
|
Q_INVOKABLE void showVRKeyboardForHudUI(bool show);
|
||||||
|
|
||||||
void showDialog(const QUrl& widgetUrl, const QUrl& tabletUrl, const QString& name) const;
|
void showDialog(const QUrl& widgetUrl, const QUrl& tabletUrl, const QString& name) const;
|
||||||
|
|
||||||
|
|
|
@ -303,10 +303,13 @@ bool Keyboard::isRaised() const {
|
||||||
return resultWithReadLock<bool>([&] { return _raised; });
|
return resultWithReadLock<bool>([&] { return _raised; });
|
||||||
}
|
}
|
||||||
|
|
||||||
void Keyboard::setRaised(bool raised) {
|
void Keyboard::setRaised(bool raised, bool inputToHudUI) {
|
||||||
|
|
||||||
bool isRaised;
|
bool isRaised;
|
||||||
withReadLock([&] { isRaised = _raised; });
|
withReadLock([&] { isRaised = _raised; });
|
||||||
|
|
||||||
|
_inputToHudUI = inputToHudUI;
|
||||||
|
|
||||||
if (isRaised != raised) {
|
if (isRaised != raised) {
|
||||||
raiseKeyboardAnchor(raised);
|
raiseKeyboardAnchor(raised);
|
||||||
raiseKeyboard(raised);
|
raiseKeyboard(raised);
|
||||||
|
@ -585,8 +588,13 @@ void Keyboard::handleTriggerBegin(const QUuid& id, const PointerEvent& event) {
|
||||||
|
|
||||||
QKeyEvent* pressEvent = new QKeyEvent(QEvent::KeyPress, scanCode, Qt::NoModifier, keyString);
|
QKeyEvent* pressEvent = new QKeyEvent(QEvent::KeyPress, scanCode, Qt::NoModifier, keyString);
|
||||||
QKeyEvent* releaseEvent = new QKeyEvent(QEvent::KeyRelease, scanCode, Qt::NoModifier, keyString);
|
QKeyEvent* releaseEvent = new QKeyEvent(QEvent::KeyRelease, scanCode, Qt::NoModifier, keyString);
|
||||||
QCoreApplication::postEvent(QCoreApplication::instance(), pressEvent);
|
if (_inputToHudUI) {
|
||||||
QCoreApplication::postEvent(QCoreApplication::instance(), releaseEvent);
|
QCoreApplication::postEvent(qApp->getPrimaryWidget(), pressEvent);
|
||||||
|
QCoreApplication::postEvent(qApp->getPrimaryWidget(), releaseEvent);
|
||||||
|
} else {
|
||||||
|
QCoreApplication::postEvent(QCoreApplication::instance(), pressEvent);
|
||||||
|
QCoreApplication::postEvent(QCoreApplication::instance(), releaseEvent);
|
||||||
|
}
|
||||||
|
|
||||||
if (!getPreferMalletsOverLasers()) {
|
if (!getPreferMalletsOverLasers()) {
|
||||||
key.startTimer(KEY_PRESS_TIMEOUT_MS);
|
key.startTimer(KEY_PRESS_TIMEOUT_MS);
|
||||||
|
|
|
@ -93,7 +93,7 @@ public:
|
||||||
void createKeyboard();
|
void createKeyboard();
|
||||||
void registerKeyboardHighlighting();
|
void registerKeyboardHighlighting();
|
||||||
bool isRaised() const;
|
bool isRaised() const;
|
||||||
void setRaised(bool raised);
|
void setRaised(bool raised, bool inputToHudUI = false);
|
||||||
void setResetKeyboardPositionOnRaise(bool reset);
|
void setResetKeyboardPositionOnRaise(bool reset);
|
||||||
bool isPassword() const;
|
bool isPassword() const;
|
||||||
void setPassword(bool password);
|
void setPassword(bool password);
|
||||||
|
@ -190,6 +190,8 @@ private:
|
||||||
QSet<QUuid> _itemsToIgnore;
|
QSet<QUuid> _itemsToIgnore;
|
||||||
std::vector<QHash<QUuid, Key>> _keyboardLayers;
|
std::vector<QHash<QUuid, Key>> _keyboardLayers;
|
||||||
|
|
||||||
|
// Send keyboard events to hud UI if true
|
||||||
|
std::atomic<bool> _inputToHudUI { false };
|
||||||
bool _created { false };
|
bool _created { false };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue