Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Gui: [skip ci] support to remap motion data array of space mouse
  • Loading branch information
wwmayer committed Oct 12, 2020
1 parent da7f105 commit e3c30e7
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/Gui/GuiApplicationNativeEventAware.cpp
Expand Up @@ -21,6 +21,9 @@
***************************************************************************/

#include "PreCompiled.h"
#include <algorithm>
#include <iomanip>
#include <sstream>

#include <QGlobalStatic>
#include <QMainWindow>
Expand Down Expand Up @@ -154,6 +157,29 @@ void Gui::GUIApplicationNativeEventAware::importSettings(std::vector<int>& motio
{
ParameterGrp::handle group = App::GetApplication().GetUserParameter().GetGroup("BaseApp")->GetGroup("Spaceball")->GetGroup("Motion");

// Remapping of motion data
long remap = group->GetInt("Remapping", 12345);
if (remap != 12345) {
std::stringstream s;
s << std::setfill('0') << std::setw(6) << remap;

std::string str;
s >> str;

// the string must have a length of 6 and it must contain all digits 0,...,5
std::string::size_type pos1 = str.find_first_not_of("012345");
std::string::size_type pos2 = std::string("012345").find_first_not_of(str);
if (pos1 == std::string::npos && pos2 == std::string::npos) {
std::vector<int> vec(str.size());
std::transform(str.begin(), str.end(), vec.begin(), [](char c) -> int { return c - '0';});

std::vector<int> copy = motionDataArray;
for (int i=0; i<6; i++) {
motionDataArray[i] = copy[vec[i]];
}
}
}

// here I import settings from a dialog. For now they are set as is
bool dominant = group->GetBool("Dominant"); // Is dominant checked
bool flipXY = group->GetBool("FlipYZ");; // Is Flip X/Y checked
Expand Down

0 comments on commit e3c30e7

Please sign in to comment.