fix crash in Controller when asking for device name out of bounds

This commit is contained in:
Brad Hefta-Gaub 2015-08-24 14:35:19 -07:00
parent 275cdf9d8f
commit 6549e47dbc
2 changed files with 9 additions and 1 deletions

View file

@ -32,6 +32,14 @@ UserInputMapper::DeviceProxy::Pointer UserInputMapper::getDeviceProxy(const Inpu
}
}
QString UserInputMapper::getDeviceName(uint16 deviceID) {
if (_registeredDevices.find(deviceID) != _registeredDevices.end()) {
return _registeredDevices[deviceID]->_name;
}
return QString("unknown");
}
void UserInputMapper::resetAllDeviceBindings() {
for (auto device : _registeredDevices) {
device.second->resetDeviceBindings();

View file

@ -123,7 +123,7 @@ public:
uint16 getFreeDeviceID() { return _nextFreeDeviceID++; }
bool registerDevice(uint16 deviceID, const DeviceProxy::Pointer& device);
DeviceProxy::Pointer getDeviceProxy(const Input& input);
QString getDeviceName(uint16 deviceID) { return _registeredDevices[deviceID]->_name; }
QString getDeviceName(uint16 deviceID);
QVector<InputPair> getAvailableInputs(uint16 deviceID) { return _registeredDevices[deviceID]->getAvailabeInputs(); }
void resetAllDeviceBindings();
void resetDevice(uint16 deviceID);