From d9f83cf89e2f4f202cdf0806d04211c88a0183e5 Mon Sep 17 00:00:00 2001 From: hecomi Date: Fri, 28 Oct 2016 17:28:22 +0900 Subject: [PATCH] implement multiple screen. --- .../Plugins/uDesktopDuplication.dll | Bin 12288 -> 20480 bytes .../Images/{cursor.png => uDD_Cursor.png} | Bin .../{cursor.png.meta => uDD_Cursor.png.meta} | 0 .../uDesktopDuplication/Scenes/Example.unity | Bin 18860 -> 18860 bytes .../Scripts/MouseDrawer.cs | 44 ------ .../uDesktopDuplication/Scripts/uDD_Cursor.cs | 39 +++++ ...MouseDrawer.cs.meta => uDD_Cursor.cs.meta} | 2 +- Assets/uDesktopDuplication/Scripts/uDD_Lib.cs | 39 +++++ .../Scripts/uDD_Lib.cs.meta | 12 ++ .../Scripts/uDD_Manager.cs | 74 +++++++++ .../Scripts/uDD_Manager.cs.meta | 12 ++ .../Scripts/uDD_Monitor.cs | 84 +++++++++++ .../Scripts/uDD_Monitor.cs.meta | 12 ++ .../Scripts/uDD_Texture.cs | 46 ++++++ ...uplication.cs.meta => uDD_Texture.cs.meta} | 2 +- .../Scripts/uDesktopDuplication.cs | 97 ------------ .../uDesktopDuplication/main.cpp | 142 +++++++++++------- ProjectSettings/ProjectSettings.asset | Bin 43089 -> 43089 bytes 18 files changed, 409 insertions(+), 196 deletions(-) rename Assets/uDesktopDuplication/Resources/uDesktopDuplication/Images/{cursor.png => uDD_Cursor.png} (100%) rename Assets/uDesktopDuplication/Resources/uDesktopDuplication/Images/{cursor.png.meta => uDD_Cursor.png.meta} (100%) delete mode 100644 Assets/uDesktopDuplication/Scripts/MouseDrawer.cs create mode 100644 Assets/uDesktopDuplication/Scripts/uDD_Cursor.cs rename Assets/uDesktopDuplication/Scripts/{MouseDrawer.cs.meta => uDD_Cursor.cs.meta} (92%) create mode 100644 Assets/uDesktopDuplication/Scripts/uDD_Lib.cs create mode 100644 Assets/uDesktopDuplication/Scripts/uDD_Lib.cs.meta create mode 100644 Assets/uDesktopDuplication/Scripts/uDD_Manager.cs create mode 100644 Assets/uDesktopDuplication/Scripts/uDD_Manager.cs.meta create mode 100644 Assets/uDesktopDuplication/Scripts/uDD_Monitor.cs create mode 100644 Assets/uDesktopDuplication/Scripts/uDD_Monitor.cs.meta create mode 100644 Assets/uDesktopDuplication/Scripts/uDD_Texture.cs rename Assets/uDesktopDuplication/Scripts/{uDesktopDuplication.cs.meta => uDD_Texture.cs.meta} (92%) delete mode 100644 Assets/uDesktopDuplication/Scripts/uDesktopDuplication.cs diff --git a/Assets/uDesktopDuplication/Plugins/uDesktopDuplication.dll b/Assets/uDesktopDuplication/Plugins/uDesktopDuplication.dll index 5687770e724602e13b1f9af552380a335622269b..aa96a8a2ebb9baf0a97c0151f49c2f2e7a475a9d 100644 GIT binary patch literal 20480 zcmeHvdwf&JmH)_=j2{>Yu)rjt5k$mJ9KaxwnA#2!lJF?Vi3{e@0JV)RV>hl+?LJ}TrFrg3U(dIg)T|-kaNjCa@&)h3n z2GiZ&@6-Kb_tTrqJu_#{oS8Z2%$YNDEh_KZ#nKsLTBLZKu}(mGtm6IGUzr-lCfs;n z0(&v*)ft@{_p39io0zk;LYt5+2$ymcbj$=nZnzTAWGsI?^a?&O+RtU_k3ienL zph4uf3TBi~V=P0dPC~XH2ofruG*$~zrBMQ0T~;uLdl_2`>Xs_TUZlpm80)8w+8EnM zib_0t6dmoii>d_nDrj;rwmTJTg^tC*Q;{S2IYCc*5XB!C;6+2GxvTR)PCO>YYUlVH z>VkEQeRV2OR-}BS+mKQoD{AH_WGr(WDr%7+D~2(pK32wJbJ`R_F-Oc*^tmLJN_1nL zv!SuMA)t1(74^jL?lI{60e?NvLUxd$pmUE!=V|eQ&`MQ%kci(sNGXq%vBfFH|5aHY zK38ao@rds1O2zmSkm3lWA76%PCf7H};2 z984_$%Oh*enXAx?iA&{=P#bA_8-dc_1()k@L@|d;ns}9ghr2nDp+A9cl|si=x*{H3 zYLNYz)M1iHcPrIKbVY)8t+^P3G1YYQ$n=Z2BY~ zk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}S@ZXVhmxE4udjyrnb_1S5b%T!IB6uF|1Wx%l<=9T>Nsw}8!URV7=caLG+K=I5?%4u_@A zP5!Mm2nd9$N{}Po5N_#^I-A2wI(;pnU^v(&FKG#O-q0NGEZe-S#D+A%*M^*MUFvKQ zWwWi8Ly@pd`K%#r!KX-bEa2lXGK{n=gddHJHYg$Kz6fTKT5ChT&B!O(rSMc|YPW}H zbXc}m+AR5PetK4wG>5BsMjR@!MSQLnN{*^Z+M4}gsl>K)O3vz~pFGRzr89I|y>x1E u7`}RG(r##^?87IbcxS?Xv(hKZpV;-po+lpLyKisb-cRKItmALY0{;U|$xVp> diff --git a/Assets/uDesktopDuplication/Resources/uDesktopDuplication/Images/cursor.png b/Assets/uDesktopDuplication/Resources/uDesktopDuplication/Images/uDD_Cursor.png similarity index 100% rename from Assets/uDesktopDuplication/Resources/uDesktopDuplication/Images/cursor.png rename to Assets/uDesktopDuplication/Resources/uDesktopDuplication/Images/uDD_Cursor.png diff --git a/Assets/uDesktopDuplication/Resources/uDesktopDuplication/Images/cursor.png.meta b/Assets/uDesktopDuplication/Resources/uDesktopDuplication/Images/uDD_Cursor.png.meta similarity index 100% rename from Assets/uDesktopDuplication/Resources/uDesktopDuplication/Images/cursor.png.meta rename to Assets/uDesktopDuplication/Resources/uDesktopDuplication/Images/uDD_Cursor.png.meta diff --git a/Assets/uDesktopDuplication/Scenes/Example.unity b/Assets/uDesktopDuplication/Scenes/Example.unity index 9c78b12e8de906b6592aaa4d95bcc0264f3fbb00..368eaa2b24b6dc236e405c0e5ec51ddd36ac58de 100644 GIT binary patch delta 87 zcmV-d0I2`0lL4%g0gx#W;LJ>5m4falf2p3tBcAztu{p#75EHlp=!2v`pHu{p#75ZIzv_2eC|Xm7t8`m?h3 tg0l?+`#cP8)8szvTK+!TI1@j!6hO2G2mk;8KL7v#Ka(LpAhYmCya7(); - udd_.onMouseMove += OnMouseMove; - } - - void OnDisable() - { - udd_.onMouseMove -= OnMouseMove; - } - - void OnMouseMove(Vector2 pos) - { - var x = pos.x * modelScale.x * 0.5f; - var y = pos.y * modelScale.y * 0.5f; - var iy = udd_.invertY ? +1 : -1; - var localPos = transform.right * x + iy * transform.up * y; - - var worldPos = transform.TransformPoint(localPos); - worldPos += cursor.right * offset.x * cursor.localScale.x; - worldPos += -cursor.up * offset.y * cursor.localScale.y; - - cursor.position = worldPos; - } -} - -} \ No newline at end of file diff --git a/Assets/uDesktopDuplication/Scripts/uDD_Cursor.cs b/Assets/uDesktopDuplication/Scripts/uDD_Cursor.cs new file mode 100644 index 0000000..92ee8d7 --- /dev/null +++ b/Assets/uDesktopDuplication/Scripts/uDD_Cursor.cs @@ -0,0 +1,39 @@ +using UnityEngine; + +namespace uDesktopDuplication +{ + +[RequireComponent(typeof(uDD_Texture))] +public class uDD_Cursor : MonoBehaviour +{ + [SerializeField] + Transform cursor; + [SerializeField] + Vector2 modelScale = Vector2.one; + [SerializeField] + Vector2 offset = new Vector2(0.5f, 0.5f); + + private uDD_Texture texture_; + + void OnEnable() + { + texture_ = GetComponent(); + } + + void Update() + { + var monitor = texture_.monitor; + if (monitor.isPointerVisible) { + var x = (1f * monitor.pointerX / monitor.width - 0.5f) * modelScale.x; + var y = (0.5f - 1f * monitor.pointerY / monitor.height) * modelScale.y; + var iy = texture_.invertY ? +1 : -1; + var localPos = transform.right * x + iy * transform.up * y; + var worldPos = transform.TransformPoint(localPos); + worldPos += cursor.right * offset.x * cursor.localScale.x; + worldPos += -cursor.up * offset.y * cursor.localScale.y; + cursor.position = worldPos; + } + } +} + +} \ No newline at end of file diff --git a/Assets/uDesktopDuplication/Scripts/MouseDrawer.cs.meta b/Assets/uDesktopDuplication/Scripts/uDD_Cursor.cs.meta similarity index 92% rename from Assets/uDesktopDuplication/Scripts/MouseDrawer.cs.meta rename to Assets/uDesktopDuplication/Scripts/uDD_Cursor.cs.meta index 081062b..a343690 100644 --- a/Assets/uDesktopDuplication/Scripts/MouseDrawer.cs.meta +++ b/Assets/uDesktopDuplication/Scripts/uDD_Cursor.cs.meta @@ -1,6 +1,6 @@ fileFormatVersion: 2 guid: d2d9e4ca459ecb44da8815bafe9655c5 -timeCreated: 1477559806 +timeCreated: 1477635630 licenseType: Pro MonoImporter: serializedVersion: 2 diff --git a/Assets/uDesktopDuplication/Scripts/uDD_Lib.cs b/Assets/uDesktopDuplication/Scripts/uDD_Lib.cs new file mode 100644 index 0000000..f3b7d71 --- /dev/null +++ b/Assets/uDesktopDuplication/Scripts/uDD_Lib.cs @@ -0,0 +1,39 @@ +using System; +using System.Text; +using System.Runtime.InteropServices; + +namespace uDesktopDuplication +{ + +public static class uDD_Lib +{ + [DllImport("uDesktopDuplication")] + public static extern int GetMonitorCount(); + [DllImport("uDesktopDuplication")] + public static extern IntPtr GetRenderEventFunc(); + [DllImport("uDesktopDuplication")] + public static extern void GetName(int id, StringBuilder buf, int len); + [DllImport("uDesktopDuplication")] + public static extern int GetWidth(int id); + [DllImport("uDesktopDuplication")] + public static extern int GetHeight(int id); + [DllImport("uDesktopDuplication")] + public static extern bool IsPrimary(int id); + [DllImport("uDesktopDuplication")] + public static extern bool IsPointerVisible(int id); + [DllImport("uDesktopDuplication")] + public static extern int GetPointerX(int id); + [DllImport("uDesktopDuplication")] + public static extern int GetPointerY(int id); + [DllImport("uDesktopDuplication")] + public static extern int SetTexturePtr(int id, IntPtr ptr); + + public static string GetName(int id) + { + var buf = new StringBuilder(32); + GetName(id, buf, buf.Capacity); + return buf.ToString(); + } +} + +} \ No newline at end of file diff --git a/Assets/uDesktopDuplication/Scripts/uDD_Lib.cs.meta b/Assets/uDesktopDuplication/Scripts/uDD_Lib.cs.meta new file mode 100644 index 0000000..493521c --- /dev/null +++ b/Assets/uDesktopDuplication/Scripts/uDD_Lib.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: cb02196c3e766c14ba398dc130e443e8 +timeCreated: 1477643164 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {fileID: 2800000, guid: 89616e59e1cccb346bd4e959257990ca, type: 3} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uDesktopDuplication/Scripts/uDD_Manager.cs b/Assets/uDesktopDuplication/Scripts/uDD_Manager.cs new file mode 100644 index 0000000..396a235 --- /dev/null +++ b/Assets/uDesktopDuplication/Scripts/uDD_Manager.cs @@ -0,0 +1,74 @@ +using UnityEngine; +using System.Collections; +using System.Collections.Generic; + +namespace uDesktopDuplication +{ + +public class uDD_Manager : MonoBehaviour +{ + private static uDD_Manager instance_; + public static uDD_Manager instance + { + get + { + if (instance_) return instance_; + var go = new GameObject("uDesktopDuplicationManager"); + return go.AddComponent(); + } + } + + private List monitors_ = new List(); + static public List monitors + { + get { return instance.monitors_; } + } + + static public uDD_Monitor primary + { + get + { + return instance.monitors_.Find(monitor => monitor.isPrimary); + } + } + + private Coroutine renderCoroutine_ = null; + + void Awake() + { + if (instance_ != null) return; + instance_ = this; + + for (int i = 0; i < uDD_Monitor.count; ++i) { + monitors.Add(new uDD_Monitor(i)); + } + } + + void OnEnable() + { + renderCoroutine_ = StartCoroutine(OnRender()); + } + + void OnDisable() + { + if (renderCoroutine_ != null) { + StopCoroutine(renderCoroutine_); + renderCoroutine_ = null; + } + } + + IEnumerator OnRender() + { + for (;;) { + yield return new WaitForEndOfFrame(); + foreach (var monitor in monitors) { + if (monitor.shouldBeUpdated) { + monitor.Render(); + } + monitor.shouldBeUpdated = false; + } + } + } +} + +} \ No newline at end of file diff --git a/Assets/uDesktopDuplication/Scripts/uDD_Manager.cs.meta b/Assets/uDesktopDuplication/Scripts/uDD_Manager.cs.meta new file mode 100644 index 0000000..4cb063d --- /dev/null +++ b/Assets/uDesktopDuplication/Scripts/uDD_Manager.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 4dccb434f55ebee4f91bfb9935092bbf +timeCreated: 1477643174 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {fileID: 2800000, guid: 89616e59e1cccb346bd4e959257990ca, type: 3} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uDesktopDuplication/Scripts/uDD_Monitor.cs b/Assets/uDesktopDuplication/Scripts/uDD_Monitor.cs new file mode 100644 index 0000000..800b6f7 --- /dev/null +++ b/Assets/uDesktopDuplication/Scripts/uDD_Monitor.cs @@ -0,0 +1,84 @@ +using UnityEngine; + +namespace uDesktopDuplication +{ + +public class uDD_Monitor +{ + public uDD_Monitor(int id) + { + this.id = id; + } + + public static int count + { + get { return uDD_Lib.GetMonitorCount(); } + } + + public int id + { + get; + private set; + } + + public string name + { + get { return uDD_Lib.GetName(id); } + } + + public bool isPrimary + { + get { return uDD_Lib.IsPrimary(id); } + } + + public int width + { + get { return uDD_Lib.GetWidth(id); } + } + + public int height + { + get { return uDD_Lib.GetHeight(id); } + } + + public bool isPointerVisible + { + get { return uDD_Lib.IsPointerVisible(id); } + } + + public int pointerX + { + get { return uDD_Lib.GetPointerX(id); } + } + + public int pointerY + { + get { return uDD_Lib.GetPointerY(id); } + } + + public bool shouldBeUpdated + { + get; + set; + } + + private Texture2D texture_; + public Texture2D texture + { + get + { + if (texture_ == null) { + texture_ = new Texture2D(width, height, TextureFormat.BGRA32, false); + uDD_Lib.SetTexturePtr(id, texture_.GetNativeTexturePtr()); + } + return texture_; + } + } + + public void Render() + { + GL.IssuePluginEvent(uDD_Lib.GetRenderEventFunc(), id); + } +} + +} \ No newline at end of file diff --git a/Assets/uDesktopDuplication/Scripts/uDD_Monitor.cs.meta b/Assets/uDesktopDuplication/Scripts/uDD_Monitor.cs.meta new file mode 100644 index 0000000..d6d63ee --- /dev/null +++ b/Assets/uDesktopDuplication/Scripts/uDD_Monitor.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 310590b113d909b43b4ea19702904ac3 +timeCreated: 1477643181 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {fileID: 2800000, guid: 89616e59e1cccb346bd4e959257990ca, type: 3} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uDesktopDuplication/Scripts/uDD_Texture.cs b/Assets/uDesktopDuplication/Scripts/uDD_Texture.cs new file mode 100644 index 0000000..647e584 --- /dev/null +++ b/Assets/uDesktopDuplication/Scripts/uDD_Texture.cs @@ -0,0 +1,46 @@ +using UnityEngine; + +namespace uDesktopDuplication +{ + +public class uDD_Texture : MonoBehaviour +{ + public uDD_Monitor monitor { get; set; } + + public bool invertX = false; + public bool invertY = false; + + private Material material_; + + void OnEnable() + { + if (monitor == null) { + monitor = uDD_Manager.primary; + } + material_ = GetComponent().material; + material_.mainTexture = monitor.texture; + } + + void Update() + { + monitor.shouldBeUpdated = true; + UpdateMaterial(); + } + + void UpdateMaterial() + { + if (invertX) { + material_.EnableKeyword("INVERT_X"); + } else { + material_.DisableKeyword("INVERT_X"); + } + + if (invertY) { + material_.EnableKeyword("INVERT_Y"); + } else { + material_.DisableKeyword("INVERT_Y"); + } + } +} + +} \ No newline at end of file diff --git a/Assets/uDesktopDuplication/Scripts/uDesktopDuplication.cs.meta b/Assets/uDesktopDuplication/Scripts/uDD_Texture.cs.meta similarity index 92% rename from Assets/uDesktopDuplication/Scripts/uDesktopDuplication.cs.meta rename to Assets/uDesktopDuplication/Scripts/uDD_Texture.cs.meta index 70283ee..667262e 100644 --- a/Assets/uDesktopDuplication/Scripts/uDesktopDuplication.cs.meta +++ b/Assets/uDesktopDuplication/Scripts/uDD_Texture.cs.meta @@ -1,6 +1,6 @@ fileFormatVersion: 2 guid: bb54a34570e4747429b1c5b66c69d356 -timeCreated: 1477559813 +timeCreated: 1477635636 licenseType: Pro MonoImporter: serializedVersion: 2 diff --git a/Assets/uDesktopDuplication/Scripts/uDesktopDuplication.cs b/Assets/uDesktopDuplication/Scripts/uDesktopDuplication.cs deleted file mode 100644 index 1f22539..0000000 --- a/Assets/uDesktopDuplication/Scripts/uDesktopDuplication.cs +++ /dev/null @@ -1,97 +0,0 @@ -using UnityEngine; -using System; -using System.Collections; -using System.Runtime.InteropServices; - -namespace uDesktopDuplication -{ - -public class uDesktopDuplication : MonoBehaviour -{ - [DllImport("uDesktopDuplication")] - private static extern void Initialize(); - [DllImport("uDesktopDuplication")] - private static extern int GetWidth(); - [DllImport("uDesktopDuplication")] - private static extern int GetHeight(); - [DllImport("uDesktopDuplication")] - private static extern bool IsPointerVisible(); - [DllImport("uDesktopDuplication")] - private static extern int GetPointerX(); - [DllImport("uDesktopDuplication")] - private static extern int GetPointerY(); - [DllImport("uDesktopDuplication")] - private static extern int SetTexturePtr(IntPtr ptr); - [DllImport("uDesktopDuplication")] - private static extern IntPtr GetRenderEventFunc(); - - private Material material_; - public bool invertX = false; - public bool invertY = false; - - public delegate void MouseMoveEventHandler(Vector2 pos); - public MouseMoveEventHandler onMouseMove { get; set; } - - private Coroutine renderCoroutine_ = null; - - void OnEnable() - { - var tex = new Texture2D(GetWidth(), GetHeight(), TextureFormat.BGRA32, false); - material_ = GetComponent().material; - material_.mainTexture = tex; - - SetTexturePtr(tex.GetNativeTexturePtr()); - renderCoroutine_ = StartCoroutine(OnRender()); - } - - void OnDisable() - { - if (renderCoroutine_ != null) { - StopCoroutine(renderCoroutine_); - renderCoroutine_ = null; - } - } - - void Update() - { - UpdateMouseEvent(); - UpdateMaterial(); - } - - void UpdateMouseEvent() - { - var isVisible = IsPointerVisible(); - if (isVisible && onMouseMove != null) { - var x = GetPointerX(); - var y = GetPointerY(); - var w = GetWidth(); - var h = GetHeight(); - onMouseMove(new Vector2(2f * x / w - 1f, 1f - 2f * y / h)); - } - } - - void UpdateMaterial() - { - if (invertX) { - material_.EnableKeyword("INVERT_X"); - } else { - material_.DisableKeyword("INVERT_X"); - } - - if (invertY) { - material_.EnableKeyword("INVERT_Y"); - } else { - material_.DisableKeyword("INVERT_Y"); - } - } - - IEnumerator OnRender() - { - for (;;) { - yield return new WaitForEndOfFrame(); - GL.IssuePluginEvent(GetRenderEventFunc(), 0); - } - } -} - -} \ No newline at end of file diff --git a/Plugins/uDesktopDuplication/uDesktopDuplication/main.cpp b/Plugins/uDesktopDuplication/uDesktopDuplication/main.cpp index 9a3c0c7..22bf2ba 100644 --- a/Plugins/uDesktopDuplication/uDesktopDuplication/main.cpp +++ b/Plugins/uDesktopDuplication/uDesktopDuplication/main.cpp @@ -1,5 +1,7 @@ #include #include +#include +#include #include "IUnityInterface.h" #include "IUnityGraphics.h" @@ -10,21 +12,39 @@ namespace { - IUnityInterfaces* g_unity = nullptr; - IDXGIOutputDuplication* g_deskDupl = nullptr; - ID3D11Texture2D* g_texture = nullptr; - bool g_isPointerVisible = -1; - int g_pointerX = -1; - int g_pointerY = -1; - int g_width = -1; - int g_height = -1; + struct Monitor + { + IDXGIOutputDuplication* output = nullptr; + ID3D11Texture2D* texture = nullptr; + std::string name = ""; + bool isPrimary = false; + bool isPointerVisible = false; + int pointerX = -1; + int pointerY = -1; + int width = -1; + int height = -1; + }; + + IUnityInterfaces* g_unity = nullptr; + std::vector g_monitors; } extern "C" { + void FinalizeDuplication() + { + for (auto& monitor : g_monitors) + { + monitor.output->Release(); + } + g_monitors.clear(); + } + void InitializeDuplication() { + FinalizeDuplication(); + IDXGIFactory1* factory; CreateDXGIFactory1(__uuidof(IDXGIFactory1), reinterpret_cast(&factory)); @@ -43,22 +63,18 @@ extern "C" monitorInfo.cbSize = sizeof(MONITORINFOEX); GetMonitorInfo(outputDesc.Monitor, &monitorInfo); - if (monitorInfo.dwFlags == MONITORINFOF_PRIMARY) - { - g_width = monitorInfo.rcMonitor.right - monitorInfo.rcMonitor.left; - g_height = monitorInfo.rcMonitor.bottom - monitorInfo.rcMonitor.top; + Monitor monitor; + monitor.name = monitorInfo.szDevice; + monitor.isPrimary = (monitorInfo.dwFlags == MONITORINFOF_PRIMARY); + monitor.width = monitorInfo.rcMonitor.right - monitorInfo.rcMonitor.left; + monitor.height = monitorInfo.rcMonitor.bottom - monitorInfo.rcMonitor.top; - auto device = g_unity->Get()->GetDevice(); - IDXGIOutput1* output1; - output1 = reinterpret_cast(output); - output1->DuplicateOutput(device, &g_deskDupl); + auto device = g_unity->Get()->GetDevice(); + IDXGIOutput1* output1; + output1 = reinterpret_cast(output); + output1->DuplicateOutput(device, &monitor.output); - output->Release(); - adapter->Release(); - factory->Release(); - - return; - } + g_monitors.push_back(monitor); output->Release(); } @@ -69,12 +85,6 @@ extern "C" factory->Release(); } - void FinalizeDuplication() - { - g_deskDupl->Release(); - g_deskDupl = nullptr; - } - UNITY_INTERFACE_EXPORT void UNITY_INTERFACE_API UnityPluginLoad(IUnityInterfaces* unityInterfaces) { g_unity = unityInterfaces; @@ -84,24 +94,27 @@ extern "C" UNITY_INTERFACE_EXPORT void UNITY_INTERFACE_API UnityPluginUnload() { g_unity = nullptr; - g_texture = nullptr; - g_width = -1; - g_height = -1; - g_pointerX = -1; - g_pointerY = -1; FinalizeDuplication(); } - void UNITY_INTERFACE_API OnRenderEvent(int eventId) + bool DoesMonitorExist(int id) { - if (g_deskDupl == nullptr || g_texture == nullptr) return; + return id >= 0 && id < g_monitors.size(); + } + + void UNITY_INTERFACE_API OnRenderEvent(int id) + { + if (!DoesMonitorExist(id)) return; + auto& monitor = g_monitors[id]; + + if (monitor.output == nullptr || monitor.texture == nullptr) return; HRESULT hr; IDXGIResource* resource = nullptr; DXGI_OUTDUPL_FRAME_INFO frameInfo; const UINT timeout = 100; // ms - hr = g_deskDupl->AcquireNextFrame(timeout, &frameInfo, &resource); + hr = monitor.output->AcquireNextFrame(timeout, &frameInfo, &resource); switch (hr) { case S_OK: @@ -120,9 +133,9 @@ extern "C" } } - g_isPointerVisible = frameInfo.PointerPosition.Visible; - g_pointerX = frameInfo.PointerPosition.Position.x; - g_pointerY = frameInfo.PointerPosition.Position.y; + monitor.isPointerVisible = frameInfo.PointerPosition.Visible == TRUE; + monitor.pointerX = frameInfo.PointerPosition.Position.x; + monitor.pointerY = frameInfo.PointerPosition.Position.y; ID3D11Texture2D* texture; hr = resource->QueryInterface(__uuidof(ID3D11Texture2D), reinterpret_cast(&texture)); @@ -137,9 +150,9 @@ extern "C" ID3D11DeviceContext* context; auto device = g_unity->Get()->GetDevice(); device->GetImmediateContext(&context); - context->CopyResource(g_texture, texture); + context->CopyResource(monitor.texture, texture); - g_deskDupl->ReleaseFrame(); + monitor.output->ReleaseFrame(); } UNITY_INTERFACE_EXPORT UnityRenderingEvent UNITY_INTERFACE_API GetRenderEventFunc() @@ -147,33 +160,56 @@ extern "C" return OnRenderEvent; } - UNITY_INTERFACE_EXPORT int UNITY_INTERFACE_API GetWidth() + UNITY_INTERFACE_EXPORT size_t UNITY_INTERFACE_API GetMonitorCount() { - return g_width; + return g_monitors.size(); } - UNITY_INTERFACE_EXPORT int UNITY_INTERFACE_API GetHeight() + UNITY_INTERFACE_EXPORT void UNITY_INTERFACE_API GetName(int id, char* buf, int len) { - return g_height; + if (!DoesMonitorExist(id)) return; + strcpy_s(buf, len, g_monitors[id].name.c_str()); } - UNITY_INTERFACE_EXPORT int UNITY_INTERFACE_API IsPointerVisible() + UNITY_INTERFACE_EXPORT bool UNITY_INTERFACE_API IsPrimary(int id) { - return g_isPointerVisible; + if (!DoesMonitorExist(id)) return false; + return g_monitors[id].isPrimary; } - UNITY_INTERFACE_EXPORT int UNITY_INTERFACE_API GetPointerX() + UNITY_INTERFACE_EXPORT int UNITY_INTERFACE_API GetWidth(int id) { - return g_pointerX; + if (!DoesMonitorExist(id)) return -1; + return g_monitors[id].width; } - UNITY_INTERFACE_EXPORT int UNITY_INTERFACE_API GetPointerY() + UNITY_INTERFACE_EXPORT int UNITY_INTERFACE_API GetHeight(int id) { - return g_pointerY; + if (!DoesMonitorExist(id)) return -1; + return g_monitors[id].height; } - UNITY_INTERFACE_EXPORT void UNITY_INTERFACE_API SetTexturePtr(void* texture) + UNITY_INTERFACE_EXPORT int UNITY_INTERFACE_API IsPointerVisible(int id) { - g_texture = reinterpret_cast(texture); + if (!DoesMonitorExist(id)) return false; + return g_monitors[id].isPointerVisible; + } + + UNITY_INTERFACE_EXPORT int UNITY_INTERFACE_API GetPointerX(int id) + { + if (!DoesMonitorExist(id)) return -1; + return g_monitors[id].pointerX; + } + + UNITY_INTERFACE_EXPORT int UNITY_INTERFACE_API GetPointerY(int id) + { + if (!DoesMonitorExist(id)) return -1; + return g_monitors[id].pointerY; + } + + UNITY_INTERFACE_EXPORT void UNITY_INTERFACE_API SetTexturePtr(int id, void* texture) + { + if (!DoesMonitorExist(id)) return; + g_monitors[id].texture = reinterpret_cast(texture); } } \ No newline at end of file diff --git a/ProjectSettings/ProjectSettings.asset b/ProjectSettings/ProjectSettings.asset index c1b79d06e5b6496638862a7c1b812da1ad65ecc7..10e3c24c4be8fb19020419ccfdb0da8dfff21057 100644 GIT binary patch delta 32 mcmcb3f$8D}rVS~xI2joj7(ke9a^WoT$qlnuHh0WA$qN9udJ7i- delta 32 lcmcb3f$8D}rVS~xI2nL|5s29)7tRu&+%St}bH}Wcya2dl3l;zX