remove vive keyboard

This commit is contained in:
Seth Alves 2016-09-13 11:27:10 -07:00
parent dff567054d
commit 92bda6827b

View file

@ -44,7 +44,7 @@ static const uint32_t RELEASE_OPENVR_HMD_DELAY_MS = 5000;
bool isOculusPresent() {
bool result = false;
#if defined(Q_OS_WIN32)
#if defined(Q_OS_WIN32)
HANDLE oculusServiceEvent = ::OpenEventW(SYNCHRONIZE, FALSE, L"OculusHMDConnected");
// The existence of the service indicates a running Oculus runtime
if (oculusServiceEvent) {
@ -54,7 +54,7 @@ bool isOculusPresent() {
}
::CloseHandle(oculusServiceEvent);
}
#endif
#endif
return result;
}
@ -123,65 +123,12 @@ static bool _keyboardShown { false };
static bool _overlayRevealed { false };
static const uint32_t SHOW_KEYBOARD_DELAY_MS = 400;
void showOpenVrKeyboard(bool show = true) {
if (!_overlay) {
return;
}
if (show) {
// To avoid flickering the keyboard when a text element is only briefly selected,
// show the keyboard asynchrnously after a very short delay, but only after we check
// that the current focus object is still one that is text enabled
QTimer::singleShot(SHOW_KEYBOARD_DELAY_MS, [] {
auto offscreenUi = DependencyManager::get<OffscreenUi>();
auto currentFocus = offscreenUi->getWindow()->focusObject();
QInputMethodQueryEvent query(Qt::ImEnabled | Qt::ImQueryInput | Qt::ImHints);
qApp->sendEvent(currentFocus, &query);
// Current focus isn't text enabled, bail early.
if (!query.value(Qt::ImEnabled).toBool()) {
return;
}
// We're going to show the keyboard now...
_keyboardFocusObject = currentFocus;
_currentHints = Qt::InputMethodHints(query.value(Qt::ImHints).toUInt());
vr::EGamepadTextInputMode inputMode = vr::k_EGamepadTextInputModeNormal;
if (_currentHints & Qt::ImhHiddenText) {
inputMode = vr::k_EGamepadTextInputModePassword;
}
vr::EGamepadTextInputLineMode lineMode = vr::k_EGamepadTextInputLineModeSingleLine;
if (_currentHints & Qt::ImhMultiLine) {
lineMode = vr::k_EGamepadTextInputLineModeMultipleLines;
}
_existingText = query.value(Qt::ImSurroundingText).toString();
auto showKeyboardResult = _overlay->ShowKeyboard(inputMode, lineMode, "Keyboard", 1024,
_existingText.toLocal8Bit().toStdString().c_str(), false, 0);
if (vr::VROverlayError_None == showKeyboardResult) {
_keyboardShown = true;
// Try to position the keyboard slightly below where the user is looking.
mat4 headPose = cancelOutRollAndPitch(toGlm(_nextSimPoseData.vrPoses[0].mDeviceToAbsoluteTracking));
mat4 keyboardTransform = glm::translate(headPose, vec3(0, -0.5, -1));
keyboardTransform = keyboardTransform * glm::rotate(mat4(), 3.14159f / 4.0f, vec3(-1, 0, 0));
auto keyboardTransformVr = toOpenVr(keyboardTransform);
_overlay->SetKeyboardTransformAbsolute(vr::ETrackingUniverseOrigin::TrackingUniverseStanding, &keyboardTransformVr);
}
});
} else {
_keyboardFocusObject = nullptr;
if (_keyboardShown) {
_overlay->HideKeyboard();
_keyboardShown = false;
}
}
}
void updateFromOpenVrKeyboardInput() {
auto chars = _overlay->GetKeyboardText(textArray, 8192);
auto newText = QString(QByteArray(textArray, chars));
_keyboardFocusObject->setProperty("text", newText);
//// TODO modify the new text to match the possible input hints:
//// ImhDigitsOnly ImhFormattedNumbersOnly ImhUppercaseOnly ImhLowercaseOnly
//// ImhDigitsOnly ImhFormattedNumbersOnly ImhUppercaseOnly ImhLowercaseOnly
//// ImhDialableCharactersOnly ImhEmailCharactersOnly ImhUrlCharactersOnly ImhLatinOnly
//QInputMethodEvent event(_existingText, QList<QInputMethodEvent::Attribute>());
//event.setCommitString(newText, 0, _existingText.size());
@ -208,11 +155,11 @@ void enableOpenVrKeyboard(PluginContainer* container) {
auto offscreenUi = DependencyManager::get<OffscreenUi>();
_overlay = vr::VROverlay();
auto menu = container->getPrimaryMenu();
auto action = menu->getActionForOption(MenuOption::Overlays);
// When the overlays are revealed, suppress the keyboard from appearing on text focus for a tenth of a second.
// When the overlays are revealed, suppress the keyboard from appearing on text focus for a tenth of a second.
_overlayMenuConnection = QObject::connect(action, &QAction::triggered, [action] {
if (action->isChecked()) {
_overlayRevealed = true;
@ -220,23 +167,6 @@ void enableOpenVrKeyboard(PluginContainer* container) {
QTimer::singleShot(KEYBOARD_DELAY_MS, [&] { _overlayRevealed = false; });
}
});
_focusConnection = QObject::connect(offscreenUi->getWindow(), &QQuickWindow::focusObjectChanged, [](QObject* object) {
if (object != _keyboardFocusObject) {
showOpenVrKeyboard(false);
}
});
_focusTextConnection = QObject::connect(offscreenUi.data(), &OffscreenUi::focusTextChanged, [](bool focusText) {
if (_openVrDisplayActive) {
if (_overlayRevealed) {
// suppress at most one text focus event
_overlayRevealed = false;
return;
}
showOpenVrKeyboard(focusText);
}
});
}
@ -276,7 +206,7 @@ void handleOpenVrEvents() {
updateFromOpenVrKeyboardInput();
break;
case vr::VREvent_KeyboardDone:
case vr::VREvent_KeyboardDone:
finishOpenVrKeyboardInput();
// FALL THROUGH