Consideration of Index controllers

Hud notifications
This commit is contained in:
SDraw 2022-03-23 11:37:07 +03:00
parent e87dfee1fe
commit 2a7e796862
No known key found for this signature in database
GPG key ID: BB95B4DAB2BB8BB5
5 changed files with 83 additions and 35 deletions

View file

@ -1,4 +1,5 @@
using ABI_RC.Core.Player;
using ABI_RC.Core.UI;
using UnityEngine;
namespace ml_lme_cvr
@ -35,8 +36,13 @@ namespace ml_lme_cvr
Settings.HeadOffsetChange += this.OnSettingsHeadOffsetChange;
m_leapController = new Leap.Controller();
m_gesturesData = new GestureMatcher.GesturesData();
m_leapController.Device += this.OnLeapDeviceInitialized;
m_leapController.DeviceFailure += this.OnLeapDeviceFailure;
m_leapController.DeviceLost += this.OnLeapDeviceLost;
m_leapController.Connect += this.OnLeapServiceConnect;
m_leapController.Disconnect += this.OnLeapServiceDisconnect;
m_gesturesData = new GestureMatcher.GesturesData();
m_leapHands = new GameObject[GestureMatcher.GesturesData.ms_handsCount];
// Patches
@ -113,6 +119,11 @@ namespace ml_lme_cvr
}
}
}
else
{
for(int i = 0; i < GestureMatcher.GesturesData.ms_handsCount; i++)
m_gesturesData.m_handsPresenses[i] = false;
}
if(m_leapTracked != null)
m_leapTracked.UpdateTracking(m_gesturesData);
@ -232,13 +243,51 @@ namespace ml_lme_cvr
}
}
// Leap events
void OnLeapDeviceInitialized(object p_sender, Leap.DeviceEventArgs p_args)
{
if(Settings.Enabled && (m_leapController != null))
{
m_leapController.ClearPolicy(Leap.Controller.PolicyFlag.POLICY_OPTIMIZE_SCREENTOP);
if(Settings.HmdMode)
m_leapController.SetPolicy(Leap.Controller.PolicyFlag.POLICY_OPTIMIZE_HMD);
else
m_leapController.ClearPolicy(Leap.Controller.PolicyFlag.POLICY_OPTIMIZE_HMD);
}
if(CohtmlHud.Instance != null)
CohtmlHud.Instance.ViewDropText("Leap Motion Extension", "Device initialized");
}
void OnLeapDeviceFailure(object p_sender, Leap.DeviceFailureEventArgs p_args)
{
if(CohtmlHud.Instance != null)
CohtmlHud.Instance.ViewDropText("Leap Motion Extension", "Device failure, code " + p_args.ErrorCode + ": " + p_args.ErrorMessage);
}
void OnLeapDeviceLost(object p_sender, Leap.DeviceEventArgs p_args)
{
if(CohtmlHud.Instance != null)
CohtmlHud.Instance.ViewDropText("Leap Motion Extension", "Device lost");
}
void OnLeapServiceConnect(object p_sender, Leap.ConnectionEventArgs p_args)
{
if(CohtmlHud.Instance != null)
CohtmlHud.Instance.ViewDropText("Leap Motion Extension", "Service connected");
}
void OnLeapServiceDisconnect(object p_sender, Leap.ConnectionLostEventArgs p_args)
{
if(CohtmlHud.Instance != null)
CohtmlHud.Instance.ViewDropText("Leap Motion Extension", "Service disconnected");
}
// Patches
static void OnAvatarSetup(ref PlayerSetup __instance)
{
if(__instance != null && __instance == PlayerSetup.Instance)
{
if((__instance != null) && (__instance == PlayerSetup.Instance))
ms_instance?.OnLocalPlayerAvatarSetup(__instance._animator, __instance.GetComponent<IndexIK>());
}
}
void OnLocalPlayerAvatarSetup(Animator p_animator, IndexIK p_indexIK)
{