aboutsummaryrefslogtreecommitdiffstats
path: root/Samples/OculusRoomTiny/MessageBox.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Samples/OculusRoomTiny/MessageBox.cpp')
-rw-r--r--Samples/OculusRoomTiny/MessageBox.cpp61
1 files changed, 61 insertions, 0 deletions
diff --git a/Samples/OculusRoomTiny/MessageBox.cpp b/Samples/OculusRoomTiny/MessageBox.cpp
new file mode 100644
index 0000000..be3d136
--- /dev/null
+++ b/Samples/OculusRoomTiny/MessageBox.cpp
@@ -0,0 +1,61 @@
+#include "MessageBox.h"
+#ifdef WIN32
+#include <Windows.h>
+#endif
+
+#ifdef __APPLE__
+#include <CoreFoundation/CoreFoundation.h>
+#endif
+
+
+MessageBoxResult MessageBox(const char * text) {
+#ifdef WIN32
+ int result = ::MessageBoxA(0, text, "Oculus Rift Detection",
+ MB_CANCELTRYCONTINUE|MB_ICONWARNING);
+ switch (result) {
+ case IDCANCEL:
+ return Cancel;
+ case IDCONTINUE:
+ return Continue;
+ case IDRETRY:
+ return Retry;
+ }
+#endif
+
+#ifdef __APPLE__
+ CFStringRef headerStrRef = CFStringCreateWithCString(NULL, "Oculus Rift Detection", kCFStringEncodingMacRoman);
+ CFStringRef messageStrRef = CFStringCreateWithCString(NULL, text, kCFStringEncodingMacRoman);
+ CFOptionFlags result;
+
+// kCFUserNotificationDefaultResponse = 0,
+// kCFUserNotificationAlternateResponse = 1,
+// kCFUserNotificationOtherResponse = 2,
+// kCFUserNotificationCancelResponse = 3
+
+ //launch the message box
+ CFUserNotificationDisplayAlert(0,
+ kCFUserNotificationNoteAlertLevel,
+ NULL, NULL, NULL,
+ headerStrRef, // header text
+ messageStrRef, // message text
+ CFSTR("Try again"),
+ CFSTR("Continue"),
+ CFSTR("Cancel"),
+ &result);
+
+ //Clean up the strings
+ CFRelease(headerStrRef);
+ CFRelease(messageStrRef);
+
+ switch (result) {
+ case kCFUserNotificationCancelResponse:
+ case kCFUserNotificationOtherResponse:
+ return Cancel;
+ case kCFUserNotificationDefaultResponse:
+ return Retry;
+ case kCFUserNotificationAlternateResponse:
+ return Continue;
+ }
+#endif
+ return Continue;
+}