예제 #1
0
    public VRInputEmulatorWrapper()
    {
        int bufferSize = CreateVRInputEmulatorWrapperInstance(null, 0);
        var buffer     = new IntPtr[bufferSize];

        if (CreateVRInputEmulatorWrapperInstance(buffer, bufferSize) != bufferSize)
        {
            throw new Exception();
        }

        var bufferIdx = 0;

        _self      = buffer[bufferIdx];
        _fnDestroy = Marshal.GetDelegateForFunctionPointer <FnAction>(buffer[++bufferIdx]);

        _fnConnect = Marshal.GetDelegateForFunctionPointer <FnConnect>(buffer[++bufferIdx]);
        _fnAddTrackedController = Marshal.GetDelegateForFunctionPointer <FnAddTrackedController>(buffer[++bufferIdx]);
        _fnSetDeviceProperty    = Marshal.GetDelegateForFunctionPointer <FnSetDeviceProperty>(buffer[++bufferIdx]);
        _fnPublishTrackedDevice = Marshal.GetDelegateForFunctionPointer <FnPublishTrackedDevice>(buffer[++bufferIdx]);
        _fnSetDeviceConnection  = Marshal.GetDelegateForFunctionPointer <FnSetDeviceConnection>(buffer[++bufferIdx]);
        _fnSetDevicePosition    = Marshal.GetDelegateForFunctionPointer <FnSetDevicePosition>(buffer[++bufferIdx]);
        _fnSetDeviceRotation    = Marshal.GetDelegateForFunctionPointer <FnSetDeviceRotation>(buffer[++bufferIdx]);
        _fnButtonEvent          = Marshal.GetDelegateForFunctionPointer <FnButtonEvent>(buffer[++bufferIdx]);
        _fnAxisEvent            = Marshal.GetDelegateForFunctionPointer <FnAxisEvent>(buffer[++bufferIdx]);
        _fnGetDeviceID          = Marshal.GetDelegateForFunctionPointer <FnGetDeviceID>(buffer[++bufferIdx]);
        _fnGetOpenVRDeviceID    = Marshal.GetDelegateForFunctionPointer <FnGetOpenVRDeviceID>(buffer[++bufferIdx]);
        _fnDisconnect           = Marshal.GetDelegateForFunctionPointer <FnDisconnect>(buffer[++bufferIdx]);
    }
예제 #2
0
        public HDROutputPlugin(FnCreateHDROutputPluginInstance fnCreateHDROutputPluginInstance, IntPtr fnUnityRenderingEvent)
        {
            _fnUnityRenderingEvent = fnUnityRenderingEvent;

            int bufferSize = fnCreateHDROutputPluginInstance(null, 0);
            var buffer     = new IntPtr[bufferSize];

            if (fnCreateHDROutputPluginInstance(buffer, bufferSize) != bufferSize)
            {
                throw new Exception();
            }

            _self                              = buffer[0];
            _fnDestroy                         = Marshal.GetDelegateForFunctionPointer <FnAction>(buffer[1]);
            _fnRunWindowProc                   = Marshal.GetDelegateForFunctionPointer <FnRunWindowProc>(buffer[2]);
            _fnRunWindowProcPtr                = Marshal.GetDelegateForFunctionPointer <FnRunWindowProcPtr>(buffer[2]);
            _fnCloseWindow                     = Marshal.GetDelegateForFunctionPointer <FnAction>(buffer[3]);
            _fnGetRequestColorSpace            = Marshal.GetDelegateForFunctionPointer <FnGetColorSpace>(buffer[4]);
            _fnSetRequestColorSpace            = Marshal.GetDelegateForFunctionPointer <FnSetColorSpace>(buffer[5]);
            _fnGetActiveColorSpace             = Marshal.GetDelegateForFunctionPointer <FnGetColorSpace>(buffer[6]);
            _fnGetConvertColorSpace            = Marshal.GetDelegateForFunctionPointer <FnGetFlag>(buffer[7]);
            _fnSetConvertColorSpace            = Marshal.GetDelegateForFunctionPointer <FnSetFlag>(buffer[8]);
            _fnGetRelativeEV                   = Marshal.GetDelegateForFunctionPointer <FnGetFloat>(buffer[9]);
            _fnSetRelativeEV                   = Marshal.GetDelegateForFunctionPointer <FnSetFloat>(buffer[10]);
            _fnSetSourceTexture                = Marshal.GetDelegateForFunctionPointer <FnSetSourceTexture>(buffer[11]);
            _fnUpdateSourceTextureDirect       = Marshal.GetDelegateForFunctionPointer <FnAction>(buffer[12]);
            _fnRequestAsyncUpdateSourceTexture = Marshal.GetDelegateForFunctionPointer <FnRequestAsyncUpdateSourceTexture>(buffer[13]);
        }
예제 #3
0
        public RustSample()
        {
            uint bufferSize = CreateRustSampleInstance(null, 0);
            var  buffer     = new IntPtr[bufferSize];

            if (CreateRustSampleInstance(buffer, bufferSize) != bufferSize)
            {
                throw new Exception();
            }

            _self              = buffer[0];
            _fnDestroy         = Marshal.GetDelegateForFunctionPointer <FnAction>(buffer[1]);
            _fnGetCurrentValue = Marshal.GetDelegateForFunctionPointer <FnGetValue>(buffer[2]);
            _fnAdd             = Marshal.GetDelegateForFunctionPointer <FnCalc>(buffer[3]);
            _fnSub             = Marshal.GetDelegateForFunctionPointer <FnCalc>(buffer[4]);
            _fnAppendChars     = Marshal.GetDelegateForFunctionPointer <FnAppendChars>(buffer[5]);
            _fnPrintChars      = Marshal.GetDelegateForFunctionPointer <FnAction>(buffer[6]);
        }
예제 #4
0
 public void Dispose()
 {
     _fnDestroy?.Invoke(_self);
     _fnDestroy = null;
     _self      = IntPtr.Zero;
 }