예제 #1
0
파일: Main.cs 프로젝트: VRCMG/ml_lme
        public override void OnApplicationStart()
        {
            DependenciesHandler.ExtractDependencies();
            // DependenciesHandler.LoadDependencies(); // DllImport above load them fine somehow

            MelonLoader.MelonPreferences.CreateCategory("LME", "Leap Motion extension");
            MelonLoader.MelonPreferences.CreateEntry("LME", "Enabled", false, "Enable Leap Motion extension");
            MelonLoader.MelonPreferences.CreateEntry("LME", "VR", false, "Enable HMD mode for Leap Motion");
            MelonLoader.MelonPreferences.CreateEntry("LME", "SDK3", false, "Send SDK3 parameters");
            MelonLoader.MelonPreferences.CreateEntry("LME", "HeadRoot", false, "Use head as root point");
            MelonLoader.MelonPreferences.CreateEntry("LME", "RootOffsetY", c_defaultRootOffsetY, "Avatar root point offset for Y axis");
            MelonLoader.MelonPreferences.CreateEntry("LME", "RootOffsetZ", c_defaultRootOffsetZ, "Avatar root point offset for Z axis");
            MelonLoader.MelonPreferences.CreateEntry("LME", "FingersOnly", false, "Fingers tracking only");

            ms_inVrMode = VRCTrackingManager.Method_Public_Static_Boolean_5();

            m_fingersBends    = new float[10];
            m_fingersBendsPtr = GCHandle.Alloc(m_fingersBends, GCHandleType.Pinned);

            m_fingersSpreads    = new float[10];
            m_fingersSpreadsPtr = GCHandle.Alloc(m_fingersSpreads, GCHandleType.Pinned);

            m_handsPresent    = new bool[2];
            m_handsPresentPtr = GCHandle.Alloc(m_handsPresent, GCHandleType.Pinned);

            m_handPositions    = new float[6];
            m_handPositionsPtr = GCHandle.Alloc(m_handPositions, GCHandleType.Pinned);

            m_handRotations    = new float[8];
            m_handRotationsPtr = GCHandle.Alloc(m_handRotations, GCHandleType.Pinned);

            // Patches
            var l_patchMethod = new Harmony.HarmonyMethod(typeof(LeapMotionExtention), "VRCIM_ControllersType");

            typeof(VRCInputManager).GetMethods().Where(x =>
                                                       x.Name.StartsWith("Method_Public_Static_Boolean_EnumNPublicSealedvaKeMoCoGaViOcViDaWaUnique_")
                                                       ).ToList().ForEach(m => Harmony.Patch(m, l_patchMethod));

            OnPreferencesSaved();
        }
예제 #2
0
        public override void OnApplicationStart()
        {
            DependenciesHandler.ExtractDependencies();

            MelonLoader.MelonPreferences.CreateCategory("LME", "Leap Motion extension");
            MelonLoader.MelonPreferences.CreateEntry("LME", "Enabled", false, "Enable Leap Motion extension");
            MelonLoader.MelonPreferences.CreateEntry("LME", "VR", false, "Enable HMD mode for Leap Motion");
            MelonLoader.MelonPreferences.CreateEntry("LME", "SDK3", false, "Send SDK3 parameters");
            MelonLoader.MelonPreferences.CreateEntry("LME", "HeadRoot", false, "Use head as root point");
            MelonLoader.MelonPreferences.CreateEntry("LME", "RootOffsetY", c_defaultRootOffsetY, "Avatar root point offset for Y axis");
            MelonLoader.MelonPreferences.CreateEntry("LME", "RootOffsetZ", c_defaultRootOffsetZ, "Avatar root point offset for Z axis");
            MelonLoader.MelonPreferences.CreateEntry("LME", "FingersOnly", false, "Fingers tracking only");

            m_leapController = new Leap.Controller();
            m_gesturesData   = new GestureMatcher.GesturesData();

            // Methods search
            m_heightMethod = MethodsResolver.GetHeightMethod();
            if (m_heightMethod != null)
            {
                MelonLoader.MelonDebug.Msg("VRCTrackingManager." + m_heightMethod.Name + " -> VRCTrackingManager.GetPlayerHeight");
            }
            else
            {
                MelonLoader.MelonLogger.Warning("Can't resolve height method, fallback to zero float");
                m_heightMethod = typeof(LeapMotionExtention).GetMethod(nameof(ZeroFloat));
            }

            m_eyeHeightMethod = MethodsResolver.GetEyeHeightMethod();
            if (m_eyeHeightMethod != null)
            {
                MelonLoader.MelonDebug.Msg("VRCTrackingManager." + m_eyeHeightMethod.Name + " -> VRCTrackingManager.GetPlayerEyeHeight (Desktop)");
            }
            else
            {
                MelonLoader.MelonLogger.Warning("Can't resolve eye height method for desktop, fallback to zero float");
                m_eyeHeightMethod = typeof(LeapMotionExtention).GetMethod(nameof(ZeroFloat));
            }

            m_vrEyeHeightMethod = MethodsResolver.GetVREyeHeightMethod();
            if (m_vrEyeHeightMethod != null)
            {
                MelonLoader.MelonDebug.Msg("VRCTrackingManager." + m_vrEyeHeightMethod.Name + " -> VRCTrackingManager.GetPlayerEyeHeight (VR)");
            }
            else
            {
                MelonLoader.MelonLogger.Warning("Can't resolve eye height method for VR, fallback to zero float");
                m_vrEyeHeightMethod = typeof(LeapMotionExtention).GetMethod(nameof(ZeroFloat));
            }

            m_vrCheckMethod = MethodsResolver.GetVRCheckMethod();
            if (m_vrCheckMethod != null)
            {
                MelonLoader.MelonDebug.Msg("VRCTrackingManager." + m_vrCheckMethod.Name + " -> VRCTrackingManager.IsInVRMode");
            }
            else
            {
                MelonLoader.MelonLogger.Warning("Can't resolve vr check method, fallback to false boolean");
                m_vrCheckMethod = typeof(LeapMotionExtention).GetMethod(nameof(FalseBoolean));
            }

            // Patches
            var l_patchMethod = new Harmony.HarmonyMethod(typeof(LeapMotionExtention), nameof(VRCIM_ControllersType));

            typeof(VRCInputManager).GetMethods().Where(x =>
                                                       x.Name.StartsWith("Method_Public_Static_Boolean_EnumNPublicSealedvaKeMoCoGaViOcViDaWaUnique_")
                                                       ).ToList().ForEach(m => Harmony.Patch(m, l_patchMethod));

            OnPreferencesSaved();
        }