Example #1
0
 public void logMouseEvent(object RawMouse, MouseEvent mevent)
 {
     //Debug.WriteLine(mevent.handle + ", " + mevent.ts + ", " + mevent.lastx + ", " + mevent.lasty + ", " + mevent.buttons);
     if (this.test_state == state.idle)
     {
         this.lastHandle = mevent.handle;
     }
     else if (this.test_state == state.collect)
     {
         this.mlog.Add(mevent);
     }
 }
Example #2
0
        public void ProcessRawInput(Message m)
        {
            if (m.Msg == WM_INPUT)
            {
                uint dwSize = 0;

                GetRawInputData(m.LParam,
                                RID_INPUT, IntPtr.Zero,
                                ref dwSize,
                                (uint)Marshal.SizeOf(typeof(RAWINPUTHEADER)));

                IntPtr buffer = Marshal.AllocHGlobal((int)dwSize);
                try
                {
                    if (buffer != IntPtr.Zero &&
                        GetRawInputData(m.LParam,
                                        RID_INPUT,
                                        buffer,
                                        ref dwSize,
                                        (uint)Marshal.SizeOf(typeof(RAWINPUTHEADER))) == dwSize)
                    {
                        RAWINPUT raw = (RAWINPUT)Marshal.PtrToStructure(buffer, typeof(RAWINPUT));

                        if (raw.header.dwType == RIM_TYPEMOUSE)
                        {
                            if (mevent != null)
                            {
                                MouseEvent meventinfo = new MouseEvent(raw.header.hDevice.ToInt32(),
                                                                       raw.mouse.buttonsStr.usButtonFlags , raw.mouse.lLastX, -raw.mouse.lLastY,
                                                                       stopWatch.ElapsedTicks * 1e3 / Stopwatch.Frequency);
                                mevent(this, meventinfo);
                            }
                            //Debug.WriteLine((stopWatch.ElapsedTicks * 1e3 / Stopwatch.Frequency).ToString() + ", " +
                            //                raw.mouse.lLastX.ToString() + ", " +
                            //                raw.mouse.lLastY.ToString());
                        }
                    }
                }
                finally
                {
                    Marshal.FreeHGlobal(buffer);
                }
            }
        }
Example #3
0
        public void logMouseEvent(object RawMouse, MouseEvent mevent)
        {
            //Debug.WriteLine(mevent.ts + ", " + mevent.lastx + ", " + mevent.lasty + ", " + mevent.buttons);
            if (this.test_state == state.idle)
            {

            }
            else if (this.test_state == state.measure_wait)
            {
                if (mevent.buttonflags == 0x0001)
                {
                    this.mlog.Add(mevent);
                    this.toolStripStatusLabel1.Text = "Measuring";
                    this.test_state = state.measure;
                }
            }
            else if (this.test_state == state.measure)
            {
                this.mlog.Add(mevent);
                if (mevent.buttonflags == 0x0002)
                {
                    double x = 0.0;
                    double y = 0.0;
                    double ts_min = this.mlog.Events[0].ts;
                    foreach (MouseEvent e in this.mlog.Events)
                    {
                        e.ts -= ts_min;
                        x += (double)e.lastx;
                        y += (double)e.lasty;
                    }
                    this.mlog.Cpi = Math.Round(Math.Sqrt((x * x) + (y * y)) / (10 / 2.54));
                    this.textBoxCPI.Text = this.mlog.Cpi.ToString();
                    this.textBox1.Text = "Press the Collect or Log Start button\r\n";
                    this.toolStripStatusLabel1.Text = "";
                    this.test_state = state.idle;
                }
            }
            else if (this.test_state == state.collect_wait)
            {
                if (mevent.buttonflags == 0x0001)
                {
                    this.mlog.Add(mevent);
                    this.toolStripStatusLabel1.Text = "Collecting";
                    this.test_state = state.collect;
                }
            }
            else if (this.test_state == state.collect)
            {
                this.mlog.Add(mevent);
                if (mevent.buttonflags == 0x0002)
                {
                    double ts_min = this.mlog.Events[0].ts;
                    foreach (MouseEvent e in this.mlog.Events)
                    {
                        e.ts -= ts_min;
                    }
                    this.textBox1.Text = "Press the plot button to view data\r\n" +
                                         "        or\r\n" +
                                         "Press the save button to save log file\r\n" +
                                         "Events: " + this.mlog.Events.Count.ToString() + "\r\n" +
                                         "Sum X: " + this.mlog.deltaX().ToString() + " counts    " + Math.Abs(this.mlog.deltaX() / this.mlog.Cpi * 2.54).ToString("0.0") + " cm\r\n" +
                                         "Sum Y: " + this.mlog.deltaY().ToString() + " counts    " + Math.Abs(this.mlog.deltaY() / this.mlog.Cpi * 2.54).ToString("0.0") + " cm\r\n" +
                                         "Path: " + this.mlog.path().ToString("0") + " counts    " + (this.mlog.path() / this.mlog.Cpi * 2.54).ToString("0.0") + " cm";
                    this.toolStripStatusLabel1.Text = "";
                    this.test_state = state.idle;
                }
            }
            else if (this.test_state == state.log)
            {
                this.mlog.Add(mevent);
            }
        }
Example #4
0
 public void Add(MouseEvent e)
 {
     this.events.Add(e);
 }
Example #5
0
 public void logMouseEvent(object RawMouse, MouseEvent mevent)
 {
     if (this.test_state == state.idle)
     {
         if (mevent.buttonflags == 0x0002)
             last_released_leftclick = mevent.hDevice;
     }
     else if (this.test_state == state.measure_wait)
     {
         if (mevent.buttonflags == 0x0001)
         {
             this.mlog.Add(mevent);
             this.toolStripStatusLabel1.Text = "Measuring";
             this.test_state = state.measure;
         }
     }
     else if (this.test_state == state.measure)
     {
         this.mlog.Add(mevent);
         if (mevent.buttonflags == 0x0002)
         {
             double x = 0.0;
             double y = 0.0;
             double ts_min = this.mlog.Events[0].ts;
             foreach (MouseEvent e in this.mlog.Events)
             {
                 e.ts -= ts_min;
                 x += (double)e.lastx;
                 y += (double)e.lasty;
             }
             this.mlog.Cpi = Math.Round(Math.Sqrt((x * x) + (y * y)) / (10 / 2.54));
             this.textBoxCPI.Text = this.mlog.Cpi.ToString();
             this.textBox1.Text = "Press the Collect or Log Start button\r\n";
             this.toolStripStatusLabel1.Text = "";
             this.test_state = state.idle;
         }
     }
     else if (this.test_state == state.collect_wait)
     {
         if (mevent.buttonflags == 0x0001)
         {
             this.toolStripStatusLabel1.Text = "Collecting";
             this.test_state = state.collect;
         }
     }
     else if (this.test_state == state.collect)
     {
         if (mevent.buttonflags == 0x0002)
             FinishCollecting();
         else
             AddEvent(mevent);
     }
     else if (this.test_state == state.log)
         AddEvent(mevent);
 }
Example #6
0
 private void AddEvent(MouseEvent mevent)
 {
     if (dual_state == dualstate.ready)
     {
         if (mevent.hDevice == mlog1.hDevice)
             mlog1.Events.Add(mevent);
         else if (mevent.hDevice == mlog2.hDevice)
             mlog2.Events.Add(mevent);
     }
     else
         this.mlog.Add(mevent);
 }
Example #7
0
 public void Add(MouseEvent e)
 {
     this.events.Add(e);
 }