port PowerManagement

This commit is contained in:
Arisotura 2024-05-25 00:41:54 +02:00
parent 449d3b342a
commit f391c39592
4 changed files with 13 additions and 17 deletions

View File

@ -68,10 +68,6 @@ int MPRecvTimeout;
std::string LANDevice;
bool DirectLAN;
bool DSBatteryLevelOkay;
int DSiBatteryLevel;
bool DSiBatteryCharging;
CameraConfig Camera[2];

View File

@ -182,10 +182,6 @@ extern int MPRecvTimeout;
extern std::string LANDevice;
extern bool DirectLAN;
extern bool DSBatteryLevelOkay;
extern int DSiBatteryLevel;
extern bool DSiBatteryCharging;
extern CameraConfig Camera[2];

View File

@ -915,12 +915,12 @@ void EmuInstance::setBatteryLevels()
if (nds->ConsoleType == 1)
{
auto dsi = static_cast<DSi*>(nds);
dsi->I2C.GetBPTWL()->SetBatteryLevel(Config::DSiBatteryLevel);
dsi->I2C.GetBPTWL()->SetBatteryCharging(Config::DSiBatteryCharging);
dsi->I2C.GetBPTWL()->SetBatteryLevel(localCfg.GetInt("DSi.Battery.Level"));
dsi->I2C.GetBPTWL()->SetBatteryCharging(localCfg.GetBool("DSi.Battery.Charging"));
}
else
{
nds->SPI.GetPowerMan()->SetBatteryLevelOkay(Config::DSBatteryLevelOkay);
nds->SPI.GetPowerMan()->SetBatteryLevelOkay(localCfg.GetBool("DS.Battery.LevelOkay"));
}
}

View File

@ -63,7 +63,7 @@ PowerManagementDialog::PowerManagementDialog(QWidget* parent) : QDialog(parent),
updateDSBatteryLevelControls();
bool defaultDSiBatteryCharging = (nds->ConsoleType == 1) ? Config::DSiBatteryCharging : false;
//bool defaultDSiBatteryCharging = (nds->ConsoleType == 1) ? Config::DSiBatteryCharging : false;
if (nds->ConsoleType == 1)
{
@ -82,8 +82,10 @@ PowerManagementDialog::PowerManagementDialog(QWidget* parent) : QDialog(parent),
}
else
{
ui->cbDSiBatteryCharging->setChecked(Config::DSiBatteryCharging);
ui->sliderDSiBatteryLevel->setValue(Config::DSiBatteryLevel);
auto& cfg = emuInstance->getLocalConfig();
ui->cbDSiBatteryCharging->setChecked(cfg.GetBool("DSi.Battery.Charging"));
ui->sliderDSiBatteryLevel->setValue(cfg.GetInt("DSi.Battery.Level"));
}
@ -107,15 +109,17 @@ void PowerManagementDialog::done(int r)
if (r == QDialog::Accepted)
{
auto& cfg = emuInstance->getLocalConfig();
if (nds->ConsoleType == 1)
{
auto dsi = static_cast<DSi*>(nds);
Config::DSiBatteryLevel = dsi->I2C.GetBPTWL()->GetBatteryLevel();
Config::DSiBatteryCharging = dsi->I2C.GetBPTWL()->GetBatteryCharging();
cfg.SetInt("DSi.Battery.Level", dsi->I2C.GetBPTWL()->GetBatteryLevel());
cfg.SetBool("DSi.Battery.Charging", dsi->I2C.GetBPTWL()->GetBatteryCharging());
}
else
{
Config::DSBatteryLevelOkay = nds->SPI.GetPowerMan()->GetBatteryLevelOkay();
cfg.SetBool("DS.Battery.LevelOkay", nds->SPI.GetPowerMan()->GetBatteryLevelOkay());
}
}
else