Compare commits

..

10 Commits

Author SHA1 Message Date
hecomi
2b108bd4b1 fix available getter bug. 2016-11-05 23:25:22 +09:00
hecomi
f9f8b14f46 show not-available texture when display is not available. 2016-11-05 23:15:57 +09:00
hecomi
7774290e71 fix text orientation. 2016-11-05 22:56:22 +09:00
hecomi
a3a7754fb0 remove unused cursor material and move icon to editor dir. 2016-11-05 22:44:17 +09:00
hecomi
0accebb657 add not-available texture. 2016-11-05 22:42:45 +09:00
hecomi
0a38eda14f update files. 2016-11-05 22:36:08 +09:00
hecomi
720f74e6f6 check unsupported display. 2016-11-05 22:34:11 +09:00
hecomi
80fa39f4eb remove unused debug.log. 2016-11-05 02:14:19 +09:00
hecomi
22b21ae3f4 check texture size before recreating it. 2016-11-05 01:44:26 +09:00
hecomi
43153266a0 rename members named pointer to cursor. 2016-11-05 01:40:20 +09:00
31 changed files with 313 additions and 311 deletions

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 022a80d652ef0304e84e9d6ac689e21f
folderAsset: yes
timeCreated: 1478353382
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 6e15bc51aada81042a909c808e25c176
folderAsset: yes
timeCreated: 1477555207
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 033e0db89e0ca1d46a399c953629f67d
timeCreated: 1477555367
licenseType: Pro
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,8 +1,8 @@
fileFormatVersion: 2
guid: 6e15bc51aada81042a909c808e25c176
guid: b281589e6b8e27b4fbf0509d620b7871
folderAsset: yes
timeCreated: 1477555207
licenseType: Pro
timeCreated: 1478354860
licenseType: Free
DefaultImporter:
userData:
assetBundleName:

View File

@@ -1,8 +1,8 @@
fileFormatVersion: 2
guid: 48b92326b146fa848beec6f35365b1f4
guid: e36cd526b654d024e875d5110a1b0442
folderAsset: yes
timeCreated: 1477555207
licenseType: Pro
timeCreated: 1478354877
licenseType: Free
DefaultImporter:
userData:
assetBundleName:

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 0e2bcc27e10c0d141a0c11cd88cdcf98
folderAsset: yes
timeCreated: 1478353263
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

View File

@@ -0,0 +1,59 @@
fileFormatVersion: 2
guid: 9855ecfc2b823c94d8a1354715d343a1
timeCreated: 1478353264
licenseType: Pro
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 2
mipmaps:
mipMapMode: 0
enableMipMap: 1
linearTexture: 0
correctGamma: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 0
cubemapConvolution: 0
cubemapConvolutionSteps: 7
cubemapConvolutionExponent: 1.5
seamlessCubemap: 0
textureFormat: -1
maxTextureSize: 2048
textureSettings:
filterMode: -1
aniso: -1
mipBias: -1
wrapMode: -1
nPOTScale: 1
lightmap: 0
rGBM: 0
compressionQuality: 50
allowsAlphaSplitting: 0
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaIsTransparency: 0
spriteTessellationDetail: -1
textureType: -1
buildTargetSettings: []
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -33,8 +33,8 @@ public class Cursor : MonoBehaviour
void UpdatePosition()
{
var x = (1f * monitor.pointerX / monitor.width - 0.5f) * modelScale.x;
var y = (1f * monitor.pointerY / monitor.height - 0.5f) * modelScale.y;
var x = (1f * monitor.cursorX / monitor.width - 0.5f) * modelScale.x;
var y = (1f * monitor.cursorY / monitor.height - 0.5f) * modelScale.y;
var iy = uddTexture_.invertY ? -1 : +1;
var localPos = transform.right * x + iy * transform.up * y;
worldPosition = transform.TransformPoint(localPos);
@@ -42,8 +42,8 @@ public class Cursor : MonoBehaviour
void UpdateTexture()
{
var w = monitor.pointerShapeWidth;
var h = monitor.pointerShapeHeight;
var w = monitor.cursorShapeWidth;
var h = monitor.cursorShapeHeight;
if (w == 0 || h == 0) return;
var scale = new Vector2(w, h);
@@ -53,17 +53,17 @@ public class Cursor : MonoBehaviour
textures_.Add(scale, texture);
}
var pointerTexture = textures_[scale];
monitor.UpdateCursorTexture(pointerTexture.GetNativeTexturePtr());
uddTexture_.material.SetTexture("_CursorTex", pointerTexture);
var cursorTexture = textures_[scale];
monitor.UpdateCursorTexture(cursorTexture.GetNativeTexturePtr());
uddTexture_.material.SetTexture("_CursorTex", cursorTexture);
}
void UpdateMaterial()
{
var x = (float)monitor.pointerX / monitor.width;
var y = (float)monitor.pointerY / monitor.height;
var w = (float)monitor.pointerShapeWidth / monitor.width;
var h = (float)monitor.pointerShapeHeight / monitor.height;
var x = (float)monitor.cursorX / monitor.width;
var y = (float)monitor.cursorY / monitor.height;
var w = (float)monitor.cursorShapeWidth / monitor.width;
var h = (float)monitor.cursorShapeHeight / monitor.height;
uddTexture_.material.SetVector("_CursorPositionScale", new Vector4(x, y, w, h));
}
}

View File

@@ -50,6 +50,8 @@ public static class Lib
[DllImport("uDesktopDuplication")]
public static extern IntPtr GetRenderEventFunc();
[DllImport("uDesktopDuplication")]
public static extern bool IsAvailable(int id);
[DllImport("uDesktopDuplication")]
public static extern void GetName(int id, StringBuilder buf, int len);
[DllImport("uDesktopDuplication")]
public static extern int GetLeft(int id);

View File

@@ -21,6 +21,11 @@ public class Monitor
get { return id < Manager.monitorCount; }
}
public bool available
{
get { return Lib.IsAvailable(id); }
}
public string name
{
get { return Lib.GetName(id); }
@@ -86,27 +91,27 @@ public class Monitor
get { return Lib.IsCursorVisible(id); }
}
public int pointerX
public int cursorX
{
get { return Lib.GetCursorX(id); }
}
public int pointerY
public int cursorY
{
get { return Lib.GetCursorY(id); }
}
public int pointerShapeWidth
public int cursorShapeWidth
{
get { return Lib.GetCursorShapeWidth(id); }
}
public int pointerShapeHeight
public int cursorShapeHeight
{
get { return Lib.GetCursorShapeHeight(id); }
}
public CursorShapeType pointerShapeType
public CursorShapeType cursorShapeType
{
get { return Lib.GetCursorShapeType(id); }
}
@@ -122,6 +127,9 @@ public class Monitor
{
get
{
if (!available) {
return Resources.Load<Texture2D>("uDesktopDuplication/Textures/NotAvailable");
}
if (texture_ == null) {
CreateTexture();
}
@@ -131,8 +139,10 @@ public class Monitor
public void Render()
{
Lib.SetTexturePtr(id, texture_.GetNativeTexturePtr());
GL.IssuePluginEvent(Lib.GetRenderEventFunc(), id);
if (texture_ && available) {
Lib.SetTexturePtr(id, texture_.GetNativeTexturePtr());
GL.IssuePluginEvent(Lib.GetRenderEventFunc(), id);
}
}
public void UpdateCursorTexture(System.IntPtr ptr)
@@ -142,6 +152,8 @@ public class Monitor
void CreateTexture()
{
if (!available) return;
var w = isHorizontal ? width : height;
var h = isHorizontal ? height : width;
bool shouldCreate = true;
@@ -155,6 +167,10 @@ public class Monitor
}
}
if (w <= 0 || h <= 0) {
shouldCreate = false;
}
if (shouldCreate) {
texture_ = new Texture2D(w, h, TextureFormat.BGRA32, false);
}

View File

@@ -50,6 +50,7 @@ public class Texture : MonoBehaviour
void Update()
{
Debug.Log(monitor.available);
monitor.shouldBeUpdated = true;
UpdateMaterial();
}

View File

@@ -17,18 +17,18 @@ struct v2f
struct Input
{
float2 uv_MainTex;
float2 uv_MainTex;
};
float2 uddInvertUV(float2 uv)
{
#ifdef INVERT_X
uv.x = 1.0 - uv.x;
uv.x = 1.0 - uv.x;
#endif
#ifdef INVERT_Y
uv.y = 1.0 - uv.y;
uv.y = 1.0 - uv.y;
#endif
return uv;
return uv;
}
float2 uddRotateUV(float2 uv)
@@ -38,14 +38,14 @@ float2 uddRotateUV(float2 uv)
uv.x = tmp.y;
uv.y = 1.0 - tmp.x;
#elif ROTATE180
uv.x = 1.0 - uv.x;
uv.y = 1.0 - uv.y;
uv.x = 1.0 - uv.x;
uv.y = 1.0 - uv.y;
#elif ROTATE270
float2 tmp = uv;
uv.x = 1.0 - tmp.y;
uv.y = tmp.x;
#endif
return uv;
return uv;
}
inline void uddConvertToLinearIfNeeded(inout fixed3 rgb)
@@ -66,19 +66,19 @@ inline fixed4 uddGetCursorTexture(sampler2D tex, float2 uv, fixed4 cursorPosScal
uv.x = (uv.x - cursorPosScale.x) / cursorPosScale.z;
uv.y = (uv.y - cursorPosScale.y) / cursorPosScale.w;
fixed4 c = tex2D(tex, uv);
fixed a = c.a * step(0, uv.x) * step(0, uv.y) * step(uv.x, 1) * step(uv.y, 1);
c *= step(0.01, a);
return c;
fixed a = c.a * step(0, uv.x) * step(0, uv.y) * step(uv.x, 1) * step(uv.y, 1);
c *= step(0.01, a);
return c;
}
inline fixed4 uddGetScreenTextureWithCursor(sampler2D screenTex, sampler2D cursorTex, float2 uv, fixed4 cursorPosScale)
{
uv = uddInvertUV(uv);
fixed4 screen = uddGetScreenTexture(screenTex, uddRotateUV(uv));
fixed4 cursor = uddGetCursorTexture(cursorTex, uv, cursorPosScale);
fixed4 color = lerp(screen, cursor, cursor.a);
uddConvertToLinearIfNeeded(color.rgb);
return color;
uv = uddInvertUV(uv);
fixed4 screen = uddGetScreenTexture(screenTex, uddRotateUV(uv));
fixed4 cursor = uddGetCursorTexture(cursorTex, uv, cursorPosScale);
fixed4 color = lerp(screen, cursor, cursor.a);
uddConvertToLinearIfNeeded(color.rgb);
return color;
}
#endif

View File

@@ -25,12 +25,12 @@ SubShader
#pragma multi_compile ___ VERTICAL
#pragma multi_compile ___ ROTATE90 ROTATE180 ROTATE270
#define SURFACE_SHADER
#define SURFACE_SHADER
#include "./uDD_Common.cginc"
#include "./uDD_Params.cginc"
#include "./uDD_Params.cginc"
half _Glossiness;
half _Metallic;
half _Glossiness;
half _Metallic;
void surf(Input IN, inout SurfaceOutputStandard o)
{

View File

@@ -6,7 +6,7 @@ Properties
_Color ("Color", Color) = (1, 1, 1, 1)
_MainTex ("Texture", 2D) = "white" {}
[Toggle(USE_BEND)] _UseBend("UseBend", Float) = 0
[PowerSlider(10.0)]_Radius ("Radius", Range(3, 100)) = 10
[PowerSlider(10.0)]_Radius ("Radius", Range(3, 100)) = 10
[KeywordEnum(Off, Front, Back)] _Cull("Culling", Int) = 2
}
@@ -28,9 +28,9 @@ v2f vert(appdata v)
{
v2f o;
#ifdef USE_BEND
half a = v.vertex.x / _Radius;
v.vertex.x = _Radius * sin(a);
v.vertex.y += _Radius * (1 - cos(a));
half a = v.vertex.x / _Radius;
v.vertex.x = _Radius * sin(a);
v.vertex.y += _Radius * (1 - cos(a));
#endif
o.vertex = UnityObjectToClipPos(v.vertex);
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
@@ -39,7 +39,7 @@ v2f vert(appdata v)
fixed4 frag(v2f i) : SV_Target
{
return uddGetScreenTextureWithCursor(_MainTex, _CursorTex, i.uv, _CursorPositionScale);
return uddGetScreenTextureWithCursor(_MainTex, _CursorTex, i.uv, _CursorPositionScale);
}
ENDCG

View File

@@ -35,23 +35,23 @@ v2f vert(appdata v)
fixed4 frag(v2f i) : SV_Target
{
fixed4 tex = uddGetScreenTextureWithCursor(_MainTex, _CursorTex, i.uv, _CursorPositionScale);
fixed alpha = pow((tex.r + tex.g + tex.b) / 3.0, _Mask);
return fixed4(tex.rgb * _Color.rgb, alpha * _Color.a);
fixed4 tex = uddGetScreenTextureWithCursor(_MainTex, _CursorTex, i.uv, _CursorPositionScale);
fixed alpha = pow((tex.r + tex.g + tex.b) / 3.0, _Mask);
return fixed4(tex.rgb * _Color.rgb, alpha * _Color.a);
}
ENDCG
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile ___ INVERT_X
#pragma multi_compile ___ INVERT_Y
#pragma multi_compile ___ VERTICAL
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile ___ INVERT_X
#pragma multi_compile ___ INVERT_Y
#pragma multi_compile ___ VERTICAL
#pragma multi_compile ___ ROTATE90 ROTATE180 ROTATE270
ENDCG
ENDCG
}
}

View File

@@ -5,8 +5,13 @@
#include "Monitor.h"
Monitor::Monitor(int id, IDXGIOutput* output)
Monitor::Monitor(int id)
: id_(id)
, cursor_(std::make_unique<Cursor>(this))
{
}
HRESULT Monitor::Initialize(IDXGIOutput* output)
{
output->GetDesc(&outputDesc_);
monitorInfo_.cbSize = sizeof(MONITORINFOEX);
@@ -15,36 +20,31 @@ Monitor::Monitor(int id, IDXGIOutput* output)
auto output1 = reinterpret_cast<IDXGIOutput1*>(output);
const auto hr = output1->DuplicateOutput(GetDevice(), &deskDupl_);
auto error = 0;
// TODO: error check
switch (hr)
{
case S_OK:
available_ = true;
break;
case E_INVALIDARG:
error = 1;
break;
case E_ACCESSDENIED:
error = 2;
// For example, when the user presses Ctrl + Alt + Delete and the screen
// switches to admin screen, this error occurs.
// GetMonitorManager()->RequireReinitilization();
break;
case DXGI_ERROR_UNSUPPORTED:
error = 3;
// If the display adapter on the computer is running under the Microsoft Hybrid system,
// this error occurs.
break;
case DXGI_ERROR_NOT_CURRENTLY_AVAILABLE:
error = 4;
// Other application use Desktop Duplication API...
// When other application use Desktop Duplication API, this error occurs.
break;
case DXGI_ERROR_SESSION_DISCONNECTED:
error = 5;
break;
}
cursor_ = std::make_unique<Cursor>(this);
// MEMO: 'output' will be released automatically after this ctor.
return hr;
}
@@ -61,7 +61,6 @@ HRESULT Monitor::Render(UINT timeout)
{
if (deskDupl_ == nullptr)
{
GetMonitorManager()->RequireReinitilization();
return 0;
}
@@ -89,7 +88,7 @@ HRESULT Monitor::Render(UINT timeout)
resource->Release();
deskDupl_->ReleaseFrame();
return 0;
return S_OK;
}
@@ -99,6 +98,12 @@ int Monitor::GetId() const
}
bool Monitor::IsAvailable() const
{
return available_;
}
void Monitor::SetUnityTexture(ID3D11Texture2D* texture)
{
unityTexture_ = texture;

View File

@@ -7,13 +7,15 @@ class Cursor;
class Monitor
{
public:
Monitor(int id, IDXGIOutput* output);
explicit Monitor(int id);
~Monitor();
HRESULT Initialize(IDXGIOutput* output);
HRESULT Render(UINT timeout = 0);
void UpdateCursorTexture(ID3D11Texture2D* texture);
public:
int GetId() const;
bool IsAvailable() const;
void SetUnityTexture(ID3D11Texture2D* texture);
ID3D11Texture2D* GetUnityTexture() const;
void GetName(char* buf, int len) const;
@@ -30,6 +32,7 @@ public:
private:
int id_ = -1;
bool available_ = false;
std::unique_ptr<Cursor> cursor_;
IDXGIOutputDuplication* deskDupl_ = nullptr;
ID3D11Texture2D* unityTexture_ = nullptr;

View File

@@ -42,7 +42,8 @@ void MonitorManager::Initialize()
IDXGIOutput* output;
for (int j = 0; (adapter->EnumOutputs(j, &output) != DXGI_ERROR_NOT_FOUND); ++j)
{
auto monitor = std::make_shared<Monitor>(id++, output);
auto monitor = std::make_shared<Monitor>(id++);
monitor->Initialize(output);
monitors_.push_back(monitor);
output->Release();
}
@@ -89,9 +90,12 @@ void MonitorManager::OnRender(int id)
{
if (auto monitor = GetMonitor(id))
{
if (!monitor->IsAvailable()) return;
const auto hr = monitor->Render(timeout_);
// If any monitor setting has changed (e.g. monitor size has changed),
// it is necessary to re-initialize monitors.
const auto hr = monitor->Render(timeout_);
if (hr == DXGI_ERROR_ACCESS_LOST)
{
isReinitializationRequired_ = true;
@@ -100,28 +104,15 @@ void MonitorManager::OnRender(int id)
}
void MonitorManager::UpdateCursorTexture(int id, ID3D11Texture2D* texture)
{
if (auto monitor = GetMonitor(id))
{
monitor->UpdateCursorTexture(texture);
}
}
void MonitorManager::SetTimeout(int timeout)
{
timeout_ = timeout;
}
void MonitorManager::SetTexturePtr(int id, void* texture)
int MonitorManager::GetTimeout() const
{
if (auto monitor = GetMonitor(id))
{
auto d3d11Texture = reinterpret_cast<ID3D11Texture2D*>(texture);
monitor->SetUnityTexture(d3d11Texture);
}
return timeout_;
}
@@ -154,163 +145,4 @@ int MonitorManager::GetTotalHeight() const
const auto minTop = *std::min_element(tops.begin(), tops.end());
const auto maxBottom = *std::max_element(bottoms.begin(), bottoms.end());
return maxBottom - minTop;
}
void MonitorManager::GetName(int id, char* buf, int len) const
{
if (auto monitor = GetMonitor(id))
{
monitor->GetName(buf, len);
}
}
bool MonitorManager::IsPrimary(int id) const
{
if (auto monitor = GetMonitor(id))
{
return monitor->IsPrimary();
}
return false;
}
int MonitorManager::GetLeft(int id) const
{
if (auto monitor = GetMonitor(id))
{
return monitor->GetLeft();
}
return 0;
}
int MonitorManager::GetRight(int id) const
{
if (auto monitor = GetMonitor(id))
{
return monitor->GetRight();
}
return 0;
}
int MonitorManager::GetTop(int id) const
{
if (auto monitor = GetMonitor(id))
{
return monitor->GetTop();
}
return 0;
}
int MonitorManager::GetBottom(int id) const
{
if (auto monitor = GetMonitor(id))
{
return monitor->GetBottom();
}
return 0;
}
int MonitorManager::GetWidth(int id) const
{
if (auto monitor = GetMonitor(id))
{
return monitor->GetWidth();
}
return -1;
}
int MonitorManager::GetHeight(int id) const
{
if (auto monitor = GetMonitor(id))
{
return monitor->GetHeight();
}
return -1;
}
int MonitorManager::GetRotation(int id) const
{
if (auto monitor = GetMonitor(id))
{
return monitor->GetRotation();
}
return DXGI_MODE_ROTATION_UNSPECIFIED;
}
bool MonitorManager::IsCursorVisible(int id) const
{
if (auto monitor = GetMonitor(id))
{
return monitor->GetCursor()->IsVisible();
}
return false;
}
int MonitorManager::GetCursorX(int id) const
{
if (auto monitor = GetMonitor(id))
{
return monitor->GetCursor()->GetX();
}
return -1;
}
int MonitorManager::GetCursorY(int id) const
{
if (auto monitor = GetMonitor(id))
{
return monitor->GetCursor()->GetY();
}
return -1;
}
int MonitorManager::GetCursorShapeWidth(int id) const
{
if (auto monitor = GetMonitor(id))
{
return monitor->GetCursor()->GetWidth();
}
return -1;
}
int MonitorManager::GetCursorShapeHeight(int id) const
{
if (auto monitor = GetMonitor(id))
{
return monitor->GetCursor()->GetHeight();
}
return -1;
}
int MonitorManager::GetCursorShapePitch(int id) const
{
if (auto monitor = GetMonitor(id))
{
return monitor->GetCursor()->GetPitch();
}
return -1;
}
int MonitorManager::GetCursorShapeType(int id) const
{
if (auto monitor = GetMonitor(id))
{
return monitor->GetCursor()->GetType();
}
return -1;
}

View File

@@ -29,31 +29,14 @@ private:
public:
void OnRender(int id);
void Update();
void UpdateCursorTexture(int id, ID3D11Texture2D* ptr);
void SetTimeout(int timeout);
void SetTexturePtr(int id, void* texture);
int GetTimeout() const;
// Getters from Unity
public:
int GetMonitorCount() const;
int GetTotalWidth() const;
int GetTotalHeight() const;
void GetName(int id, char* buf, int len) const;
bool IsPrimary(int id) const;
int GetLeft(int id) const;
int GetRight(int id) const;
int GetTop(int id) const;
int GetBottom(int id) const;
int GetWidth(int id) const;
int GetHeight(int id) const;
int GetRotation(int id) const;
bool IsCursorVisible(int id) const;
int GetCursorX(int id) const;
int GetCursorY(int id) const;
int GetCursorShapeWidth(int id) const;
int GetCursorShapeHeight(int id) const;
int GetCursorShapePitch(int id) const;
int GetCursorShapeType(int id) const;
private:
int timeout_ = 10;

View File

@@ -10,6 +10,8 @@
#include "IUnityGraphicsD3D11.h"
#include "Common.h"
#include "Monitor.h"
#include "Cursor.h"
#include "MonitorManager.h"
#pragma comment(lib, "dxgi.lib")
@@ -124,111 +126,191 @@ extern "C"
g_manager->SetTimeout(timeout);
}
UNITY_INTERFACE_EXPORT bool UNITY_INTERFACE_API IsAvailable(int id)
{
if (!g_manager) return false;
if (auto monitor = g_manager->GetMonitor(id))
{
return monitor->IsAvailable();
}
return false;
}
UNITY_INTERFACE_EXPORT void UNITY_INTERFACE_API GetName(int id, char* buf, int len)
{
if (!g_manager) return;
g_manager->GetName(id, buf, len);
if (auto monitor = g_manager->GetMonitor(id))
{
monitor->GetName(buf, len);
}
}
UNITY_INTERFACE_EXPORT bool UNITY_INTERFACE_API IsPrimary(int id)
{
if (!g_manager) return false;
return g_manager->IsPrimary(id);
if (auto monitor = g_manager->GetMonitor(id))
{
return monitor->IsPrimary();
}
return false;
}
UNITY_INTERFACE_EXPORT int UNITY_INTERFACE_API GetLeft(int id)
{
if (!g_manager) return -1;
return g_manager->GetLeft(id);
if (!g_manager) return -1;
if (auto monitor = g_manager->GetMonitor(id))
{
return monitor->GetLeft();
}
return -1;
}
UNITY_INTERFACE_EXPORT int UNITY_INTERFACE_API GetRight(int id)
{
if (!g_manager) return -1;
return g_manager->GetRight(id);
if (!g_manager) return -1;
if (auto monitor = g_manager->GetMonitor(id))
{
return monitor->GetRight();
}
return 0;
}
UNITY_INTERFACE_EXPORT int UNITY_INTERFACE_API GetTop(int id)
{
if (!g_manager) return -1;
return g_manager->GetTop(id);
if (!g_manager) return -1;
if (auto monitor = g_manager->GetMonitor(id))
{
return monitor->GetTop();
}
return 0;
}
UNITY_INTERFACE_EXPORT int UNITY_INTERFACE_API GetBottom(int id)
{
if (!g_manager) return -1;
return g_manager->GetBottom(id);
if (!g_manager) return -1;
if (auto monitor = g_manager->GetMonitor(id))
{
return monitor->GetBottom();
}
return 0;
}
UNITY_INTERFACE_EXPORT int UNITY_INTERFACE_API GetWidth(int id)
{
if (!g_manager) return -1;
return g_manager->GetWidth(id);
if (!g_manager) return -1;
if (auto monitor = g_manager->GetMonitor(id))
{
return monitor->GetWidth();
}
return -1;
}
UNITY_INTERFACE_EXPORT int UNITY_INTERFACE_API GetHeight(int id)
{
if (!g_manager) return -1;
return g_manager->GetHeight(id);
if (!g_manager) return -1;
if (auto monitor = g_manager->GetMonitor(id))
{
return monitor->GetHeight();
}
return -1;
}
UNITY_INTERFACE_EXPORT int UNITY_INTERFACE_API GetRotation(int id)
{
if (!g_manager) return -1;
return g_manager->GetRotation(id);
if (!g_manager) return -1;
if (auto monitor = g_manager->GetMonitor(id))
{
return monitor->GetRotation();
}
return DXGI_MODE_ROTATION_UNSPECIFIED;
}
UNITY_INTERFACE_EXPORT bool UNITY_INTERFACE_API IsCursorVisible(int id)
{
if (!g_manager) return false;
return g_manager->IsCursorVisible(id);
if (!g_manager) return false;
if (auto monitor = g_manager->GetMonitor(id))
{
return monitor->GetCursor()->IsVisible();
}
return false;
}
UNITY_INTERFACE_EXPORT int UNITY_INTERFACE_API GetCursorX(int id)
{
if (!g_manager) return -1;
return g_manager->GetCursorX(id);
if (!g_manager) return -1;
if (auto monitor = g_manager->GetMonitor(id))
{
return monitor->GetCursor()->GetX();
}
return -1;
}
UNITY_INTERFACE_EXPORT int UNITY_INTERFACE_API GetCursorY(int id)
{
if (!g_manager) return -1;
return g_manager->GetCursorY(id);
if (!g_manager) return -1;
if (auto monitor = g_manager->GetMonitor(id))
{
return monitor->GetCursor()->GetY();
}
return -1;
}
UNITY_INTERFACE_EXPORT int UNITY_INTERFACE_API GetCursorShapeWidth(int id)
{
if (!g_manager) return -1;
return g_manager->GetCursorShapeWidth(id);
if (!g_manager) return -1;
if (auto monitor = g_manager->GetMonitor(id))
{
return monitor->GetCursor()->GetWidth();
}
return -1;
}
UNITY_INTERFACE_EXPORT int UNITY_INTERFACE_API GetCursorShapeHeight(int id)
{
if (!g_manager) return -1;
return g_manager->GetCursorShapeHeight(id);
if (!g_manager) return -1;
if (auto monitor = g_manager->GetMonitor(id))
{
return monitor->GetCursor()->GetHeight();
}
return -1;
}
UNITY_INTERFACE_EXPORT int UNITY_INTERFACE_API GetCursorShapePitch(int id)
{
if (!g_manager) return -1;
return g_manager->GetCursorShapePitch(id);
if (!g_manager) return -1;
if (auto monitor = g_manager->GetMonitor(id))
{
return monitor->GetCursor()->GetPitch();
}
return -1;
}
UNITY_INTERFACE_EXPORT int UNITY_INTERFACE_API GetCursorShapeType(int id)
{
if (!g_manager) return -1;
return g_manager->GetCursorShapeType(id);
if (!g_manager) return -1;
if (auto monitor = g_manager->GetMonitor(id))
{
return monitor->GetCursor()->GetType();
}
return -1;
}
UNITY_INTERFACE_EXPORT void UNITY_INTERFACE_API UpdateCursorTexture(int id, ID3D11Texture2D* ptr)
UNITY_INTERFACE_EXPORT void UNITY_INTERFACE_API UpdateCursorTexture(int id, ID3D11Texture2D* texture)
{
if (!g_manager) return;
g_manager->UpdateCursorTexture(id, ptr);
if (!g_manager) return;
if (auto monitor = g_manager->GetMonitor(id))
{
monitor->UpdateCursorTexture(texture);
}
}
UNITY_INTERFACE_EXPORT void UNITY_INTERFACE_API SetTexturePtr(int id, void* texture)
{
if (!g_manager) return;
g_manager->SetTexturePtr(id, texture);
if (!g_manager) return;
if (auto monitor = g_manager->GetMonitor(id))
{
auto d3d11Texture = reinterpret_cast<ID3D11Texture2D*>(texture);
monitor->SetUnityTexture(d3d11Texture);
}
}
}