fix indent.
This commit is contained in:
@@ -9,7 +9,7 @@ const std::unique_ptr<MonitorManager>& GetMonitorManager();
|
|||||||
|
|
||||||
enum class Message
|
enum class Message
|
||||||
{
|
{
|
||||||
None = -1,
|
None = -1,
|
||||||
Reinitialized = 0,
|
Reinitialized = 0,
|
||||||
};
|
};
|
||||||
void SendMessageToUnity(Message message);
|
void SendMessageToUnity(Message message);
|
||||||
@@ -28,46 +28,46 @@ Cursor::~Cursor()
|
|||||||
|
|
||||||
void Cursor::UpdateBuffer(const DXGI_OUTDUPL_FRAME_INFO& frameInfo)
|
void Cursor::UpdateBuffer(const DXGI_OUTDUPL_FRAME_INFO& frameInfo)
|
||||||
{
|
{
|
||||||
if (frameInfo.LastMouseUpdateTime.QuadPart == 0)
|
if (frameInfo.LastMouseUpdateTime.QuadPart == 0)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
x_ = frameInfo.PointerPosition.Position.x;
|
x_ = frameInfo.PointerPosition.Position.x;
|
||||||
y_ = frameInfo.PointerPosition.Position.y;
|
y_ = frameInfo.PointerPosition.Position.y;
|
||||||
if (frameInfo.PointerPosition.Visible != 0) {
|
if (frameInfo.PointerPosition.Visible != 0) {
|
||||||
GetMonitorManager()->SetCursorMonitorId(monitor_->GetId());
|
GetMonitorManager()->SetCursorMonitorId(monitor_->GetId());
|
||||||
timestamp_ = frameInfo.LastMouseUpdateTime;
|
timestamp_ = frameInfo.LastMouseUpdateTime;
|
||||||
isVisible_ = frameInfo.PointerPosition.Visible != 0;
|
isVisible_ = frameInfo.PointerPosition.Visible != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (frameInfo.PointerShapeBufferSize == 0)
|
if (frameInfo.PointerShapeBufferSize == 0)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Increase the buffer size if needed
|
// Increase the buffer size if needed
|
||||||
if (frameInfo.PointerShapeBufferSize > apiBufferSize_)
|
if (frameInfo.PointerShapeBufferSize > apiBufferSize_)
|
||||||
{
|
{
|
||||||
if (apiBuffer_) delete[] apiBuffer_;
|
if (apiBuffer_) delete[] apiBuffer_;
|
||||||
apiBuffer_ = new BYTE[frameInfo.PointerShapeBufferSize];
|
apiBuffer_ = new BYTE[frameInfo.PointerShapeBufferSize];
|
||||||
apiBufferSize_ = frameInfo.PointerShapeBufferSize;
|
apiBufferSize_ = frameInfo.PointerShapeBufferSize;
|
||||||
}
|
}
|
||||||
if (apiBuffer_ == nullptr) return;
|
if (apiBuffer_ == nullptr) return;
|
||||||
|
|
||||||
// Get mouse pointer information
|
// Get mouse pointer information
|
||||||
UINT bufferSize;
|
UINT bufferSize;
|
||||||
const auto hr = monitor_->GetDeskDupl()->GetFramePointerShape(
|
const auto hr = monitor_->GetDeskDupl()->GetFramePointerShape(
|
||||||
frameInfo.PointerShapeBufferSize,
|
frameInfo.PointerShapeBufferSize,
|
||||||
reinterpret_cast<void*>(apiBuffer_),
|
reinterpret_cast<void*>(apiBuffer_),
|
||||||
&bufferSize,
|
&bufferSize,
|
||||||
&shapeInfo_);
|
&shapeInfo_);
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
{
|
{
|
||||||
delete[] apiBuffer_;
|
delete[] apiBuffer_;
|
||||||
apiBuffer_ = nullptr;
|
apiBuffer_ = nullptr;
|
||||||
apiBufferSize_ = 0;
|
apiBufferSize_ = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -78,9 +78,9 @@ void Cursor::UpdateTexture()
|
|||||||
const bool isColorMask = GetType() == DXGI_OUTDUPL_POINTER_SHAPE_TYPE_MASKED_COLOR;
|
const bool isColorMask = GetType() == DXGI_OUTDUPL_POINTER_SHAPE_TYPE_MASKED_COLOR;
|
||||||
|
|
||||||
// Size
|
// Size
|
||||||
const auto w = GetWidth();
|
const auto w = GetWidth();
|
||||||
const auto h = GetHeight();
|
const auto h = GetHeight();
|
||||||
const auto p = GetPitch();
|
const auto p = GetPitch();
|
||||||
|
|
||||||
// Convert the buffer given by API into BGRA32
|
// Convert the buffer given by API into BGRA32
|
||||||
const UINT bgraBufferSize = w * h * 4;
|
const UINT bgraBufferSize = w * h * 4;
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ public:
|
|||||||
explicit Cursor(Monitor* monitor);
|
explicit Cursor(Monitor* monitor);
|
||||||
~Cursor();
|
~Cursor();
|
||||||
void UpdateBuffer(const DXGI_OUTDUPL_FRAME_INFO& frameInfo);
|
void UpdateBuffer(const DXGI_OUTDUPL_FRAME_INFO& frameInfo);
|
||||||
void UpdateTexture();
|
void UpdateTexture();
|
||||||
void GetTexture(ID3D11Texture2D* texture);
|
void GetTexture(ID3D11Texture2D* texture);
|
||||||
|
|
||||||
bool IsVisible() const;
|
bool IsVisible() const;
|
||||||
@@ -31,5 +31,5 @@ private:
|
|||||||
BYTE* bgra32Buffer_ = nullptr;
|
BYTE* bgra32Buffer_ = nullptr;
|
||||||
UINT bgra32BufferSize_ = 0;
|
UINT bgra32BufferSize_ = 0;
|
||||||
DXGI_OUTDUPL_POINTER_SHAPE_INFO shapeInfo_;
|
DXGI_OUTDUPL_POINTER_SHAPE_INFO shapeInfo_;
|
||||||
LARGE_INTEGER timestamp_;
|
LARGE_INTEGER timestamp_;
|
||||||
};
|
};
|
||||||
@@ -21,32 +21,32 @@ HRESULT Monitor::Initialize(IDXGIOutput* output)
|
|||||||
auto output1 = reinterpret_cast<IDXGIOutput1*>(output);
|
auto output1 = reinterpret_cast<IDXGIOutput1*>(output);
|
||||||
const auto hr = output1->DuplicateOutput(GetDevice(), &deskDupl_);
|
const auto hr = output1->DuplicateOutput(GetDevice(), &deskDupl_);
|
||||||
|
|
||||||
// TODO: error check
|
// TODO: error check
|
||||||
switch (hr)
|
switch (hr)
|
||||||
{
|
{
|
||||||
case S_OK:
|
case S_OK:
|
||||||
state_ = State::Available;
|
state_ = State::Available;
|
||||||
break;
|
break;
|
||||||
case E_INVALIDARG:
|
case E_INVALIDARG:
|
||||||
state_ = State::InvalidArg;
|
state_ = State::InvalidArg;
|
||||||
break;
|
break;
|
||||||
case E_ACCESSDENIED:
|
case E_ACCESSDENIED:
|
||||||
// For example, when the user presses Ctrl + Alt + Delete and the screen
|
// For example, when the user presses Ctrl + Alt + Delete and the screen
|
||||||
// switches to admin screen, this error occurs.
|
// switches to admin screen, this error occurs.
|
||||||
state_ = State::AccessDenied;
|
state_ = State::AccessDenied;
|
||||||
break;
|
break;
|
||||||
case DXGI_ERROR_UNSUPPORTED:
|
case DXGI_ERROR_UNSUPPORTED:
|
||||||
// If the display adapter on the computer is running under the Microsoft Hybrid system,
|
// If the display adapter on the computer is running under the Microsoft Hybrid system,
|
||||||
// this error occurs.
|
// this error occurs.
|
||||||
state_ = State::Unsupported;
|
state_ = State::Unsupported;
|
||||||
break;
|
break;
|
||||||
case DXGI_ERROR_NOT_CURRENTLY_AVAILABLE:
|
case DXGI_ERROR_NOT_CURRENTLY_AVAILABLE:
|
||||||
// When other application use Desktop Duplication API, this error occurs.
|
// When other application use Desktop Duplication API, this error occurs.
|
||||||
state_ = State::CurrentlyNotAvailable;
|
state_ = State::CurrentlyNotAvailable;
|
||||||
break;
|
break;
|
||||||
case DXGI_ERROR_SESSION_DISCONNECTED:
|
case DXGI_ERROR_SESSION_DISCONNECTED:
|
||||||
state_ = State::SessionDisconnected;
|
state_ = State::SessionDisconnected;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return hr;
|
return hr;
|
||||||
@@ -55,21 +55,21 @@ HRESULT Monitor::Initialize(IDXGIOutput* output)
|
|||||||
|
|
||||||
Monitor::~Monitor()
|
Monitor::~Monitor()
|
||||||
{
|
{
|
||||||
if (deskDupl_ != nullptr)
|
if (deskDupl_ != nullptr)
|
||||||
{
|
{
|
||||||
deskDupl_->Release();
|
deskDupl_->Release();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
HRESULT Monitor::Render(UINT timeout)
|
HRESULT Monitor::Render(UINT timeout)
|
||||||
{
|
{
|
||||||
if (deskDupl_ == nullptr)
|
if (deskDupl_ == nullptr)
|
||||||
{
|
{
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unityTexture_ == nullptr) return 0;
|
if (unityTexture_ == nullptr) return 0;
|
||||||
|
|
||||||
IDXGIResource* resource = nullptr;
|
IDXGIResource* resource = nullptr;
|
||||||
DXGI_OUTDUPL_FRAME_INFO frameInfo;
|
DXGI_OUTDUPL_FRAME_INFO frameInfo;
|
||||||
@@ -77,21 +77,21 @@ HRESULT Monitor::Render(UINT timeout)
|
|||||||
const auto hr = deskDupl_->AcquireNextFrame(timeout, &frameInfo, &resource);
|
const auto hr = deskDupl_->AcquireNextFrame(timeout, &frameInfo, &resource);
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
{
|
{
|
||||||
switch (hr)
|
switch (hr)
|
||||||
{
|
{
|
||||||
case DXGI_ERROR_ACCESS_LOST:
|
case DXGI_ERROR_ACCESS_LOST:
|
||||||
// If any monitor setting has changed (e.g. monitor size has changed),
|
// If any monitor setting has changed (e.g. monitor size has changed),
|
||||||
// it is necessary to re-initialize monitors.
|
// it is necessary to re-initialize monitors.
|
||||||
state_ = State::AccessLost;
|
state_ = State::AccessLost;
|
||||||
break;
|
break;
|
||||||
case DXGI_ERROR_WAIT_TIMEOUT:
|
case DXGI_ERROR_WAIT_TIMEOUT:
|
||||||
break;
|
break;
|
||||||
case DXGI_ERROR_INVALID_CALL:
|
case DXGI_ERROR_INVALID_CALL:
|
||||||
break;
|
break;
|
||||||
case E_INVALIDARG:
|
case E_INVALIDARG:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
ID3D11Texture2D* texture;
|
ID3D11Texture2D* texture;
|
||||||
@@ -103,7 +103,7 @@ HRESULT Monitor::Render(UINT timeout)
|
|||||||
context->Release();
|
context->Release();
|
||||||
|
|
||||||
cursor_->UpdateBuffer(frameInfo);
|
cursor_->UpdateBuffer(frameInfo);
|
||||||
cursor_->UpdateTexture();
|
cursor_->UpdateTexture();
|
||||||
|
|
||||||
resource->Release();
|
resource->Release();
|
||||||
deskDupl_->ReleaseFrame();
|
deskDupl_->ReleaseFrame();
|
||||||
@@ -120,7 +120,7 @@ int Monitor::GetId() const
|
|||||||
|
|
||||||
MonitorState Monitor::GetState() const
|
MonitorState Monitor::GetState() const
|
||||||
{
|
{
|
||||||
return state_;
|
return state_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -168,31 +168,31 @@ bool Monitor::IsPrimary() const
|
|||||||
|
|
||||||
int Monitor::GetLeft() const
|
int Monitor::GetLeft() const
|
||||||
{
|
{
|
||||||
return outputDesc_.DesktopCoordinates.left;
|
return outputDesc_.DesktopCoordinates.left;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int Monitor::GetRight() const
|
int Monitor::GetRight() const
|
||||||
{
|
{
|
||||||
return outputDesc_.DesktopCoordinates.right;
|
return outputDesc_.DesktopCoordinates.right;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int Monitor::GetTop() const
|
int Monitor::GetTop() const
|
||||||
{
|
{
|
||||||
return outputDesc_.DesktopCoordinates.top;
|
return outputDesc_.DesktopCoordinates.top;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int Monitor::GetBottom() const
|
int Monitor::GetBottom() const
|
||||||
{
|
{
|
||||||
return outputDesc_.DesktopCoordinates.bottom;
|
return outputDesc_.DesktopCoordinates.bottom;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int Monitor::GetRotation() const
|
int Monitor::GetRotation() const
|
||||||
{
|
{
|
||||||
return static_cast<int>(outputDesc_.Rotation);
|
return static_cast<int>(outputDesc_.Rotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -6,20 +6,20 @@ class Cursor;
|
|||||||
|
|
||||||
enum class MonitorState
|
enum class MonitorState
|
||||||
{
|
{
|
||||||
NotSet = -1,
|
NotSet = -1,
|
||||||
Available = 0,
|
Available = 0,
|
||||||
InvalidArg = 1,
|
InvalidArg = 1,
|
||||||
AccessDenied = 2,
|
AccessDenied = 2,
|
||||||
Unsupported = 3,
|
Unsupported = 3,
|
||||||
CurrentlyNotAvailable = 4,
|
CurrentlyNotAvailable = 4,
|
||||||
SessionDisconnected = 5,
|
SessionDisconnected = 5,
|
||||||
AccessLost = 6,
|
AccessLost = 6,
|
||||||
};
|
};
|
||||||
|
|
||||||
class Monitor
|
class Monitor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using State = MonitorState;
|
using State = MonitorState;
|
||||||
|
|
||||||
explicit Monitor(int id);
|
explicit Monitor(int id);
|
||||||
~Monitor();
|
~Monitor();
|
||||||
@@ -29,24 +29,24 @@ public:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
int GetId() const;
|
int GetId() const;
|
||||||
State GetState() const;
|
State GetState() const;
|
||||||
void SetUnityTexture(ID3D11Texture2D* texture);
|
void SetUnityTexture(ID3D11Texture2D* texture);
|
||||||
ID3D11Texture2D* GetUnityTexture() const;
|
ID3D11Texture2D* GetUnityTexture() const;
|
||||||
void GetName(char* buf, int len) const;
|
void GetName(char* buf, int len) const;
|
||||||
bool IsPrimary() const;
|
bool IsPrimary() const;
|
||||||
int GetLeft() const;
|
int GetLeft() const;
|
||||||
int GetRight() const;
|
int GetRight() const;
|
||||||
int GetTop() const;
|
int GetTop() const;
|
||||||
int GetBottom() const;
|
int GetBottom() const;
|
||||||
int GetWidth() const;
|
int GetWidth() const;
|
||||||
int GetHeight() const;
|
int GetHeight() const;
|
||||||
int GetRotation() const;
|
int GetRotation() const;
|
||||||
IDXGIOutputDuplication* GetDeskDupl();
|
IDXGIOutputDuplication* GetDeskDupl();
|
||||||
const std::unique_ptr<Cursor>& GetCursor();
|
const std::unique_ptr<Cursor>& GetCursor();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int id_ = -1;
|
int id_ = -1;
|
||||||
State state_ = State::NotSet;
|
State state_ = State::NotSet;
|
||||||
std::unique_ptr<Cursor> cursor_;
|
std::unique_ptr<Cursor> cursor_;
|
||||||
IDXGIOutputDuplication* deskDupl_ = nullptr;
|
IDXGIOutputDuplication* deskDupl_ = nullptr;
|
||||||
ID3D11Texture2D* unityTexture_ = nullptr;
|
ID3D11Texture2D* unityTexture_ = nullptr;
|
||||||
|
|||||||
@@ -61,14 +61,14 @@ void MonitorManager::Finalize()
|
|||||||
|
|
||||||
void MonitorManager::RequireReinitilization()
|
void MonitorManager::RequireReinitilization()
|
||||||
{
|
{
|
||||||
isReinitializationRequired_ = true;
|
isReinitializationRequired_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MonitorManager::Reinitialize()
|
void MonitorManager::Reinitialize()
|
||||||
{
|
{
|
||||||
Initialize();
|
Initialize();
|
||||||
SendMessageToUnity(Message::Reinitialized);
|
SendMessageToUnity(Message::Reinitialized);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -84,11 +84,11 @@ std::shared_ptr<Monitor> MonitorManager::GetMonitor(int id) const
|
|||||||
|
|
||||||
void MonitorManager::Update()
|
void MonitorManager::Update()
|
||||||
{
|
{
|
||||||
if (isReinitializationRequired_)
|
if (isReinitializationRequired_)
|
||||||
{
|
{
|
||||||
Reinitialize();
|
Reinitialize();
|
||||||
isReinitializationRequired_ = false;
|
isReinitializationRequired_ = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -111,26 +111,26 @@ int MonitorManager::GetMonitorCount() const
|
|||||||
|
|
||||||
int MonitorManager::GetTotalWidth() const
|
int MonitorManager::GetTotalWidth() const
|
||||||
{
|
{
|
||||||
std::vector<int> lefts, rights;
|
std::vector<int> lefts, rights;
|
||||||
for (const auto& monitor : monitors_)
|
for (const auto& monitor : monitors_)
|
||||||
{
|
{
|
||||||
lefts.push_back(monitor->GetLeft());
|
lefts.push_back(monitor->GetLeft());
|
||||||
rights.push_back(monitor->GetRight());
|
rights.push_back(monitor->GetRight());
|
||||||
}
|
}
|
||||||
const auto minLeft = *std::min_element(lefts.begin(), lefts.end());
|
const auto minLeft = *std::min_element(lefts.begin(), lefts.end());
|
||||||
const auto maxRight = *std::max_element(rights.begin(), rights.end());
|
const auto maxRight = *std::max_element(rights.begin(), rights.end());
|
||||||
return maxRight - minLeft;
|
return maxRight - minLeft;
|
||||||
}
|
}
|
||||||
|
|
||||||
int MonitorManager::GetTotalHeight() const
|
int MonitorManager::GetTotalHeight() const
|
||||||
{
|
{
|
||||||
std::vector<int> tops, bottoms;
|
std::vector<int> tops, bottoms;
|
||||||
for (const auto& monitor : monitors_)
|
for (const auto& monitor : monitors_)
|
||||||
{
|
{
|
||||||
tops.push_back(monitor->GetTop());
|
tops.push_back(monitor->GetTop());
|
||||||
bottoms.push_back(monitor->GetBottom());
|
bottoms.push_back(monitor->GetBottom());
|
||||||
}
|
}
|
||||||
const auto minTop = *std::min_element(tops.begin(), tops.end());
|
const auto minTop = *std::min_element(tops.begin(), tops.end());
|
||||||
const auto maxBottom = *std::max_element(bottoms.begin(), bottoms.end());
|
const auto maxBottom = *std::max_element(bottoms.begin(), bottoms.end());
|
||||||
return maxBottom - minTop;
|
return maxBottom - minTop;
|
||||||
}
|
}
|
||||||
@@ -13,8 +13,8 @@ class MonitorManager
|
|||||||
public:
|
public:
|
||||||
explicit MonitorManager();
|
explicit MonitorManager();
|
||||||
~MonitorManager();
|
~MonitorManager();
|
||||||
void Reinitialize();
|
void Reinitialize();
|
||||||
void RequireReinitilization();
|
void RequireReinitilization();
|
||||||
void SetCursorMonitorId(int id) { cursorMonitorId_ = id; }
|
void SetCursorMonitorId(int id) { cursorMonitorId_ = id; }
|
||||||
int GetCursorMonitorId() const { return cursorMonitorId_; }
|
int GetCursorMonitorId() const { return cursorMonitorId_; }
|
||||||
std::shared_ptr<Monitor> GetMonitor(int id) const;
|
std::shared_ptr<Monitor> GetMonitor(int id) const;
|
||||||
@@ -25,7 +25,7 @@ private:
|
|||||||
|
|
||||||
// Setters from Unity
|
// Setters from Unity
|
||||||
public:
|
public:
|
||||||
void Update();
|
void Update();
|
||||||
void SetTimeout(int timeout);
|
void SetTimeout(int timeout);
|
||||||
int GetTimeout() const;
|
int GetTimeout() const;
|
||||||
|
|
||||||
@@ -40,5 +40,5 @@ private:
|
|||||||
std::vector<std::shared_ptr<Monitor>> monitors_;
|
std::vector<std::shared_ptr<Monitor>> monitors_;
|
||||||
std::shared_ptr<Cursor> cursor_;
|
std::shared_ptr<Cursor> cursor_;
|
||||||
int cursorMonitorId_ = -1;
|
int cursorMonitorId_ = -1;
|
||||||
bool isReinitializationRequired_ = false;
|
bool isReinitializationRequired_ = false;
|
||||||
};
|
};
|
||||||
@@ -21,7 +21,7 @@ namespace
|
|||||||
{
|
{
|
||||||
IUnityInterfaces* g_unity = nullptr;
|
IUnityInterfaces* g_unity = nullptr;
|
||||||
std::unique_ptr<MonitorManager> g_manager;
|
std::unique_ptr<MonitorManager> g_manager;
|
||||||
std::queue<Message> g_messages;
|
std::queue<Message> g_messages;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -45,7 +45,7 @@ const std::unique_ptr<MonitorManager>& GetMonitorManager()
|
|||||||
|
|
||||||
void SendMessageToUnity(Message message)
|
void SendMessageToUnity(Message message)
|
||||||
{
|
{
|
||||||
g_messages.push(message);
|
g_messages.push(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -53,32 +53,32 @@ extern "C"
|
|||||||
{
|
{
|
||||||
UNITY_INTERFACE_EXPORT void UNITY_INTERFACE_API InitializeUDD()
|
UNITY_INTERFACE_EXPORT void UNITY_INTERFACE_API InitializeUDD()
|
||||||
{
|
{
|
||||||
if (g_unity && !g_manager)
|
if (g_unity && !g_manager)
|
||||||
{
|
{
|
||||||
g_manager = std::make_unique<MonitorManager>();
|
g_manager = std::make_unique<MonitorManager>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
UNITY_INTERFACE_EXPORT void UNITY_INTERFACE_API FinalizeUDD()
|
UNITY_INTERFACE_EXPORT void UNITY_INTERFACE_API FinalizeUDD()
|
||||||
{
|
{
|
||||||
g_manager.reset();
|
g_manager.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
UNITY_INTERFACE_EXPORT void UNITY_INTERFACE_API UnityPluginLoad(IUnityInterfaces* unityInterfaces)
|
UNITY_INTERFACE_EXPORT void UNITY_INTERFACE_API UnityPluginLoad(IUnityInterfaces* unityInterfaces)
|
||||||
{
|
{
|
||||||
g_unity = unityInterfaces;
|
g_unity = unityInterfaces;
|
||||||
InitializeUDD();
|
InitializeUDD();
|
||||||
}
|
}
|
||||||
|
|
||||||
UNITY_INTERFACE_EXPORT void UNITY_INTERFACE_API UnityPluginUnload()
|
UNITY_INTERFACE_EXPORT void UNITY_INTERFACE_API UnityPluginUnload()
|
||||||
{
|
{
|
||||||
g_unity = nullptr;
|
g_unity = nullptr;
|
||||||
FinalizeUDD();
|
FinalizeUDD();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UNITY_INTERFACE_API OnRenderEvent(int id)
|
void UNITY_INTERFACE_API OnRenderEvent(int id)
|
||||||
{
|
{
|
||||||
if (!g_manager) return;
|
if (!g_manager) return;
|
||||||
if (auto monitor = g_manager->GetMonitor(id))
|
if (auto monitor = g_manager->GetMonitor(id))
|
||||||
{
|
{
|
||||||
monitor->Render(g_manager->GetTimeout());
|
monitor->Render(g_manager->GetTimeout());
|
||||||
@@ -92,52 +92,52 @@ extern "C"
|
|||||||
|
|
||||||
UNITY_INTERFACE_EXPORT void UNITY_INTERFACE_API Reinitialize()
|
UNITY_INTERFACE_EXPORT void UNITY_INTERFACE_API Reinitialize()
|
||||||
{
|
{
|
||||||
if (!g_manager) return;
|
if (!g_manager) return;
|
||||||
return g_manager->Reinitialize();
|
return g_manager->Reinitialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
UNITY_INTERFACE_EXPORT void UNITY_INTERFACE_API Update()
|
UNITY_INTERFACE_EXPORT void UNITY_INTERFACE_API Update()
|
||||||
{
|
{
|
||||||
if (!g_manager) return;
|
if (!g_manager) return;
|
||||||
g_manager->Update();
|
g_manager->Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
UNITY_INTERFACE_EXPORT Message PopMessage()
|
UNITY_INTERFACE_EXPORT Message PopMessage()
|
||||||
{
|
{
|
||||||
if (g_messages.empty()) return Message::None;
|
if (g_messages.empty()) return Message::None;
|
||||||
|
|
||||||
const auto message = g_messages.front();
|
const auto message = g_messages.front();
|
||||||
g_messages.pop();
|
g_messages.pop();
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
UNITY_INTERFACE_EXPORT size_t UNITY_INTERFACE_API GetMonitorCount()
|
UNITY_INTERFACE_EXPORT size_t UNITY_INTERFACE_API GetMonitorCount()
|
||||||
{
|
{
|
||||||
if (!g_manager) return 0;
|
if (!g_manager) return 0;
|
||||||
return g_manager->GetMonitorCount();
|
return g_manager->GetMonitorCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
UNITY_INTERFACE_EXPORT int UNITY_INTERFACE_API GetTotalWidth()
|
UNITY_INTERFACE_EXPORT int UNITY_INTERFACE_API GetTotalWidth()
|
||||||
{
|
{
|
||||||
if (!g_manager) return 0;
|
if (!g_manager) return 0;
|
||||||
return g_manager->GetTotalWidth();
|
return g_manager->GetTotalWidth();
|
||||||
}
|
}
|
||||||
|
|
||||||
UNITY_INTERFACE_EXPORT int UNITY_INTERFACE_API GetTotalHeight()
|
UNITY_INTERFACE_EXPORT int UNITY_INTERFACE_API GetTotalHeight()
|
||||||
{
|
{
|
||||||
if (!g_manager) return 0;
|
if (!g_manager) return 0;
|
||||||
return g_manager->GetTotalHeight();
|
return g_manager->GetTotalHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
UNITY_INTERFACE_EXPORT void UNITY_INTERFACE_API SetTimeout(int timeout)
|
UNITY_INTERFACE_EXPORT void UNITY_INTERFACE_API SetTimeout(int timeout)
|
||||||
{
|
{
|
||||||
if (!g_manager) return;
|
if (!g_manager) return;
|
||||||
g_manager->SetTimeout(timeout);
|
g_manager->SetTimeout(timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
UNITY_INTERFACE_EXPORT MonitorState UNITY_INTERFACE_API GetState(int id)
|
UNITY_INTERFACE_EXPORT MonitorState UNITY_INTERFACE_API GetState(int id)
|
||||||
{
|
{
|
||||||
if (!g_manager) return MonitorState::NotSet;
|
if (!g_manager) return MonitorState::NotSet;
|
||||||
if (auto monitor = g_manager->GetMonitor(id))
|
if (auto monitor = g_manager->GetMonitor(id))
|
||||||
{
|
{
|
||||||
return monitor->GetState();
|
return monitor->GetState();
|
||||||
@@ -147,7 +147,7 @@ extern "C"
|
|||||||
|
|
||||||
UNITY_INTERFACE_EXPORT void UNITY_INTERFACE_API GetName(int id, char* buf, int len)
|
UNITY_INTERFACE_EXPORT void UNITY_INTERFACE_API GetName(int id, char* buf, int len)
|
||||||
{
|
{
|
||||||
if (!g_manager) return;
|
if (!g_manager) return;
|
||||||
if (auto monitor = g_manager->GetMonitor(id))
|
if (auto monitor = g_manager->GetMonitor(id))
|
||||||
{
|
{
|
||||||
monitor->GetName(buf, len);
|
monitor->GetName(buf, len);
|
||||||
@@ -156,7 +156,7 @@ extern "C"
|
|||||||
|
|
||||||
UNITY_INTERFACE_EXPORT bool UNITY_INTERFACE_API IsPrimary(int id)
|
UNITY_INTERFACE_EXPORT bool UNITY_INTERFACE_API IsPrimary(int id)
|
||||||
{
|
{
|
||||||
if (!g_manager) return false;
|
if (!g_manager) return false;
|
||||||
if (auto monitor = g_manager->GetMonitor(id))
|
if (auto monitor = g_manager->GetMonitor(id))
|
||||||
{
|
{
|
||||||
return monitor->IsPrimary();
|
return monitor->IsPrimary();
|
||||||
|
|||||||
Reference in New Issue
Block a user