From 1bcd130f73aca34f10196fcbfa69cf0c969ccbdf Mon Sep 17 00:00:00 2001 From: AKMaily Date: Thu, 17 Oct 2024 09:32:24 +0200 Subject: [PATCH] TEST: More than one axis 2 --- src/handler.cpp | 37 ++++++++++--------------------------- 1 file changed, 10 insertions(+), 27 deletions(-) diff --git a/src/handler.cpp b/src/handler.cpp index 47a69685..26598e8d 100644 --- a/src/handler.cpp +++ b/src/handler.cpp @@ -36,35 +36,18 @@ static std::vector getDeviceInfos() { &std::pair::first)){ const int maxAxes = 3; // Maximale Anzahl der Achsen (hier 3) if (assignedEgus.size() < maxAxes) { - // Make sure ImAxis_ values haven't changed - static_assert((ImAxis_Y1 + 1) == ImAxis_Y2); - - // Check for axis - ImAxis_ nextYAxis; - bool axisAlreadyAssigned = false; - - // check if egu already has an axis - for (const auto& [assignedEgu, axis] : assignedEgus) { - if (assignedEgu == egu) { - nextYAxis = axis; - axisAlreadyAssigned = true; - break; - } - } + static_assert((ImAxis_Y1 + 1) == ImAxis_Y2, "Achsenwerte haben sich geändert"); + + ImAxis_ nextYAxis = static_cast(ImAxis_Y1 + assignedEgus.size()); - // If there are less than 3 egus it is possible to have an axis for each device - if (!axisAlreadyAssigned || assignedEgus.size() < maxAxes) { - nextYAxis = static_cast(ImAxis_Y1 + assignedEgus.size()); - - // check if it is possible to have a new axis - if (assignedEgus.size() < maxAxes) { - assignedEgus.push_back(std::make_pair(egu, nextYAxis)); - } else { - fmt::print("Zu viele Achsen hinzugefügt. Keine weitere EGU-Achse hinzugefügt für: " - "{}\nDevice id: {}", egu, id.value()); - } + if (assignedEgus.size() < maxAxes) { + assignedEgus.emplace_back(egu, nextYAxis); + fmt::print("Achse hinzugefügt. Neue EGU-Achse für: {}\nDevice id: {}", egu, id.value()); + } else { + fmt::print("Zu viele Achsen hinzugefügt. Keine weitere EGU-Achse für: {}\nDevice id: {}", egu, id.value()); } - } else { + } + else { //Error print if more than 3 axis are used fmt::print("Maximale Anzahl an Achsen (3) erreicht. Keine weitere Achse hinzugefügt für: " "{}\nDevice id: {}", egu, id.value());