aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backends/platform/wii/main.cpp19
-rw-r--r--backends/platform/wii/osystem.cpp2
-rw-r--r--backends/platform/wii/osystem.h13
-rw-r--r--backends/platform/wii/osystem_events.cpp9
4 files changed, 43 insertions, 0 deletions
diff --git a/backends/platform/wii/main.cpp b/backends/platform/wii/main.cpp
index 7529df6de3..5753ecefe4 100644
--- a/backends/platform/wii/main.cpp
+++ b/backends/platform/wii/main.cpp
@@ -36,6 +36,17 @@
extern "C" {
#endif
+bool reset_btn_pressed = false;
+bool power_btn_pressed = false;
+
+void reset_cb(void) {
+ reset_btn_pressed = true;
+}
+
+void power_cb(void) {
+ power_btn_pressed = true;
+}
+
int main(int argc, char *argv[]) {
s32 res;
@@ -50,6 +61,9 @@ int main(int argc, char *argv[]) {
printf("startup\n");
+ SYS_SetResetCallback(reset_cb);
+ SYS_SetPowerCallback(power_cb);
+
if (!fatInitDefault()) {
printf("fatInitDefault failed\n");
} else {
@@ -77,6 +91,11 @@ int main(int argc, char *argv[]) {
fatUnsafeUnmount(PI_DEFAULT);
}
+ if (power_btn_pressed) {
+ printf("shutting down\n");
+ SYS_ResetSystem(SYS_POWEROFF, 0, 0);
+ }
+
printf("reloading\n");
return res;
diff --git a/backends/platform/wii/osystem.cpp b/backends/platform/wii/osystem.cpp
index 97bee24d0f..2667ecb69d 100644
--- a/backends/platform/wii/osystem.cpp
+++ b/backends/platform/wii/osystem.cpp
@@ -63,6 +63,8 @@ OSystem_Wii::OSystem_Wii() :
_mouseKeyColor(0),
_mouseCursor(NULL),
+ _event_quit(false),
+
_savefile(NULL),
_mixer(NULL),
_timer(NULL) {
diff --git a/backends/platform/wii/osystem.h b/backends/platform/wii/osystem.h
index f65310bada..2a168fd0b7 100644
--- a/backends/platform/wii/osystem.h
+++ b/backends/platform/wii/osystem.h
@@ -37,6 +37,17 @@
#include <gccore.h>
#include <ogcsys.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern bool reset_btn_pressed;
+extern bool power_btn_pressed;
+
+#ifdef __cplusplus
+}
+#endif
+
class OSystem_Wii : public OSystem {
private:
s64 _startup_time;
@@ -69,6 +80,8 @@ private:
u8 _mouseKeyColor;
u8 *_mouseCursor;
+ bool _event_quit;
+
u32 _lastPadCheck;
void initGfx();
diff --git a/backends/platform/wii/osystem_events.cpp b/backends/platform/wii/osystem_events.cpp
index 09dfb5e96b..2d7c2d9c18 100644
--- a/backends/platform/wii/osystem_events.cpp
+++ b/backends/platform/wii/osystem_events.cpp
@@ -140,6 +140,15 @@ void OSystem_Wii::updateEventScreenResolution() {
} while (0)
bool OSystem_Wii::pollEvent(Common::Event &event) {
+ if ((reset_btn_pressed || power_btn_pressed) && !_event_quit) {
+ _event_quit = true;
+ event.type = Common::EVENT_QUIT;
+
+ printf("quit event\n");
+
+ return true;
+ }
+
u32 bd, bh, bu;
PAD_ScanPads();