From e3c30e7481a73c2e0869a432b0a5305b5c137e97 Mon Sep 17 00:00:00 2001 From: wmayer Date: Mon, 12 Oct 2020 14:11:53 +0200 Subject: [PATCH] Gui: [skip ci] support to remap motion data array of space mouse --- src/Gui/GuiApplicationNativeEventAware.cpp | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/Gui/GuiApplicationNativeEventAware.cpp b/src/Gui/GuiApplicationNativeEventAware.cpp index 10dfe7bf2810..3506ec9e6853 100644 --- a/src/Gui/GuiApplicationNativeEventAware.cpp +++ b/src/Gui/GuiApplicationNativeEventAware.cpp @@ -21,6 +21,9 @@ ***************************************************************************/ #include "PreCompiled.h" +#include +#include +#include #include #include @@ -154,6 +157,29 @@ void Gui::GUIApplicationNativeEventAware::importSettings(std::vector& 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 vec(str.size()); + std::transform(str.begin(), str.end(), vec.begin(), [](char c) -> int { return c - '0';}); + + std::vector 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