From 1c55328bf8c1d1e7b58fc3301cd706cd5a798838 Mon Sep 17 00:00:00 2001 From: Gergely Mincsovics Date: Sun, 27 Dec 2020 03:19:20 +0100 Subject: [PATCH] load/save of the mouse absolutecoordinate option --- src/axis.cpp | 25 ++++++++++++++++++++++--- src/axis.h | 2 +- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/axis.cpp b/src/axis.cpp index 136bf82..171445f 100644 --- a/src/axis.cpp +++ b/src/axis.cpp @@ -13,7 +13,9 @@ Axis::Axis( int i, QObject *parent ) : QObject(parent) { isOn = false; isDown = false; state = 0; + interpretation = ZeroOne; gradient = false; + absolute = false; toDefault(); tick = 0; } @@ -117,8 +119,20 @@ bool Axis::read( QTextStream &stream ) { else return false; } //the rest of the options are keywords without integers - else if (*it == "gradient") { + else if (*it == "zeroone") { + interpretation = ZeroOne; + gradient = false; + absolute = false; + } + else if (*it == "absolute") { + interpretation = Absolute2; // to avoid name collision with a #define Absolute gradient = true; + absolute = true; + } + else if (*it == "gradient") { + interpretation = Gradient; + gradient = true; + absolute = false; } else if (*it == "throttle+") { throttle = 1; @@ -157,7 +171,8 @@ void Axis::timerCalled() { void Axis::write( QTextStream &stream ) { stream << "\tAxis " << (index+1) << ": "; - if (gradient) stream << "gradient, "; + stream << ((interpretation == ZeroOne)?"ZeroOne": + (interpretation == Gradient)?"Gradient":"Absolute") << ", "; if (throttle > 0) stream << "throttle+, "; else if (throttle < 0) stream << "throttle-, "; if (dZone != DZONE) stream << "dZone " << dZone << ", "; @@ -235,7 +250,9 @@ void Axis::jsevent( int value ) { void Axis::toDefault() { release(); + interpretation = ZeroOne; gradient = false; + absolute = false; throttle = 0; maxSpeed = 100; transferCurve = Quadratic; @@ -254,7 +271,9 @@ void Axis::toDefault() { } bool Axis::isDefault() { - return (gradient == false) && + return (interpretation == ZeroOne) && + (gradient == false) && + (absolute == false) && (throttle == 0) && (maxSpeed == 100) && (dZone == DZONE) && diff --git a/src/axis.h b/src/axis.h index 4e8e112..f187bab 100644 --- a/src/axis.h +++ b/src/axis.h @@ -22,7 +22,7 @@ class Axis : public QObject { Q_OBJECT //each axis can create a key press or move the mouse in one of four directions. - enum Interpretation { ZeroOne, Gradient, Absolute }; + enum Interpretation { ZeroOne, Gradient, Absolute, Absolute2 = Absolute }; enum Mode {Keyboard, MousePosVert, MouseNegVert, MousePosHor, MouseNegHor}; enum TransferCurve {Linear, Quadratic, Cubic, QuadraticExtreme, PowerFunction};