add error code getter.

This commit is contained in:
hecomi
2016-10-30 19:35:00 +09:00
parent 7a27d86eff
commit 73018f671a
4 changed files with 12 additions and 5 deletions
@@ -29,6 +29,8 @@ public static class Lib
public static extern int GetPointerY(int id);
[DllImport("uDesktopDuplication")]
public static extern int SetTexturePtr(int id, IntPtr ptr);
[DllImport("uDesktopDuplication")]
public static extern int GetErrorCode();
public static string GetName(int id)
{
@@ -27,6 +27,7 @@ namespace
IUnityInterfaces* g_unity = nullptr;
int g_timeout = 10;
HRESULT g_errorCode = 0;
std::vector<Monitor> g_monitors;
}
@@ -110,12 +111,11 @@ extern "C"
if (monitor.output == nullptr || monitor.texture == nullptr) return;
HRESULT hr;
IDXGIResource* resource = nullptr;
DXGI_OUTDUPL_FRAME_INFO frameInfo;
hr = monitor.output->AcquireNextFrame(g_timeout, &frameInfo, &resource);
switch (hr)
g_errorCode = monitor.output->AcquireNextFrame(g_timeout, &frameInfo, &resource);
switch (g_errorCode)
{
case S_OK:
{
@@ -138,8 +138,8 @@ extern "C"
monitor.pointerY = frameInfo.PointerPosition.Position.y;
ID3D11Texture2D* texture;
hr = resource->QueryInterface(__uuidof(ID3D11Texture2D), reinterpret_cast<void**>(&texture));
if (hr != S_OK)
g_errorCode = resource->QueryInterface(__uuidof(ID3D11Texture2D), reinterpret_cast<void**>(&texture));
if (g_errorCode != S_OK)
{
resource->Release();
monitor.output->ReleaseFrame();
@@ -218,4 +218,9 @@ extern "C"
if (!DoesMonitorExist(id)) return;
g_monitors[id].texture = reinterpret_cast<ID3D11Texture2D*>(texture);
}
UNITY_INTERFACE_EXPORT int UNITY_INTERFACE_API GetErrorCode()
{
return static_cast<int>(g_errorCode);
}
}