Пример #1
0
    protected override void initializeReports()
    {
        reports = new IntPtr[maxNumberOfReports];
        VRPNButtonReport bReport = new VRPNButtonReport();

        bReport.button = 0;
        bReport.state  = 0;
        for (int i = 0; i < maxNumberOfReports; i++)
        {
            reports[i] = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(VRPNButtonReport)));
            // Copy the report struct to unmanaged memory (reports array)
            Marshal.StructureToPtr(bReport, reports[i], true);
        }
    }
Пример #2
0
    // Update is called once per frame
    void Update()
    {
        if (!initialized && !startDevice())
        {
            return;
        }

        int num = maxNumberOfReports;

        // Get button reports if any
        if (VRPNButtonNumReports(deviceName) > 0)
        {
            VRPNButtonReports(deviceName, reports, ref num, IntPtr.Zero, -1, true);
            for (int i = 0; i < num; i++)
            {
                VRPNButtonReport brep = (VRPNButtonReport)Marshal.PtrToStructure(reports[i], typeof(VRPNButtonReport));
                if (OnButton != null)
                {
                    OnButton(brep);
                }
            }
        }
    }