add error code getter.
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -29,6 +29,8 @@ public static class Lib
|
|||||||
public static extern int GetPointerY(int id);
|
public static extern int GetPointerY(int id);
|
||||||
[DllImport("uDesktopDuplication")]
|
[DllImport("uDesktopDuplication")]
|
||||||
public static extern int SetTexturePtr(int id, IntPtr ptr);
|
public static extern int SetTexturePtr(int id, IntPtr ptr);
|
||||||
|
[DllImport("uDesktopDuplication")]
|
||||||
|
public static extern int GetErrorCode();
|
||||||
|
|
||||||
public static string GetName(int id)
|
public static string GetName(int id)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ namespace
|
|||||||
|
|
||||||
IUnityInterfaces* g_unity = nullptr;
|
IUnityInterfaces* g_unity = nullptr;
|
||||||
int g_timeout = 10;
|
int g_timeout = 10;
|
||||||
|
HRESULT g_errorCode = 0;
|
||||||
std::vector<Monitor> g_monitors;
|
std::vector<Monitor> g_monitors;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,12 +111,11 @@ extern "C"
|
|||||||
|
|
||||||
if (monitor.output == nullptr || monitor.texture == nullptr) return;
|
if (monitor.output == nullptr || monitor.texture == nullptr) return;
|
||||||
|
|
||||||
HRESULT hr;
|
|
||||||
IDXGIResource* resource = nullptr;
|
IDXGIResource* resource = nullptr;
|
||||||
DXGI_OUTDUPL_FRAME_INFO frameInfo;
|
DXGI_OUTDUPL_FRAME_INFO frameInfo;
|
||||||
|
|
||||||
hr = monitor.output->AcquireNextFrame(g_timeout, &frameInfo, &resource);
|
g_errorCode = monitor.output->AcquireNextFrame(g_timeout, &frameInfo, &resource);
|
||||||
switch (hr)
|
switch (g_errorCode)
|
||||||
{
|
{
|
||||||
case S_OK:
|
case S_OK:
|
||||||
{
|
{
|
||||||
@@ -138,8 +138,8 @@ extern "C"
|
|||||||
monitor.pointerY = frameInfo.PointerPosition.Position.y;
|
monitor.pointerY = frameInfo.PointerPosition.Position.y;
|
||||||
|
|
||||||
ID3D11Texture2D* texture;
|
ID3D11Texture2D* texture;
|
||||||
hr = resource->QueryInterface(__uuidof(ID3D11Texture2D), reinterpret_cast<void**>(&texture));
|
g_errorCode = resource->QueryInterface(__uuidof(ID3D11Texture2D), reinterpret_cast<void**>(&texture));
|
||||||
if (hr != S_OK)
|
if (g_errorCode != S_OK)
|
||||||
{
|
{
|
||||||
resource->Release();
|
resource->Release();
|
||||||
monitor.output->ReleaseFrame();
|
monitor.output->ReleaseFrame();
|
||||||
@@ -218,4 +218,9 @@ extern "C"
|
|||||||
if (!DoesMonitorExist(id)) return;
|
if (!DoesMonitorExist(id)) return;
|
||||||
g_monitors[id].texture = reinterpret_cast<ID3D11Texture2D*>(texture);
|
g_monitors[id].texture = reinterpret_cast<ID3D11Texture2D*>(texture);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UNITY_INTERFACE_EXPORT int UNITY_INTERFACE_API GetErrorCode()
|
||||||
|
{
|
||||||
|
return static_cast<int>(g_errorCode);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user