// Update() is called once per frame
    void Update()
    {
        // Input.GetKeyDown() is true if the key gets pressed within that frame
        EscapeDown = Input.GetKeyDown(KeyCode.Escape);

        BackSpaceDown = Input.GetKeyDown(KeyCode.Backspace);
        EnterKeyDown  = Input.GetKeyDown(KeyCode.Return);

        F1KeyDown = Input.GetKeyDown(KeyCode.F1);

        RightMouseDown = Input.GetKeyDown(KeyCode.Mouse1);
        PKeyDown       = Input.GetKey(KeyCode.P);

        UpArrow   = Input.GetKey(KeyCode.UpArrow);
        DownArrow = Input.GetKey(KeyCode.DownArrow);

        LeftArrowDown  = Input.GetKeyDown(KeyCode.LeftArrow);
        RightArrowDown = Input.GetKeyDown(KeyCode.RightArrow);

        // Quit Application
        if (EscapeDown)
        {
            Application.Quit();
        }

        // Enable or Disable user controller viewing
        if (BackSpaceDown)
        {
            MouseAndControllerLook.enabled = false;
        }
        if (EnterKeyDown)
        {
            MouseAndControllerLook.enabled = true;
        }

        // Enable/disable all inputs except movement from the controller
        if (F1KeyDown)
        {
            ControllerInput.movementOnly = !ControllerInput.movementOnly;
        }

        // Pause or unpause the simulation
        if (RightMouseDown || PKeyDown)
        {
            NBodySim.TogglePause();
        }

        // Change Speed Scale (i.e. highlight precision)
        if (UpArrow)
        {
            NBodySim.IncreaseSpeedScale();
        }
        if (DownArrow)
        {
            NBodySim.DecreaseSpeedScale();
        }

        // Cycle Data files
        if (LeftArrowDown)
        {
            CycleICs.PreviousInitialContdition();
        }
        if (RightArrowDown)
        {
            CycleICs.NextInitialContdition();
        }
    }
    void Update()
    {
        LeftStickX = -Input.GetAxis("Horizontal"); // left is +1, right is -1
        LeftStickY = -Input.GetAxis("Vertical");   // up is +1, down is -1

        // GetKey = active while held; GetKeyDown = active during the frame in which the button is pressed.
        // See http://wiki.unity3d.com/index.php?title=Xbox360Controller for button mappings (diagram here http://wiki.unity3d.com/index.php/File:X360Controller2.png)
        aButton         = Input.GetKey(KeyCode.Joystick1Button0);
        bButtonDown     = Input.GetKeyDown(KeyCode.Joystick1Button1);
        xButtonDown     = Input.GetKeyDown(KeyCode.Joystick1Button2);
        yButtonDown     = Input.GetKeyDown(KeyCode.Joystick1Button3);
        LeftBumper      = Input.GetKey(KeyCode.Joystick1Button4);
        RightBumper     = Input.GetKey(KeyCode.Joystick1Button5);
        StartButtonDown = Input.GetKeyDown(KeyCode.JoystickButton7);

        // right trigger is represented by range -1 to 0, left trigger by range 0 to 1
        Triggers = -Input.GetAxis("Triggers");


        // Movement
        forward = _Camera.transform.TransformDirection(Vector3.forward);
        left    = _Camera.transform.TransformDirection(Vector3.left);

        up = _Camera.transform.TransformDirection(Vector3.up);

        speed = (aButton) ? moveSpeed * 1.7f : moveSpeed;
        if (LeftStickY != 0.0f)
        {
            transform.Translate(LeftStickY * forward * speed * Time.deltaTime, Space.World);
        }
        if (LeftStickX != 0.0f)
        {
            transform.Translate(LeftStickX * left * speed * Time.deltaTime, Space.World);
        }
        if (Triggers != 0.0f)
        {
            transform.Translate(Triggers * up * speed * Time.deltaTime, Space.World);
        }

        if (!movementOnly)
        {
            // Pause or unpause the simulation
            if (StartButtonDown)
            {
                NBodySim.TogglePause();
            }

            // Change Speed Scale (i.e. highlight precision)
            if (RightBumper)
            {
                NBodySim.IncreaseSpeedScale();
            }
            if (LeftBumper)
            {
                NBodySim.DecreaseSpeedScale();
            }

            // Cycle Initial conditions
            if (bButtonDown)
            {
                CycleICs.PreviousInitialContdition();
            }
            if (xButtonDown)
            {
                CycleICs.NextInitialContdition();
            }
        }
    }