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,8 +28,22 @@ UserInputMapper::~UserInputMapper() {
} }
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) { bool UserInputMapper::registerDevice(uint16 deviceID, const DeviceProxy::Pointer& proxy) {
proxy->_name += " (" + QString::number(deviceID) + ")"; int numberOfType = recordDeviceOfType(proxy->_name);
if (numberOfType > 1) {
proxy->_name += QString::number(numberOfType);
}
_registeredDevices[deviceID] = proxy; _registeredDevices[deviceID] = proxy;
return true; return true;
} }

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

View file

@ -122,6 +122,7 @@ void SixenseManager::activate() {
#endif #endif
loadSettings(); loadSettings();
sixenseInit(); sixenseInit();
_activated = true;
#endif #endif
} }
@ -138,6 +139,7 @@ void SixenseManager::deactivate() {
#endif #endif
sixenseExit(); sixenseExit();
_activated = false;
#ifdef __APPLE__ #ifdef __APPLE__
delete _sixenseLibrary; delete _sixenseLibrary;
@ -157,6 +159,12 @@ void SixenseManager::setSixenseFilter(bool filter) {
} }
void SixenseManager::update(float deltaTime, bool jointsCaptured) { 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 #ifdef HAVE_SIXENSE
_buttonPressedMap.clear(); _buttonPressedMap.clear();

View file

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