Example #1
0
 private void OnGestureDetected(DisplayCP7 sender, GestureDetectedEventArgs e)
 {
     if (Program.CheckAndInvoke(this.GestureDetected, this.onGestureDetected, sender, e))
     {
         this.GestureDetected(sender, e);
     }
 }
Example #2
0
 private void OnScreenReleased(DisplayCP7 sender, EventArgs e)
 {
     if (Program.CheckAndInvoke(this.ScreenReleased, this.onScreenReleased, sender, e))
     {
         this.ScreenReleased(sender, e);
     }
 }
Example #3
0
 private void OnBackPressed(DisplayCP7 sender, EventArgs e)
 {
     if (Program.CheckAndInvoke(this.BackPressed, this.onBackPressed, sender, e))
     {
         this.BackPressed(sender, e);
     }
 }
Example #4
0
        /// <summary>
        /// Raises events for both the touch positions and touch gestures
        /// </summary>
        /// <param name="sender">The module that is sending the event</param>
        /// <param name="touchStatus">A class that contains all information about the screen</param>
        protected virtual void OnTouchEvent(DisplayCP7 sender, TouchStatus touchStatus)
        {
            int numberOfFingers = (ReadRegister(0x02) & 0xF);

            if (numberOfFingers == 0)
            {
                if (!bSentReleased)
                {
                    if (this.onScreenReleased == null)
                    {
                        this.onScreenReleased = new TouchEventHandlerTouchReleased(this.onScreenReleased);
                    }

                    if (Program.CheckAndInvoke(ScreenReleased, this.onScreenReleased, this))
                    {
                        this.ScreenReleased(this);
                    }

                    bSentReleased = true;
                }

                return;
            }

            bSentReleased = false;

            int gesture = (ReadRegister(0x01) & 0xFF);

            if (gesture != (int)Gesture_ID.No_Gesture)
            {
                if (this.onGestureDetected == null)
                {
                    this.onGestureDetected = new TouchGestureDetected(this.onGestureDetected);
                }

                if (Program.CheckAndInvoke(GestureDetected, this.onGestureDetected, this, (Gesture_ID)gesture))
                {
                    this.GestureDetected(this, (Gesture_ID)gesture);
                }

                return;
            }
            //Debug.Print("num fingers" + numberOfFingers);

            TouchStatus ts = new TouchStatus();

            ts.numTouches = numberOfFingers;

            for (int i = 0; i < 5; i++)
            {
                if (i < numberOfFingers)
                {
                    int x = ((ReadRegister((byte)(3 + i * 6)) & 0xF) << 8) + ReadRegister((byte)(4 + i * 6));
                    int y = ((ReadRegister((byte)(5 + i * 6)) & 0xF) << 8) + ReadRegister((byte)(6 + i * 6));

                    ts.touchPos[i] = new Finger(x, y, true);

                    //////////////////////////////////////////////////////////////////////
                    // HEY LISTEN
                    // DO THE BUTTON THINGS RIGHT HERE
                    /////////////////////////////////////////////////////////////////////
                    // Check to see if a user has used one of the "Android" buttons
                    if (x > 800)
                    {
                        if (y >= 0 && y <= 50)
                        {
                            // Home
                            if (this.onHomePressed == null)
                            {
                                this.onHomePressed = new TouchEventHandlerHomeButton(this.onHomePressed);
                            }

                            if (Program.CheckAndInvoke(HomePressed, this.onHomePressed, this))
                            {
                                this.HomePressed(this);
                            }
                        }
                        if (y >= 100 && y <= 150)
                        {
                            // Menu
                            if (this.onMenuPressed == null)
                            {
                                this.onMenuPressed = new TouchEventHandlerMenuButton(this.onMenuPressed);
                            }

                            if (Program.CheckAndInvoke(MenuPressed, this.onMenuPressed, this))
                            {
                                this.MenuPressed(this);
                            }
                        }
                        else if (y >= 200 && y <= 250)
                        {
                            // Back
                            if (this.onBackPressed == null)
                            {
                                this.onBackPressed = new TouchEventHandlerBackButton(this.onBackPressed);
                            }

                            if (Program.CheckAndInvoke(BackPressed, this.onBackPressed, this))
                            {
                                this.BackPressed(this);
                            }
                        }
                    }
                }
                else
                {
                    ts.touchPos[i] = new Finger(-1, -1, false);
                }

                //Debug.Print("X: " + x + " Y: " + y);
            }

            if (this.onTouch == null)
            {
                this.onTouch = new TouchEventHandler(this.OnTouchEvent);
            }

            if (Program.CheckAndInvoke(ScreenPressed, this.onTouch, sender, ts))
            {
                this.ScreenPressed(sender, ts);
            }
        }