From 477ea4d6606aa4659549f786935096942f187b37 Mon Sep 17 00:00:00 2001 From: Ray Date: Tue, 12 Mar 2019 16:00:26 +0100 Subject: Support external config flags --- src/utils.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/utils.c') diff --git a/src/utils.c b/src/utils.c index b31ce6ae..6b174354 100644 --- a/src/utils.c +++ b/src/utils.c @@ -30,9 +30,13 @@ * **********************************************************************************************/ -#include "config.h" - #include "raylib.h" // WARNING: Required for: LogType enum + +// Check if config flags have been externally provided on compilation line +#if !defined(EXTERNAL_CONFIG_FLAGS) + #include "config.h" // Defines module configuration flags +#endif + #include "utils.h" #if defined(PLATFORM_ANDROID) -- cgit v1.2.3 From f21761fbbb02f0b58b5b54342f0c3ad3abc0003e Mon Sep 17 00:00:00 2001 From: ChillerDragon Date: Sun, 7 Apr 2019 17:49:12 +0200 Subject: Happy new year 2019 --- src/utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/utils.c') diff --git a/src/utils.c b/src/utils.c index 6b174354..10cce9b9 100644 --- a/src/utils.c +++ b/src/utils.c @@ -11,7 +11,7 @@ * * LICENSE: zlib/libpng * -* Copyright (c) 2014-2018 Ramon Santamaria (@raysan5) +* Copyright (c) 2014-2019 Ramon Santamaria (@raysan5) * * This software is provided "as-is", without any express or implied warranty. In no event * will the authors be held liable for any damages arising from the use of this software. -- cgit v1.2.3 From e67ebabb02c1068d6e7f5107dcff5388ede3faa5 Mon Sep 17 00:00:00 2001 From: Ray Date: Tue, 23 Apr 2019 14:55:35 +0200 Subject: Support custom memory management macros Users can define their custom memory management macros. NOTE: Most external libraries support custom macros in the same way, raylib should redefine those macros to raylib ones, to unify custom memory loading. That redefinition is only implemented as example for stb_image.h in [textures] module. --- src/utils.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/utils.c') diff --git a/src/utils.c b/src/utils.c index 10cce9b9..3cff472b 100644 --- a/src/utils.c +++ b/src/utils.c @@ -45,10 +45,10 @@ #include // Required for: Android assets manager: AAsset, AAssetManager_open(), ... #endif -#include // Required for: malloc(), free() -#include // Required for: fopen(), fclose(), fputc(), fwrite(), printf(), fprintf(), funopen() +#include // Required for: exit() +#include // Required for: printf(), sprintf() #include // Required for: va_list, va_start(), vfprintf(), va_end() -#include // Required for: strlen(), strrchr(), strcmp() +#include // Required for: strcpy(), strcat() #define MAX_TRACELOG_BUFFER_SIZE 128 // Max length of one trace-log message -- cgit v1.2.3 From 2de1f318212dbceb71db6be053be995208748f2a Mon Sep 17 00:00:00 2001 From: Reece Mackie <20544390+Rover656@users.noreply.github.com> Date: Sat, 27 Apr 2019 19:33:51 +0100 Subject: 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 --- src/utils.c | 92 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 90 insertions(+), 2 deletions(-) (limited to 'src/utils.c') 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 -- cgit v1.2.3 From e8c413b7cd1696c207d015bc3e4a00edf71300d2 Mon Sep 17 00:00:00 2001 From: raysan5 Date: Sat, 27 Apr 2019 22:47:03 +0200 Subject: Review UWP implementation Basically, formating review and some variables naming to follow raylib conventions. --- src/utils.c | 63 ++++++++++++++++++++++++------------------------------------- 1 file changed, 25 insertions(+), 38 deletions(-) (limited to 'src/utils.c') diff --git a/src/utils.c b/src/utils.c index c886d2a7..52fd0b45 100644 --- a/src/utils.c +++ b/src/utils.c @@ -205,73 +205,64 @@ static int android_close(void *cookie) #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 +#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 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 +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; + UWPMessage *msg = (UWPMessage *)RL_MALLOC(sizeof(UWPMessage)); + msg->type = UWP_MSG_NONE; + Vector2 v0 = { 0, 0 }; + msg->paramVector0 = v0; + msg->paramInt0 = 0; + msg->paramInt1 = 0; + msg->paramChar0 = 0; + msg->paramFloat0 = 0; + msg->paramDouble0 = 0; + msg->paramBool0 = false; return msg; } -void DeleteUWPMessage(UWPMessage* msg) +void DeleteUWPMessage(UWPMessage *msg) { RL_FREE(msg); } bool UWPHasMessages(void) { - return UWPOutMessageId > -1; + return (UWPOutMessageId > -1); } -UWPMessage* UWPGetMessage(void) +UWPMessage *UWPGetMessage(void) { - if (UWPHasMessages()) - { - return UWPOutMessages[UWPOutMessageId--]; - } + if (UWPHasMessages()) return UWPOutMessages[UWPOutMessageId--]; return NULL; } -void UWPSendMessage(UWPMessage* msg) +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."); - } + else TraceLog(LOG_WARNING, "[UWP Messaging] Not enough array space to register new UWP inbound Message."); } -void SendMessageToUWP(UWPMessage* msg) +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."); - } + else TraceLog(LOG_WARNING, "[UWP Messaging] Not enough array space to register new UWP outward Message."); } bool HasMessageFromUWP(void) @@ -281,12 +272,8 @@ bool HasMessageFromUWP(void) UWPMessage* GetMessageFromUWP(void) { - if (HasMessageFromUWP()) - { - return UWPInMessages[UWPInMessageId--]; - } + if (HasMessageFromUWP()) return UWPInMessages[UWPInMessageId--]; return NULL; } - -#endif +#endif // defined(PLATFORM_UWP) -- cgit v1.2.3 From 40940f439860b3345198dc44cd493f0c0dc12f7c Mon Sep 17 00:00:00 2001 From: raysan5 Date: Sun, 28 Apr 2019 16:45:23 +0200 Subject: Some formatting review --- src/utils.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/utils.c') diff --git a/src/utils.c b/src/utils.c index 52fd0b45..ee4be46d 100644 --- a/src/utils.c +++ b/src/utils.c @@ -34,7 +34,7 @@ // Check if config flags have been externally provided on compilation line #if !defined(EXTERNAL_CONFIG_FLAGS) - #include "config.h" // Defines module configuration flags + #include "config.h" // Defines module configuration flags #endif #include "utils.h" @@ -69,7 +69,7 @@ AAssetManager *assetManager; // Module specific Functions Declaration //---------------------------------------------------------------------------------- #if defined(PLATFORM_ANDROID) -/* This should be in , but Travis doesn't find it... */ +// This should be in , but Travis does not find it... FILE *funopen(const void *cookie, int (*readfn)(void *, char *, int), int (*writefn)(void *, const char *, int), fpos_t (*seekfn)(void *, fpos_t, int), int (*closefn)(void *)); @@ -173,7 +173,7 @@ FILE *android_fopen(const char *fileName, const char *mode) return funopen(asset, android_read, android_write, android_seek, android_close); } -#endif +#endif // PLATFORM_ANDROID //---------------------------------------------------------------------------------- // Module specific Functions Definition @@ -201,7 +201,7 @@ static int android_close(void *cookie) AAsset_close((AAsset *)cookie); return 0; } -#endif +#endif // PLATFORM_ANDROID #if defined(PLATFORM_UWP) @@ -276,4 +276,4 @@ UWPMessage* GetMessageFromUWP(void) return NULL; } -#endif // defined(PLATFORM_UWP) +#endif // PLATFORM_UWP -- cgit v1.2.3