diff --git a/Common/Common.vcxproj b/Common/Common.vcxproj
index c066494c66..a28696099b 100644
--- a/Common/Common.vcxproj
+++ b/Common/Common.vcxproj
@@ -550,6 +550,7 @@
+
@@ -1005,6 +1006,7 @@
+
diff --git a/Common/Common.vcxproj.filters b/Common/Common.vcxproj.filters
index cce4e7656a..23b138fb39 100644
--- a/Common/Common.vcxproj.filters
+++ b/Common/Common.vcxproj.filters
@@ -494,6 +494,9 @@
ext\basis_universal
+
+ System
+
@@ -920,6 +923,9 @@
ext\basis_universal
+
+ System
+
diff --git a/Common/System/Message.cpp b/Common/System/Message.cpp
new file mode 100644
index 0000000000..8a09fc3a04
--- /dev/null
+++ b/Common/System/Message.cpp
@@ -0,0 +1,55 @@
+#include "Common/System/Message.h"
+#include "Common/System/System.h"
+#include "Common/Log.h"
+
+RequestManager g_RequestManager;
+
+const char *RequestTypeAsString(SystemRequestType type) {
+ switch (type) {
+ case SystemRequestType::INPUT_TEXT_MODAL: return "INPUT_TEXT_MODAL";
+ default: return "N/A";
+ }
+}
+
+bool RequestManager::MakeSystemRequest(SystemRequestType type, RequestCallback callback, const char *param1, const char *param2) {
+ int requestId = idCounter_++;
+ if (!System_MakeRequest(type, requestId, param1, param2)) {
+ return false;
+ }
+
+ if (!callback) {
+ // We don't expect a response, this is a one-directional request. We're thus done.
+ return true;
+ }
+
+ std::lock_guard guard(callbackMutex_);
+ callbackMap_[requestId] = callback;
+ return true;
+}
+
+void RequestManager::PostSystemResponse(int requestId, const char *responseString, int responseValue) {
+ std::lock_guard guard(callbackMutex_);
+ auto iter = callbackMap_.find(requestId);
+ if (iter == callbackMap_.end()) {
+ // Unexpected!
+ ERROR_LOG(SYSTEM, "PostSystemResponse: Unexpected request ID %d for %s (responseString=%s)", requestId, responseString);
+ return;
+ }
+
+ std::lock_guard responseGuard(responseMutex_);
+ PendingResponse response;
+ response.callback = iter->second;
+ response.responseString = responseString;
+ response.responseValue = responseValue;
+ pendingResponses_.push_back(response);
+}
+
+void RequestManager::ProcessRequests() {
+ std::lock_guard guard(responseMutex_);
+ for (auto &iter : pendingResponses_) {
+ if (iter.callback) {
+ iter.callback(iter.responseString.c_str(), iter.responseValue);
+ }
+ }
+ pendingResponses_.clear();
+}
diff --git a/Common/System/Message.h b/Common/System/Message.h
new file mode 100644
index 0000000000..88cd58df41
--- /dev/null
+++ b/Common/System/Message.h
@@ -0,0 +1,50 @@
+#pragma once
+
+#include
+#include
+#include