Permalink
Browse files

Merge remote-tracking branch 'origin/master' into development

  • Loading branch information...
matlo committed Sep 27, 2017
2 parents 86b7880 + bab65bb commit 4641cb6e83270d4ace0e275ad51557075ee83316
View
@@ -6,8 +6,8 @@
LD = $(CXX)
CFLAGS += -Wall -Wextra -s -O3
CXXFLAGS += -Wall -Wextra -s -O3
CFLAGS += -Wall -Wextra -O3
CXXFLAGS += -Wall -Wextra -O3
#Comment the above two lines and uncomment the below two lines to compile with debug symbols.
#CFLAGS += -Wall -Wextra -O0 -g
#CXXFLAGS += -Wall -Wextra -O0 -g
View
@@ -585,6 +585,13 @@ void configFrame::readLabels()
}
}
static bool ToDouble(const wxString & from, double * to, const wxString & decimalPoint)
{
wxString tmp = from;
tmp.Replace(wxT("."), decimalPoint);
return tmp.ToDouble(to);
}
/*
* \brief Constructor.
*
@@ -600,6 +607,9 @@ configFrame::configFrame(wxString file,wxWindow* parent, wxWindowID id __attribu
#endif
locale->AddCatalog(wxT("gimx"));
struct lconv * l = localeconv();
decimalPoint = wxString(l->decimal_point, wxConvUTF8);
//(*Initialize(configFrame)
wxFlexGridSizer* FlexGridSizer30;
wxFlexGridSizer* FlexGridSizer46;
@@ -3523,8 +3533,6 @@ void configFrame::OnMenuSetMouseDPI(wxCommandEvent& event __attribute__((unused)
*/
void configFrame::OnTextCtrl(wxCommandEvent& event)
{
wxLocale eng(wxLANGUAGE_ENGLISH); // make sure to use '.' as decimal separator
wxString str;
wxTextCtrl* text;
double value;
@@ -3534,14 +3542,22 @@ void configFrame::OnTextCtrl(wxCommandEvent& event)
long pos = text->GetInsertionPoint();
str = text->GetValue();
if(str.IsEmpty() || str == wxT("-") || str == wxT(".") || str == wxT("-."))
if(str.Replace(wxT(","), wxT(".")))
{
return;
text->SetValue(str);
}
if(str.Replace(wxT(","), wxT(".")))
if (decimalPoint != wxT(".")) // avoid infinite recursion
{
text->SetValue(str);
if(str.Replace(decimalPoint, wxT(".")))
{
text->SetValue(str);
}
}
if(str.IsEmpty() || str == wxT("-") || str == wxT(".") || str == wxT("-."))
{
return;
}
if(str.Freq('.') > 1)
@@ -3566,14 +3582,14 @@ void configFrame::OnTextCtrl(wxCommandEvent& event)
}
else if(text == AxisTabSensitivity)
{
if(!str.ToDouble(&value))
if(!ToDouble(str, &value, decimalPoint))
{
text->SetValue(wxT("1.00"));
}
}
else if(text == AxisTabAcceleration)
{
if(!str.ToDouble(&value))
if(!ToDouble(str, &value, decimalPoint))
{
text->SetValue(wxT("1.00"));
}
@@ -3599,7 +3615,7 @@ void configFrame::OnTextCtrl(wxCommandEvent& event)
}
else if(text == MouseOptionsFilter)
{
if(!str.ToDouble(&value))
if(!ToDouble(str, &value, decimalPoint))
{
text->SetValue(wxT("0.00"));
}
@@ -1,6 +1,5 @@
[Desktop Entry]
Type=Application
Version=0.25
Name=Gimx-config
GenericName=Gimx-config
Icon=gimx-config
View
@@ -520,6 +520,7 @@ class configFrame: public wxFrame
//*)
wxLocale* locale;
wxString decimalPoint;
EventCatcher* evcatch;
ConfigurationFile configFile;
View
@@ -12,7 +12,6 @@
#include <limits.h>
#include <dirent.h>
#include <libxml/xmlreader.h>
#include <iconv.h>
#include "gimx.h"
#include <controller.h>
#include "../directories.h"
@@ -36,21 +35,7 @@ static void reset_entry()
memset(&entry.params, 0x00, sizeof(entry.params));
}
static char r_device_name[128];
const char* _UTF8_to_8BIT(const char* _utf8)
{
iconv_t cd;
char* input = (char*)_utf8;
size_t in = strlen(input) + 1;
static char output[256];
char* poutput = output;
size_t out = sizeof(output);
cd = iconv_open ("ISO-8859-1//TRANSLIT", "UTF-8");
iconv(cd, &input, &in, &poutput, &out);
iconv_close(cd);
return output;
}
static char * r_device_name = NULL;
/*
* Get the device name and store it into r_device_name.
@@ -65,7 +50,11 @@ int GetDeviceName(xmlNode* a_node)
prop = (char*) xmlGetProp(a_node, (xmlChar*) X_ATTR_NAME);
if(prop)
{
strcpy(r_device_name, prop);
r_device_name = strdup(prop);
if(r_device_name == NULL)
{
ret = -1;
}
}
else
{
@@ -88,13 +77,13 @@ static void warnDeviceNotFound()
switch(entry.device.type)
{
case E_DEVICE_TYPE_JOYSTICK:
gwarn(_("joystick not found: %s %d\n"), _UTF8_to_8BIT(r_device_name), entry.device.id);
gwarn(_("joystick not found: %s %d\n"), r_device_name, entry.device.id);
break;
case E_DEVICE_TYPE_MOUSE:
gwarn(_("mouse not found: %s %d\n"), _UTF8_to_8BIT(r_device_name), entry.device.id);
gwarn(_("mouse not found: %s %d\n"), r_device_name, entry.device.id);
break;
case E_DEVICE_TYPE_KEYBOARD:
gwarn(_("keyboard not found: %s %d\n"), _UTF8_to_8BIT(r_device_name), entry.device.id);
gwarn(_("keyboard not found: %s %d\n"), r_device_name, entry.device.id);
break;
case E_DEVICE_TYPE_UNKNOWN:
return;
@@ -197,6 +186,9 @@ static int GetDeviceId(xmlNode* a_node)
}
}
free(r_device_name);
r_device_name = NULL;
return ret;
}
Oops, something went wrong.

0 comments on commit 4641cb6

Please sign in to comment.