コード例 #1
0
 //Public method that allows to start recording in the indicated path
 //It registers the listener method in the event manager
 public void StartRecording()
 {
     data.deviceType = ButtonType.ToString();
     data.deviceName = ButtonName.ToString();
     VRPNEventManager.StartListeningButton(ButtonType, ButtonName, Record);
     isRecording = true;
 }
コード例 #2
0
    //To add a listener for Buttons
    public static void StartListeningButton(VRPNManager.Button_Types deviceType, VRPNDeviceConfig.Device_Names deviceName, UnityAction <string, VRPNButton.ButtonReport> listener)
    {
        if (eventManager == null)
        {
            Debug.LogError("There needs to be one active EventManger script on a GameObject in your scene.");
            return;
        }
        VRPNButtonEvent thisEvent = null;

        if (instance.eventDictionaryButton.TryGetValue(deviceType.ToString() + " " + deviceName.ToString(), out thisEvent))
        {
            thisEvent.AddListener(listener);
        }
        else
        {
            thisEvent = new VRPNButtonEvent();
            thisEvent.AddListener(listener);
            instance.eventDictionaryButton.Add(deviceType.ToString() + " " + deviceName.ToString(), thisEvent);
        }
    }
コード例 #3
0
    // Update is called once per frame
    void Update()
    {
        // Ensure device is ready
        if (!initialized && !StartButton())
        {
            return;
        }

        // Check for new reports and process
        if (VRPNButtonNumReports(ButtonName.ToString()) > 0)
        {
            // Get Reports
            int num = MaxReports;
            VRPNButtonReports(ButtonName.ToString(), reportsPtr, ref num, LastReport, ButtonNumber, purgeReports);
            ButtonReport[] reports = new ButtonReport[num];

            // Process Reports
            int    i;
            string reportString = ButtonName.ToString();
            for (i = 0; i < num; i++)
            {
                reports[i] = (ButtonReport)Marshal.PtrToStructure(reportsPtr[i], typeof(ButtonReport));
                //Trigger button event in event manager
                VRPNEventManager.TriggerEventButton(ButtonType.ToString(), ButtonName.ToString(), reports[i]);
                if (ShowDebug)
                {
                    reportString += "\n " + reports[i].button + "->" + reports[i].state + " @ " + reports[i].msg_time.tv_sec + "." + reports[i].msg_time.tv_usec;
                }
            }

            if (ShowDebug)
            {
                debug_text = reportString;
            }

            // Only need time value of most recent report
            if (num > 0 && useLastReportTime)
            {
                LastReport.tv_sec  = reports[num - 1].msg_time.tv_sec;
                LastReport.tv_usec = reports[num - 1].msg_time.tv_usec;
            }
        }
    }