diff options
author | Brad Davis <[email protected]> | 2013-10-13 20:28:58 -0700 |
---|---|---|
committer | Brad Davis <[email protected]> | 2013-10-13 20:28:58 -0700 |
commit | 672cdd0ef5455cd62a0d7f7eb6b9889f3ea35f21 (patch) | |
tree | f3454dc864242744aef1ea5474b5011556d0f388 /Samples/OculusRoomTiny/MessageBox.cpp | |
parent | 1408ed7b208c7a1cff1a2448fc890e9b8bd6dc4e (diff) |
Updating to cmake, glew, xrandr
Diffstat (limited to 'Samples/OculusRoomTiny/MessageBox.cpp')
-rw-r--r-- | Samples/OculusRoomTiny/MessageBox.cpp | 61 |
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; +} |