Put standard 'makeinput' functions on the base class

This commit is contained in:
Brad Davis 2015-10-16 17:15:46 -07:00
parent 94ff1893d4
commit 1dcf03d61e
2 changed files with 34 additions and 1 deletions

View file

@ -57,3 +57,28 @@ UserInputMapper::PoseValue InputDevice::getPose(int channel) const {
return UserInputMapper::PoseValue();
}
}
UserInputMapper::Input InputDevice::makeInput(controller::StandardButtonChannel button) {
return UserInputMapper::Input(_deviceID, button, UserInputMapper::ChannelType::BUTTON);
}
UserInputMapper::Input InputDevice::makeInput(controller::StandardAxisChannel axis) {
return UserInputMapper::Input(_deviceID, axis, UserInputMapper::ChannelType::AXIS);
}
UserInputMapper::Input InputDevice::makeInput(controller::StandardPoseChannel pose) {
return UserInputMapper::Input(_deviceID, pose, UserInputMapper::ChannelType::POSE);
}
UserInputMapper::InputPair InputDevice::makePair(controller::StandardButtonChannel button, const QString& name) {
return UserInputMapper::InputPair(makeInput(button), name);
}
UserInputMapper::InputPair InputDevice::makePair(controller::StandardAxisChannel axis, const QString& name) {
return UserInputMapper::InputPair(makeInput(axis), name);
}
UserInputMapper::InputPair InputDevice::makePair(controller::StandardPoseChannel pose, const QString& name) {
return UserInputMapper::InputPair(makeInput(pose), name);
}

View file

@ -11,6 +11,7 @@
#pragma once
#include "UserInputMapper.h"
#include "StandardControls.h"
// Event types for each controller
const unsigned int CONTROLLER_0_EVENT = 1500U;
@ -33,7 +34,7 @@ public:
UserInputMapper::PoseValue getPose(int channel) const;
virtual void registerToUserInputMapper(UserInputMapper& mapper) = 0;
virtual void assignDefaultInputMapping(UserInputMapper& mapper) = 0;
virtual void assignDefaultInputMapping(UserInputMapper& mapper) {};
// Update call MUST be called once per simulation loop
// It takes care of updating the action states and deltas
@ -49,10 +50,17 @@ public:
static bool getLowVelocityFilter() { return _lowVelocityFilter; };
UserInputMapper::Input makeInput(controller::StandardButtonChannel button);
UserInputMapper::Input makeInput(controller::StandardAxisChannel axis);
UserInputMapper::Input makeInput(controller::StandardPoseChannel pose);
UserInputMapper::InputPair makePair(controller::StandardButtonChannel button, const QString& name);
UserInputMapper::InputPair makePair(controller::StandardAxisChannel button, const QString& name);
UserInputMapper::InputPair makePair(controller::StandardPoseChannel button, const QString& name);
public slots:
static void setLowVelocityFilter(bool newLowVelocityFilter) { _lowVelocityFilter = newLowVelocityFilter; };
protected:
int _deviceID = 0;
QString _name;