Merge pull request #5659 from jherico/nelson

Fix UserInputMapper event generation
This commit is contained in:
Brad Hefta-Gaub 2015-08-25 22:14:37 -07:00
commit 5d5c1584c3
2 changed files with 5 additions and 1 deletions

View file

@ -226,9 +226,12 @@ void UserInputMapper::update(float deltaTime) {
}
// Scale all the channel step with the scale
static const float EPSILON = 0.01f;
for (auto i = 0; i < NUM_ACTIONS; i++) {
_actionStates[i] *= _actionScales[i];
if (_actionStates[i] > 0) {
// Emit only on change, and emit when moving back to 0
if (fabs(_actionStates[i] - _lastActionStates[i]) > EPSILON) {
_lastActionStates[i] = _actionStates[i];
emit actionEvent(i, _actionStates[i]);
}
// TODO: emit signal for pose changes

View file

@ -248,6 +248,7 @@ protected:
std::vector<float> _actionStates = std::vector<float>(NUM_ACTIONS, 0.0f);
std::vector<float> _actionScales = std::vector<float>(NUM_ACTIONS, 1.0f);
std::vector<float> _lastActionStates = std::vector<float>(NUM_ACTIONS, 0.0f);
std::vector<PoseValue> _poseStates = std::vector<PoseValue>(NUM_ACTIONS);
glm::mat4 _sensorToWorldMat;