Esempio n. 1
0
 //Auxiliar method that sends last frame report for each button
 private void sendingReports(Dictionary <int, VRPNButton.ButtonReportNew> lastReports)
 {
     foreach (KeyValuePair <int, VRPNButton.ButtonReportNew> pair in lastReports)
     {
         VRPNButton.ButtonReport newReport  = new VRPNButton.ButtonReport();
         VRPNManager.TimeVal     newMsgTime = new VRPNManager.TimeVal();
         newMsgTime.tv_sec  = (UInt32)pair.Value.msg_time.tv_sec;
         newMsgTime.tv_usec = (UInt32)pair.Value.msg_time.tv_usec;
         newReport.msg_time = newMsgTime;
         newReport.button   = pair.Value.button;
         newReport.state    = pair.Value.state;
         VRPNEventManager.TriggerEventButton(data.deviceType, data.deviceName, newReport);
     }
 }
Esempio n. 2
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;
            }
        }
    }