Review UWP implementation

Basically, formating review and some variables naming to follow raylib conventions.
This commit is contained in:
raysan5 2019-04-27 22:47:03 +02:00
parent 2de1f31821
commit e8c413b7cd
7 changed files with 299 additions and 385 deletions

View file

@ -30,25 +30,13 @@ static int gTime = 0;
// This method is called every frame
void App::Update()
{
//return;
// Draw
BeginDrawing();
ClearBackground(RAYWHITE);
// Update
//----------------------------------------------------------------------------------
posX += GetGamepadAxisMovement(GAMEPAD_PLAYER1, GAMEPAD_XBOX_AXIS_LEFT_X) * 5;
posY += GetGamepadAxisMovement(GAMEPAD_PLAYER1, GAMEPAD_XBOX_AXIS_LEFT_Y) * -5;
DrawRectangle(posX, posY, 400, 100, RED);
DrawLine(0, 0, GetScreenWidth(), GetScreenHeight(), BLUE);
auto mPos = GetMousePosition();
DrawCircle(mPos.x, mPos.y, 40, BLUE);
if (IsKeyDown(KEY_S)) DrawCircle(100, 100, 100, BLUE);
if (IsKeyPressed(KEY_A))
{
posX -= 50;
@ -61,18 +49,31 @@ void App::Update()
DisableCursor();
}
if (IsKeyDown(KEY_LEFT_ALT))
DrawRectangle(250, 250, 20, 20, BLACK);
if (IsKeyDown(KEY_BACKSPACE))
DrawRectangle(280, 250, 20, 20, BLACK);
if (IsMouseButtonDown(MOUSE_LEFT_BUTTON))
DrawRectangle(280, 250, 20, 20, BLACK);
static int pos = 0;
pos -= GetMouseWheelMove();
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(RAYWHITE);
DrawRectangle(posX, posY, 400, 100, RED);
DrawLine(0, 0, GetScreenWidth(), GetScreenHeight(), BLUE);
DrawCircle(mPos.x, mPos.y, 40, BLUE);
if (IsKeyDown(KEY_S)) DrawCircle(100, 100, 100, BLUE);
if (IsKeyDown(KEY_LEFT_ALT)) DrawRectangle(250, 250, 20, 20, BLACK);
if (IsKeyDown(KEY_BACKSPACE)) DrawRectangle(280, 250, 20, 20, BLACK);
if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) DrawRectangle(280, 250, 20, 20, BLACK);
DrawRectangle(280, pos + 50, 20, 20, BLACK);
DrawRectangle(250, 280 + (gTime++ % 60), 10, 10, PURPLE);
EndDrawing();
//----------------------------------------------------------------------------------
}

View file

@ -139,8 +139,8 @@ public:
// Send display dimensions
UWPMessage *msg = CreateUWPMessage();
msg->Type = SetDisplayDims;
msg->Vector0 = screenSize;
msg->type = UWP_MSG_SET_DISPLAY_DIMS;
msg->paramVector0 = screenSize;
UWPSendMessage(msg);
// Send the time to the core
@ -148,8 +148,7 @@ public:
auto timeStart = clock::now();
// Set fps if 0
if (GetFPS() <= 0)
SetTargetFPS(60);
if (GetFPS() <= 0) SetTargetFPS(60);
while (!mWindowClosed)
{
@ -159,8 +158,8 @@ public:
auto delta = clock::now() - timeStart;
UWPMessage *timeMsg = CreateUWPMessage();
timeMsg->Type = SetGameTime;
timeMsg->Double0 = std::chrono::duration_cast<std::chrono::seconds>(delta).count();
timeMsg->type = UWP_MSG_SET_GAME_TIME;
timeMsg->paramDouble0 = std::chrono::duration_cast<std::chrono::seconds>(delta).count();
UWPSendMessage(timeMsg);
// Call update function
@ -198,26 +197,26 @@ protected:
auto msg = UWPGetMessage();
// Carry out the command
switch(msg->Type)
switch(msg->type)
{
case ShowMouse: //Do the same thing because of how UWP works...
case UnlockMouse:
case UWP_MSG_SHOW_MOUSE: // Do the same thing because of how UWP works...
case UWP_MSG_UNLOCK_MOUSE:
{
CoreWindow::GetForCurrentThread()->PointerCursor = regularCursor;
cursorLocked = false;
MoveMouse(GetMousePosition());
break;
}
case HideMouse: //Do the same thing because of how UWP works...
case LockMouse:
case UWP_MSG_HIDE_MOUSE: // Do the same thing because of how UWP works...
case UWP_MSG_LOCK_MOUSE:
{
CoreWindow::GetForCurrentThread()->PointerCursor = nullptr;
cursorLocked = true;
break;
}
case SetMouseLocation:
case UWP_MSG_SET_MOUSE_LOCATION:
{
MoveMouse(msg->Vector0);
MoveMouse(msg->paramVector0);
break;
}
}
@ -283,7 +282,8 @@ protected:
// Process Mouse
{
if (CurrentPointerID > -1) {
if (CurrentPointerID > -1)
{
auto point = PointerPoint::GetCurrentPoint(CurrentPointerID);
auto props = point->Properties;
@ -355,9 +355,9 @@ protected:
// e.g. player 1, 2, and 3 are playing a game - if player2 disconnects, p3's controller would now be mapped to p2's character since p3 is now second in the list.
UWPMessage* msg = CreateUWPMessage();
msg->Type = MarkGamepadActive;
msg->Int0 = i;
msg->Bool0 = i < Gamepad::Gamepads->Size;
msg->type = UWP_MSG_SET_GAMEPAD_ACTIVE;
msg->paramInt0 = i;
msg->paramBool0 = i < Gamepad::Gamepads->Size;
UWPSendMessage(msg);
}
@ -410,7 +410,7 @@ protected:
void OnWindowSizeChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::WindowSizeChangedEventArgs^ args)
{
UWPMessage* msg = CreateUWPMessage();
msg->Type = HandleResize;
msg->type = UWP_MSG_HANDLE_RESIZE;
UWPSendMessage(msg);
}
@ -439,8 +439,8 @@ protected:
void PointerWheelChanged(Windows::UI::Core::CoreWindow ^sender, Windows::UI::Core::PointerEventArgs^ args)
{
UWPMessage* msg = CreateUWPMessage();
msg->Type = ScrollWheelUpdate;
msg->Float0 = args->CurrentPoint->Properties->MouseWheelDelta;
msg->type = UWP_MSG_SCROLL_WHEEL_UPDATE;
msg->paramFloat0 = args->CurrentPoint->Properties->MouseWheelDelta;
UWPSendMessage(msg);
}
@ -492,9 +492,9 @@ private:
void RegisterKey(int key, char status)
{
UWPMessage* msg = CreateUWPMessage();
msg->Type = UWPMessageType::RegisterKey;
msg->Int0 = key;
msg->Char0 = status;
msg->type = UWPMessageType::UWP_MSG_REGISTER_KEY;
msg->paramInt0 = key;
msg->paramChar0 = status;
UWPSendMessage(msg);
}
@ -508,37 +508,37 @@ private:
void RegisterGamepadButton(int gamepad, int button, char status)
{
UWPMessage* msg = CreateUWPMessage();
msg->Type = MarkGamepadButton;
msg->Int0 = gamepad;
msg->Int1 = button;
msg->Char0 = status;
msg->type = UWP_MSG_SET_GAMEPAD_BUTTON;
msg->paramInt0 = gamepad;
msg->paramInt1 = button;
msg->paramChar0 = status;
UWPSendMessage(msg);
}
void RegisterGamepadAxis(int gamepad, int axis, float value)
{
UWPMessage* msg = CreateUWPMessage();
msg->Type = MarkGamepadAxis;
msg->Int0 = gamepad;
msg->Int1 = axis;
msg->Float0 = value;
msg->type = UWP_MSG_SET_GAMEPAD_AXIS;
msg->paramInt0 = gamepad;
msg->paramInt1 = axis;
msg->paramFloat0 = value;
UWPSendMessage(msg);
}
void UpdateMousePosition(Vector2 pos)
{
UWPMessage* msg = CreateUWPMessage();
msg->Type = UpdateMouseLocation;
msg->Vector0 = pos;
msg->type = UWP_MSG_UPDATE_MOUSE_LOCATION;
msg->paramVector0 = pos;
UWPSendMessage(msg);
}
void RegisterClick(int button, char status)
{
UWPMessage* msg = CreateUWPMessage();
msg->Type = UWPMessageType::RegisterClick;
msg->Int0 = button;
msg->Char0 = status;
msg->type = UWPMessageType::UWP_MSG_REGISTER_CLICK;
msg->paramInt0 = button;
msg->paramChar0 = status;
UWPSendMessage(msg);
}

View file

@ -391,7 +391,6 @@ static int gamepadStream[MAX_GAMEPADS] = { -1 };// Gamepad device file descripto
static pthread_t gamepadThreadId; // Gamepad reading thread id
static char gamepadName[64]; // Gamepad name holder
#endif
//-----------------------------------------------------------------------------------
// Timming system variables
@ -402,7 +401,6 @@ static double updateTime = 0.0; // Time measure for frame update
static double drawTime = 0.0; // Time measure for frame draw
static double frameTime = 0.0; // Time measure for one frame
static double targetTime = 0.0; // Desired time for one frame, if 0 not applied
//-----------------------------------------------------------------------------------
// Config internal variables
@ -1028,7 +1026,7 @@ void ShowCursor(void)
#endif
#if defined(PLATFORM_UWP)
UWPMessage *msg = CreateUWPMessage();
msg->Type = ShowMouse;
msg->type = UWP_MSG_SHOW_MOUSE;
SendMessageToUWP(msg);
#endif
cursorHidden = false;
@ -1042,7 +1040,7 @@ void HideCursor(void)
#endif
#if defined(PLATFORM_UWP)
UWPMessage *msg = CreateUWPMessage();
msg->Type = HideMouse;
msg->type = UWP_MSG_HIDE_MOUSE;
SendMessageToUWP(msg);
#endif
cursorHidden = true;
@ -1065,7 +1063,7 @@ void EnableCursor(void)
#endif
#if defined(PLATFORM_UWP)
UWPMessage *msg = CreateUWPMessage();
msg->Type = LockMouse;
msg->type = UWP_MSG_LOCK_MOUSE;
SendMessageToUWP(msg);
#endif
cursorHidden = false;
@ -1082,7 +1080,7 @@ void DisableCursor(void)
#endif
#if defined(PLATFORM_UWP)
UWPMessage *msg = CreateUWPMessage();
msg->Type = UnlockMouse;
msg->type = UWP_MSG_UNLOCK_MOUSE;
SendMessageToUWP(msg);
#endif
cursorHidden = true;
@ -2237,9 +2235,9 @@ void SetMousePosition(int x, int y)
#endif
#if defined(PLATFORM_UWP)
UWPMessage *msg = CreateUWPMessage();
msg->Type = SetMouseLocation;
msg->Vector0.x = mousePosition.x;
msg->Vector0.y = mousePosition.y;
msg->type = UWP_MSG_SET_MOUSE_LOCATION;
msg->paramVector0.x = mousePosition.x;
msg->paramVector0.y = mousePosition.y;
SendMessageToUWP(msg);
#endif
}
@ -2711,8 +2709,6 @@ static bool InitGraphicsDevice(int width, int height)
}
}
//SetupFramebuffer(displayWidth, displayHeight);
EGLint numConfigs = 0;
if ((eglChooseConfig(display, framebufferAttribs, &config, 1, &numConfigs) == EGL_FALSE) || (numConfigs == 0))
{
@ -2769,8 +2765,6 @@ static bool InitGraphicsDevice(int width, int height)
eglQuerySurface(display, surface, EGL_WIDTH, &screenWidth);
eglQuerySurface(display, surface, EGL_HEIGHT, &screenHeight);
//SetupFramebuffer(displayWidth, displayHeight); //Borked
#else // PLATFORM_ANDROID, PLATFORM_RPI
EGLint numConfigs;
@ -3126,7 +3120,6 @@ static void PollInputEvents(void)
#endif
#if defined(PLATFORM_UWP)
// Register previous keys states
for (int i = 0; i < 512; i++) previousKeyState[i] = currentKeyState[i];
@ -3141,25 +3134,21 @@ static void PollInputEvents(void)
// Register previous mouse states
previousMouseWheelY = currentMouseWheelY;
currentMouseWheelY = 0;
for (int i = 0; i < 3; i++)
{
previousMouseState[i] = currentMouseState[i];
}
for (int i = 0; i < 3; i++) previousMouseState[i] = currentMouseState[i];
// Loop over pending messages
while (HasMessageFromUWP())
{
UWPMessage *msg = GetMessageFromUWP();
switch (msg->Type)
switch (msg->type)
{
case RegisterKey:
case UWP_MSG_REGISTER_KEY:
{
// Convert from virtualKey
int actualKey = -1;
switch (msg->Int0)
switch (msg->paramInt0)
{
case 0x08: actualKey = KEY_BACKSPACE; break;
case 0x20: actualKey = KEY_SPACE; break;
@ -3224,60 +3213,30 @@ static void PollInputEvents(void)
case 0x58: actualKey = KEY_X; break;
case 0x59: actualKey = KEY_Y; break;
case 0x5A: actualKey = KEY_Z; break;
default: break;
}
if (actualKey > -1)
currentKeyState[actualKey] = msg->Char0;
break;
}
if (actualKey > -1) currentKeyState[actualKey] = msg->paramChar0;
case RegisterClick:
} break;
case UWP_MSG_REGISTER_CLICK: currentMouseState[msg->paramInt0] = msg->paramChar0; break;
case UWP_MSG_SCROLL_WHEEL_UPDATE: currentMouseWheelY += msg->paramInt0; break;
case UWP_MSG_UPDATE_MOUSE_LOCATION: mousePosition = msg->paramVector0; break;
case UWP_MSG_SET_GAMEPAD_ACTIVE: if (msg->paramInt0 < MAX_GAMEPADS) gamepadReady[msg->paramInt0] = msg->paramBool0; break;
case UWP_MSG_SET_GAMEPAD_BUTTON:
{
currentMouseState[msg->Int0] = msg->Char0;
break;
}
case ScrollWheelUpdate:
if ((msg->paramInt0 < MAX_GAMEPADS) && (msg->paramInt1 < MAX_GAMEPAD_BUTTONS)) currentGamepadState[msg->paramInt0][msg->paramInt1] = msg->paramChar0;
} break;
case UWP_MSG_SET_GAMEPAD_AXIS:
{
currentMouseWheelY += msg->Int0;
break;
}
case UpdateMouseLocation:
if ((msg->paramInt0 < MAX_GAMEPADS) && (msg->paramInt1 < MAX_GAMEPAD_AXIS)) gamepadAxisState[msg->paramInt0][msg->paramInt1] = msg->paramFloat0;
} break;
case UWP_MSG_SET_DISPLAY_DIMS:
{
mousePosition = msg->Vector0;
break;
}
case MarkGamepadActive:
{
if (msg->Int0 < MAX_GAMEPADS)
gamepadReady[msg->Int0] = msg->Bool0;
break;
}
case MarkGamepadButton:
{
if (msg->Int0 < MAX_GAMEPADS && msg->Int1 < MAX_GAMEPAD_BUTTONS)
currentGamepadState[msg->Int0][msg->Int1] = msg->Char0;
break;
}
case MarkGamepadAxis:
{
if (msg->Int0 < MAX_GAMEPADS && msg->Int1 < MAX_GAMEPAD_AXIS)
gamepadAxisState[msg->Int0][msg->Int1] = msg->Float0;
break;
}
case SetDisplayDims:
{
displayWidth = msg->Vector0.x;
displayHeight = msg->Vector0.y;
break;
}
case HandleResize:
displayWidth = msg->paramVector0.x;
displayHeight = msg->paramVector0.y;
} break;
case UWP_MSG_HANDLE_RESIZE:
{
eglQuerySurface(display, surface, EGL_WIDTH, &screenWidth);
eglQuerySurface(display, surface, EGL_HEIGHT, &screenHeight);
@ -3300,21 +3259,15 @@ static void PollInputEvents(void)
// NOTE: Postprocessing texture is not scaled to new size
windowResized = true;
break;
}
case SetGameTime:
{
currentTime = msg->Double0;
break;
}
} break;
case UWP_MSG_SET_GAME_TIME: currentTime = msg->paramDouble0; break;
default: break;
}
DeleteUWPMessage(msg); //Delete, we are done
}
#endif
#endif // defined(PLATFORM_UWP)
#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_WEB)
// Mouse input polling

View file

@ -422,8 +422,8 @@ RLAPI void rlTranslatef(float x, float y, float z); // Multiply the current ma
RLAPI void rlRotatef(float angleDeg, float x, float y, float z); // Multiply the current matrix by a rotation matrix
RLAPI void rlScalef(float x, float y, float z); // Multiply the current matrix by a scaling matrix
RLAPI void rlMultMatrixf(float *matf); // Multiply the current matrix by another matrix
RLAPI void rlFrustum(double left, double right, double bottom, double top, double near, double far);
RLAPI void rlOrtho(double left, double right, double bottom, double top, double near, double far);
RLAPI void rlFrustum(double left, double right, double bottom, double top, double znear, double zfar);
RLAPI void rlOrtho(double left, double right, double bottom, double top, double znear, double zfar);
RLAPI void rlViewport(int x, int y, int width, int height); // Set the viewport area
//------------------------------------------------------------------------------------
@ -888,14 +888,14 @@ void rlMatrixMode(int mode)
}
}
void rlFrustum(double left, double right, double bottom, double top, double zNear, double zFar)
void rlFrustum(double left, double right, double bottom, double top, double znear, double zfar)
{
glFrustum(left, right, bottom, top, zNear, zFar);
glFrustum(left, right, bottom, top, znear, zfar);
}
void rlOrtho(double left, double right, double bottom, double top, double zNear, double zFar)
void rlOrtho(double left, double right, double bottom, double top, double znear, double zfar)
{
glOrtho(left, right, bottom, top, zNear, zFar);
glOrtho(left, right, bottom, top, znear, zfar);
}
void rlPushMatrix(void) { glPushMatrix(); }
@ -1491,7 +1491,6 @@ void rlglInit(int width, int height)
GLint numExt = 0;
#if defined(GRAPHICS_API_OPENGL_33)
// NOTE: On OpenGL 3.3 VAO and NPOT are supported by default
vaoSupported = true;
@ -1504,12 +1503,7 @@ void rlglInit(int width, int height)
// NOTE: We don't need to check again supported extensions but we do (GLAD already dealt with that)
glGetIntegerv(GL_NUM_EXTENSIONS, &numExt);
#if defined(_MSC_VER)
const char **extList = RL_MALLOC(sizeof(const char *)*numExt);
#else
const char *extList[numExt];
#endif
for (int i = 0; i < numExt; i++) extList[i] = (char *)glGetStringi(GL_EXTENSIONS, i);
#elif defined(GRAPHICS_API_OPENGL_ES2)
@ -1523,10 +1517,10 @@ void rlglInit(int width, int height)
// NOTE: String could be splitted using strtok() function (string.h)
// NOTE: strtok() modifies the passed string, it can not be const
char *extList[512]; // Allocate 512 strings pointers (2 KB)
// Allocate 512 strings pointers (2 KB)
const char **extList = RL_MALLOC(sizeof(const char *)*512);
extList[numExt] = strtok(extensionsDup, " ");
while (extList[numExt] != NULL)
{
numExt++;
@ -1619,9 +1613,7 @@ void rlglInit(int width, int height)
if (strcmp(extList[i], (const char *)"GL_EXT_debug_marker") == 0) debugMarkerSupported = true;
}
#if defined(_WIN32) && defined(_MSC_VER) && !defined(PLATFORM_UWP) //is this a hotfix? I may need to find out why this is broken
RL_FREE(extList);
#endif
#if defined(GRAPHICS_API_OPENGL_ES2)
if (vaoSupported) TraceLog(LOG_INFO, "[EXTENSION] VAO extension detected, VAO functions initialized successfully");
@ -1642,11 +1634,8 @@ void rlglInit(int width, int height)
if (debugMarkerSupported) TraceLog(LOG_INFO, "[EXTENSION] Debug Marker supported");
// Initialize buffers, default shaders and default textures
//----------------------------------------------------------
// Init default white texture
unsigned char pixels[4] = { 255, 255, 255, 255 }; // 1 pixel RGBA (4 bytes)
defaultTextureId = rlLoadTexture(pixels, 1, 1, UNCOMPRESSED_R8G8B8A8, 1);
@ -4623,6 +4612,6 @@ int GetPixelDataSize(int width, int height, int format)
return dataSize;
}
#endif
#endif // RLGL_STANDALONE
#endif // RLGL_IMPLEMENTATION

View file

@ -216,15 +216,15 @@ static UWPMessage* UWPInMessages[MAX_MESSAGES]; //Messages in from UWP
UWPMessage* CreateUWPMessage(void)
{
UWPMessage *msg = (UWPMessage *)RL_MALLOC(sizeof(UWPMessage));
msg->Type = None;
msg->type = UWP_MSG_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;
msg->paramVector0 = v0;
msg->paramInt0 = 0;
msg->paramInt1 = 0;
msg->paramChar0 = 0;
msg->paramFloat0 = 0;
msg->paramDouble0 = 0;
msg->paramBool0 = false;
return msg;
}
@ -235,15 +235,12 @@ void DeleteUWPMessage(UWPMessage* msg)
bool UWPHasMessages(void)
{
return UWPOutMessageId > -1;
return (UWPOutMessageId > -1);
}
UWPMessage *UWPGetMessage(void)
{
if (UWPHasMessages())
{
return UWPOutMessages[UWPOutMessageId--];
}
if (UWPHasMessages()) return UWPOutMessages[UWPOutMessageId--];
return NULL;
}
@ -255,10 +252,7 @@ void UWPSendMessage(UWPMessage* msg)
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)
@ -268,10 +262,7 @@ void SendMessageToUWP(UWPMessage* msg)
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)

View file

@ -60,56 +60,40 @@ FILE *android_fopen(const char *fileName, const char *mode); // Replacement f
#endif
#if defined(PLATFORM_UWP)
// UWP Messages System
typedef enum
{
None = 0,
typedef enum {
UWP_MSG_NONE = 0,
// Send
ShowMouse,
HideMouse,
LockMouse,
UnlockMouse,
SetMouseLocation, //Vector0 (pos)
UWP_MSG_SHOW_MOUSE,
UWP_MSG_HIDE_MOUSE,
UWP_MSG_LOCK_MOUSE,
UWP_MSG_UNLOCK_MOUSE,
UWP_MSG_SET_MOUSE_LOCATION, // paramVector0 (pos)
//Recieve (Into C)
RegisterKey, //Int0 (key), Char0 (status)
RegisterClick, //Int0 (button), Char0 (status)
ScrollWheelUpdate, //Int0 (delta)
UpdateMouseLocation, //Vector0 (pos)
MarkGamepadActive, //Int0 (gamepad), Bool0 (active or not)
MarkGamepadButton, //Int0 (gamepad), Int1 (button), Char0 (status)
MarkGamepadAxis,//Int0 (gamepad), int1 (axis), Float0 (value)
SetDisplayDims, //Vector0 (display dimensions)
HandleResize, //Vector0 (new dimensions) - Onresized event
SetGameTime, //Int0
// Receive (Into C)
UWP_MSG_REGISTER_KEY, // paramInt0 (key), paramChar0 (status)
UWP_MSG_REGISTER_CLICK, // paramInt0 (button), paramChar0 (status)
UWP_MSG_SCROLL_WHEEL_UPDATE, // paramInt0 (delta)
UWP_MSG_UPDATE_MOUSE_LOCATION, // paramVector0 (pos)
UWP_MSG_SET_GAMEPAD_ACTIVE, // paramInt0 (gamepad), paramBool0 (active or not)
UWP_MSG_SET_GAMEPAD_BUTTON, // paramInt0 (gamepad), paramInt1 (button), paramChar0 (status)
UWP_MSG_SET_GAMEPAD_AXIS, // paramInt0 (gamepad), int1 (axis), paramFloat0 (value)
UWP_MSG_SET_DISPLAY_DIMS, // paramVector0 (display dimensions)
UWP_MSG_HANDLE_RESIZE, // paramVector0 (new dimensions) - Onresized event
UWP_MSG_SET_GAME_TIME, // paramInt0
} UWPMessageType;
typedef struct UWPMessage
{
//The message type
UWPMessageType Type;
typedef struct UWPMessage {
UWPMessageType type; // Message type
//Vector parameters
Vector2 Vector0;
//Int parameters
int Int0;
int Int1;
//Char parameters
char Char0;
//Float parameters
float Float0;
//Double parameters
double Double0;
//Bool parameters
bool Bool0;
Vector2 paramVector0; // Vector parameters
int paramInt0; // Int parameter
int paramInt1; // Int parameter
char paramChar0; // Char parameters
float paramFloat0; // Float parameters
double paramDouble0; // Double parameters
bool paramBool0; // Bool parameters
// More parameters can be added and fed to functions
} UWPMessage;
@ -126,13 +110,13 @@ RLAPI UWPMessage* UWPGetMessage(void);
RLAPI void UWPSendMessage(UWPMessage* msg);
// For C to call
#ifndef _cplusplus //Hide from C++ code
#ifndef __cplusplus // Hide from C++ code
void SendMessageToUWP(UWPMessage* msg);
bool HasMessageFromUWP(void);
UWPMessage* GetMessageFromUWP(void);
#endif
#endif
#endif //defined(PLATFORM_UWP)
#ifdef __cplusplus
}