Use 'Messages' to handle the cursor functions so code is more portable.
This commit is contained in:
parent
9b99d025b3
commit
1104f5e5fc
1 changed files with 193 additions and 50 deletions
74
src/core.c
74
src/core.c
|
|
@ -391,6 +391,23 @@ 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
|
||||
|
||||
#if defined(PLATFORM_UWP)
|
||||
// UWP Messages
|
||||
|
||||
#define MAX_MESSAGES 128 //If there are over 128 messages, I will cry... either way, this may be too much
|
||||
|
||||
static int UWPOutMessageId = -1; //Stores the last index for the message
|
||||
static UWPMessage* UWPOutMessages[MAX_MESSAGES]; //Messages out to UWP
|
||||
|
||||
static void SendToUWP(UWPMessage* msg)
|
||||
{
|
||||
UWPOutMessageId++;
|
||||
UWPOutMessages[UWPOutMessageId] = msg;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------------
|
||||
|
||||
// Timming system variables
|
||||
|
|
@ -624,11 +641,13 @@ void InitWindow(int width, int height, const char *title)
|
|||
mousePosition.y = (float)screenHeight/2.0f;
|
||||
|
||||
// raylib logo appearing animation (if enabled)
|
||||
#if !defined(PLATFORM_UWP)
|
||||
if (showLogo)
|
||||
{
|
||||
SetTargetFPS(60);
|
||||
LogoAnimation();
|
||||
}
|
||||
#endif //defined(PLATFORM_UWP)
|
||||
#endif // defined(PLATFORM_ANDROID)
|
||||
}
|
||||
|
||||
|
|
@ -1018,13 +1037,16 @@ void SetClipboardText(const char *text)
|
|||
#endif
|
||||
}
|
||||
|
||||
#if !defined(PLATFORM_UWP)
|
||||
|
||||
// Show mouse cursor
|
||||
void ShowCursor(void)
|
||||
{
|
||||
#if defined(PLATFORM_DESKTOP)
|
||||
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_NORMAL);
|
||||
#endif
|
||||
#if defined(PLATFORM_UWP)
|
||||
UWPMessage* msg = CreateUWPMessage();
|
||||
msg->Type = ShowMouse;
|
||||
SendToUWP(msg);
|
||||
#endif
|
||||
cursorHidden = false;
|
||||
}
|
||||
|
|
@ -1034,6 +1056,11 @@ void HideCursor(void)
|
|||
{
|
||||
#if defined(PLATFORM_DESKTOP)
|
||||
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_HIDDEN);
|
||||
#endif
|
||||
#if defined(PLATFORM_UWP)
|
||||
UWPMessage* msg = CreateUWPMessage();
|
||||
msg->Type = HideMouse;
|
||||
SendToUWP(msg);
|
||||
#endif
|
||||
cursorHidden = true;
|
||||
}
|
||||
|
|
@ -1052,6 +1079,11 @@ void EnableCursor(void)
|
|||
#endif
|
||||
#if defined(PLATFORM_WEB)
|
||||
toggleCursorLock = true;
|
||||
#endif
|
||||
#if defined(PLATFORM_UWP)
|
||||
UWPMessage* msg = CreateUWPMessage();
|
||||
msg->Type = LockMouse;
|
||||
SendToUWP(msg);
|
||||
#endif
|
||||
cursorHidden = false;
|
||||
}
|
||||
|
|
@ -1064,12 +1096,15 @@ void DisableCursor(void)
|
|||
#endif
|
||||
#if defined(PLATFORM_WEB)
|
||||
toggleCursorLock = true;
|
||||
#endif
|
||||
#if defined(PLATFORM_UWP)
|
||||
UWPMessage* msg = CreateUWPMessage();
|
||||
msg->Type = UnlockMouse;
|
||||
SendToUWP(msg);
|
||||
#endif
|
||||
cursorHidden = true;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// Set background color (framebuffer clear color)
|
||||
void ClearBackground(Color color)
|
||||
{
|
||||
|
|
@ -2210,6 +2245,13 @@ void SetMousePosition(int x, int y)
|
|||
// NOTE: emscripten not implemented
|
||||
glfwSetCursorPos(window, mousePosition.x, mousePosition.y);
|
||||
#endif
|
||||
#if defined(PLATFORM_UWP)
|
||||
UWPMessage* msg = CreateUWPMessage();
|
||||
msg->Type = SetMouseLocation;
|
||||
msg->Float0 = mousePosition.x;
|
||||
msg->Float1 = mousePosition.y;
|
||||
SendToUWP(msg);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Set mouse offset
|
||||
|
|
@ -4717,6 +4759,30 @@ void UWPGamepadAxis(int gamepad, int axis, float value)
|
|||
gamepadAxisState[gamepad][axis] = value;
|
||||
}
|
||||
|
||||
bool UWPHasMessages()
|
||||
{
|
||||
if (UWPOutMessageId > -1)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
UWPMessage* UWPGetMessage()
|
||||
{
|
||||
if (UWPHasMessages())
|
||||
{
|
||||
return UWPOutMessages[UWPOutMessageId--];
|
||||
}
|
||||
|
||||
return CreateUWPMessage();
|
||||
}
|
||||
|
||||
/*void UWPSendMessage(UWPMessage* msg)
|
||||
{
|
||||
switch(msg->Type)
|
||||
{
|
||||
}
|
||||
}*/
|
||||
|
||||
#endif
|
||||
|
||||
// Plays raylib logo appearing animation
|
||||
|
|
|
|||
Loading…
Reference in a new issue