summaryrefslogtreecommitdiffhomepage
path: root/src/utils.c
diff options
context:
space:
mode:
authorReece Mackie <[email protected]>2019-04-27 19:33:51 +0100
committerRay <[email protected]>2019-04-27 20:33:51 +0200
commit2de1f318212dbceb71db6be053be995208748f2a (patch)
treea357bfc6e8b825ebfd26098a32bc11efa2c8dc8e /src/utils.c
parentf37e55a77bd6177dbaea4d7f484961c09104e104 (diff)
downloadraylib-2de1f318212dbceb71db6be053be995208748f2a.tar.gz
raylib-2de1f318212dbceb71db6be053be995208748f2a.zip
UWP Support Overhaul (#819)
* Working build * Fix build again, stop deleting files * Hotfix crash, needs investigating * Remove VS2015.UWP, I cannot update the project * Lots of UWP work, added keyboard and mouse press support. Still need to finish scroll wheel, mouse position and cursor hiding, plus other stuff that I haven't seen yet. * Implemented a ton more things, added BaseApp.h to provide common code to UWP apps. * Remove constant window dimensions * Enable and Disable cursor support. * Actually use mouse delta * Gamepad Support * Cleaning and small tweaks * Restore original example. * Update comment * Use 'Messages' to handle the cursor functions so code is more portable. * Comment * Comment unused message fields and use vector for mouse pos instead. * Move messages to utils.h and use messages for everything. No more plat-specific code in raylib.h * Working build * Fix build again, stop deleting files * Hotfix crash, needs investigating * Remove VS2015.UWP, I cannot update the project * Lots of UWP work, added keyboard and mouse press support. Still need to finish scroll wheel, mouse position and cursor hiding, plus other stuff that I haven't seen yet. * Implemented a ton more things, added BaseApp.h to provide common code to UWP apps. * Remove constant window dimensions * Enable and Disable cursor support. * Actually use mouse delta * Gamepad Support * Cleaning and small tweaks * Restore original example. * Update comment * Use 'Messages' to handle the cursor functions so code is more portable. * Comment * Comment unused message fields and use vector for mouse pos instead. * Move messages to utils.h and use messages for everything. No more plat-specific code in raylib.h * Tested some desktop stuff and added projection matrix updates for window resizing. * Fixed big bad mouse bug * Fix alt buttons and add hack to combat flickery key presses (far from perfect) * Remove debug code * Final commit * Well, so I thought * Wow, i am bad * Remove packages folder * Remove useless include * Apply requested changes and fix linux build * Try to stop packages folder * Have we fixed the formatting properly? * Third time's the charm? * Where did this come from? * Re-fix * Autoformat is gonna kill * Fixed XBOX ONE Support * Fix tabs
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