コード例 #1
0
        private static bool PollNextEvent_Hooked(IntPtr instance, IntPtr pEvent, uint uncbVREvent)
        {
            OpenVRInject This = (OpenVRInject)HookRuntimeInfo.Callback;

            try
            {
                var  pollNextEvent = Marshal.GetDelegateForFunctionPointer <vr_PollNextEventDelegate>(This.PollNextEventPtr);
                bool res           = pollNextEvent(instance, pEvent, uncbVREvent); // CRASH on 32 bit
                if (res)
                {
                    //This.Interface.Write("Event type: " + (EVREventType)pEvent.eventType);
                    //This.Interface.Write("Device index: " + pEvent.trackedDeviceIndex);
                    return(true);
                }
                else if (This.MyEvent.Queued)
                {
                    res = This.CreateEvent(pEvent);
                    //This.Interface.Write("Event type: " + (EVREventType)pEvent.eventType);
                    //This.Interface.Write("Device index: " + pEvent.trackedDeviceIndex);
                    return(true);
                }
            }
            catch (Exception ex)
            {
                // This.Interface.Write("Error in PollNextEvent_Hooked " + ex);
            }
            return(false);
        }
コード例 #2
0
        private static bool PollNextEventWithPose_Hooked(IntPtr instance, ETrackingUniverseOrigin eOrigin, IntPtr pEvent, uint uncbVREvent, IntPtr pTrackedDevicePose)
        {
            OpenVRInject This = (OpenVRInject)HookRuntimeInfo.Callback;
            bool         res  = false;

            try
            {
                var pollNextEventWithPose = Marshal.GetDelegateForFunctionPointer <vr_PollNextEventWithPoseDelegate>(This.PollNextEventPtr);
                res = pollNextEventWithPose(instance, eOrigin, pEvent, uncbVREvent, pTrackedDevicePose);
                if (res)
                {
                    //This.Interface.Write("Event type: " + (EVREventType)pEvent.eventType);
                    //This.Interface.Write("Device index: " + pEvent.trackedDeviceIndex);
                    return(true);
                }
                else if (This.MyEvent.Queued)
                {
                    res = This.CreateEvent(pEvent);
                    //This.Interface.Write("Event type: " + (EVREventType)pEvent.eventType);
                    //This.Interface.Write("Device index: " + pEvent.trackedDeviceIndex);
                    return(true);
                }
            }
            catch
            {
            }
            return(res);
        }
コード例 #3
0
        private static bool GetControllerStateWithPose_Hooked(IntPtr instance, ETrackingUniverseOrigin eOrigin, uint unControllerDeviceIndex, IntPtr pControllerState, uint unControllerStateSize, IntPtr pTrackedDevicePose)
        {
            bool         res  = false;
            OpenVRInject This = (OpenVRInject)HookRuntimeInfo.Callback;

            try
            {
                var getControllerStateWithPose = Marshal.GetDelegateForFunctionPointer <vr_GetControllerStateWithPoseDelegate>(This.GetControllerStateWithPosePtr);
                res = getControllerStateWithPose(instance, eOrigin, unControllerDeviceIndex, pControllerState, unControllerStateSize, pTrackedDevicePose);
                This.SetControllerState(pControllerState, unControllerDeviceIndex);
            }
            catch
            {
            }
            return(res);
        }