diff --git a/ml_lme_cvr/Main.cs b/ml_lme_cvr/Main.cs
index e6ab840..4dc91dd 100644
--- a/ml_lme_cvr/Main.cs
+++ b/ml_lme_cvr/Main.cs
@@ -12,7 +12,6 @@ namespace ml_lme_cvr
static LeapMotionExtension ms_instance = null;
Leap.Controller m_leapController = null;
- long m_lastFrameId = 0;
GestureMatcher.GesturesData m_gesturesData = null;
GameObject m_leapTrackingRoot = null;
@@ -101,26 +100,28 @@ namespace ml_lme_cvr
public override void OnUpdate()
{
- if(Settings.Enabled && (m_leapController != null))
+ if(Settings.Enabled)
{
for(int i = 0; i < GestureMatcher.GesturesData.ms_handsCount; i++)
m_gesturesData.m_handsPresenses[i] = false;
- Leap.Frame l_frame = m_leapController.Frame();
- if((l_frame != null) && (m_lastFrameId != l_frame.Id))
+ if((m_leapController != null) && m_leapController.IsConnected)
{
- m_lastFrameId = l_frame.Id;
-
- GestureMatcher.GetGestures(l_frame, ref m_gesturesData);
- for(int i = 0; i < GestureMatcher.GesturesData.ms_handsCount; i++)
+ Leap.Frame l_frame = m_leapController.Frame();
+ if(l_frame != null)
{
- if((m_leapHands[i] != null) && m_gesturesData.m_handsPresenses[i])
+ GestureMatcher.GetGestures(l_frame, ref m_gesturesData);
+
+ for(int i = 0; i < GestureMatcher.GesturesData.ms_handsCount; i++)
{
- Vector3 l_pos = m_gesturesData.m_handsPositons[i];
- Quaternion l_rot = m_gesturesData.m_handsRotations[i];
- ReorientateLeapToUnity(ref l_pos, ref l_rot, Settings.HmdMode);
- m_leapHands[i].transform.localPosition = l_pos;
- m_leapHands[i].transform.localRotation = l_rot;
+ if((m_leapHands[i] != null) && m_gesturesData.m_handsPresenses[i])
+ {
+ Vector3 l_pos = m_gesturesData.m_handsPositons[i];
+ Quaternion l_rot = m_gesturesData.m_handsRotations[i];
+ ReorientateLeapToUnity(ref l_pos, ref l_rot, Settings.HmdMode);
+ m_leapHands[i].transform.localPosition = l_pos;
+ m_leapHands[i].transform.localRotation = l_rot;
+ }
}
}
}
diff --git a/ml_lme_cvr/Properties/AssemblyInfo.cs b/ml_lme_cvr/Properties/AssemblyInfo.cs
index 2ca0168..ed50dc6 100644
--- a/ml_lme_cvr/Properties/AssemblyInfo.cs
+++ b/ml_lme_cvr/Properties/AssemblyInfo.cs
@@ -1,10 +1,10 @@
using System.Reflection;
[assembly: AssemblyTitle("LeapMotionExtension")]
-[assembly: AssemblyVersion("1.0.2")]
-[assembly: AssemblyFileVersion("1.0.2")]
+[assembly: AssemblyVersion("1.0.3")]
+[assembly: AssemblyFileVersion("1.0.3")]
-[assembly: MelonLoader.MelonInfo(typeof(ml_lme_cvr.LeapMotionExtension), "LeapMotionExtension", "1.0.2", "SDraw", "https://github.com/SDraw")]
+[assembly: MelonLoader.MelonInfo(typeof(ml_lme_cvr.LeapMotionExtension), "LeapMotionExtension", "1.0.3", "SDraw", "https://github.com/SDraw")]
[assembly: MelonLoader.MelonGame(null, "ChilloutVR")]
[assembly: MelonLoader.MelonPlatform(MelonLoader.MelonPlatformAttribute.CompatiblePlatforms.WINDOWS_X64)]
[assembly: MelonLoader.MelonPlatformDomain(MelonLoader.MelonPlatformDomainAttribute.CompatibleDomains.MONO)]
diff --git a/ml_lme_cvr/vendor/LeapCSharp/Connection.cs b/ml_lme_cvr/vendor/LeapCSharp/Connection.cs
index 5b23698..a92ddaa 100644
--- a/ml_lme_cvr/vendor/LeapCSharp/Connection.cs
+++ b/ml_lme_cvr/vendor/LeapCSharp/Connection.cs
@@ -245,6 +245,18 @@ namespace LeapInternal
_polster.Join();
}
+ ///
+ /// Returns the version of the currently installed Tracking Service.
+ /// Might return 0.0.0 if no device is connected or it cannot get the current version.
+ ///
+ /// the current tracking service version
+ public LEAP_VERSION GetCurrentServiceVersion()
+ {
+ LEAP_VERSION currentVersion = new LEAP_VERSION { major = 0, minor = 0, patch = 0 };
+ LeapC.GetVersion(_leapConnection, eLeapVersionPart.eLeapVersionPart_ServerLibrary, ref currentVersion);
+ return currentVersion;
+ }
+
//Run in Polster thread, fills in object queues
private void processMessages()
{
@@ -586,7 +598,13 @@ namespace LeapInternal
private void handleLostDevice(ref LEAP_DEVICE_EVENT deviceMsg)
{
- Device lost = _devices.FindDeviceByHandle(deviceMsg.device.handle);
+ IntPtr deviceHandle;
+ eLeapRS result = LeapC.OpenDevice(deviceMsg.device, out deviceHandle);
+ if (result != eLeapRS.eLeapRS_Success)
+ return;
+
+ //UnityEngine.Debug.Log("handleLostDevice: " + deviceHandle);
+ Device lost = _devices.FindDeviceByHandle(deviceHandle);
if (lost != null)
{
_devices.Remove(lost);
diff --git a/ml_lme_cvr/vendor/LeapCSharp/Controller.cs b/ml_lme_cvr/vendor/LeapCSharp/Controller.cs
index fb73fb5..3e9d475 100644
--- a/ml_lme_cvr/vendor/LeapCSharp/Controller.cs
+++ b/ml_lme_cvr/vendor/LeapCSharp/Controller.cs
@@ -497,6 +497,27 @@ namespace Leap
}
}
+ ///
+ /// 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
+ ///
+ /// The minimum service version to check against
+ ///
+ public bool CheckRequiredServiceVersion(LEAP_VERSION minServiceVersion)
+ {
+ LEAP_VERSION currentServiceVersion = _connection.GetCurrentServiceVersion();
+
+ // check that minServiceVersion is smaller or equal to the current service version
+ if (minServiceVersion.major < currentServiceVersion.major) return true;
+ else if (minServiceVersion.major == currentServiceVersion.major)
+ {
+ if (minServiceVersion.minor < currentServiceVersion.minor) return true;
+ else if (minServiceVersion.minor == currentServiceVersion.minor && minServiceVersion.patch <= currentServiceVersion.patch) return true;
+ }
+ return false;
+ }
+
///
/// Requests setting a policy.
///