public override void Update()
            {
                // Did we switch modes?
                if (inputMode != GamePadInput.ActiveMode)
                {
                    inputMode    = GamePadInput.ActiveMode;
                    shared.dirty = true;
                }

                if (AuthUI.IsModalActive)
                {
                    return;
                }

                // Input focus and not pushing?
                if (parent.Active && CommandStack.Peek() == parent.commandMap && shared.pushOffset == 0.0f)
                {
                    GamePadInput pad = GamePadInput.GetGamePad0();

                    if (Actions.Cancel.WasPressed)
                    {
                        Actions.Cancel.ClearAllWasPressedState();

                        parent.Deactivate();
                        Foley.PlayShuffle();
                        shared.dirty = true;
                    }

                    bool moveLeft  = false;
                    bool moveRight = false;

                    // left
                    if (Actions.ComboLeft.WasPressedOrRepeat)
                    {
                        moveLeft = true;
                    }

                    // right
                    if (Actions.ComboRight.WasPressedOrRepeat)
                    {
                        moveRight = true;
                    }

                    //touch?
                    if (GamePadInput.ActiveMode == GamePadInput.InputMode.Touch)
                    {
                        TouchContact touch    = TouchInput.GetOldestTouch();
                        Vector2      touchHit = Vector2.Zero;

                        SwipeGestureRecognizer swipeGesture = TouchGestureManager.Get().SwipeGesture;
                        if (swipeGesture.WasSwiped() &&
                            swipeGesture.SwipeDirection == Boku.Programming.Directions.East)
                        {
                            moveLeft = true;
                        }
                        else if (swipeGesture.WasSwiped() &&
                                 swipeGesture.SwipeDirection == Boku.Programming.Directions.West)
                        {
                            moveRight = true;
                        }
                        else if (touch != null)
                        {
                            touchHit = touch.position;

                            if (shared.leftArrowBox.Touched(touch, touchHit))
                            {
                                moveLeft = true;
                            }

                            if (shared.rightArrowBox.Touched(touch, touchHit))
                            {
                                moveRight = true;
                            }

                            if (shared.backBox.Touched(touch, touchHit))
                            {
                                Actions.Cancel.ClearAllWasPressedState();

                                parent.Deactivate();
                                Foley.PlayShuffle();
                                shared.dirty = true;
                            }
                        }
                    }

                    // Mouse hit?
                    else if (GamePadInput.ActiveMode == GamePadInput.InputMode.KeyboardMouse)
                    {
                        Vector2 mouseHit = new Vector2(MouseInput.Position.X, MouseInput.Position.Y);

                        if (shared.leftArrowBox.LeftPressed(mouseHit))
                        {
                            moveLeft = true;
                        }

                        if (shared.rightArrowBox.LeftPressed(mouseHit))
                        {
                            moveRight = true;
                        }

                        if (shared.backBox.LeftPressed(mouseHit))
                        {
                            Actions.Cancel.ClearAllWasPressedState();

                            parent.Deactivate();
                            Foley.PlayShuffle();
                            shared.dirty = true;
                        }
                    }

                    if (moveLeft)
                    {
                        --shared.curScreen;
                        if (shared.curScreen < 0)
                        {
                            parent.Deactivate();
                        }
                        Foley.PlayShuffle();
                        shared.dirty = true;

                        shared.pushOffset = -BokuGame.ScreenSize.X;
                    }

                    if (moveRight)
                    {
                        ++shared.curScreen;
                        if (shared.curScreen >= shared.screenList.Count)
                        {
                            parent.Deactivate();
                        }
                        Foley.PlayShuffle();
                        shared.dirty = true;

                        shared.pushOffset = BokuGame.ScreenSize.X;
                    }
                }

                if (shared.dirty && shared.curScreen >= 0 && shared.curScreen < shared.screenList.Count)
                {
                    shared.prevTexture = shared.curTexture;

                    // Get the correct overlay image to use depending on input mode.
                    string name = GamePadInput.ActiveMode == GamePadInput.InputMode.GamePad ? shared.screenList[shared.curScreen].name : shared.screenList[shared.curScreen].mouseName;
                    shared.curTexture = BokuGame.Load <Texture2D>(BokuGame.Settings.MediaPath + @"Textures\HelpScreens\" + name);
                    shared.dirty      = false;

                    // Create a twitch to do the push.
                    TwitchManager.Set <float> set = delegate(float val, Object param) { shared.pushOffset = val; };
                    TwitchManager.CreateTwitch <float>(shared.pushOffset, 0.0f, set, 0.3f, TwitchCurve.Shape.EaseOut);
                }
            }   // end of Update()
        private void HandleTouchInput(Camera camera)
        {
            if (GamePadInput.ActiveMode != GamePadInput.InputMode.Touch)
            {
                return;
            }

            // Touch input
            // If the touch is over the menu, move the selection index to the item under the mouse.
            // On touch down, make the item (if any) under the touch the ClickedOnItem.
            // On tap, if the touch is still over the ClickedOnItem, activate it.  If not, just clear ClickedOnItem.
            TouchContact touch = TouchInput.GetOldestTouch();

            if (touch != null)
            {
                Vector2 hitUV = TouchInput.GetHitUV(touch.position, camera, ref invWorldMatrix, width, height, useRtCoords: useRtCoords);

                // See if we're over anything.  If so, set that item to being selected but only if we've moved the mouse.
                // This prevents the menu from feeling 'broken' if the mouse is over it and the user tries to use
                // the gamepad or keyboard.
                int touchItem = -1;
                for (int i = 0; i < itemList.Count; i++)
                {
                    if (itemList[i].UVBoundingBox != null && itemList[i].UVBoundingBox.Contains(hitUV))
                    {
                        // Only update the current in-focus element when the mouse moves.
                        if (true) // touch.position != touch.previousPosition)
                        {
                            CurIndex = i;
                        }
                        touchItem = i;
                    }
                }

                //if ( TouchInput.TapGesture.WasTapped() )
                if (TouchInput.IsTouched)
                {
                    if (touchItem != -1)
                    {
                        touch.TouchedObject = itemList[touchItem];
                    }
                }
                if (TouchGestureManager.Get().TapGesture.WasTapped())
                {
                    // Make sure we're still over the ClickedOnItem.
                    if (touchItem != -1 && touch.TouchedObject == itemList[touchItem])
                    {
                        ToggleState();
                    }
                }

                Vector2 hit = touch.position;
                if (useRtCoords)
                {
                    hit = ScreenWarp.ScreenToRT(hit);
                }

                if (changeBox.Touched(touch, hit))
                {
                    ToggleState();
                }
                if (backBox.Touched(touch, hit))
                {
                    Deactivate();
                    Foley.PlayBack();
                }

                // Allow Swipeto cycle through elements.
                // Allow scroll wheel to cycle through elements.
                SwipeGestureRecognizer swipeGesture = TouchGestureManager.Get().SwipeGesture;
                if (swipeGesture.WasSwiped())
                {
                    if (swipeGesture.SwipeDirection == Boku.Programming.Directions.South)
                    {
                        curIndex -= 6;
                        if (curIndex < 0)
                        {
                            curIndex = itemList.Count - 1;
                        }
                        Foley.PlayShuffle();
                    }
                    else if (swipeGesture.SwipeDirection == Boku.Programming.Directions.North)
                    {
                        curIndex += 6;
                        if (curIndex > (itemList.Count - 1))
                        {
                            curIndex = 0;
                        }
                        Foley.PlayShuffle();
                    }
                }

                // If we click outside of the list, close it treating it as if select was chosen.
                //if (TouchInput.TapGesture.WasTapped() && touch.touchedObject == null)
                if (TouchInput.WasTouched && touch.TouchedObject == null)
                {
                    Deactivate();
                }
            }
        }