mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 06:09:50 -06:00
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
This commit is contained in:
@ -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)
|
||||
{
|
||||
|
Reference in New Issue
Block a user