feedback changes

This commit is contained in:
Dante Ruiz 2018-11-05 16:30:30 -08:00
parent f664421fe0
commit 358aa547b1
10 changed files with 121 additions and 16 deletions

View file

@ -31,8 +31,8 @@
"localOrientation": {
"w": 0.000,
"x": 0.000,
"y": 0.976,
"z": 0.216
"y": 0.906,
"z": 0.423
},
"leftMargin": 0.0,
"rightMargin": 0.0,

View file

@ -195,6 +195,10 @@ Item {
keyboardEnabled = HMD.active;
}
Component.onDestruction: {
keyboardRaised = false;
}
Keys.onPressed: {
switch(event.key) {
case Qt.Key_L:

View file

@ -95,6 +95,18 @@ TabletModalWindow {
}
}
Timer {
id: keyboardTimer
repeat: false
interval: 200
onTriggered: {
if (MenuInterface.isOptionChecked("Use 3D Keyboard")) {
KeyboardScriptingInterface.raised = true;
}
}
}
TabletModalFrame {
id: mfRoot
@ -131,6 +143,10 @@ TabletModalWindow {
loginKeyboard.raised = false;
}
Component.onCompleted: {
keyboardTimer.start();
}
Keyboard {
id: loginKeyboard
raised: root.keyboardEnabled && root.keyboardRaised

View file

@ -41,7 +41,7 @@ Rectangle {
}
Component.onDestruction: {
keyboard.raised = false;
KeyboardScriptingInterface.raised = false;
}
Connections {

View file

@ -2644,6 +2644,7 @@ void Application::cleanupBeforeQuit() {
// it accesses the PickManager to delete its associated Pick
DependencyManager::destroy<PointerManager>();
DependencyManager::destroy<PickManager>();
DependencyManager::destroy<KeyboardScriptingInterface>();
DependencyManager::destroy<Keyboard>();
qCDebug(interfaceapp) << "Application::cleanupBeforeQuit() complete";
@ -2929,6 +2930,7 @@ void Application::initializeRenderEngine() {
// Now that OpenGL is initialized, we are sure we have a valid context and can create the various pipeline shaders with success.
DependencyManager::get<GeometryCache>()->initializeShapePipelines();
DependencyManager::get<Keyboard>()->registerKeyboardHighlighting();
});
}

View file

@ -56,14 +56,14 @@ unsigned int PointerScriptingInterface::createPointer(const PickQuery::PickType&
* @property {boolean} [hover=false] If this pointer should generate hover events.
* @property {boolean} [enabled=false]
* @property {Vec3} [tipOffset] The specified offset of the from the joint index.
* @property {Pointers.StylusPointerProperties.model} [model] Data to replace the default model url, positionOffset and rotationOffset. {@link Pointers.StylusPointerProperties.model}
* @property {Pointers.StylusPointerProperties.model} [model] Data to replace the default model url, positionOffset and rotationOffset.
*/
/**jsdoc
* properties defining stylus pick model that can be included to {@link Pointers.StylusPointerProperties}
* @typedef {object} Pointers.StylusPointerProperties.model
* @property {string} [url] url to the model
* @property {Vec3} [dimensions] the dimensions of the model
* @property {Vec3} [positionOffset] the position offset of the model from the parent joint index
* @property {Vec3} [positionOffset] the position offset of the model from the stylus tip.
* @property {Vec3} [rotationOffset] the rotation offset of the model from the parent joint index
*/
unsigned int PointerScriptingInterface::createStylus(const QVariant& properties) const {

View file

@ -44,6 +44,7 @@
#include "raypick/PickScriptingInterface.h"
#include "scripting/HMDScriptingInterface.h"
#include "scripting/WindowScriptingInterface.h"
#include "scripting/SelectionScriptingInterface.h"
#include "DependencyManager.h"
#include "raypick/StylusPointer.h"
@ -53,12 +54,12 @@
static const int LEFT_HAND_CONTROLLER_INDEX = 0;
static const int RIGHT_HAND_CONTROLLER_INDEX = 1;
static const float MALLET_LENGTH = 0.4f;
static const float MALLET_TOUCH_Y_OFFSET = 0.105f;
static const float MALLET_Y_OFFSET = 0.35f;
static const float MALLET_LENGTH = 0.2f;
static const float MALLET_TOUCH_Y_OFFSET = 0.052f;
static const float MALLET_Y_OFFSET = 0.180f;
static const glm::quat MALLET_ROTATION_OFFSET{0.70710678f, 0.0f, -0.70710678f, 0.0f};
static const glm::vec3 MALLET_MODEL_DIMENSIONS{0.05f, MALLET_LENGTH, 0.05f};
static const glm::vec3 MALLET_MODEL_DIMENSIONS{0.03f, MALLET_LENGTH, 0.03f};
static const glm::vec3 MALLET_POSITION_OFFSET{0.0f, -MALLET_Y_OFFSET / 2.0f, 0.0f};
static const glm::vec3 MALLET_TIP_OFFSET{0.0f, MALLET_LENGTH - MALLET_TOUCH_Y_OFFSET, 0.0f};
@ -88,6 +89,28 @@ static const QString BACKSPACE_STRING = "backspace";
static const QString SPACE_STRING = "space";
static const QString ENTER_STRING = "enter";
static const QString KEY_HOVER_HIGHLIGHT = "keyHoverHiglight";
static const QString KEY_PRESSED_HIGHLIGHT = "keyPressesHighlight";
static const QVariantMap KEY_HOVERING_STYLE {
{ "isOutlineSmooth", true },
{ "outlineWidth", 3 },
{ "outlineUnoccludedColor", QVariantMap {{"red", 13}, {"green", 152}, {"blue", 186}}},
{ "outlineUnoccludedAlpha", 1.0 },
{ "outlineOccludedAlpha", 0.0 },
{ "fillUnoccludedAlpha", 0.0 },
{ "fillOccludedAlpha", 0.0 }
};
static const QVariantMap KEY_PRESSING_STYLE {
{ "isOutlineSmooth", true },
{ "outlineWidth", 3 },
{ "fillUnoccludedColor", QVariantMap {{"red", 50}, {"green", 50}, {"blue", 50}}},
{ "outlineUnoccludedAlpha", 0.0 },
{ "outlineOccludedAlpha", 0.0 },
{ "fillUnoccludedAlpha", 0.6 },
{ "fillOccludedAlpha", 0.0 }
};
std::pair<glm::vec3, glm::quat> calculateKeyboardPositionAndOrientation() {
auto myAvatar = DependencyManager::get<AvatarManager>()->getMyAvatar();
auto hmd = DependencyManager::get<HMDScriptingInterface>();
@ -201,10 +224,20 @@ Keyboard::Keyboard() {
connect(pointerManager.data(), &PointerManager::triggerBeginOverlay, this, &Keyboard::handleTriggerBegin, Qt::QueuedConnection);
connect(pointerManager.data(), &PointerManager::triggerContinueOverlay, this, &Keyboard::handleTriggerContinue, Qt::QueuedConnection);
connect(pointerManager.data(), &PointerManager::triggerEndOverlay, this, &Keyboard::handleTriggerEnd, Qt::QueuedConnection);
connect(pointerManager.data(), &PointerManager::hoverBeginOverlay, this, &Keyboard::handleHoverBegin, Qt::QueuedConnection);
connect(pointerManager.data(), &PointerManager::hoverEndOverlay, this, &Keyboard::handleHoverEnd, Qt::QueuedConnection);
connect(myAvatar.get(), &MyAvatar::sensorToWorldScaleChanged, this, &Keyboard::scaleKeyboard, Qt::QueuedConnection);
connect(windowScriptingInterface.data(), &WindowScriptingInterface::domainChanged, [&]() { setRaised(false); });
}
void Keyboard::registerKeyboardHighlighting() {
auto selection = DependencyManager::get<SelectionScriptingInterface>();
selection->enableListHighlight(KEY_HOVER_HIGHLIGHT, KEY_HOVERING_STYLE);
selection->enableListToScene(KEY_HOVER_HIGHLIGHT);
selection->enableListHighlight(KEY_PRESSED_HIGHLIGHT, KEY_PRESSING_STYLE);
selection->enableListToScene(KEY_PRESSED_HIGHLIGHT);
}
void Keyboard::createKeyboard() {
auto pointerManager = DependencyManager::get<PointerManager>();
@ -450,7 +483,7 @@ void Keyboard::handleTriggerBegin(const OverlayID& overlayID, const PointerEvent
AudioInjectorOptions audioOptions;
audioOptions.localOnly = true;
audioOptions.position = keyWorldPosition;
audioOptions.volume = 0.4f;
audioOptions.volume = 0.1f;
AudioInjector::playSound(_keySound->getByteArray(), audioOptions);
@ -504,6 +537,8 @@ void Keyboard::handleTriggerBegin(const OverlayID& overlayID, const PointerEvent
QCoreApplication::postEvent(QCoreApplication::instance(), releaseEvent);
key.startTimer(KEY_PRESS_TIMEOUT_MS);
auto selection = DependencyManager::get<SelectionScriptingInterface>();
selection->addToSelectedItemsList(KEY_PRESSED_HIGHLIGHT, "overlay", overlayID);
}
}
@ -536,6 +571,9 @@ void Keyboard::handleTriggerEnd(const OverlayID& overlayID, const PointerEvent&
if (key.timerFinished()) {
key.startTimer(KEY_PRESS_TIMEOUT_MS);
}
auto selection = DependencyManager::get<SelectionScriptingInterface>();
selection->removeFromSelectedItemsList(KEY_PRESSED_HIGHLIGHT, "overlay", overlayID);
}
void Keyboard::handleTriggerContinue(const OverlayID& overlayID, const PointerEvent& event) {
@ -565,9 +603,8 @@ void Keyboard::handleTriggerContinue(const OverlayID& overlayID, const PointerEv
if (base3DOverlay) {
auto pointerManager = DependencyManager::get<PointerManager>();
auto pickResult = pointerManager->getPrevPickResult(pointerID);
auto pickResultVariant = pickResult->toVariantMap();
float distance = pickResultVariant["distance"].toFloat();
auto stylusPickResult = std::dynamic_pointer_cast<StylusPickResult>(pickResult);
float distance = stylusPickResult->distance;
static const float PENATRATION_THRESHOLD = 0.025f;
if (distance < PENATRATION_THRESHOLD) {
@ -583,6 +620,50 @@ void Keyboard::handleTriggerContinue(const OverlayID& overlayID, const PointerEv
}
}
void Keyboard::handleHoverBegin(const OverlayID& overlayID, const PointerEvent& event) {
if (_keyboardLayers.empty() || !isLayerSwitchTimerFinished()) {
return;
}
auto pointerID = event.getID();
if (pointerID != _leftHandStylus && pointerID != _rightHandStylus) {
return;
}
auto& keyboardLayer = _keyboardLayers[_layerIndex];
auto search = keyboardLayer.find(overlayID);
if (search == keyboardLayer.end()) {
return;
}
auto selection = DependencyManager::get<SelectionScriptingInterface>();
selection->addToSelectedItemsList(KEY_HOVER_HIGHLIGHT, "overlay", overlayID);
}
void Keyboard::handleHoverEnd(const OverlayID& overlayID, const PointerEvent& event) {
if (_keyboardLayers.empty() || !isLayerSwitchTimerFinished()) {
return;
}
auto pointerID = event.getID();
if (pointerID != _leftHandStylus && pointerID != _rightHandStylus) {
return;
}
auto& keyboardLayer = _keyboardLayers[_layerIndex];
auto search = keyboardLayer.find(overlayID);
if (search == keyboardLayer.end()) {
return;
}
auto selection = DependencyManager::get<SelectionScriptingInterface>();
selection->removeFromSelectedItemsList(KEY_HOVER_HIGHLIGHT, "overlay", overlayID);
}
void Keyboard::disableStylus() {
auto pointerManager = DependencyManager::get<PointerManager>();
pointerManager->setRenderState(_leftHandStylus, "events off");

View file

@ -90,6 +90,7 @@ class Keyboard : public Dependency, public QObject, public ReadWriteLockable {
public:
Keyboard();
void createKeyboard();
void registerKeyboardHighlighting();
bool isRaised() const;
void setRaised(bool raised);
@ -103,6 +104,8 @@ public slots:
void handleTriggerBegin(const OverlayID& overlayID, const PointerEvent& event);
void handleTriggerEnd(const OverlayID& overlayID, const PointerEvent& event);
void handleTriggerContinue(const OverlayID& overlayID, const PointerEvent& event);
void handleHoverBegin(const OverlayID& overlayID, const PointerEvent& event);
void handleHoverEnd(const OverlayID& overlayID, const PointerEvent& event);
void scaleKeyboard(float sensorToWorldScale);
private:

View file

@ -147,7 +147,6 @@ void setupPreferences() {
preferences->addPreference(new CheckPreference(UI_CATEGORY, "Prefer Avatar Finger Over Stylus", getter, setter));
}
*/
// Snapshots
static const QString SNAPSHOTS { "Snapshots" };
{

View file

@ -280,8 +280,8 @@ public:
StylusTip(const bilateral::Side& side, const glm::vec3& tipOffset = Vectors::ZERO ,const glm::vec3& position = Vectors::ZERO,
const glm::quat& orientation = Quaternions::IDENTITY, const glm::vec3& velocity = Vectors::ZERO) :
side(side), tipOffset(tipOffset), position(position), orientation(orientation), velocity(velocity) {}
StylusTip(const QVariantMap& pickVariant) : side(bilateral::Side(pickVariant["side"].toInt())), position(vec3FromVariant(pickVariant["position"])),
orientation(quatFromVariant(pickVariant["orientation"])), velocity(vec3FromVariant(pickVariant["velocity"])) {}
StylusTip(const QVariantMap& pickVariant) : side(bilateral::Side(pickVariant["side"].toInt())), tipOffset(vec3FromVariant(pickVariant["tipOffset"])),
position(vec3FromVariant(pickVariant["position"])), orientation(quatFromVariant(pickVariant["orientation"])), velocity(vec3FromVariant(pickVariant["velocity"])) {}
bilateral::Side side { bilateral::Side::Invalid };
glm::vec3 tipOffset;