Navigation Menu

Skip to content

Commit

Permalink
gimx-config truncates sensitivity decimals #510
Browse files Browse the repository at this point in the history
  • Loading branch information
matlo committed Jan 10, 2018
1 parent e286376 commit afb1a04
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions config/gimx-config.cpp
Expand Up @@ -12,6 +12,7 @@
#include <math.h>
#include <sstream>
#include <iomanip>
#include <climits>

//(*InternalHeaders(configFrame)
#include <wx/string.h>
Expand Down Expand Up @@ -3394,6 +3395,13 @@ void configFrame::OnMenuReplaceKeyboard(wxCommandEvent& event __attribute__((unu
replaceDevice(wxT("keyboard"));
}

int numPlaces (int n)
{
if (n < 0) return numPlaces ((n == INT_MIN) ? INT_MAX: -n);
if (n < 10) return 1;
return 1 + numPlaces (n / 10);
}

/*
* \brief Method called on Edit>Replace_Mouse_DPI click. \
* It converts the sensitivity in the current controller. \
Expand Down Expand Up @@ -3465,11 +3473,21 @@ void configFrame::OnMenuReplaceMouseDPI(wxCommandEvent& event __attribute__((unu
{
continue;
}
double val = atof(it->GetEvent()->GetMultiplier().c_str());
double exp = atof(it->GetEvent()->GetExponent().c_str());
double val;
if(!ToDouble(it->GetEvent()->GetMultiplier().c_str(), &val, decimalPoint))
{
wxMessageBox( _("Failed to parse sensitivity value!"), _("Error"), wxICON_ERROR);
continue;
}
double exp;
if(!ToDouble(it->GetEvent()->GetExponent().c_str(), &exp, decimalPoint))
{
wxMessageBox( _("Failed to parse acceleration value!"), _("Error"), wxICON_ERROR);
continue;
}
val = val * pow((double)old_value / new_value, exp);
ostringstream ios;
ios << setprecision(2) << val;
ios << setprecision(2 + numPlaces((int)val)) << val;
it->GetEvent()->SetMultiplier(ios.str());
}
}
Expand Down

4 comments on commit afb1a04

@ytak01
Copy link

@ytak01 ytak01 commented on afb1a04 Jan 23, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Compiling error will occur in Raspberry Pi.

Can you please investigate?

g++ -Wall -Wextra -O3 -I../shared wx-config --cflags -Winvalid-pch -include wx_pch.h -DWX_PRECOMP -Wno-unused-local-typedefs -c -o gimx-config.o gimx-config.cpp
gimx-config.cpp: In member function ‘void configFrame::OnMenuReplaceMouseDPI(wxCommandEvent&)’:
gimx-config.cpp:3477:91: error: conversion from ‘const char*’ to ‘const wxString’ is ambiguous
if(!ToDouble(it->GetEvent()->GetMultiplier().c_str(), &val, decimalPoint))
^
gimx-config.cpp:3477:70: note: candidates are:
if(!ToDouble(it->GetEvent()->GetMultiplier().c_str(), &val, decimalPoint))

@matlo
Copy link
Owner

@matlo matlo commented on afb1a04 Jan 26, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked and it compiles with no issue on my side.
Maybe you are compiling with an old version of wxWidgets?
Try running wx-config --version to see the version.

@ytak01
Copy link

@ytak01 ytak01 commented on afb1a04 Jan 29, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your reply
It will be below

pi@rpi-gimx:~ $ sudo dpkg -l | /bin/grep wx
ii libwxbase2.8-0:armhf 2.8.12.1+dfsg2-2 armhf wxBase library (runtime) - non-GUI support classes of wxWidgets toolkit
ii libwxbase2.8-dev 2.8.12.1+dfsg2-2 armhf wxBase library (development) - non-GUI support classes of wxWidgets toolkit
ii libwxbase3.0-0:armhf 3.0.2-1 armhf wxBase library (runtime) - non-GUI support classes of wxWidgets toolkit
ii libwxgtk2.8-0:armhf 2.8.12.1+dfsg2-2 armhf wxWidgets Cross-platform C++ GUI toolkit (GTK+ runtime)
ii libwxgtk2.8-dev 2.8.12.1+dfsg2-2 armhf wxWidgets Cross-platform C++ GUI toolkit (GTK+ development)
ii libwxgtk3.0-0:armhf 3.0.2-1 armhf wxWidgets Cross-platform C++ GUI toolkit (GTK+ runtime)
ii wx-common 3.0.2-1 armhf wxWidgets Cross-platform C++ GUI toolkit (common support files)
ii wx2.8-headers 2.8.12.1+dfsg2-2 armhf wxWidgets Cross-platform C++ GUI toolkit (header files)
pi@rpi-gimx:~ $ wx-config --version
2.8.12

@ytak01
Copy link

@ytak01 ytak01 commented on afb1a04 Jan 29, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Compilation succeeded by VersionUp wxWidgets below.

apt-get install libwxbase3.0-dev libwxgtk3.0-dev

Thank you very much.

Please sign in to comment.