From 8d5c9f30ada8604a6608e1b18d8bd95060fbe8f4 Mon Sep 17 00:00:00 2001 From: Jordan Woyak Date: Sat, 24 Apr 2010 20:09:01 +0000 Subject: [PATCH] Fixed new GCPad/Wiimote plugin IniFile code to handle saving/loading of values with leading/trailing whitespace. Was causing issues with gamepads that had trailing whitespace in their names. Also, reordered drum pad colors in the GUI to match their physical layout. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5404 8ced0084-cf51-0410-be5f-012b33b47a6e --- .../Plugins/InputPluginCommon/Src/IniFile.cpp | 18 ++++++++++++++++-- .../Src/WiimoteEmu/Attachment/Drums.cpp | 4 ++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/Source/Plugins/InputPluginCommon/Src/IniFile.cpp b/Source/Plugins/InputPluginCommon/Src/IniFile.cpp index 903b9d3eef..0f10b25452 100644 --- a/Source/Plugins/InputPluginCommon/Src/IniFile.cpp +++ b/Source/Plugins/InputPluginCommon/Src/IniFile.cpp @@ -66,7 +66,15 @@ void IniFile::Save( std::ostream& file ) Section::const_iterator si = i->second.begin(), se = i->second.end(); for ( ; si != se; ++si ) - file << si->first << " = " << si->second << '\n'; + { + file << si->first << " = "; + // if value has quotes or whitespace, surround it with quotes + if (si->second.find_first_of("\"\t ") != std::string::npos) + file << '"' << si->second << '"'; + else + file << si->second; + file << '\n'; + } } } @@ -103,7 +111,13 @@ void IniFile::Load( std::istream& file ) std::istringstream ss(line); std::string key; std::getline( ss, key, '=' ); std::string val; std::getline( ss, val ); - (*section)[ TrimChars(key,space) ] = TrimChars(val,space); + val = TrimChars(val,space); + // handle quote surrounded values + if (val.length() > 1) + if ('"' == val[0]) + val = val.substr(1, val.length()-2); + + (*section)[ TrimChars(key,space) ] = val; break; } } diff --git a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Attachment/Drums.cpp b/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Attachment/Drums.cpp index 1d5580560b..e3f0acb22c 100644 --- a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Attachment/Drums.cpp +++ b/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Attachment/Drums.cpp @@ -20,16 +20,16 @@ static const u8 drums_id[] = { 0x01, 0x00, 0xa4, 0x20, 0x01, 0x03 }; const u16 drum_pad_bitmasks[] = { DRUMS_RED, + DRUMS_YELLOW, DRUMS_BLUE, DRUMS_GREEN, - DRUMS_YELLOW, DRUMS_ORANGE, DRUMS_BASS, }; const char* drum_pad_names[] = { - "Red","Blue","Green","Yellow","Orange","Bass" + "Red","Yellow","Blue","Green","Orange","Bass" }; const u16 drum_button_bitmasks[] =