add function to fetch left/right/top/bottom/rotation.

This commit is contained in:
hecomi
2016-11-05 00:09:04 +09:00
parent 1d7b7e8650
commit 90b811cd31
11 changed files with 216 additions and 3 deletions
+23
View File
@@ -18,6 +18,15 @@ public enum CursorShapeType
MaskedColor = 4,
}
public enum MonitorRotation
{
Unspecified = 0,
Identity = 1,
Rotate90 = 2,
Rotate180 = 3,
Rotate270 = 4
}
public static class Lib
{
public delegate void MessageHandler(Message message);
@@ -33,16 +42,30 @@ public static class Lib
[DllImport("uDesktopDuplication")]
public static extern int GetMonitorCount();
[DllImport("uDesktopDuplication")]
public static extern int GetTotalWidth();
[DllImport("uDesktopDuplication")]
public static extern int GetTotalHeight();
[DllImport("uDesktopDuplication")]
public static extern void SetTimeout(int timeout);
[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 GetLeft(int id);
[DllImport("uDesktopDuplication")]
public static extern int GetRight(int id);
[DllImport("uDesktopDuplication")]
public static extern int GetTop(int id);
[DllImport("uDesktopDuplication")]
public static extern int GetBottom(int id);
[DllImport("uDesktopDuplication")]
public static extern int GetWidth(int id);
[DllImport("uDesktopDuplication")]
public static extern int GetHeight(int id);
[DllImport("uDesktopDuplication")]
public static extern MonitorRotation GetRotation(int id);
[DllImport("uDesktopDuplication")]
public static extern bool IsPrimary(int id);
[DllImport("uDesktopDuplication")]
public static extern bool IsCursorVisible(int id);
@@ -31,6 +31,26 @@ public class Monitor
get { return Lib.IsPrimary(id); }
}
public int left
{
get { return Lib.GetLeft(id); }
}
public int right
{
get { return Lib.GetRight(id); }
}
public int top
{
get { return Lib.GetTop(id); }
}
public int bottom
{
get { return Lib.GetBottom(id); }
}
public int width
{
get { return Lib.GetWidth(id); }
@@ -41,6 +61,11 @@ public class Monitor
get { return Lib.GetHeight(id); }
}
public MonitorRotation rotation
{
get { return Lib.GetRotation(id); }
}
public float aspect
{
get { return (float)width / height; }
@@ -52,6 +52,7 @@ public class Texture : MonoBehaviour
{
monitor.shouldBeUpdated = true;
UpdateMaterial();
Debug.Log(Lib.GetTotalWidth() + " " + Lib.GetTotalHeight());
}
void UpdateMaterial()