예제 #1
0
 //This is the listener that is called by the event manager
 //It transforms and adds the received report to the reports list
 void Record(string name, VRPNButton.ButtonReport report)
 {
     if (firstReport)
     {
         firstTime_sec  = report.msg_time.tv_sec;
         firstTime_usec = report.msg_time.tv_usec;
         firstReport    = false;
     }
     if (report.msg_time.tv_usec < firstTime_usec)
     {
         report.msg_time.tv_sec  = report.msg_time.tv_sec - (firstTime_sec + 1);
         report.msg_time.tv_usec = (report.msg_time.tv_usec + 1000000) - firstTime_usec;
     }
     else
     {
         report.msg_time.tv_sec  = report.msg_time.tv_sec - firstTime_sec;
         report.msg_time.tv_usec = report.msg_time.tv_usec - firstTime_usec;
     }
     VRPNButton.ButtonReportNew newReport  = new VRPNButton.ButtonReportNew();
     VRPNManager.TimeValNew     newMsgTime = new VRPNManager.TimeValNew();
     newMsgTime.tv_sec  = (int)report.msg_time.tv_sec;
     newMsgTime.tv_usec = (int)report.msg_time.tv_usec;
     newReport.msg_time = newMsgTime;
     newReport.button   = report.button;
     newReport.state    = report.state;
     data.list.Add(newReport);
 }
예제 #2
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);
     }
 }
예제 #3
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);
     }
 }
예제 #4
0
    //To add a trigger for Buttons
    public static void TriggerEventButton(string deviceType, string deviceName, VRPNButton.ButtonReport report)
    {
        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 + " " + deviceName, out thisEvent))
        {
            thisEvent.Invoke(deviceType + " " + deviceName, report);
        }
    }