mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2025-07-25 07:10:00 -06:00
botch one more thing
This commit is contained in:
@ -30,43 +30,47 @@
|
|||||||
|
|
||||||
#include <QtDebug>
|
#include <QtDebug>
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
#include "EmuInstance.h"
|
||||||
|
|
||||||
using namespace melonDS;
|
using namespace melonDS;
|
||||||
|
|
||||||
PowerManagementDialog* PowerManagementDialog::currentDlg = nullptr;
|
PowerManagementDialog* PowerManagementDialog::currentDlg = nullptr;
|
||||||
|
|
||||||
PowerManagementDialog::PowerManagementDialog(QWidget* parent, EmuThread* emuThread) : QDialog(parent), emuThread(emuThread), ui(new Ui::PowerManagementDialog)
|
PowerManagementDialog::PowerManagementDialog(QWidget* parent) : QDialog(parent), ui(new Ui::PowerManagementDialog)
|
||||||
{
|
{
|
||||||
inited = false;
|
inited = false;
|
||||||
|
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
setAttribute(Qt::WA_DeleteOnClose);
|
setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
|
||||||
if (emuThread->NDS->ConsoleType == 1)
|
emuInstance = ((MainWindow*)parent)->getEmuInstance();
|
||||||
|
auto nds = emuInstance->getNDS();
|
||||||
|
|
||||||
|
if (nds->ConsoleType == 1)
|
||||||
{
|
{
|
||||||
ui->grpDSBattery->setEnabled(false);
|
ui->grpDSBattery->setEnabled(false);
|
||||||
|
|
||||||
auto& dsi = static_cast<DSi&>(*emuThread->NDS);
|
auto dsi = static_cast<DSi*>(nds);
|
||||||
oldDSiBatteryLevel = dsi.I2C.GetBPTWL()->GetBatteryLevel();
|
oldDSiBatteryLevel = dsi->I2C.GetBPTWL()->GetBatteryLevel();
|
||||||
oldDSiBatteryCharging = dsi.I2C.GetBPTWL()->GetBatteryCharging();
|
oldDSiBatteryCharging = dsi->I2C.GetBPTWL()->GetBatteryCharging();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ui->grpDSiBattery->setEnabled(false);
|
ui->grpDSiBattery->setEnabled(false);
|
||||||
|
|
||||||
oldDSBatteryLevel = emuThread->NDS->SPI.GetPowerMan()->GetBatteryLevelOkay();
|
oldDSBatteryLevel = nds->SPI.GetPowerMan()->GetBatteryLevelOkay();
|
||||||
}
|
}
|
||||||
|
|
||||||
updateDSBatteryLevelControls();
|
updateDSBatteryLevelControls();
|
||||||
|
|
||||||
bool defaultDSiBatteryCharging = (emuThread->NDS->ConsoleType == 1) ? Config::DSiBatteryCharging : false;
|
bool defaultDSiBatteryCharging = (nds->ConsoleType == 1) ? Config::DSiBatteryCharging : false;
|
||||||
|
|
||||||
if (emuThread->NDS->ConsoleType == 1)
|
if (nds->ConsoleType == 1)
|
||||||
{
|
{
|
||||||
auto& dsi = static_cast<DSi&>(*emuThread->NDS);
|
auto dsi = static_cast<DSi*>(nds);
|
||||||
ui->cbDSiBatteryCharging->setChecked(dsi.I2C.GetBPTWL()->GetBatteryCharging());
|
ui->cbDSiBatteryCharging->setChecked(dsi->I2C.GetBPTWL()->GetBatteryCharging());
|
||||||
int dsiBatterySliderPos = 4;
|
int dsiBatterySliderPos = 4;
|
||||||
switch (dsi.I2C.GetBPTWL()->GetBatteryLevel())
|
switch (dsi->I2C.GetBPTWL()->GetBatteryLevel())
|
||||||
{
|
{
|
||||||
case DSi_BPTWL::batteryLevel_AlmostEmpty: dsiBatterySliderPos = 0; break;
|
case DSi_BPTWL::batteryLevel_AlmostEmpty: dsiBatterySliderPos = 0; break;
|
||||||
case DSi_BPTWL::batteryLevel_Low: dsiBatterySliderPos = 1; break;
|
case DSi_BPTWL::batteryLevel_Low: dsiBatterySliderPos = 1; break;
|
||||||
@ -99,30 +103,32 @@ PowerManagementDialog::~PowerManagementDialog()
|
|||||||
|
|
||||||
void PowerManagementDialog::done(int r)
|
void PowerManagementDialog::done(int r)
|
||||||
{
|
{
|
||||||
|
auto nds = emuInstance->getNDS();
|
||||||
|
|
||||||
if (r == QDialog::Accepted)
|
if (r == QDialog::Accepted)
|
||||||
{
|
{
|
||||||
if (emuThread->NDS->ConsoleType == 1)
|
if (nds->ConsoleType == 1)
|
||||||
{
|
{
|
||||||
auto& dsi = static_cast<DSi&>(*emuThread->NDS);
|
auto dsi = static_cast<DSi*>(nds);
|
||||||
Config::DSiBatteryLevel = dsi.I2C.GetBPTWL()->GetBatteryLevel();
|
Config::DSiBatteryLevel = dsi->I2C.GetBPTWL()->GetBatteryLevel();
|
||||||
Config::DSiBatteryCharging = dsi.I2C.GetBPTWL()->GetBatteryCharging();
|
Config::DSiBatteryCharging = dsi->I2C.GetBPTWL()->GetBatteryCharging();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Config::DSBatteryLevelOkay = emuThread->NDS->SPI.GetPowerMan()->GetBatteryLevelOkay();
|
Config::DSBatteryLevelOkay = nds->SPI.GetPowerMan()->GetBatteryLevelOkay();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (emuThread->NDS->ConsoleType == 1)
|
if (nds->ConsoleType == 1)
|
||||||
{
|
{
|
||||||
auto& dsi = static_cast<DSi&>(*emuThread->NDS);
|
auto dsi = static_cast<DSi*>(nds);
|
||||||
dsi.I2C.GetBPTWL()->SetBatteryLevel(oldDSiBatteryLevel);
|
dsi->I2C.GetBPTWL()->SetBatteryLevel(oldDSiBatteryLevel);
|
||||||
dsi.I2C.GetBPTWL()->SetBatteryCharging(oldDSiBatteryCharging);
|
dsi->I2C.GetBPTWL()->SetBatteryCharging(oldDSiBatteryCharging);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
emuThread->NDS->SPI.GetPowerMan()->SetBatteryLevelOkay(oldDSBatteryLevel);
|
nds->SPI.GetPowerMan()->SetBatteryLevelOkay(oldDSBatteryLevel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,17 +139,17 @@ void PowerManagementDialog::done(int r)
|
|||||||
|
|
||||||
void PowerManagementDialog::on_rbDSBatteryLow_clicked()
|
void PowerManagementDialog::on_rbDSBatteryLow_clicked()
|
||||||
{
|
{
|
||||||
emuThread->NDS->SPI.GetPowerMan()->SetBatteryLevelOkay(false);
|
emuInstance->getNDS()->SPI.GetPowerMan()->SetBatteryLevelOkay(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PowerManagementDialog::on_rbDSBatteryOkay_clicked()
|
void PowerManagementDialog::on_rbDSBatteryOkay_clicked()
|
||||||
{
|
{
|
||||||
emuThread->NDS->SPI.GetPowerMan()->SetBatteryLevelOkay(true);
|
emuInstance->getNDS()->SPI.GetPowerMan()->SetBatteryLevelOkay(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PowerManagementDialog::updateDSBatteryLevelControls()
|
void PowerManagementDialog::updateDSBatteryLevelControls()
|
||||||
{
|
{
|
||||||
if (emuThread->NDS->SPI.GetPowerMan()->GetBatteryLevelOkay())
|
if (emuInstance->getNDS()->SPI.GetPowerMan()->GetBatteryLevelOkay())
|
||||||
ui->rbDSBatteryOkay->setChecked(true);
|
ui->rbDSBatteryOkay->setChecked(true);
|
||||||
else
|
else
|
||||||
ui->rbDSBatteryLow->setChecked(true);
|
ui->rbDSBatteryLow->setChecked(true);
|
||||||
@ -151,10 +157,12 @@ void PowerManagementDialog::updateDSBatteryLevelControls()
|
|||||||
|
|
||||||
void PowerManagementDialog::on_cbDSiBatteryCharging_toggled()
|
void PowerManagementDialog::on_cbDSiBatteryCharging_toggled()
|
||||||
{
|
{
|
||||||
if (emuThread->NDS->ConsoleType == 1)
|
auto nds = emuInstance->getNDS();
|
||||||
|
|
||||||
|
if (nds->ConsoleType == 1)
|
||||||
{
|
{
|
||||||
auto& dsi = static_cast<DSi&>(*emuThread->NDS);
|
auto dsi = static_cast<DSi*>(nds);
|
||||||
dsi.I2C.GetBPTWL()->SetBatteryCharging(ui->cbDSiBatteryCharging->isChecked());
|
dsi->I2C.GetBPTWL()->SetBatteryCharging(ui->cbDSiBatteryCharging->isChecked());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -162,9 +170,11 @@ void PowerManagementDialog::on_sliderDSiBatteryLevel_valueChanged(int value)
|
|||||||
{
|
{
|
||||||
if (!inited) return;
|
if (!inited) return;
|
||||||
|
|
||||||
if (emuThread->NDS->ConsoleType == 1)
|
auto nds = emuInstance->getNDS();
|
||||||
|
|
||||||
|
if (nds->ConsoleType == 1)
|
||||||
{
|
{
|
||||||
auto& dsi = static_cast<DSi&>(*emuThread->NDS);
|
auto dsi = static_cast<DSi*>(nds);
|
||||||
u8 newBatteryLevel = DSi_BPTWL::batteryLevel_Full;
|
u8 newBatteryLevel = DSi_BPTWL::batteryLevel_Full;
|
||||||
switch (value)
|
switch (value)
|
||||||
{
|
{
|
||||||
@ -174,7 +184,7 @@ void PowerManagementDialog::on_sliderDSiBatteryLevel_valueChanged(int value)
|
|||||||
case 3: newBatteryLevel = DSi_BPTWL::batteryLevel_ThreeQuarters; break;
|
case 3: newBatteryLevel = DSi_BPTWL::batteryLevel_ThreeQuarters; break;
|
||||||
case 4: newBatteryLevel = DSi_BPTWL::batteryLevel_Full; break;
|
case 4: newBatteryLevel = DSi_BPTWL::batteryLevel_Full; break;
|
||||||
}
|
}
|
||||||
dsi.I2C.GetBPTWL()->SetBatteryLevel(newBatteryLevel);
|
dsi->I2C.GetBPTWL()->SetBatteryLevel(newBatteryLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateDSBatteryLevelControls();
|
updateDSBatteryLevelControls();
|
||||||
|
@ -25,19 +25,19 @@
|
|||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
|
||||||
namespace Ui { class PowerManagementDialog; }
|
namespace Ui { class PowerManagementDialog; }
|
||||||
class EmuThread;
|
|
||||||
class PowerManagementDialog;
|
class PowerManagementDialog;
|
||||||
|
class EmuInstance;
|
||||||
|
|
||||||
class PowerManagementDialog : public QDialog
|
class PowerManagementDialog : public QDialog
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit PowerManagementDialog(QWidget* parent, EmuThread* emu_thread);
|
explicit PowerManagementDialog(QWidget* parent);
|
||||||
~PowerManagementDialog();
|
~PowerManagementDialog();
|
||||||
|
|
||||||
static PowerManagementDialog* currentDlg;
|
static PowerManagementDialog* currentDlg;
|
||||||
static PowerManagementDialog* openDlg(QWidget* parent, EmuThread* emu_thread)
|
static PowerManagementDialog* openDlg(QWidget* parent)
|
||||||
{
|
{
|
||||||
if (currentDlg)
|
if (currentDlg)
|
||||||
{
|
{
|
||||||
@ -45,7 +45,7 @@ public:
|
|||||||
return currentDlg;
|
return currentDlg;
|
||||||
}
|
}
|
||||||
|
|
||||||
currentDlg = new PowerManagementDialog(parent, emu_thread);
|
currentDlg = new PowerManagementDialog(parent);
|
||||||
currentDlg->open();
|
currentDlg->open();
|
||||||
return currentDlg;
|
return currentDlg;
|
||||||
}
|
}
|
||||||
@ -65,7 +65,7 @@ private slots:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::PowerManagementDialog* ui;
|
Ui::PowerManagementDialog* ui;
|
||||||
EmuThread* emuThread;
|
EmuInstance* emuInstance;
|
||||||
|
|
||||||
bool inited;
|
bool inited;
|
||||||
bool oldDSBatteryLevel;
|
bool oldDSBatteryLevel;
|
||||||
|
Reference in New Issue
Block a user