mirror of
https://github.com/overte-org/overte.git
synced 2025-08-04 02:03:36 +02:00
MErging maybe finally ??????
This commit is contained in:
parent
2ad6c2067b
commit
249efa383e
1 changed files with 0 additions and 171 deletions
|
@ -93,177 +93,6 @@ QVector<QString> UserInputMapper::getDeviceNames() {
|
||||||
}
|
}
|
||||||
|
|
||||||
UserInputMapper::Input UserInputMapper::findDeviceInput(const QString& inputName) const {
|
UserInputMapper::Input UserInputMapper::findDeviceInput(const QString& inputName) const {
|
||||||
/*=======
|
|
||||||
|
|
||||||
// Default contruct allocate the poutput size with the current hardcoded action channels
|
|
||||||
UserInputMapper::UserInputMapper() {
|
|
||||||
registerStandardDevice();
|
|
||||||
assignDefaulActionScales();
|
|
||||||
createActionNames();
|
|
||||||
}
|
|
||||||
|
|
||||||
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) {
|
|
||||||
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());
|
|
||||||
if (device != _registeredDevices.end()) {
|
|
||||||
return (device->second);
|
|
||||||
} else {
|
|
||||||
return DeviceProxy::Pointer();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void UserInputMapper::resetDevice(uint16 deviceID) {
|
|
||||||
auto device = _registeredDevices.find(deviceID);
|
|
||||||
if (device != _registeredDevices.end()) {
|
|
||||||
device->second->resetDeviceBindings();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int UserInputMapper::findDevice(QString name) {
|
|
||||||
for (auto device : _registeredDevices) {
|
|
||||||
if (device.second->_name.split(" (")[0] == name) {
|
|
||||||
return device.first;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
QVector<QString> UserInputMapper::getDeviceNames() {
|
|
||||||
QVector<QString> result;
|
|
||||||
for (auto device : _registeredDevices) {
|
|
||||||
QString deviceName = device.second->_name.split(" (")[0];
|
|
||||||
result << deviceName;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool UserInputMapper::addInputChannel(Action action, const Input& input, float scale) {
|
|
||||||
return addInputChannel(action, input, Input(), scale);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool UserInputMapper::addInputChannel(Action action, const Input& input, const Input& modifier, float scale) {
|
|
||||||
// Check that the device is registered
|
|
||||||
if (!getDeviceProxy(input)) {
|
|
||||||
qDebug() << "UserInputMapper::addInputChannel: The input comes from a device #" << input.getDevice() << "is unknown. no inputChannel mapped.";
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto inputChannel = InputChannel(input, modifier, action, scale);
|
|
||||||
|
|
||||||
// Insert or replace the input to modifiers
|
|
||||||
if (inputChannel.hasModifier()) {
|
|
||||||
auto& modifiers = _inputToModifiersMap[input.getID()];
|
|
||||||
modifiers.push_back(inputChannel._modifier);
|
|
||||||
std::sort(modifiers.begin(), modifiers.end());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Now update the action To Inputs side of things
|
|
||||||
_actionToInputsMap.insert(ActionToInputsMap::value_type(action, inputChannel));
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
int UserInputMapper::addInputChannels(const InputChannels& channels) {
|
|
||||||
int nbAdded = 0;
|
|
||||||
for (auto& channel : channels) {
|
|
||||||
nbAdded += addInputChannel(channel._action, channel._input, channel._modifier, channel._scale);
|
|
||||||
}
|
|
||||||
return nbAdded;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool UserInputMapper::removeInputChannel(InputChannel inputChannel) {
|
|
||||||
// Remove from Input to Modifiers map
|
|
||||||
if (inputChannel.hasModifier()) {
|
|
||||||
_inputToModifiersMap.erase(inputChannel._input.getID());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Remove from Action to Inputs map
|
|
||||||
std::pair<ActionToInputsMap::iterator, ActionToInputsMap::iterator> ret;
|
|
||||||
ret = _actionToInputsMap.equal_range(inputChannel._action);
|
|
||||||
for (ActionToInputsMap::iterator it=ret.first; it!=ret.second; ++it) {
|
|
||||||
if (it->second == inputChannel) {
|
|
||||||
_actionToInputsMap.erase(it);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void UserInputMapper::removeAllInputChannels() {
|
|
||||||
_inputToModifiersMap.clear();
|
|
||||||
_actionToInputsMap.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
void UserInputMapper::removeAllInputChannelsForDevice(uint16 device) {
|
|
||||||
QVector<InputChannel> channels = getAllInputsForDevice(device);
|
|
||||||
for (auto& channel : channels) {
|
|
||||||
removeInputChannel(channel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void UserInputMapper::removeDevice(int device) {
|
|
||||||
removeAllInputChannelsForDevice((uint16) device);
|
|
||||||
_registeredDevices.erase(device);
|
|
||||||
}
|
|
||||||
|
|
||||||
int UserInputMapper::getInputChannels(InputChannels& channels) const {
|
|
||||||
for (auto& channel : _actionToInputsMap) {
|
|
||||||
channels.push_back(channel.second);
|
|
||||||
}
|
|
||||||
|
|
||||||
return _actionToInputsMap.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
QVector<UserInputMapper::InputChannel> UserInputMapper::getAllInputsForDevice(uint16 device) {
|
|
||||||
InputChannels allChannels;
|
|
||||||
getInputChannels(allChannels);
|
|
||||||
|
|
||||||
QVector<InputChannel> channels;
|
|
||||||
for (InputChannel inputChannel : allChannels) {
|
|
||||||
if (inputChannel._input._device == device) {
|
|
||||||
channels.push_back(inputChannel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
>>>>>>> 80cffdb764d3faa5516c8b0eb0a49d84cc395416*/
|
|
||||||
|
|
||||||
// Split the full input name as such: deviceName.inputName
|
// Split the full input name as such: deviceName.inputName
|
||||||
auto names = inputName.split('.');
|
auto names = inputName.split('.');
|
||||||
|
|
Loading…
Reference in a new issue