Permalink
Browse files

gimx-config truncates sensitivity decimals #510

  • Loading branch information...
matlo committed Jan 10, 2018
1 parent e286376 commit afb1a047cd3db21f3231e571a985bda015ccccce
Showing with 21 additions and 3 deletions.
  1. +21 −3 config/gimx-config.cpp
View
@@ -12,6 +12,7 @@
#include <math.h>
#include <sstream>
#include <iomanip>
#include <climits>
//(*InternalHeaders(configFrame)
#include <wx/string.h>
@@ -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. \
@@ -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());
}
}

4 comments on commit afb1a04

@ytak01

This comment has been minimized.

Show comment
Hide comment
@ytak01

ytak01 Jan 23, 2018

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))

ytak01 replied Jan 23, 2018

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

This comment has been minimized.

Show comment
Hide comment
@matlo

matlo Jan 26, 2018

Owner

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.

Owner

matlo replied Jan 26, 2018

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

This comment has been minimized.

Show comment
Hide comment
@ytak01

ytak01 Jan 29, 2018

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 replied Jan 29, 2018

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

This comment has been minimized.

Show comment
Hide comment
@ytak01

ytak01 Jan 29, 2018

Compilation succeeded by VersionUp wxWidgets below.

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

Thank you very much.

ytak01 replied Jan 29, 2018

Compilation succeeded by VersionUp wxWidgets below.

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

Thank you very much.

Please sign in to comment.