Fixed XBOX ONE Support
This commit is contained in:
parent
1325e84a3b
commit
2d24a9c7a1
|
|
@ -25,11 +25,12 @@ App::App()
|
||||||
|
|
||||||
static int posX = 100;
|
static int posX = 100;
|
||||||
static int posY = 100;
|
static int posY = 100;
|
||||||
static int time = 0;
|
static int gTime = 0;
|
||||||
|
|
||||||
// This method is called every frame
|
// This method is called every frame
|
||||||
void App::Update()
|
void App::Update()
|
||||||
{
|
{
|
||||||
|
//return;
|
||||||
// Draw
|
// Draw
|
||||||
BeginDrawing();
|
BeginDrawing();
|
||||||
|
|
||||||
|
|
@ -71,7 +72,7 @@ void App::Update()
|
||||||
pos -= GetMouseWheelMove();
|
pos -= GetMouseWheelMove();
|
||||||
|
|
||||||
DrawRectangle(280, pos + 50, 20, 20, BLACK);
|
DrawRectangle(280, pos + 50, 20, 20, BLACK);
|
||||||
DrawRectangle(250, 280 + (time++ % 60), 10, 10, PURPLE);
|
DrawRectangle(250, 280 + (gTime++ % 60), 10, 10, PURPLE);
|
||||||
|
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
}
|
}
|
||||||
|
|
@ -37,6 +37,7 @@
|
||||||
#include PCH
|
#include PCH
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <chrono>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <wrl.h>
|
#include <wrl.h>
|
||||||
|
|
||||||
|
|
@ -142,10 +143,26 @@ public:
|
||||||
msg->Vector0 = screenSize;
|
msg->Vector0 = screenSize;
|
||||||
UWPSendMessage(msg);
|
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)
|
while (!mWindowClosed)
|
||||||
{
|
{
|
||||||
if (mWindowVisible)
|
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
|
//Call update function
|
||||||
Update();
|
Update();
|
||||||
|
|
||||||
|
|
|
||||||
18
src/core.c
18
src/core.c
|
|
@ -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 drawTime = 0.0; // Time measure for frame draw
|
||||||
static double frameTime = 0.0; // Time measure for one frame
|
static double frameTime = 0.0; // Time measure for one frame
|
||||||
static double targetTime = 0.0; // Desired time for one frame, if 0 not applied
|
static double targetTime = 0.0; // Desired time for one frame, if 0 not applied
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Config internal variables
|
// Config internal variables
|
||||||
|
|
@ -1163,6 +1164,8 @@ void EndDrawing(void)
|
||||||
|
|
||||||
frameTime += extraTime;
|
frameTime += extraTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize 2D mode with custom camera (2D)
|
// Initialize 2D mode with custom camera (2D)
|
||||||
|
|
@ -1439,6 +1442,11 @@ double GetTime(void)
|
||||||
|
|
||||||
return (double)(time - baseTime)*1e-9; // Elapsed time since InitTimer()
|
return (double)(time - baseTime)*1e-9; // Elapsed time since InitTimer()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(PLATFORM_UWP)
|
||||||
|
//Updated through messages
|
||||||
|
return currentTime;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns hexadecimal value for a Color
|
// 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
|
// http://stackoverflow.com/questions/43057578/c-programming-win32-games-sleep-taking-longer-than-expected
|
||||||
static void Wait(float ms)
|
static void Wait(float ms)
|
||||||
{
|
{
|
||||||
#if defined(SUPPORT_BUSY_WAIT_LOOP)
|
#if defined(SUPPORT_BUSY_WAIT_LOOP) && !defined(PLATFORM_UWP)
|
||||||
double prevTime = GetTime();
|
double prevTime = GetTime();
|
||||||
double nextTime = 0.0;
|
double nextTime = 0.0;
|
||||||
|
|
||||||
|
|
@ -3295,6 +3303,12 @@ static void PollInputEvents(void)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case SetGameTime:
|
||||||
|
{
|
||||||
|
currentTime = msg->Double0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DeleteUWPMessage(msg); //Delete, we are done
|
DeleteUWPMessage(msg); //Delete, we are done
|
||||||
|
|
@ -4789,7 +4803,7 @@ static void *GamepadThread(void *arg)
|
||||||
// Plays raylib logo appearing animation
|
// Plays raylib logo appearing animation
|
||||||
static void LogoAnimation(void)
|
static void LogoAnimation(void)
|
||||||
{
|
{
|
||||||
#if !defined(PLATFORM_WEB)
|
#if !defined(PLATFORM_WEB) && !defined(PLATFORM_UWP)
|
||||||
int logoPositionX = screenWidth/2 - 128;
|
int logoPositionX = screenWidth/2 - 128;
|
||||||
int logoPositionY = screenHeight/2 - 128;
|
int logoPositionY = screenHeight/2 - 128;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -223,6 +223,7 @@ UWPMessage* CreateUWPMessage(void)
|
||||||
msg->Int1 = 0;
|
msg->Int1 = 0;
|
||||||
msg->Char0 = 0;
|
msg->Char0 = 0;
|
||||||
msg->Float0 = 0;
|
msg->Float0 = 0;
|
||||||
|
msg->Double0 = 0;
|
||||||
msg->Bool0 = false;
|
msg->Bool0 = false;
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -84,6 +84,7 @@ typedef enum
|
||||||
MarkGamepadAxis,//Int0 (gamepad), int1 (axis), Float0 (value)
|
MarkGamepadAxis,//Int0 (gamepad), int1 (axis), Float0 (value)
|
||||||
SetDisplayDims, //Vector0 (display dimensions)
|
SetDisplayDims, //Vector0 (display dimensions)
|
||||||
HandleResize, //Vector0 (new dimensions) - Onresized event
|
HandleResize, //Vector0 (new dimensions) - Onresized event
|
||||||
|
SetGameTime, //Int0
|
||||||
} UWPMessageType;
|
} UWPMessageType;
|
||||||
|
|
||||||
typedef struct UWPMessage
|
typedef struct UWPMessage
|
||||||
|
|
@ -104,6 +105,9 @@ typedef struct UWPMessage
|
||||||
//Float parameters
|
//Float parameters
|
||||||
float Float0;
|
float Float0;
|
||||||
|
|
||||||
|
//Double parameters
|
||||||
|
double Double0;
|
||||||
|
|
||||||
//Bool parameters
|
//Bool parameters
|
||||||
bool Bool0;
|
bool Bool0;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user