use system cursor position for zoom when cursor is invisible (e.g. dragging).

This commit is contained in:
hecomi
2016-11-12 16:28:33 +09:00
parent 1eb821b34d
commit a0edc1a439
4 changed files with 71 additions and 6 deletions
@@ -1,4 +1,5 @@
using UnityEngine;
using System.Runtime.InteropServices;
namespace uDesktopDuplication
{
@@ -157,6 +158,24 @@ public class Monitor
get { return Lib.GetCursorY(id); }
}
public int systemCursorX
{
get
{
var p = Utility.GetCursorPos();
return p.x - left;
}
}
public int systemCursorY
{
get
{
var p = Utility.GetCursorPos();
return p.y - top;
}
}
public int cursorShapeWidth
{
get { return Lib.GetCursorShapeWidth(id); }
@@ -0,0 +1,30 @@
using UnityEngine;
using System.Runtime.InteropServices;
namespace uDesktopDuplication
{
public struct MousePoint
{
public int x;
public int y;
}
public static class Utility
{
[DllImport("user32.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetCursorPos(out MousePoint point);
public static MousePoint GetCursorPos()
{
MousePoint p;
if (!GetCursorPos(out p)) {
p.x = -1;
p.y = -1;
}
return p;
}
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 6c7e8da181b03ce4fb343ffa33cbb929
timeCreated: 1478934399
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: