From 2cb5a1aa565bdc31e50b216d3b7b13e92a16ed98 Mon Sep 17 00:00:00 2001 From: Soren Jorvang Date: Sat, 15 Jan 2011 21:16:13 +0000 Subject: [PATCH] HID reports can use negative numbers. Use UTF-8 for input device names and profile filenames. From8Bit->To8Bit is not transparent. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6857 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/DolphinWX/Src/ConfigMain.cpp | 4 ++-- Source/Core/DolphinWX/Src/InputConfigDiag.cpp | 7 +++---- .../Src/ControllerInterface/OSX/OSXJoystick.h | 1 + .../Src/ControllerInterface/OSX/OSXJoystick.mm | 9 ++++----- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/Source/Core/DolphinWX/Src/ConfigMain.cpp b/Source/Core/DolphinWX/Src/ConfigMain.cpp index 20168e2789..95fcdd7c0b 100644 --- a/Source/Core/DolphinWX/Src/ConfigMain.cpp +++ b/Source/Core/DolphinWX/Src/ConfigMain.cpp @@ -974,7 +974,7 @@ void CConfigMain::ChooseMemcardPath(std::string& strMemcard, bool isSlotA) { std::string filename = std::string(wxFileSelector( _("Choose a file to open"), - wxString::From8BitData(File::GetUserPath(D_GCUSER_IDX)), + wxString::FromUTF8(File::GetUserPath(D_GCUSER_IDX)), isSlotA ? wxT(GC_MEMCARDA) : wxT(GC_MEMCARDB), wxEmptyString, _("Gamecube Memory Cards (*.raw,*.gcp)") + wxString(wxT("|*.raw;*.gcp"))).mb_str()); @@ -1234,7 +1234,7 @@ void CConfigMain::FillChoiceBox(wxChoice* _pChoice, int _PluginType, const std:: if (rPluginInfo.Type == _PluginType) { wxString temp; - temp = wxGetTranslation(wxString::From8BitData(rInfos[i].GetPluginInfo().Name)); + temp = wxGetTranslation(wxString::FromUTF8(rInfos[i].GetPluginInfo().Name)); int NewIndex = _pChoice->Append(temp, (void*)&rInfos[i]); if (rInfos[i].GetFilename() == _SelectFilename) diff --git a/Source/Core/DolphinWX/Src/InputConfigDiag.cpp b/Source/Core/DolphinWX/Src/InputConfigDiag.cpp index c83e3a3e64..d0e8f7e617 100644 --- a/Source/Core/DolphinWX/Src/InputConfigDiag.cpp +++ b/Source/Core/DolphinWX/Src/InputConfigDiag.cpp @@ -19,10 +19,9 @@ #include "UDPConfigDiag.h" #define _connect_macro_(b, f, c, s) (b)->Connect(wxID_ANY, (c), wxCommandEventHandler(f), (wxObject*)0, (wxEvtHandler*)s) -#define WXSTR_FROM_STR(s) (wxString::From8BitData((s).c_str())) -#define WXTSTR_FROM_CSTR(s) (wxGetTranslation(wxString::From8BitData(s))) -// ToAscii was causing probs with some extended ascii characters, To8BitData seems to work -#define STR_FROM_WXSTR(w) (std::string((w).To8BitData())) +#define WXSTR_FROM_STR(s) (wxString::FromUTF8((s).c_str())) +#define WXTSTR_FROM_CSTR(s) (wxGetTranslation(wxString::FromUTF8(s))) +#define STR_FROM_WXSTR(w) (std::string((w).ToUTF8())) void GamepadPage::ConfigUDPWii(wxCommandEvent &event) { diff --git a/Source/Core/InputCommon/Src/ControllerInterface/OSX/OSXJoystick.h b/Source/Core/InputCommon/Src/ControllerInterface/OSX/OSXJoystick.h index d9270d6994..c9bb7bdfaf 100644 --- a/Source/Core/InputCommon/Src/ControllerInterface/OSX/OSXJoystick.h +++ b/Source/Core/InputCommon/Src/ControllerInterface/OSX/OSXJoystick.h @@ -50,6 +50,7 @@ protected: std::string m_name; direction m_direction; float m_neutral; + float m_scale; }; bool UpdateInput(); diff --git a/Source/Core/InputCommon/Src/ControllerInterface/OSX/OSXJoystick.mm b/Source/Core/InputCommon/Src/ControllerInterface/OSX/OSXJoystick.mm index 9b5f654b32..b3012b6c87 100644 --- a/Source/Core/InputCommon/Src/ControllerInterface/OSX/OSXJoystick.mm +++ b/Source/Core/InputCommon/Src/ControllerInterface/OSX/OSXJoystick.mm @@ -173,8 +173,9 @@ Joystick::Axis::Axis(IOHIDElementRef element, direction dir) m_name = std::string("Axis ") + description; m_name.append((m_direction == positive) ? "+" : "-"); - m_neutral = (IOHIDElementGetLogicalMax(m_element) - + m_neutral = (IOHIDElementGetLogicalMax(m_element) + IOHIDElementGetLogicalMin(m_element)) / 2.; + m_scale = 1 / fabs(IOHIDElementGetLogicalMax(m_element) - m_neutral); } ControlState Joystick::Axis::GetState(IOHIDDeviceRef device) const @@ -185,12 +186,10 @@ ControlState Joystick::Axis::GetState(IOHIDDeviceRef device) const { float position = IOHIDValueGetIntegerValue(value); - //NSLog(@"%s %f %f", m_name.c_str(), m_neutral, position); - if (m_direction == positive && position > m_neutral) - return (position - m_neutral) / m_neutral; + return (position - m_neutral) * m_scale; if (m_direction == negative && position < m_neutral) - return (m_neutral - position) / m_neutral; + return (m_neutral - position) * m_scale; } return 0;