summaryrefslogtreecommitdiff
path: root/Source/Core/Common
diff options
context:
space:
mode:
authorLPFaint99 <lpfaint99@gmail.com>2010-12-22 08:00:08 +0000
committerLPFaint99 <lpfaint99@gmail.com>2010-12-22 08:00:08 +0000
commit547c18fb5504b52fd851a61ae80bc73a86e39809 (patch)
treec0d088665b2756ef7b7f22fe241124283fb04b57 /Source/Core/Common
parent3d68608024d395c415c59f8018e07d78511d50a9 (diff)
Add the ability to Get / Set Array data from SysConf
wiimote bd's are now read from (or added to if < 4 exist) SysConf in theory you should be able to use any valid sysconf file now, but i would advise against using a dolphin edited SysConf on a wii git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6646 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source/Core/Common')
-rw-r--r--Source/Core/Common/Src/SysConf.h62
1 files changed, 62 insertions, 0 deletions
diff --git a/Source/Core/Common/Src/SysConf.h b/Source/Core/Common/Src/SysConf.h
index c2db94fa3b..13cbbe5df1 100644
--- a/Source/Core/Common/Src/SysConf.h
+++ b/Source/Core/Common/Src/SysConf.h
@@ -55,6 +55,25 @@ struct SSysConfEntry
template<class T>
T GetData() { return *(T*)data; }
+ bool GetArrayData(u8* dest, u16 destSize)
+ {
+ if (dest && destSize >= dataLength)
+ {
+ memcpy(dest, data, dataLength);
+ return true;
+ }
+ return false;
+ }
+ bool SetArrayData(u8* buffer, u16 bufferSize)
+ {
+
+ if (buffer && bufferSize == dataLength)
+ {
+ memcpy(data, buffer, dataLength);
+ return true;
+ }
+ return false;
+ }
};
class SysConf
@@ -95,6 +114,49 @@ public:
return m_Entries.at(index).GetData<T>();
}
+ bool GetArrayData(const char* sectionName, u8* dest, u16 destSize)
+ {
+ if (!m_IsValid)
+ {
+ PanicAlert("Trying to read from invalid SYSCONF");
+ return 0;
+ }
+
+ size_t index = 0;
+ for (; index < m_Entries.size() - 1; index++)
+ {
+ if (strcmp(m_Entries.at(index).name, sectionName) == 0)
+ break;
+ }
+ if (index == m_Entries.size() - 1)
+ {
+ PanicAlert("Section %s not found in SYSCONF", sectionName);
+ return 0;
+ }
+
+ return m_Entries.at(index).GetArrayData(dest, destSize);
+ }
+
+ bool SetArrayData(const char* sectionName, u8* buffer, u16 bufferSize)
+ {
+ if (!m_IsValid)
+ return false;
+
+ size_t index = 0;
+ for (; index < m_Entries.size() - 1; index++)
+ {
+ if (strcmp(m_Entries.at(index).name, sectionName) == 0)
+ break;
+ }
+ if (index == m_Entries.size() - 1)
+ {
+ PanicAlert("Section %s not found in SYSCONF", sectionName);
+ return false;
+ }
+
+ return m_Entries.at(index).SetArrayData(buffer, bufferSize);
+ }
+
template<class T>
bool SetData(const char* sectionName, T newValue)
{