Add Platform::GetMousePosition/WindowsPlatform::SetMousePosition for unified access to screen-space mouse position on all platforms
#1109
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
#include "Engine/Platform/MemoryStats.h"
|
||||
#include "Engine/Platform/MessageBox.h"
|
||||
#include "Engine/Platform/FileSystem.h"
|
||||
#include "Engine/Platform/Window.h"
|
||||
#include "Engine/Platform/User.h"
|
||||
#include "Engine/Core/Log.h"
|
||||
#include "Engine/Core/Types/DateTime.h"
|
||||
@@ -520,6 +521,21 @@ void PlatformBase::CreateGuid(Guid& result)
|
||||
result = Guid(dateThingHigh, randomThing | (sequentialThing << 16), cyclesThing, dateThingLow);
|
||||
}
|
||||
|
||||
Float2 PlatformBase::GetMousePosition()
|
||||
{
|
||||
const Window* win = Engine::MainWindow;
|
||||
if (win)
|
||||
return win->ClientToScreen(win->GetMousePosition());
|
||||
return Float2::Minimum;
|
||||
}
|
||||
|
||||
void PlatformBase::SetMousePosition(const Float2& position)
|
||||
{
|
||||
const Window* win = Engine::MainWindow;
|
||||
if (win)
|
||||
win->SetMousePosition(win->ScreenToClient(position));
|
||||
}
|
||||
|
||||
Float2 PlatformBase::GetVirtualDesktopSize()
|
||||
{
|
||||
return Platform::GetVirtualDesktopBounds().Size;
|
||||
|
||||
@@ -660,6 +660,18 @@ public:
|
||||
|
||||
public:
|
||||
|
||||
/// <summary>
|
||||
/// Gets the mouse cursor position in screen-space coordinates.
|
||||
/// </summary>
|
||||
/// <returns>Mouse cursor coordinates.</returns>
|
||||
API_PROPERTY() static Float2 GetMousePosition();
|
||||
|
||||
/// <summary>
|
||||
/// Sets the mouse cursor position in screen-space coordinates.
|
||||
/// </summary>
|
||||
/// <param name="position">Cursor position to set.</param>
|
||||
API_PROPERTY() static void SetMousePosition(const Float2& position);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the origin position and size of the monitor at the given screen-space location.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user