summaryrefslogtreecommitdiffhomepage
path: root/src/utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils.c')
-rw-r--r--src/utils.c92
1 files changed, 90 insertions, 2 deletions
diff --git a/src/utils.c b/src/utils.c
index 3cff472b..c886d2a7 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -132,7 +132,7 @@ void TraceLog(int logType, const char *text, ...)
#else
char buffer[MAX_TRACELOG_BUFFER_SIZE] = { 0 };
- switch(logType)
+ switch (logType)
{
case LOG_TRACE: strcpy(buffer, "TRACE: "); break;
case LOG_DEBUG: strcpy(buffer, "DEBUG: "); break;
@@ -150,7 +150,7 @@ void TraceLog(int logType, const char *text, ...)
va_end(args);
- if (logType >= logTypeExit) exit(1); // If exit message, exit program
+ if (logType >= logTypeExit) exit(1); // If exit message, exit program
#endif // SUPPORT_TRACELOG
}
@@ -202,3 +202,91 @@ static int android_close(void *cookie)
return 0;
}
#endif
+
+#if defined(PLATFORM_UWP)
+
+#define MAX_MESSAGES 512 //If there are over 128 messages, I will cry... either way, this may be too much EDIT: Welp, 512
+
+static int UWPOutMessageId = -1; //Stores the last index for the message
+static UWPMessage* UWPOutMessages[MAX_MESSAGES]; //Messages out to UWP
+
+static int UWPInMessageId = -1; //Stores the last index for the message
+static UWPMessage* UWPInMessages[MAX_MESSAGES]; //Messages in from UWP
+
+UWPMessage* CreateUWPMessage(void)
+{
+ UWPMessage* msg = (UWPMessage*)RL_MALLOC(sizeof(UWPMessage));
+ msg->Type = None;
+ Vector2 v0 = {0, 0};
+ msg->Vector0 = v0;
+ msg->Int0 = 0;
+ msg->Int1 = 0;
+ msg->Char0 = 0;
+ msg->Float0 = 0;
+ msg->Double0 = 0;
+ msg->Bool0 = false;
+ return msg;
+}
+
+void DeleteUWPMessage(UWPMessage* msg)
+{
+ RL_FREE(msg);
+}
+
+bool UWPHasMessages(void)
+{
+ return UWPOutMessageId > -1;
+}
+
+UWPMessage* UWPGetMessage(void)
+{
+ if (UWPHasMessages())
+ {
+ return UWPOutMessages[UWPOutMessageId--];
+ }
+
+ return NULL;
+}
+
+void UWPSendMessage(UWPMessage* msg)
+{
+ if (UWPInMessageId + 1 < MAX_MESSAGES)
+ {
+ UWPInMessageId++;
+ UWPInMessages[UWPInMessageId] = msg;
+ }
+ else
+ {
+ TraceLog(LOG_WARNING, "[UWP Messaging] Not enough array space to register new UWP inbound Message.");
+ }
+}
+
+void SendMessageToUWP(UWPMessage* msg)
+{
+ if (UWPOutMessageId + 1 < MAX_MESSAGES)
+ {
+ UWPOutMessageId++;
+ UWPOutMessages[UWPOutMessageId] = msg;
+ }
+ else
+ {
+ TraceLog(LOG_WARNING, "[UWP Messaging] Not enough array space to register new UWP outward Message.");
+ }
+}
+
+bool HasMessageFromUWP(void)
+{
+ return UWPInMessageId > -1;
+}
+
+UWPMessage* GetMessageFromUWP(void)
+{
+ if (HasMessageFromUWP())
+ {
+ return UWPInMessages[UWPInMessageId--];
+ }
+
+ return NULL;
+}
+
+#endif