Exemple #1
0
        public int GetMouseClicks(ButtonReport report)
        {
            int buttons = 0;

            if ((report.Buttons & (int)MouseButtons.LeftClick) > 0)
            {
                buttons += Win32.DWORD_FLAGS.MOUSEEVENTF_LEFTDOWN;
            }
            else if ((report.Buttons & (int)MouseButtons.LeftClick) == 0)
            {
                buttons += Win32.DWORD_FLAGS.MOUSEEVENTF_LEFTUP;
            }

            return(buttons);
        }
Exemple #2
0
    // Functions

    void Start()
    {
        //allocate unmanaged memory for button reports
        reportsPtr = new IntPtr[MaxReports];
        ButtonReport report = new ButtonReport();

        report.button = 0;
        report.state  = 0;
        for (int i = 0; i < MaxReports; i++)
        {
            reportsPtr[i] = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(ButtonReport)));
            Marshal.StructureToPtr(report, reportsPtr[i], true);
        }

        // Setup last report time memory
        LastReport = new VRPNManager.TimeVal();
    }
Exemple #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;
            }
        }
    }
 protected void InterfaceCallback(IntPtr userdata, ref TimeValue timestamp, ref ButtonReport report)
 {
     OnStateChanged(timestamp, report.sensor, report.state);
 }
Exemple #5
0
 static void myButtonCallback(IntPtr userdata, ref TimeValue timestamp, ref ButtonReport report)
 {
     Console.WriteLine("Got report: button is {0}", report.state == 1 ? "pressed" : "released");
 }