Handle BT.DINF properly
The section is 0x461 bytes long, not 0x460. The config data is also now initialised to zero to avoid garbage being written to the SYSCONF. Because our handling has been wrong forever, we discard older BT.DINF section backups as using them would result in the section being the wrong size / incomplete again.
This commit is contained in:
parent
c759739ee9
commit
02f32a9b26
|
@ -21,7 +21,7 @@ namespace HLE
|
||||||
{
|
{
|
||||||
void BackUpBTInfoSection(const SysConf* sysconf)
|
void BackUpBTInfoSection(const SysConf* sysconf)
|
||||||
{
|
{
|
||||||
const std::string filename = File::GetUserPath(D_SESSION_WIIROOT_IDX) + DIR_SEP WII_BTDINF_BACKUP;
|
const std::string filename = File::GetUserPath(D_CONFIG_IDX) + DIR_SEP WII_BTDINF_BACKUP;
|
||||||
if (File::Exists(filename))
|
if (File::Exists(filename))
|
||||||
return;
|
return;
|
||||||
File::IOFile backup(filename, "wb");
|
File::IOFile backup(filename, "wb");
|
||||||
|
@ -31,18 +31,18 @@ void BackUpBTInfoSection(const SysConf* sysconf)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const std::vector<u8>& section = btdinf->bytes;
|
const std::vector<u8>& section = btdinf->bytes;
|
||||||
if (!backup.WriteBytes(section.data(), section.size() - 1))
|
if (!backup.WriteBytes(section.data(), section.size()))
|
||||||
ERROR_LOG(IOS_WIIMOTE, "Failed to back up BT.DINF section");
|
ERROR_LOG(IOS_WIIMOTE, "Failed to back up BT.DINF section");
|
||||||
}
|
}
|
||||||
|
|
||||||
void RestoreBTInfoSection(SysConf* sysconf)
|
void RestoreBTInfoSection(SysConf* sysconf)
|
||||||
{
|
{
|
||||||
const std::string filename = File::GetUserPath(D_SESSION_WIIROOT_IDX) + DIR_SEP WII_BTDINF_BACKUP;
|
const std::string filename = File::GetUserPath(D_CONFIG_IDX) + DIR_SEP WII_BTDINF_BACKUP;
|
||||||
File::IOFile backup(filename, "rb");
|
File::IOFile backup(filename, "rb");
|
||||||
if (!backup)
|
if (!backup)
|
||||||
return;
|
return;
|
||||||
auto& section = sysconf->GetOrAddEntry("BT.DINF", SysConf::Entry::Type::BigArray)->bytes;
|
auto& section = sysconf->GetOrAddEntry("BT.DINF", SysConf::Entry::Type::BigArray)->bytes;
|
||||||
if (!backup.ReadBytes(section.data(), section.size() - 1))
|
if (!backup.ReadBytes(section.data(), section.size()))
|
||||||
{
|
{
|
||||||
ERROR_LOG(IOS_WIIMOTE, "Failed to read backed up BT.DINF section");
|
ERROR_LOG(IOS_WIIMOTE, "Failed to read backed up BT.DINF section");
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -47,7 +47,7 @@ BluetoothEmu::BluetoothEmu(Kernel& ios, const std::string& device_name)
|
||||||
if (!Core::WantsDeterminism())
|
if (!Core::WantsDeterminism())
|
||||||
BackUpBTInfoSection(&sysconf);
|
BackUpBTInfoSection(&sysconf);
|
||||||
|
|
||||||
_conf_pads BT_DINF;
|
_conf_pads BT_DINF{};
|
||||||
bdaddr_t tmpBD;
|
bdaddr_t tmpBD;
|
||||||
u8 i = 0;
|
u8 i = 0;
|
||||||
while (i < MAX_BBMOTES)
|
while (i < MAX_BBMOTES)
|
||||||
|
@ -79,7 +79,7 @@ BluetoothEmu::BluetoothEmu(Kernel& ios, const std::string& device_name)
|
||||||
// save now so that when games load sysconf file it includes the new Wii Remotes
|
// save now so that when games load sysconf file it includes the new Wii Remotes
|
||||||
// and the correct order for connected Wii Remotes
|
// and the correct order for connected Wii Remotes
|
||||||
auto& section = sysconf.GetOrAddEntry("BT.DINF", SysConf::Entry::Type::BigArray)->bytes;
|
auto& section = sysconf.GetOrAddEntry("BT.DINF", SysConf::Entry::Type::BigArray)->bytes;
|
||||||
section.resize(sizeof(_conf_pads) + 1);
|
section.resize(sizeof(_conf_pads));
|
||||||
std::memcpy(section.data(), &BT_DINF, sizeof(_conf_pads));
|
std::memcpy(section.data(), &BT_DINF, sizeof(_conf_pads));
|
||||||
if (!sysconf.Save())
|
if (!sysconf.Save())
|
||||||
PanicAlertT("Failed to write BT.DINF to SYSCONF");
|
PanicAlertT("Failed to write BT.DINF to SYSCONF");
|
||||||
|
|
|
@ -191,7 +191,7 @@ private:
|
||||||
u8 num_registered;
|
u8 num_registered;
|
||||||
_conf_pad_device registered[CONF_PAD_MAX_REGISTERED];
|
_conf_pad_device registered[CONF_PAD_MAX_REGISTERED];
|
||||||
_conf_pad_device active[MAX_BBMOTES];
|
_conf_pad_device active[MAX_BBMOTES];
|
||||||
u8 unknown[0x45];
|
_conf_pad_device unknown;
|
||||||
};
|
};
|
||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue