mirror of
https://github.com/hanetzer/sdraw_mods_cvr.git
synced 2025-09-03 18:39:23 +00:00
Update to LeapCSharp 5.9.0
This commit is contained in:
parent
987aa798ba
commit
d748e10241
11 changed files with 343 additions and 54 deletions
|
@ -21,7 +21,8 @@ namespace ml_lme_cvr
|
|||
|
||||
public override void OnApplicationStart()
|
||||
{
|
||||
ms_instance = this;
|
||||
if(ms_instance == null)
|
||||
ms_instance = this;
|
||||
|
||||
DependenciesHandler.ExtractDependencies();
|
||||
|
||||
|
@ -137,11 +138,11 @@ namespace ml_lme_cvr
|
|||
if(Settings.Enabled)
|
||||
{
|
||||
m_leapController.StartConnection();
|
||||
m_leapController.ClearPolicy(Leap.Controller.PolicyFlag.POLICY_OPTIMIZE_SCREENTOP);
|
||||
m_leapController.ClearPolicy(Leap.Controller.PolicyFlag.POLICY_OPTIMIZE_SCREENTOP, null);
|
||||
if(Settings.HmdMode)
|
||||
m_leapController.SetPolicy(Leap.Controller.PolicyFlag.POLICY_OPTIMIZE_HMD);
|
||||
m_leapController.SetPolicy(Leap.Controller.PolicyFlag.POLICY_OPTIMIZE_HMD, null);
|
||||
else
|
||||
m_leapController.ClearPolicy(Leap.Controller.PolicyFlag.POLICY_OPTIMIZE_HMD);
|
||||
m_leapController.ClearPolicy(Leap.Controller.PolicyFlag.POLICY_OPTIMIZE_HMD, null);
|
||||
}
|
||||
else
|
||||
m_leapController.StopConnection();
|
||||
|
@ -177,11 +178,11 @@ namespace ml_lme_cvr
|
|||
{
|
||||
if(m_leapController != null)
|
||||
{
|
||||
m_leapController.ClearPolicy(Leap.Controller.PolicyFlag.POLICY_OPTIMIZE_SCREENTOP);
|
||||
m_leapController.ClearPolicy(Leap.Controller.PolicyFlag.POLICY_OPTIMIZE_SCREENTOP, null);
|
||||
if(Settings.HmdMode)
|
||||
m_leapController.SetPolicy(Leap.Controller.PolicyFlag.POLICY_OPTIMIZE_HMD);
|
||||
m_leapController.SetPolicy(Leap.Controller.PolicyFlag.POLICY_OPTIMIZE_HMD, null);
|
||||
else
|
||||
m_leapController.ClearPolicy(Leap.Controller.PolicyFlag.POLICY_OPTIMIZE_HMD);
|
||||
m_leapController.ClearPolicy(Leap.Controller.PolicyFlag.POLICY_OPTIMIZE_HMD, null);
|
||||
}
|
||||
|
||||
if(m_leapControllerModel != null)
|
||||
|
@ -249,11 +250,11 @@ namespace ml_lme_cvr
|
|||
{
|
||||
if(Settings.Enabled && (m_leapController != null))
|
||||
{
|
||||
m_leapController.ClearPolicy(Leap.Controller.PolicyFlag.POLICY_OPTIMIZE_SCREENTOP);
|
||||
m_leapController.ClearPolicy(Leap.Controller.PolicyFlag.POLICY_OPTIMIZE_SCREENTOP, null);
|
||||
if(Settings.HmdMode)
|
||||
m_leapController.SetPolicy(Leap.Controller.PolicyFlag.POLICY_OPTIMIZE_HMD);
|
||||
m_leapController.SetPolicy(Leap.Controller.PolicyFlag.POLICY_OPTIMIZE_HMD, null);
|
||||
else
|
||||
m_leapController.ClearPolicy(Leap.Controller.PolicyFlag.POLICY_OPTIMIZE_HMD);
|
||||
m_leapController.ClearPolicy(Leap.Controller.PolicyFlag.POLICY_OPTIMIZE_HMD, null);
|
||||
}
|
||||
|
||||
if(CohtmlHud.Instance != null)
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
using System.Reflection;
|
||||
|
||||
[assembly: AssemblyTitle("LeapMotionExtension")]
|
||||
[assembly: AssemblyVersion("1.0.4")]
|
||||
[assembly: AssemblyFileVersion("1.0.4")]
|
||||
[assembly: AssemblyVersion("1.0.5")]
|
||||
[assembly: AssemblyFileVersion("1.0.5")]
|
||||
|
||||
[assembly: MelonLoader.MelonInfo(typeof(ml_lme_cvr.LeapMotionExtension), "LeapMotionExtension", "1.0.4", "SDraw", "https://github.com/SDraw/ml_mods_cvr")]
|
||||
[assembly: MelonLoader.MelonInfo(typeof(ml_lme_cvr.LeapMotionExtension), "LeapMotionExtension", "1.0.5", "SDraw", "https://github.com/SDraw/ml_mods_cvr")]
|
||||
[assembly: MelonLoader.MelonGame(null, "ChilloutVR")]
|
||||
[assembly: MelonLoader.MelonPlatform(MelonLoader.MelonPlatformAttribute.CompatiblePlatforms.WINDOWS_X64)]
|
||||
[assembly: MelonLoader.MelonPlatformDomain(MelonLoader.MelonPlatformDomainAttribute.CompatibleDomains.MONO)]
|
||||
|
|
|
@ -127,6 +127,6 @@
|
|||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>copy /y "$(TargetPath)" "C:\Games\Steam\steamapps\common\ChilloutVR\Mods\</PostBuildEvent>
|
||||
<PostBuildEvent>copy /y "$(TargetPath)" "C:\Games\Steam\common\ChilloutVR\Mods\</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
</Project>
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<ReferencePath>C:\Games\Steam\steamapps\common\ChilloutVR\MelonLoader\;C:\Games\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\</ReferencePath>
|
||||
<ReferencePath>C:\Games\Steam\common\ChilloutVR\MelonLoader\;C:\Games\Steam\common\ChilloutVR\ChilloutVR_Data\Managed\</ReferencePath>
|
||||
</PropertyGroup>
|
||||
</Project>
|
159
ml_lme_cvr/vendor/LeapCSharp/Connection.cs
vendored
159
ml_lme_cvr/vendor/LeapCSharp/Connection.cs
vendored
|
@ -71,11 +71,21 @@ namespace LeapInternal
|
|||
private int _frameBufferLength = 60; //TODO, surface this value in LeapC, currently hardcoded!
|
||||
|
||||
private IntPtr _leapConnection;
|
||||
private bool _isRunning = false;
|
||||
private volatile bool _isRunning = false;
|
||||
private Thread _polster;
|
||||
|
||||
//Policy and enabled features
|
||||
private UInt64 _activePolicies = 0;
|
||||
/// <summary>
|
||||
/// Has the connection been set up in multi device aware mode
|
||||
/// </summary>
|
||||
private bool _multiDeviceAwareConnection = false;
|
||||
|
||||
/// <summary>
|
||||
/// Minimum service version that support setting the tracking mode on a per dervice basis
|
||||
/// </summary>
|
||||
private static LEAP_VERSION MinServiceVersionForMultiModeSupport = new LEAP_VERSION() { major = 5, minor = 4, patch = 4 };
|
||||
|
||||
//Policy and enabled features, indexed by device ID
|
||||
private Dictionary<uint, UInt64> _activePolicies = new Dictionary<uint, ulong>();
|
||||
|
||||
//Config change status
|
||||
private Dictionary<uint, string> _configRequests = new Dictionary<uint, string>();
|
||||
|
@ -173,6 +183,7 @@ namespace LeapInternal
|
|||
config.server_namespace = Marshal.StringToHGlobalAnsi(serverNamespace);
|
||||
config.flags = multiDeviceAware ? (uint)eLeapConnectionFlag.eLeapConnectionFlag_MultipleDevicesAware : 0;
|
||||
config.size = (uint)Marshal.SizeOf(config);
|
||||
_multiDeviceAwareConnection = multiDeviceAware;
|
||||
Start(config);
|
||||
}
|
||||
|
||||
|
@ -279,6 +290,7 @@ namespace LeapInternal
|
|||
|
||||
LEAP_CONNECTION_MESSAGE _msg = new LEAP_CONNECTION_MESSAGE();
|
||||
uint timeout = 150;
|
||||
|
||||
result = LeapC.PollConnection(_leapConnection, timeout, ref _msg);
|
||||
|
||||
if (result != eLeapRS.eLeapRS_Success)
|
||||
|
@ -325,9 +337,8 @@ namespace LeapInternal
|
|||
case eLeapEventType.eLeapEventType_Policy:
|
||||
LEAP_POLICY_EVENT policy_evt;
|
||||
StructMarshal<LEAP_POLICY_EVENT>.PtrToStruct(_msg.eventStructPtr, out policy_evt);
|
||||
handlePolicyChange(ref policy_evt);
|
||||
handlePolicyChange(ref policy_evt, _msg.deviceID);
|
||||
break;
|
||||
|
||||
case eLeapEventType.eLeapEventType_Tracking:
|
||||
LEAP_TRACKING_EVENT tracking_evt;
|
||||
StructMarshal<LEAP_TRACKING_EVENT>.PtrToStruct(_msg.eventStructPtr, out tracking_evt);
|
||||
|
@ -482,7 +493,16 @@ namespace LeapInternal
|
|||
|
||||
public Frame GetInterpolatedFrame(Int64 time, Device device = null)
|
||||
{
|
||||
Frame frame = new Frame();
|
||||
Frame frame;
|
||||
if (device == null)
|
||||
{
|
||||
frame = new Frame();
|
||||
}
|
||||
else
|
||||
{
|
||||
frame = new Frame(device.DeviceID);
|
||||
}
|
||||
|
||||
GetInterpolatedFrame(frame, time, device);
|
||||
return frame;
|
||||
}
|
||||
|
@ -638,7 +658,8 @@ namespace LeapInternal
|
|||
(Device.DeviceType)deviceInfo.type,
|
||||
deviceInfo.status == (uint)eLeapDeviceStatus.eLeapDeviceStatus_Streaming,
|
||||
deviceInfo.status,
|
||||
Marshal.PtrToStringAnsi(deviceInfo.serial));
|
||||
Marshal.PtrToStringAnsi(deviceInfo.serial),
|
||||
deviceMsg.device.id);
|
||||
|
||||
Marshal.FreeCoTaskMem(deviceInfo.serial);
|
||||
_devices.AddOrUpdate(apiDevice);
|
||||
|
@ -663,6 +684,11 @@ namespace LeapInternal
|
|||
{
|
||||
_devices.Remove(lost);
|
||||
|
||||
if (_activePolicies.ContainsKey(deviceMsg.device.id))
|
||||
{
|
||||
_activePolicies.Remove(deviceMsg.device.id);
|
||||
}
|
||||
|
||||
if (LeapDeviceLost != null)
|
||||
{
|
||||
LeapDeviceLost.DispatchOnContext(this, EventContext, new DeviceEventArgs(lost));
|
||||
|
@ -856,38 +882,117 @@ namespace LeapInternal
|
|||
}
|
||||
}
|
||||
|
||||
private void handlePolicyChange(ref LEAP_POLICY_EVENT policyMsg)
|
||||
private void handlePolicyChange(ref LEAP_POLICY_EVENT policyMsg, UInt32 deviceID)
|
||||
{
|
||||
// Avoid raising spurious policy change signals.
|
||||
if (policyMsg.current_policy == _activePolicies) return;
|
||||
if (_activePolicies.ContainsKey(deviceID))
|
||||
{
|
||||
if (policyMsg.current_policy == _activePolicies[deviceID])
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (LeapPolicyChange != null)
|
||||
{
|
||||
LeapPolicyChange.DispatchOnContext(this, EventContext, new PolicyEventArgs(policyMsg.current_policy, _activePolicies));
|
||||
if (_activePolicies.ContainsKey(deviceID))
|
||||
{
|
||||
LeapPolicyChange.DispatchOnContext(this, EventContext,
|
||||
new PolicyEventArgs(policyMsg.current_policy, _activePolicies[deviceID], true, _devices.FindDeviceByID(deviceID)));
|
||||
}
|
||||
else
|
||||
{
|
||||
// We should get a policy flags event on device connection. This tells us the current policy. From our perspective we don't
|
||||
// have a record of a 'previous' policy, so assume it's zero and raise an event
|
||||
LeapPolicyChange.DispatchOnContext(this, EventContext,
|
||||
new PolicyEventArgs(policyMsg.current_policy, 0, false, _devices.FindDeviceByID(deviceID)));
|
||||
}
|
||||
}
|
||||
|
||||
_activePolicies = policyMsg.current_policy;
|
||||
_activePolicies[deviceID] = policyMsg.current_policy;
|
||||
}
|
||||
|
||||
public void SetAndClearPolicy(Controller.PolicyFlag set, Controller.PolicyFlag clear)
|
||||
public void SetAndClearPolicy(Controller.PolicyFlag set, Controller.PolicyFlag clear, Device device = null)
|
||||
{
|
||||
UInt64 setFlags = (ulong)FlagForPolicy(set);
|
||||
UInt64 clearFlags = (ulong)FlagForPolicy(clear);
|
||||
eLeapRS result = LeapC.SetPolicyFlags(_leapConnection, setFlags, clearFlags);
|
||||
eLeapRS result;
|
||||
|
||||
if (device == null || !_multiDeviceAwareConnection)
|
||||
{
|
||||
result = LeapC.SetPolicyFlags(_leapConnection, setFlags, clearFlags);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!Controller.CheckRequiredServiceVersion(MinServiceVersionForMultiModeSupport, this))
|
||||
{
|
||||
UnityEngine.Debug.LogWarning(String.Format("Your current tracking service does not support setting policy flags on a per device basis (min version is {0}.{1}.{2}). Please update your service: https://developer.leapmotion.com/tracking-software-download",
|
||||
MinServiceVersionForMultiModeSupport.major,
|
||||
MinServiceVersionForMultiModeSupport.minor,
|
||||
MinServiceVersionForMultiModeSupport.patch));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
result = LeapC.SetPolicyFlagsEx(_leapConnection, device.Handle, setFlags, clearFlags);
|
||||
}
|
||||
|
||||
reportAbnormalResults("LeapC SetAndClearPolicy call was ", result);
|
||||
}
|
||||
|
||||
public void SetPolicy(Controller.PolicyFlag policy)
|
||||
public void SetPolicy(Controller.PolicyFlag policy, Device device = null)
|
||||
{
|
||||
UInt64 setFlags = (ulong)FlagForPolicy(policy);
|
||||
eLeapRS result = LeapC.SetPolicyFlags(_leapConnection, setFlags, 0);
|
||||
|
||||
eLeapRS result;
|
||||
|
||||
if (device == null || !_multiDeviceAwareConnection)
|
||||
{
|
||||
result = LeapC.SetPolicyFlags(_leapConnection, setFlags, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!Controller.CheckRequiredServiceVersion(MinServiceVersionForMultiModeSupport, this))
|
||||
{
|
||||
UnityEngine.Debug.LogWarning(String.Format("Your current tracking service does not support setting policy flags on a per device basis (min version is {0}.{1}.{2}). Please update your service: https://developer.leapmotion.com/tracking-software-download",
|
||||
MinServiceVersionForMultiModeSupport.major,
|
||||
MinServiceVersionForMultiModeSupport.minor,
|
||||
MinServiceVersionForMultiModeSupport.patch));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
result = LeapC.SetPolicyFlagsEx(_leapConnection, device.Handle, setFlags, 0);
|
||||
}
|
||||
|
||||
reportAbnormalResults("LeapC SetPolicyFlags call was ", result);
|
||||
}
|
||||
|
||||
public void ClearPolicy(Controller.PolicyFlag policy)
|
||||
public void ClearPolicy(Controller.PolicyFlag policy, Device device = null)
|
||||
{
|
||||
UInt64 clearFlags = (ulong)FlagForPolicy(policy);
|
||||
eLeapRS result = LeapC.SetPolicyFlags(_leapConnection, 0, clearFlags);
|
||||
|
||||
eLeapRS result;
|
||||
|
||||
if (device == null || !_multiDeviceAwareConnection)
|
||||
{
|
||||
result = LeapC.SetPolicyFlags(_leapConnection, 0, clearFlags);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!Controller.CheckRequiredServiceVersion(MinServiceVersionForMultiModeSupport, this))
|
||||
{
|
||||
UnityEngine.Debug.LogWarning(String.Format("Your current tracking service does not support clearing policy flags on a per device basis (min version is {0}.{1}.{2}). Please update your service: https://developer.leapmotion.com/tracking-software-download",
|
||||
MinServiceVersionForMultiModeSupport.major,
|
||||
MinServiceVersionForMultiModeSupport.minor,
|
||||
MinServiceVersionForMultiModeSupport.patch));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
result = LeapC.SetPolicyFlagsEx(_leapConnection, device.Handle, 0, clearFlags);
|
||||
}
|
||||
|
||||
reportAbnormalResults("LeapC SetPolicyFlags call was ", result);
|
||||
}
|
||||
|
||||
|
@ -929,10 +1034,26 @@ namespace LeapInternal
|
|||
///
|
||||
/// @since 2.1.6
|
||||
/// </summary>
|
||||
public bool IsPolicySet(Controller.PolicyFlag policy)
|
||||
public bool IsPolicySet(Controller.PolicyFlag policy, Device device = null)
|
||||
{
|
||||
UInt64 policyToCheck = (ulong)FlagForPolicy(policy);
|
||||
return (_activePolicies & policyToCheck) == policyToCheck;
|
||||
|
||||
uint deviceID = 0;
|
||||
if (device != null)
|
||||
{
|
||||
deviceID = device.DeviceID;
|
||||
}
|
||||
|
||||
if (_activePolicies.ContainsKey(deviceID))
|
||||
{
|
||||
return (_activePolicies[deviceID] & policyToCheck) == policyToCheck;
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.Log("Warning: an attempt has been made to check whether a policy flag is set for an unknown device");
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public uint GetConfigValue(string config_key)
|
||||
|
|
107
ml_lme_cvr/vendor/LeapCSharp/Controller.cs
vendored
107
ml_lme_cvr/vendor/LeapCSharp/Controller.cs
vendored
|
@ -514,10 +514,11 @@ namespace Leap
|
|||
/// the argument minServiceVersion is smaller or equal to it
|
||||
/// </summary>
|
||||
/// <param name="minServiceVersion">The minimum service version to check against</param>
|
||||
/// <returns></returns>
|
||||
public bool CheckRequiredServiceVersion(LEAP_VERSION minServiceVersion)
|
||||
/// <param name="connection">The connection</param>
|
||||
/// <returns>True if the version of the running service is equal to or less than the minimum version specified</returns>
|
||||
public static bool CheckRequiredServiceVersion(LEAP_VERSION minServiceVersion, Connection connection)
|
||||
{
|
||||
LEAP_VERSION currentServiceVersion = _connection.GetCurrentServiceVersion();
|
||||
LEAP_VERSION currentServiceVersion = connection.GetCurrentServiceVersion();
|
||||
|
||||
// check that minServiceVersion is smaller or equal to the current service version
|
||||
if (minServiceVersion.major < currentServiceVersion.major) return true;
|
||||
|
@ -529,6 +530,54 @@ namespace Leap
|
|||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks whether a minimum or required tracking service version is installed.
|
||||
/// Gets the currently installed service version from the connection and checks whether
|
||||
/// the argument minServiceVersion is smaller or equal to it
|
||||
/// </summary>
|
||||
/// <param name="minServiceVersion">The minimum service version to check against</param>
|
||||
/// <returns>True if the version of the running service is equal to or less than the minimum version specified</returns>
|
||||
public bool CheckRequiredServiceVersion(LEAP_VERSION minServiceVersion)
|
||||
{
|
||||
return Controller.CheckRequiredServiceVersion(minServiceVersion, _connection);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Requests setting and clearing policy flags on a specific device
|
||||
///
|
||||
/// A request to change a policy is subject to user approval and a policy
|
||||
/// can be changed by the user at any time (using the Leap Motion settings dialog).
|
||||
/// The desired policy flags must be set every time an application runs.
|
||||
///
|
||||
/// Policy changes are completed asynchronously and, because they are subject
|
||||
/// to user approval or system compatibility checks, may not complete successfully. Call
|
||||
/// Controller.IsPolicySet() after a suitable interval to test whether
|
||||
/// the change was accepted.
|
||||
/// @since 2.1.6 (5.4.4 for specific device)
|
||||
/// </summary>
|
||||
public void SetAndClearPolicy(PolicyFlag set, PolicyFlag clear, string deviceSerial = "", Device device = null)
|
||||
{
|
||||
_connection.SetAndClearPolicy(set, clear, device);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Requests setting a policy on a specific device
|
||||
///
|
||||
/// A request to change a policy is subject to user approval and a policy
|
||||
/// can be changed by the user at any time (using the Leap Motion settings dialog).
|
||||
/// The desired policy flags must be set every time an application runs.
|
||||
///
|
||||
/// Policy changes are completed asynchronously and, because they are subject
|
||||
/// to user approval or system compatibility checks, may not complete successfully. Call
|
||||
/// Controller.IsPolicySet() after a suitable interval to test whether
|
||||
/// the change was accepted.
|
||||
/// @since 2.1.6 (5.4.4 for specific device)
|
||||
/// </summary>
|
||||
public void SetPolicy(PolicyFlag policy, Device device = null)
|
||||
{
|
||||
_connection.SetPolicy(policy, device);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Requests setting a policy.
|
||||
///
|
||||
|
@ -542,18 +591,28 @@ namespace Leap
|
|||
/// the change was accepted.
|
||||
/// @since 2.1.6
|
||||
/// </summary>
|
||||
public void SetAndClearPolicy(PolicyFlag set, PolicyFlag clear, string deviceSerial = "")
|
||||
{
|
||||
_connection.SetAndClearPolicy(set, clear);
|
||||
}
|
||||
|
||||
[Obsolete("Use the version of SetPolicy that also takes the device")]
|
||||
public void SetPolicy(PolicyFlag policy)
|
||||
{
|
||||
_connection.SetPolicy(policy);
|
||||
SetPolicy(policy, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Requests clearing a policy.
|
||||
/// Requests clearing a policy on a specific device
|
||||
///
|
||||
/// Policy changes are completed asynchronously and, because they are subject
|
||||
/// to user approval or system compatibility checks, may not complete successfully. Call
|
||||
/// Controller.IsPolicySet() after a suitable interval to test whether
|
||||
/// the change was accepted.
|
||||
/// @since 2.1.6 (5.4.4 for specific device)
|
||||
/// </summary>
|
||||
public void ClearPolicy(PolicyFlag policy, Device device = null)
|
||||
{
|
||||
_connection.ClearPolicy(policy, device);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Requests clearing a policy
|
||||
///
|
||||
/// Policy changes are completed asynchronously and, because they are subject
|
||||
/// to user approval or system compatibility checks, may not complete successfully. Call
|
||||
|
@ -561,13 +620,33 @@ namespace Leap
|
|||
/// the change was accepted.
|
||||
/// @since 2.1.6
|
||||
/// </summary>
|
||||
[Obsolete("Use the version of ClearPolicy that also takes the device")]
|
||||
public void ClearPolicy(PolicyFlag policy)
|
||||
{
|
||||
_connection.ClearPolicy(policy);
|
||||
ClearPolicy(policy, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the active setting for a specific policy.
|
||||
/// Gets the active setting for a specific device.
|
||||
///
|
||||
/// Keep in mind that setting a policy flag is asynchronous, so changes are
|
||||
/// not effective immediately after calling setPolicyFlag(). In addition, a
|
||||
/// policy request can be declined by the user. You should always set the
|
||||
/// policy flags required by your application at startup and check that the
|
||||
/// policy change request was successful after an appropriate interval.
|
||||
///
|
||||
/// If the controller object is not connected to the Leap Motion software, then the default
|
||||
/// state for the selected policy is returned.
|
||||
///
|
||||
/// @since 2.1.6 (5.4.4 for specific device)
|
||||
/// </summary>
|
||||
public bool IsPolicySet(PolicyFlag policy, Device device = null)
|
||||
{
|
||||
return _connection.IsPolicySet(policy, device);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the active setting
|
||||
///
|
||||
/// Keep in mind that setting a policy flag is asynchronous, so changes are
|
||||
/// not effective immediately after calling setPolicyFlag(). In addition, a
|
||||
|
@ -579,10 +658,10 @@ namespace Leap
|
|||
/// state for the selected policy is returned.
|
||||
///
|
||||
/// @since 2.1.6
|
||||
/// </summary>
|
||||
[Obsolete("Use the version of IsPolicySet that also takes the device")]
|
||||
public bool IsPolicySet(PolicyFlag policy)
|
||||
{
|
||||
return _connection.IsPolicySet(policy);
|
||||
return IsPolicySet(policy, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
24
ml_lme_cvr/vendor/LeapCSharp/Device.cs
vendored
24
ml_lme_cvr/vendor/LeapCSharp/Device.cs
vendored
|
@ -49,7 +49,8 @@ namespace Leap
|
|||
DeviceType type,
|
||||
bool isStreaming,
|
||||
uint status,
|
||||
string serialNumber)
|
||||
string serialNumber,
|
||||
uint deviceID)
|
||||
{
|
||||
Handle = deviceHandle;
|
||||
InternalHandle = internalHandle;
|
||||
|
@ -60,9 +61,24 @@ namespace Leap
|
|||
Type = type;
|
||||
IsStreaming = isStreaming;
|
||||
SerialNumber = serialNumber;
|
||||
DeviceID = deviceID;
|
||||
UpdateStatus((eLeapDeviceStatus)status);
|
||||
}
|
||||
|
||||
public Device(IntPtr deviceHandle,
|
||||
IntPtr internalHandle,
|
||||
float horizontalViewAngle,
|
||||
float verticalViewAngle,
|
||||
float range,
|
||||
float baseline,
|
||||
DeviceType type,
|
||||
bool isStreaming,
|
||||
uint status,
|
||||
string serialNumber) : this(deviceHandle, internalHandle, horizontalViewAngle,
|
||||
verticalViewAngle, range, baseline, type, isStreaming, status, serialNumber, 0)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// For internal use only.
|
||||
/// </summary>
|
||||
|
@ -228,6 +244,12 @@ namespace Leap
|
|||
/// </summary>
|
||||
public string SerialNumber { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Reports the ID assoicated with the device
|
||||
///
|
||||
/// </summary>
|
||||
public uint DeviceID { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Returns the internal status field of the current device
|
||||
/// </summary>
|
||||
|
|
32
ml_lme_cvr/vendor/LeapCSharp/DeviceList.cs
vendored
32
ml_lme_cvr/vendor/LeapCSharp/DeviceList.cs
vendored
|
@ -10,6 +10,7 @@ namespace Leap
|
|||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
/// <summary>
|
||||
/// The DeviceList class represents a list of Device objects.
|
||||
|
@ -40,6 +41,20 @@ namespace Leap
|
|||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// For internal use only.
|
||||
/// </summary>
|
||||
public Device FindDeviceByID(uint deviceID)
|
||||
{
|
||||
for (int d = 0; d < this.Count; d++)
|
||||
{
|
||||
if (this[d].DeviceID == deviceID)
|
||||
return this[d];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
[Obsolete("Multiple devices can now be streaming, use ActiveDevices instead.", false)]
|
||||
/// <summary>
|
||||
/// The device that is currently streaming tracking data.
|
||||
/// If no streaming devices are found, returns null
|
||||
|
@ -66,6 +81,23 @@ namespace Leap
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The devices that are currently streaming tracking data.
|
||||
/// If no streaming devices are found, returns null
|
||||
/// </summary>
|
||||
public IEnumerable<Device> ActiveDevices
|
||||
{
|
||||
get
|
||||
{
|
||||
for (int d = 0; d < Count; d++)
|
||||
{
|
||||
this[d].UpdateStatus(LeapInternal.eLeapDeviceStatus.eLeapDeviceStatus_Streaming);
|
||||
}
|
||||
|
||||
return this.Where(d => d.IsStreaming);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// For internal use only.
|
||||
/// </summary>
|
||||
|
|
27
ml_lme_cvr/vendor/LeapCSharp/Events.cs
vendored
27
ml_lme_cvr/vendor/LeapCSharp/Events.cs
vendored
|
@ -106,14 +106,41 @@ namespace Leap
|
|||
/// </summary>
|
||||
public class PolicyEventArgs : LeapEventArgs
|
||||
{
|
||||
public PolicyEventArgs(UInt64 currentPolicies, UInt64 oldPolicies, bool oldPolicyIsValid, Device device) : base(LeapEvent.EVENT_POLICY_CHANGE)
|
||||
{
|
||||
this.currentPolicies = currentPolicies;
|
||||
this.oldPolicies = oldPolicies;
|
||||
this.device = device;
|
||||
}
|
||||
|
||||
[Obsolete("Use the constructor that takes the device and oldPolicyIsValid flag")]
|
||||
public PolicyEventArgs(UInt64 currentPolicies, UInt64 oldPolicies) : base(LeapEvent.EVENT_POLICY_CHANGE)
|
||||
{
|
||||
this.currentPolicies = currentPolicies;
|
||||
this.oldPolicies = oldPolicies;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Current policy flags
|
||||
/// </summary>
|
||||
public UInt64 currentPolicies { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Previous policy flags, if known
|
||||
/// </summary>
|
||||
public UInt64 oldPolicies { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Is the value for the old policy flags valid / known
|
||||
/// @since 5.7.0 (plugin)
|
||||
/// </summary>
|
||||
public bool oldPolicyIsValid { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The device associated with the policy flag change
|
||||
/// @since 5.7.0 (plugin)
|
||||
/// </summary>
|
||||
public Device device { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
7
ml_lme_cvr/vendor/LeapCSharp/IController.cs
vendored
7
ml_lme_cvr/vendor/LeapCSharp/IController.cs
vendored
|
@ -17,10 +17,17 @@ namespace Leap
|
|||
Frame GetTransformedFrame(LeapTransform trs, int history = 0);
|
||||
Frame GetInterpolatedFrame(Int64 time);
|
||||
|
||||
[Obsolete]
|
||||
void SetPolicy(Controller.PolicyFlag policy);
|
||||
[Obsolete]
|
||||
void ClearPolicy(Controller.PolicyFlag policy);
|
||||
[Obsolete]
|
||||
bool IsPolicySet(Controller.PolicyFlag policy);
|
||||
|
||||
void SetPolicy(Controller.PolicyFlag policy, Device device = null);
|
||||
void ClearPolicy(Controller.PolicyFlag policy, Device device = null);
|
||||
bool IsPolicySet(Controller.PolicyFlag policy, Device device = null);
|
||||
|
||||
long Now();
|
||||
|
||||
bool IsConnected { get; }
|
||||
|
|
10
ml_lme_cvr/vendor/LeapCSharp/MemoryManager.cs
vendored
10
ml_lme_cvr/vendor/LeapCSharp/MemoryManager.cs
vendored
|
@ -47,8 +47,8 @@ namespace LeapInternal
|
|||
|
||||
private static ConcurrentDictionary<IntPtr, ActiveMemoryInfo> _activeMemory =
|
||||
new ConcurrentDictionary<IntPtr, ActiveMemoryInfo>();
|
||||
private static ConcurrentDictionary<PoolKey, Queue<object>> _pooledMemory =
|
||||
new ConcurrentDictionary<PoolKey, Queue<object>>();
|
||||
private static ConcurrentDictionary<PoolKey, ConcurrentQueue<object>> _pooledMemory =
|
||||
new ConcurrentDictionary<PoolKey, ConcurrentQueue<object>>();
|
||||
|
||||
[MonoPInvokeCallback(typeof(Allocate))]
|
||||
public static IntPtr Pin(UInt32 size, eLeapAllocatorType typeHint, IntPtr state)
|
||||
|
@ -63,11 +63,11 @@ namespace LeapInternal
|
|||
};
|
||||
|
||||
//Attempt to find the pool that holds this type of allocation
|
||||
Queue<object> pool;
|
||||
ConcurrentQueue<object> pool;
|
||||
if (!_pooledMemory.TryGetValue(key, out pool))
|
||||
{
|
||||
//Construct a new pool if none exists yet
|
||||
pool = new Queue<object>();
|
||||
pool = new ConcurrentQueue<object>();
|
||||
_pooledMemory[key] = pool;
|
||||
}
|
||||
|
||||
|
@ -75,7 +75,7 @@ namespace LeapInternal
|
|||
object memory;
|
||||
if (EnablePooling && pool.Count > MinPoolSize)
|
||||
{
|
||||
memory = pool.Dequeue();
|
||||
pool.TryDequeue(out memory);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue