Skip to content

Commit

Permalink
Enable ignore required firmware version for USB install
Browse files Browse the repository at this point in the history
  • Loading branch information
satelliteseeker committed Oct 17, 2018
1 parent 3f1a8c9 commit a923b94
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
2 changes: 2 additions & 0 deletions include/mode/usb_install_mode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace tin::ui
private:
std::vector<std::string> m_nspNames;
FsStorageId m_destStorageId = FsStorageId_SdCard;
bool m_ignoreReqFirmVersion = false;

public:
USBInstallMode();
Expand All @@ -20,5 +21,6 @@ namespace tin::ui
void OnSelected() override;
void OnNSPSelected();
void OnDestinationSelected();
void OnIgnoreReqFirmVersionSelected();
};
}
32 changes: 30 additions & 2 deletions source/mode/usb_install_mode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,15 +166,43 @@ namespace tin::ui
m_destStorageId = FsStorageId_NandUser;
}

auto view = std::make_unique<tin::ui::ConsoleView>(4);
auto view = std::make_unique<tin::ui::ConsoleOptionsView>();
view->AddEntry("Ignore Required Firmware Version", tin::ui::ConsoleEntrySelectType::HEADING, nullptr);
view->AddEntry("", tin::ui::ConsoleEntrySelectType::NONE, nullptr);
view->AddEntry("No", tin::ui::ConsoleEntrySelectType::SELECT, std::bind(&USBInstallMode::OnIgnoreReqFirmVersionSelected, this));
view->AddEntry("Yes", tin::ui::ConsoleEntrySelectType::SELECT, std::bind(&USBInstallMode::OnIgnoreReqFirmVersionSelected, this));
manager.PushView(std::move(view));
}

void USBInstallMode::OnIgnoreReqFirmVersionSelected()
{
// Retrieve previous selection
tin::ui::ViewManager& manager = tin::ui::ViewManager::Instance();
ConsoleOptionsView* prevView;

if (!(prevView = dynamic_cast<ConsoleOptionsView*>(manager.GetCurrentView())))
{
throw std::runtime_error("Previous view must be a ConsoleOptionsView!");
}

auto optStr = prevView->GetSelectedOptionValue()->GetText();
m_ignoreReqFirmVersion = false;

if (optStr == "Yes")
{
m_ignoreReqFirmVersion = true;
}

// Push a blank view ready for installation
auto view = std::make_unique<tin::ui::ConsoleView>(5);
manager.PushView(std::move(view));

for (auto& nspName : m_nspNames)
{
tin::install::nsp::USBNSP usbNSP(nspName);

printf("Installing from %s\n", nspName.c_str());
tin::install::nsp::RemoteNSPInstall install(m_destStorageId, false, &usbNSP);
tin::install::nsp::RemoteNSPInstall install(m_destStorageId, m_ignoreReqFirmVersion, &usbNSP);

printf("Preparing install...\n");
install.Prepare();
Expand Down

0 comments on commit a923b94

Please sign in to comment.