mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-09 05:03:41 +02:00
Supporting a InHMD action and using it to enable COmfort mode
This commit is contained in:
parent
b2c3311947
commit
87cf3b237b
6 changed files with 27 additions and 6 deletions
|
@ -3,6 +3,7 @@
|
|||
"channels": [
|
||||
{ "from": "Standard.LY", "to": "Actions.TranslateZ" },
|
||||
{ "from": "Standard.LX", "to": "Actions.TranslateX" },
|
||||
{ "from": "Standard.RX", "with": "Actions.InHMD", "to": "Actions.StepYaw" },
|
||||
{ "from": "Standard.RX", "to": "Actions.Yaw" },
|
||||
{ "from": "Standard.RY", "to": "Actions.Pitch" },
|
||||
|
||||
|
|
|
@ -2703,6 +2703,9 @@ void Application::update(float deltaTime) {
|
|||
|
||||
auto myAvatar = getMyAvatar();
|
||||
auto userInputMapper = DependencyManager::get<UserInputMapper>();
|
||||
// Reflect some state into the Actions of the UserInpuMapper
|
||||
userInputMapper->resetActionState(controller::Action::IN_HMD, (float)qApp->getAvatarUpdater()->isHMDMode());
|
||||
|
||||
userInputMapper->setSensorToWorldMat(myAvatar->getSensorToWorldMatrix());
|
||||
userInputMapper->update(deltaTime);
|
||||
|
||||
|
@ -2738,6 +2741,11 @@ void Application::update(float deltaTime) {
|
|||
}
|
||||
myAvatar->setDriveKeys(ZOOM, userInputMapper->getActionState(controller::Action::TRANSLATE_CAMERA_Z));
|
||||
}
|
||||
|
||||
float lhc = userInputMapper->getActionState(controller::Action::LEFT_HAND_CLICK);
|
||||
if (lhc != 0.0f) {
|
||||
std::cout << "Left Hand click = " << lhc << std::endl;
|
||||
}
|
||||
controller::Pose leftHand = userInputMapper->getPoseState(controller::Action::LEFT_HAND);
|
||||
controller::Pose rightHand = userInputMapper->getPoseState(controller::Action::RIGHT_HAND);
|
||||
Hand* hand = DependencyManager::get<AvatarManager>()->getMyAvatar()->getHand();
|
||||
|
|
|
@ -75,6 +75,8 @@ namespace controller {
|
|||
makeAxisPair(Action::BOOM_IN, "BoomIn"),
|
||||
makeAxisPair(Action::BOOM_OUT, "BoomOut"),
|
||||
|
||||
makeButtonPair(Action::IN_HMD, "InHMD"),
|
||||
|
||||
// Deprecated aliases
|
||||
// FIXME remove after we port all scripts
|
||||
makeAxisPair(Action::LONGITUDINAL_BACKWARD, "LONGITUDINAL_BACKWARD"),
|
||||
|
|
|
@ -78,6 +78,8 @@ enum class Action {
|
|||
BOOM_IN,
|
||||
BOOM_OUT,
|
||||
|
||||
IN_HMD, // THis is a read only action ?
|
||||
|
||||
NUM_ACTIONS,
|
||||
};
|
||||
|
||||
|
|
|
@ -953,19 +953,17 @@ Mapping::Pointer UserInputMapper::parseMapping(const QString& json) {
|
|||
QJsonDocument doc = QJsonDocument::fromJson(json.toUtf8(), &error);
|
||||
// check validity of the document
|
||||
if (doc.isNull()) {
|
||||
qDebug() << "Invalid JSON...\n";
|
||||
qDebug() << error.errorString();
|
||||
qDebug() << "JSON was:\n" << json << endl;
|
||||
return Mapping::Pointer();
|
||||
}
|
||||
|
||||
if (!doc.isObject()) {
|
||||
qWarning() << "Mapping json Document is not an object" << endl;
|
||||
qDebug() << "JSON was:\n" << json << endl;
|
||||
return Mapping::Pointer();
|
||||
}
|
||||
|
||||
// FIXME how did we detect this?
|
||||
// qDebug() << "Invalid JSON...\n";
|
||||
// qDebug() << error.errorString();
|
||||
// qDebug() << "JSON was:\n" << json << endl;
|
||||
//}
|
||||
return parseMapping(doc.object());
|
||||
}
|
||||
|
||||
|
@ -1019,5 +1017,13 @@ void UserInputMapper::disableMapping(const Mapping::Pointer& mapping) {
|
|||
}
|
||||
}
|
||||
|
||||
void UserInputMapper::resetActionState(Action action, float value) {
|
||||
auto endpoint = endpointFor(inputFromAction(action));
|
||||
if (endpoint) {
|
||||
endpoint->apply(value, 0.0f, Endpoint::Pointer());
|
||||
}
|
||||
_actionStates[toInt(action)] = value;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -84,7 +84,9 @@ namespace controller {
|
|||
Pose getPoseState(Action action) const { return _poseStates[toInt(action)]; }
|
||||
int findAction(const QString& actionName) const;
|
||||
QVector<QString> getActionNames() const;
|
||||
Input inputFromAction(Action action) const { return getActionInputs()[toInt(action)].first; }
|
||||
|
||||
void resetActionState(Action action, float value);
|
||||
void setActionState(Action action, float value) { _actionStates[toInt(action)] = value; }
|
||||
void deltaActionState(Action action, float delta) { _actionStates[toInt(action)] += delta; }
|
||||
void setActionState(Action action, const Pose& value) { _poseStates[toInt(action)] = value; }
|
||||
|
|
Loading…
Reference in a new issue