コード例 #1
0
		/// <summary>
		/// Function receiving callback from mouse.
		/// </summary>
		/// <param name="pTouchMouseStatus">Values indicating status of mouse.</param>
		/// <param name="pabImage">Bytes forming image, 13 rows of 15 columns.</param>
		/// <param name="dwImageSize">Size of image, assumed to always be 195 (13x15).</param>
		internal void TouchMouseCallback(ref TOUCHMOUSESTATUS pTouchMouseStatus, byte[] pabImage, int dwImageSize)
		{
			// Reinizialize Touched Zones
			_pixelFound[0] = 0;
			_pixelFound[1] = 0;

			for (var y = 0; y < pTouchMouseStatus.m_dwImageHeight; y++)
			{
				for (var x = 0; x < pTouchMouseStatus.m_dwImageWidth; x++)
				{
					var pixel = pabImage[pTouchMouseStatus.m_dwImageWidth * y + x];
					if (pixel != 0)
					{
						_touchMap[x, y] = true;
						if (pixel == 0)
						{
							continue;
						}

						foreach (var touchZone in _touchZoneProvider.Get())
							touchZone.Consume(x, y, pixel);
					}
				}
			}

			// Calculate and display the center of mass for the touches present.
			foreach (var touchZone in _touchZoneProvider.Get())
			{
				touchZone.AppendTime(pTouchMouseStatus.m_dwTimeDelta);
				touchZone.ComputeCenter();
			}

			if (pTouchMouseStatus.m_dwTimeDelta == 0)
			{
				// If the time delta is zero then there has been an 
				// undetermined delta since the last report.
				Log.Info("New touch detected");
				_machine.Idle();

				foreach (var touchZone in _touchZoneProvider.Get())
				{
					touchZone.Reset();
				}
			}

			foreach (var touchZone in _touchZoneProvider.Get())
			{
				touchZone.DetectEvents();
			}

			foreach (var touchZone in _touchZoneProvider.Get())
			{
				touchZone.Prepare();
			}

			if (pTouchMouseStatus.m_fDisconnect)
			{
				// The mouse is now disconnected, if we had created objects to track 
				// the mouse they would be destroyed here.
				Log.InfoFormat("\nMouse #{0:X4}: Disconnected\n",
					(pTouchMouseStatus.m_dwID & 0xFFFF));
			}

			OnTouchMouseEvent(new TouchMouseEventArgs
			{
				Image = pabImage,
				ImageSize = dwImageSize,
				Status = pTouchMouseStatus
			});
		}
コード例 #2
0
        /// <summary>
        /// Function receiving callback from mouse.
        /// </summary>
        /// <param name="pTouchMouseStatus">Values indicating status of mouse.</param>
        /// <param name="pabImage">Bytes forming image, 13 rows of 15 columns.</param>
        /// <param name="dwImageSize">Size of image, assumed to always be 195 (13x15).</param>
        internal void TouchMouseCallback(ref TOUCHMOUSESTATUS pTouchMouseStatus, byte[] pabImage, int dwImageSize)
        {
            // Reinizialize Touched Zones
            _pixelFound[0] = 0;
            _pixelFound[1] = 0;

            for (var y = 0; y < pTouchMouseStatus.m_dwImageHeight; y++)
            {
                for (var x = 0; x < pTouchMouseStatus.m_dwImageWidth; x++)
                {
                    var pixel = pabImage[pTouchMouseStatus.m_dwImageWidth * y + x];
                    if (pixel != 0)
                    {
                        _touchMap[x, y] = true;
                        if (pixel == 0)
                        {
                            continue;
                        }

                        foreach (var touchZone in _touchZoneProvider.Get())
                        {
                            touchZone.Consume(x, y, pixel);
                        }
                    }
                }
            }

            // Calculate and display the center of mass for the touches present.
            foreach (var touchZone in _touchZoneProvider.Get())
            {
                touchZone.AppendTime(pTouchMouseStatus.m_dwTimeDelta);
                touchZone.ComputeCenter();
            }

            if (pTouchMouseStatus.m_dwTimeDelta == 0)
            {
                // If the time delta is zero then there has been an
                // undetermined delta since the last report.
                Log.Info("New touch detected");
                _machine.Idle();

                foreach (var touchZone in _touchZoneProvider.Get())
                {
                    touchZone.Reset();
                }
            }

            foreach (var touchZone in _touchZoneProvider.Get())
            {
                touchZone.DetectEvents();
            }

            foreach (var touchZone in _touchZoneProvider.Get())
            {
                touchZone.Prepare();
            }

            if (pTouchMouseStatus.m_fDisconnect)
            {
                // The mouse is now disconnected, if we had created objects to track
                // the mouse they would be destroyed here.
                Log.InfoFormat("\nMouse #{0:X4}: Disconnected\n",
                               (pTouchMouseStatus.m_dwID & 0xFFFF));
            }

            OnTouchMouseEvent(new TouchMouseEventArgs
            {
                Image     = pabImage,
                ImageSize = dwImageSize,
                Status    = pTouchMouseStatus
            });
        }
コード例 #3
0
        /// <summary>
        /// Function receiving callback from mouse.
        /// </summary>
        /// <param name="pTouchMouseStatus">Values indicating status of mouse.</param>
        /// <param name="pabImage">Bytes forming image, 13 rows of 15 columns.</param>
        /// <param name="dwImageSize">Size of image, assumed to always be 195 (13x15).</param>
        internal static void TouchMouseCallbackFunction(ref TOUCHMOUSESTATUS pTouchMouseStatus,
                                                        byte[] pabImage,
                                                        int dwImageSize)
        {
            // Reinizialize Touched Zones
            PixelFound[0] = 0;
            PixelFound[1] = 0;
            // Iterate over rows.
            for (int y = 0; y < pTouchMouseStatus.m_dwImageHeight; y++)
            {
                // Iterate over columns.
                for (int x = 0; x < pTouchMouseStatus.m_dwImageWidth; x++)
                {
                    if (pabImage[pTouchMouseStatus.m_dwImageWidth*y + x] != 0)
                        // analyze captured image for touch gesture.
                    {
                        TouchMap[x, y] = true; // touch detected
                        int pixel = pabImage[pTouchMouseStatus.m_dwImageWidth*y + x]; // touch strength recorded
                        if (pixel == 0)
                        {
                        	continue;
                        }

                        // Get the pixel value at current position.
                        if (LeftMask[y,x] == 1)
                        {
                            // Increment values.
                            _leftZone.Consume(x, y, pixel);                            
                        }
                        else if (RightMask[y,x] == 1)
                        {
                            // Increment values.
                            _rightZone.Consume(x, y, pixel);                            
                        }
                    }
                }
            }
            
            // Calculate and display the center of mass for the touches present.
            _leftZone.AppendTime(pTouchMouseStatus.m_dwTimeDelta);
            _rightZone.AppendTime(pTouchMouseStatus.m_dwTimeDelta);
            _leftZone.ComputeCenter();
            _rightZone.ComputeCenter();

            if (pTouchMouseStatus.m_dwTimeDelta == 0)
            {
                // If the time delta is zero then there has been an 
                // undetermined delta since the last report.
                Log.Info("New touch detected");
                Machine.Idle();
                _leftZone.Reset();
                _rightZone.Reset();
            }

            ApproachThree();

            if (pTouchMouseStatus.m_fDisconnect)
            {
                // The mouse is now disconnected, if we had created objects to track 
                // the mouse they would be destroyed here.
                Log.InfoFormat("\nMouse #{0:X4}: Disconnected\n",
                                  (pTouchMouseStatus.m_dwID & 0xFFFF));
            }
        }
コード例 #4
0
        /// <summary>
        /// Function receiving callback from mouse.
        /// </summary>
        /// <param name="pTouchMouseStatus">Values indicating status of mouse.</param>
        /// <param name="pabImage">Bytes forming image, 13 rows of 15 columns.</param>
        /// <param name="dwImageSize">Size of image, assumed to always be 195 (13x15).</param>
        internal static void TouchMouseCallbackFunction(ref TOUCHMOUSESTATUS pTouchMouseStatus,
                                                        byte[] pabImage,
                                                        int dwImageSize)
        {
            // Reinizialize Touched Zones
            PixelFound[0] = 0;
            PixelFound[1] = 0;
            // Iterate over rows.
            for (int y = 0; y < pTouchMouseStatus.m_dwImageHeight; y++)
            {
                // Iterate over columns.
                for (int x = 0; x < pTouchMouseStatus.m_dwImageWidth; x++)
                {
                    if (pabImage[pTouchMouseStatus.m_dwImageWidth * y + x] != 0)
                    // analyze captured image for touch gesture.
                    {
                        TouchMap[x, y] = true;                                          // touch detected
                        int pixel = pabImage[pTouchMouseStatus.m_dwImageWidth * y + x]; // touch strength recorded
                        if (pixel == 0)
                        {
                            continue;
                        }

                        // Get the pixel value at current position.
                        if (LeftMask[y, x] == 1)
                        {
                            // Increment values.
                            _leftZone.Consume(x, y, pixel);
                        }
                        else if (RightMask[y, x] == 1)
                        {
                            // Increment values.
                            _rightZone.Consume(x, y, pixel);
                        }
                    }
                }
            }

            // Calculate and display the center of mass for the touches present.
            _leftZone.AppendTime(pTouchMouseStatus.m_dwTimeDelta);
            _rightZone.AppendTime(pTouchMouseStatus.m_dwTimeDelta);
            _leftZone.ComputeCenter();
            _rightZone.ComputeCenter();

            if (pTouchMouseStatus.m_dwTimeDelta == 0)
            {
                // If the time delta is zero then there has been an
                // undetermined delta since the last report.
                Log.Info("New touch detected");
                Machine.Idle();
                _leftZone.Reset();
                _rightZone.Reset();
            }

            ApproachThree();

            if (pTouchMouseStatus.m_fDisconnect)
            {
                // The mouse is now disconnected, if we had created objects to track
                // the mouse they would be destroyed here.
                Log.InfoFormat("\nMouse #{0:X4}: Disconnected\n",
                               (pTouchMouseStatus.m_dwID & 0xFFFF));
            }
        }