Trying to get a state controller to work

This commit is contained in:
samcake 2015-10-28 09:23:20 -07:00
parent b2a5452f87
commit 92ca658aae
4 changed files with 57 additions and 57 deletions

View file

@ -3,6 +3,7 @@
"channels": [
{ "from": "Standard.LY", "to": "Actions.TranslateZ" },
{ "from": "Standard.LX", "to": "Actions.TranslateX" },
{ "from": "Standard.RX", "width": "Application.InHMD", to": "Actions.StepYaw" },
{ "from": "Standard.RX", "to": "Actions.Yaw" },
{ "from": "Standard.RY", "to": "Actions.Pitch" },

View file

@ -143,6 +143,8 @@
#include "ui/UpdateDialog.h"
#include "Util.h"
#include "controllers/StateController.h"
// ON WIndows PC, NVidia Optimus laptop, we want to enable NVIDIA GPU
// FIXME seems to be broken.
#if defined(Q_OS_WIN)
@ -633,9 +635,19 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) :
}
});
static controller::StateController _stateController;
auto InHMDLambda = controller::StateController::ReadLambda([]() -> float {
return (float) qApp->getAvatarUpdater()->isHMDMode();
});
_stateController.addInputVariant("InHMD", InHMDLambda);
userInputMapper->registerDevice(&_stateController);
// Setup the keyboardMouseDevice and the user input mapper with the default bindings
userInputMapper->registerDevice(_keyboardMouseDevice);
//userInputMapper->getApplicationDevice()->(float)qApp->getAvatarUpdater()->isHMDMode()
// check first run...
if (_firstRun.get()) {
qCDebug(interfaceapp) << "This is a first run...";
@ -2703,9 +2715,6 @@ 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);

View file

@ -21,6 +21,7 @@
#include <NumericalConstants.h>
#include "StandardController.h"
#include "StateController.h"
#include "Logging.h"
@ -43,7 +44,6 @@
namespace controller {
const uint16_t UserInputMapper::ACTIONS_DEVICE = Input::INVALID_DEVICE - 0xFF;
const uint16_t UserInputMapper::STATE_DEVICE = ACTIONS_DEVICE - 0xFF;
const uint16_t UserInputMapper::STANDARD_DEVICE = 0;
}
@ -1021,13 +1021,5 @@ void UserInputMapper::disableMapping(const Mapping::Pointer& mapping) {
}
}
void UserInputMapper::resetActionState(Action action, float value) {
auto endpoint = endpointFor(inputFromAction(action));
if (endpoint) {
endpoint->apply(value, Endpoint::Pointer());
}
_actionStates[toInt(action)] = value;
}
}

View file

@ -58,7 +58,6 @@ namespace controller {
static const uint16_t ACTIONS_DEVICE;
static const uint16_t STANDARD_DEVICE;
static const uint16_t STATE_DEVICE;
UserInputMapper();
virtual ~UserInputMapper();
@ -87,7 +86,6 @@ namespace controller {
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; }