diff --git a/libraries/controllers/src/controllers/UserInputMapper.cpp b/libraries/controllers/src/controllers/UserInputMapper.cpp index 0d0ae7d85f..fbf1994d87 100755 --- a/libraries/controllers/src/controllers/UserInputMapper.cpp +++ b/libraries/controllers/src/controllers/UserInputMapper.cpp @@ -31,14 +31,28 @@ UserInputMapper::UserInputMapper() { UserInputMapper::~UserInputMapper() { } - -bool UserInputMapper::registerDevice(uint16 deviceID, const DeviceProxy::Pointer& proxy){ - proxy->_name += " (" + QString::number(deviceID) + ")"; - _registeredDevices[deviceID] = proxy; - qCDebug(controllers) << "Registered input device <" << proxy->_name << "> deviceID = " << deviceID; - 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); + } + + qCDebug(controllers) << "Registered input device <" << proxy->_name << "> deviceID = " << deviceID; + _registeredDevices[deviceID] = proxy; + return true; + +} + + bool UserInputMapper::registerStandardDevice(const DeviceProxy::Pointer& device) { device->_name = "Standard"; // Just to make sure _registeredDevices[getStandardDeviceID()] = device;