Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ZeroOne mode fix. Case sensitivity fixes. #61

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions src/axis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ bool Axis::read( QTextStream &stream ) {
float fval;
//step through each word, check if it's a token we recognize
for ( QStringList::Iterator it = words.begin(); it != words.end(); ++it ) {
if (*it == "maxspeed") {
if (*it == "maxSpeed") {
++it; //move to the next word, which should be the maximum speed.
//if no value was given, there's an error in the file, stop reading.
if (it == words.end()) return false;
Expand Down Expand Up @@ -120,7 +120,7 @@ bool Axis::read( QTextStream &stream ) {
else return false;
}
//the rest of the options are keywords without integers
else if (*it == "zeroone") {
else if (*it == "ZeroOne") {
interpretation = ZeroOne;
gradient = false;
absolute = false;
Expand Down Expand Up @@ -220,9 +220,11 @@ void Axis::jsevent( int value ) {
state = (value + JOYMAX) / 2;
//set isOn, deal with state changing.
//if was on but now should be off:

if (isOn && abs(state) <= dZone) {
isOn = false;
if (gradient) {
if (gradient || ((interpretation == ZeroOne) && (mode != Keyboard))) {
//"mode > Keyboard"" might be easier but do we want that for absolute mode?
duration = 0;
release();
timer.stop();
Expand All @@ -233,17 +235,19 @@ void Axis::jsevent( int value ) {
//if was off but now should be on:
else if (!isOn && abs(state) >= dZone) {
isOn = true;
if (gradient) {
if (gradient || ((interpretation == ZeroOne) && (mode != Keyboard))) {
//"mode > Keyboard"" might be easier but do we want that for absolute mode?
duration = (abs(state) * FREQ) / JOYMAX;
connect(&timer, SIGNAL(timeout()), this, SLOT(timerCalled()));
timer.start(MSEC);
}
}
//otherwise, state doesn't change! Don't touch it.
else return;

else return; //this line would hurt ZeroOne without the timer that was previously only used by gradient
//We never even get here and if we did, the feedback on the gui would not happen
//gradient will trigger movement on its own via timer().
//non-gradient needs to be told to move.

if (!gradient) {
move(isOn);
}
Expand Down Expand Up @@ -437,6 +441,8 @@ void Axis::move( bool press ) {
else dist = maxSpeed;

e.type = absolute ? FakeEvent::MouseMoveAbsolute : FakeEvent::MouseMove;
//go the right direction for ZeroOne mode
if ((interpretation == ZeroOne) && (state < 0)) dist = -dist;
if (mode == MousePosVert) {
e.move.x = 0;
e.move.y = dist;
Expand Down