Merge pull request #6082 from ZappoMan/renameInputPlugins

Controllers branch - Rename input plugins
This commit is contained in:
Brad Davis 2015-10-15 12:29:35 -07:00
commit 80cffdb764
4 changed files with 34 additions and 5 deletions

View file

@ -28,11 +28,25 @@ UserInputMapper::~UserInputMapper() {
}
bool UserInputMapper::registerDevice(uint16 deviceID, const DeviceProxy::Pointer& proxy){
proxy->_name += " (" + QString::number(deviceID) + ")";
_registeredDevices[deviceID] = proxy;
return true;
}
int UserInputMapper::recordDeviceOfType(const QString& deviceName) {
if (!_deviceCounts.contains(deviceName)) {
_deviceCounts[deviceName] = 0;
}
_deviceCounts[deviceName] += 1;
return _deviceCounts[deviceName];
}
bool UserInputMapper::registerDevice(uint16 deviceID, const DeviceProxy::Pointer& proxy) {
int numberOfType = recordDeviceOfType(proxy->_name);
if (numberOfType > 1) {
proxy->_name += QString::number(numberOfType);
}
_registeredDevices[deviceID] = proxy;
return true;
}
UserInputMapper::DeviceProxy::Pointer UserInputMapper::getDeviceProxy(const Input& input) {
auto device = _registeredDevices.find(input.getDevice());

View file

@ -133,6 +133,7 @@ public:
};
// GetFreeDeviceID should be called before registering a device to use an ID not used by a different device.
uint16 getFreeDeviceID() { return _nextFreeDeviceID++; }
bool registerDevice(uint16 deviceID, const DeviceProxy::Pointer& device);
bool registerStandardDevice(const DeviceProxy::Pointer& device) { _standardDevice = device; return true; }
DeviceProxy::Pointer getDeviceProxy(const Input& input);
@ -293,6 +294,9 @@ protected:
std::vector<PoseValue> _poseStates = std::vector<PoseValue>(NUM_ACTIONS);
glm::mat4 _sensorToWorldMat;
int recordDeviceOfType(const QString& deviceName);
QHash<const QString&, int> _deviceCounts;
};
Q_DECLARE_METATYPE(UserInputMapper::InputPair)

View file

@ -122,6 +122,7 @@ void SixenseManager::activate() {
#endif
loadSettings();
sixenseInit();
_activated = true;
#endif
}
@ -138,6 +139,7 @@ void SixenseManager::deactivate() {
#endif
sixenseExit();
_activated = false;
#ifdef __APPLE__
delete _sixenseLibrary;
@ -157,6 +159,12 @@ void SixenseManager::setSixenseFilter(bool filter) {
}
void SixenseManager::update(float deltaTime, bool jointsCaptured) {
// FIXME - Some of the code in update() will crash if you haven't actually activated the
// plugin. But we want register with the UserInputMapper if we don't call this.
// We need to clean this up.
//if (!_activated) {
// return;
//}
#ifdef HAVE_SIXENSE
_buttonPressedMap.clear();

View file

@ -118,6 +118,9 @@ private:
static const QString NAME;
static const QString HYDRA_ID_STRING;
bool _activated = false;
};
#endif // hifi_SixenseManager_h