// Update is called once per frame
    void Update()
    {
        device = SteamVR_Controller.Input((int)trackedObj.index);

        if (objectMenuManager == null)
        {
            return;
        }

        if (device.GetTouchDown(SteamVR_Controller.ButtonMask.Touchpad))
        {
            objectMenuManager.ShowMenu();
            //touchLast = device.GetAxis(Valve.VR.EVRButtonId.k_EButton_SteamVR_Touchpad).x;
        }
        if (device.GetPressDown(SteamVR_Controller.ButtonMask.Touchpad))
        {
            // if the user presses the left half of the touchpad
            if (device.GetAxis(Valve.VR.EVRButtonId.k_EButton_SteamVR_Touchpad).x < 0)
            {
                //Debug.Log("pressing on" + device.GetAxis(Valve.VR.EVRButtonId.k_EButton_SteamVR_Touchpad).x);
                SwipeLeft();
                hasPressedLeft  = true;
                hasPressedRight = false;
            }

            // if the user presses the right half of the touchpad
            if (device.GetAxis(Valve.VR.EVRButtonId.k_EButton_SteamVR_Touchpad).x > 0)
            {
                //Debug.Log("pressing on" + device.GetAxis(Valve.VR.EVRButtonId.k_EButton_SteamVR_Touchpad).x);
                SwipeRight();
                hasPressedLeft  = false;
                hasPressedRight = true;
            }


            //only accessing x horizontal value of touchpad

            /*
             * touchCurrent = device.GetAxis(Valve.VR.EVRButtonId.k_EButton_SteamVR_Touchpad).x;
             * distance = touchCurrent - touchLast;
             * touchLast = touchCurrent;
             * swipeSum += distance;
             */


/*
 *          if (!hasSwipedRight)
 *          {
 *              if (swipeSum > 0.5f)
 *              {
 *                  swipeSum = 0;
 *                  SwipeRight();
 *                  hasSwipedRight = true;
 *                  hasSwipedLeft = false;
 *              }
 *          }
 *          if(!hasSwipedLeft)
 *          {
 *              if (swipeSum < -0.5f)
 *              {
 *                  swipeSum = 0;
 *                  SwipeLeft();
 *                  hasSwipedRight = false;
 *                  hasSwipedLeft = true;
 *
 *              }
 *          }
 */
        }
        if (device.GetTouchUp(SteamVR_Controller.ButtonMask.Touchpad))
        {
            swipeSum        = 0;
            touchCurrent    = 0;
            touchLast       = 0;
            hasPressedLeft  = false;
            hasPressedRight = false;
            objectMenuManager.HideMenu();
        }

        if (device.GetPressDown(SteamVR_Controller.ButtonMask.Trigger) && objectMenuManager.GetMenuActiveState() == true)
        {
            // spawn object selected by menu
            SpawnObject();
        }
    }