Fixed XBOX ONE Support

This commit is contained in:
Reece Mackie 2019-04-27 18:15:28 +01:00
parent 1325e84a3b
commit 2d24a9c7a1
5 changed files with 41 additions and 4 deletions

View File

@ -25,11 +25,12 @@ App::App()
static int posX = 100;
static int posY = 100;
static int time = 0;
static int gTime = 0;
// This method is called every frame
void App::Update()
{
//return;
// Draw
BeginDrawing();
@ -71,7 +72,7 @@ void App::Update()
pos -= GetMouseWheelMove();
DrawRectangle(280, pos + 50, 20, 20, BLACK);
DrawRectangle(250, 280 + (time++ % 60), 10, 10, PURPLE);
DrawRectangle(250, 280 + (gTime++ % 60), 10, 10, PURPLE);
EndDrawing();
}

View File

@ -37,6 +37,7 @@
#include PCH
#endif
#include <chrono>
#include <memory>
#include <wrl.h>
@ -142,10 +143,26 @@ public:
msg->Vector0 = screenSize;
UWPSendMessage(msg);
//Send the time to the core
using clock = std::chrono::high_resolution_clock;
auto timeStart = clock::now();
//Set fps if 0
if (GetFPS() <= 0)
SetTargetFPS(60);
while (!mWindowClosed)
{
if (mWindowVisible)
{
//Send time
auto delta = clock::now() - timeStart;
UWPMessage* timeMsg = CreateUWPMessage();
timeMsg->Type = SetGameTime;
timeMsg->Double0 = std::chrono::duration_cast<std::chrono::seconds>(delta).count();
UWPSendMessage(timeMsg);
//Call update function
Update();

View File

@ -402,6 +402,7 @@ 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
@ -1163,6 +1164,8 @@ void EndDrawing(void)
frameTime += extraTime;
}
return;
}
// Initialize 2D mode with custom camera (2D)
@ -1439,6 +1442,11 @@ double GetTime(void)
return (double)(time - baseTime)*1e-9; // Elapsed time since InitTimer()
#endif
#if defined(PLATFORM_UWP)
//Updated through messages
return currentTime;
#endif
}
// Returns hexadecimal value for a Color
@ -3023,7 +3031,7 @@ static void InitTimer(void)
// http://stackoverflow.com/questions/43057578/c-programming-win32-games-sleep-taking-longer-than-expected
static void Wait(float ms)
{
#if defined(SUPPORT_BUSY_WAIT_LOOP)
#if defined(SUPPORT_BUSY_WAIT_LOOP) && !defined(PLATFORM_UWP)
double prevTime = GetTime();
double nextTime = 0.0;
@ -3295,6 +3303,12 @@ static void PollInputEvents(void)
break;
}
case SetGameTime:
{
currentTime = msg->Double0;
break;
}
}
DeleteUWPMessage(msg); //Delete, we are done
@ -4789,7 +4803,7 @@ static void *GamepadThread(void *arg)
// Plays raylib logo appearing animation
static void LogoAnimation(void)
{
#if !defined(PLATFORM_WEB)
#if !defined(PLATFORM_WEB) && !defined(PLATFORM_UWP)
int logoPositionX = screenWidth/2 - 128;
int logoPositionY = screenHeight/2 - 128;

View File

@ -223,6 +223,7 @@ UWPMessage* CreateUWPMessage(void)
msg->Int1 = 0;
msg->Char0 = 0;
msg->Float0 = 0;
msg->Double0 = 0;
msg->Bool0 = false;
return msg;
}

View File

@ -84,6 +84,7 @@ typedef enum
MarkGamepadAxis,//Int0 (gamepad), int1 (axis), Float0 (value)
SetDisplayDims, //Vector0 (display dimensions)
HandleResize, //Vector0 (new dimensions) - Onresized event
SetGameTime, //Int0
} UWPMessageType;
typedef struct UWPMessage
@ -104,6 +105,9 @@ typedef struct UWPMessage
//Float parameters
float Float0;
//Double parameters
double Double0;
//Bool parameters
bool Bool0;