예제 #1
0
        private void ReceiveTouchInformation(Int32 deviceId, Int32 deviceStatus, Int32 packetID, Int32 touches, Int32 ghostTouches)
        {
            //Check if we have received touch information.
            if (deviceStatus == (int)DeviceStatus.DS_TOUCH_INFO)
            {
                lock (m_lock)
                {
                    this.FTouches.Clear();
                    this.FpacketID       = packetID;
                    this.FCurrentTouches = touches;

                    for (int tch = 0; tch < Imports.MAX_TOUCHES; tch++)
                    {
                        if ((this.FCurrentTouches & (1 << tch)) > 0)
                        {
                            //Get the touch information.
                            NWTouchPoint touchPt = new NWTouchPoint();
                            SuccessCode  retCode = (SuccessCode)Imports.GetTouch(myDeviceID, FpacketID, out touchPt, (1 << tch), 0);
                            if (retCode == SuccessCode.SUCCESS)
                            {
                                if (touchPt.TouchEventType == (int)TouchEventType.TE_TOUCH_DOWN ||
                                    touchPt.TouchEventType == (int)TouchEventType.TE_TOUCHING)
                                {
                                    this.FTouches[touchPt.TouchID] = touchPt;
                                }
                            }
                        }
                    }
                    this.FInvalidateTouches = true;
                }
            }
        }
예제 #2
0
        public void Evaluate(int SpreadMax)
        {
            if (this.FInvalidateDeviceCount)
            {
                this.FDeviceCount = Imports.GetConnectedDeviceCount();
                this.FPinOutDevicesCount.SetValue(0, this.FDeviceCount);
                this.FInvalidateDeviceCount = false;

                this.myDeviceID = -1;

                if (this.FDeviceCount > 0)
                {
                    myDeviceID = Imports.GetConnectedDeviceID(0);
                    Imports.OpenDevice(myDeviceID, eventHandler);
                    Imports.SetReportMode(myDeviceID, (int)ReportModes.RM_SLOPESMODE);
                    Imports.SetTouchScreenDimensions(myDeviceID, -1, -1, 1, 1);
                }
            }

            this.FPinOutOnData.SetValue(0, Convert.ToDouble(this.FInvalidateTouches));

            if (this.FInvalidateTouches)
            {
                lock (m_lock)
                {
                    //Loop through all the touches.

                    this.FPinOutPosition.SliceCount  = this.FTouches.Count;
                    this.FPinOutId.SliceCount        = this.FTouches.Count;
                    this.FPinOutType.SliceCount      = this.FTouches.Count;
                    this.FPinOutSize.SliceCount      = this.FTouches.Count;
                    this.FPinOutVelocity.SliceCount  = this.FTouches.Count;
                    this.FpinOutLevel.SliceCount     = this.FTouches.Count;
                    this.FpinOutEventType.SliceCount = this.FTouches.Count;

                    int cnt = 0;
                    foreach (int key in this.FTouches.Keys)
                    {
                        NWTouchPoint touch = this.FTouches[key];
                        this.FPinOutId.SetValue(cnt, touch.TouchID);
                        this.FPinOutPosition.SetValue2D(cnt, touch.TouchPos.x, -touch.TouchPos.y);
                        this.FPinOutSize.SetValue2D(cnt, touch.Width, touch.Height);
                        this.FPinOutVelocity.SetValue(cnt, touch.Velocity);
                        this.FpinOutLevel.SetValue(cnt, touch.ConfidenceLevel);
                        if (touch.TouchType == (int)TouchType.TT_CENTROID)
                        {
                            this.FPinOutType.SetString(cnt, "Centroid");
                        }
                        else
                        {
                            if (touch.TouchType == (int)TouchType.TT_GHOSTTOUCH)
                            {
                                this.FPinOutType.SetString(cnt, "Ghost");
                            }
                            else
                            {
                                this.FPinOutType.SetString(cnt, "Touch");
                            }
                        }

                        if (touch.TouchEventType == (int)TouchEventType.TE_TOUCH_DOWN)
                        {
                            this.FpinOutEventType.SetString(cnt, "Down");
                        }
                        else
                        {
                            if (touch.TouchEventType == (int)TouchEventType.TE_TOUCH_UP)
                            {
                                this.FpinOutEventType.SetString(cnt, "Up");
                            }
                            else
                            {
                                this.FpinOutEventType.SetString(cnt, "Move");
                            }
                        }
                        cnt++;
                    }
                }
                this.FInvalidateTouches = false;
            }
        }