Skip to content

Commit d6fca7a

Browse files
abairedracc
authored andcommitted
menu: Adds option to power off the XBOX.
1 parent d43e27b commit d6fca7a

4 files changed

Lines changed: 21 additions & 0 deletions

File tree

Includes/menu.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,10 @@ Menu::Menu(const Config& config, Renderer& renderer) :
335335
std::shared_ptr<MenuExec> newNode = std::make_shared<MenuExec>(
336336
e["label"], [](Menu*) { XBELauncher::exitToDashboard(); });
337337
this->rootNode.addNode(newNode);
338+
} else if (!static_cast<std::string>(e["type"]).compare("shutdown")) {
339+
std::shared_ptr<MenuExec> newNode = std::make_shared<MenuExec>(
340+
e["label"], [](Menu*) { XBELauncher::shutdown(); });
341+
this->rootNode.addNode(newNode);
338342
} else if (!static_cast<std::string>(e["type"]).compare("settings")) {
339343
std::shared_ptr<MenuNode> newNode = std::make_shared<settingsMenu>(currentMenu,
340344
e["label"]);

Includes/xbeLauncher.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,15 @@
33
#ifdef NXDK
44
#include <hal/video.h>
55
#include <hal/xbox.h>
6+
#include <xboxkrnl/xboxkrnl.h>
67
#endif
78

9+
void XBELauncher::shutdown() {
10+
#ifdef NXDK
11+
HalInitiateShutdown();
12+
#endif
13+
}
14+
815
void XBELauncher::exitToDashboard() {
916
showLaunchImage();
1017
// TODO: Switch to XLaunchXBE(nullptr) if XboxDev/nxdk#501 is merged.

Includes/xbeLauncher.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,13 @@
66
// Launches an XBE (or the dashboard).
77
class XBELauncher {
88
public:
9+
// Powers down the XBOX. Should not return.
10+
static void shutdown();
11+
12+
// Returns to the dashboard. Should not return.
913
static void exitToDashboard();
14+
15+
// Launches the XBE at the given path. Should not return.
1016
static void launch(std::string const& xbePath);
1117

1218
private:

sampleconfig.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@
6464
"label": "Reboot",
6565
"type": "reboot"
6666
},
67+
{
68+
"label": "Power off",
69+
"type": "shutdown"
70+
},
6771
{
6872
"label": "Some stupid submenu",
6973
"type": "submenu"

0 commit comments

Comments
 (0)