예제 #1
0
 override public Capture ForceEndCapture(InputState input, CaptureData data)
 {
     Tool.CancelStroke();
     return(Capture.End);
 }
 public override Capture ForceEndCapture(InputState input, CaptureData data)
 {
     cockpit.ActiveCamera.SetTargetVisible(false);
     return(Capture.End);
 }
예제 #3
0
 override public Capture BeginCapture(InputState input, CaptureSide eSide)
 {
     Tool.BeginStroke(SceneRay(ref input, Context.Scene));
     return(Capture.Begin(this));
 }
예제 #4
0
 // [RMS] maybe we should do capture & forward in this class, then
 //   we have more control? but what for?
 bool supports_input_type(InputBehavior b, InputState i)
 {
     return((b.SupportedDevices & i.eDevice) != 0);
 }
 public override Capture BeginCapture(InputState input, CaptureSide eSide)
 {
     return(Capture.Begin(this, eSide, null));
 }
예제 #6
0
        public void DoCameraControl(FScene scene, fCamera mainCamera, InputState input)
        {
            if (bInAction == false)
            {
                if (Input.GetMouseButtonDown(0) || Input.GetMouseButtonDown(1) || Input.GetMouseButtonDown(2))
                {
                    curPos2D  = new Vector2(0, 0);
                    rcInfo    = new CameraManipulator.RateControlInfo(curPos2D);
                    bInAction = bUsingMouse = true;
                }
                else if (InputExtension.Get.GamepadRightShoulder.Down || InputExtension.Get.GamepadLeftShoulder.Down)
                {
                    curPos2D  = secondPos2D = new Vector2(0, 0);
                    rcInfo    = new CameraManipulator.RateControlInfo(curPos2D);
                    rcInfo2   = new CameraManipulator.RateControlInfo(secondPos2D);
                    bInAction = bUsingGamepad = true;
                }
            }

            if (bInAction && bUsingMouse)
            {
                Vector2f mouseDelta = InputExtension.Get.Mouse.PositionDelta;
                curPos2D.x += mouseDelta.x;
                curPos2D.y += mouseDelta.y;

                if (Input.GetMouseButton(0))
                {
                    mainCamera.Manipulator().SceneRateControlledFly(scene, mainCamera, curPos2D, rcInfo);
                }
                else if (Input.GetMouseButton(1))
                {
                    mainCamera.Manipulator().SceneRateControlledZoom(scene, mainCamera, curPos2D, rcInfo);
                }
                else if (Input.GetMouseButton(2))
                {
                    mainCamera.Manipulator().SceneRateControlledEgogentricPan(scene, mainCamera, curPos2D, rcInfo);
                }
            }


            if (bInAction && bUsingGamepad)
            {
                Vector2f stick1 = InputExtension.Get.GamepadLeftStick.Position;
                Vector2f stick2 = InputExtension.Get.GamepadRightStick.Position;
                float    dx     = stick1.x;
                float    dy     = stick1.y;
                float    dx2    = stick2.x;
                float    dy2    = stick2.y;
                curPos2D.x    += dx;
                curPos2D.y    += dy;
                secondPos2D.x += dx2;
                secondPos2D.y += dy2;
                float use_t = 3.0f;     // 5 == hard stop, 1 == bit too soft
                curPos2D.x    = MathUtil.SignedClamp(curPos2D.x, rcInfo.rampUpRadius);
                curPos2D.x    = Mathf.Lerp(curPos2D.x, 0, use_t * Time.deltaTime);
                curPos2D.y    = MathUtil.SignedClamp(curPos2D.y, rcInfo.rampUpRadius);
                curPos2D.y    = Mathf.Lerp(curPos2D.y, 0, use_t * Time.deltaTime);
                secondPos2D.x = MathUtil.SignedClamp(secondPos2D.x, rcInfo.rampUpRadius);
                secondPos2D.x = Mathf.Lerp(secondPos2D.x, 0, use_t * Time.deltaTime);
                secondPos2D.y = MathUtil.SignedClamp(secondPos2D.y, rcInfo.rampUpRadius);
                secondPos2D.y = Mathf.Lerp(secondPos2D.y, 0, use_t * Time.deltaTime);

                if (InputExtension.Get.GamepadRightShoulder.Down)
                {
                    mainCamera.Manipulator().SceneRateControlledZoom(scene, mainCamera, curPos2D, rcInfo);
                    secondPos2D[0] = 0;
                    mainCamera.Manipulator().SceneRateControlledEgogentricPan(scene, mainCamera, secondPos2D, rcInfo2);
                }
                else if (InputExtension.Get.GamepadLeftShoulder.Down)
                {
                    mainCamera.Manipulator().SceneRateControlledFly(scene, mainCamera, curPos2D, rcInfo);
                    mainCamera.Manipulator().SceneRateControlledEgogentricPan(scene, mainCamera, secondPos2D, rcInfo2);
                }
            }
        }
예제 #7
0
 override public Capture ForceEndCapture(InputState input, CaptureData data)
 {
     return(Capture.End);
 }
예제 #8
0
        public void DoCameraControl(FScene scene, fCamera mainCamera, InputState input)
        {
            Vector2f mouseDelta = InputExtension.Get.Mouse.PositionDelta;
            Vector2f stick1     = InputExtension.Get.GamepadLeftStick.Position;
            Vector2f stick2     = InputExtension.Get.GamepadRightStick.Position;
            float    dx         = mouseDelta.x + stick1.x;
            float    dy         = mouseDelta.y + stick1.y;
            float    dx2        = stick2.x;
            float    dy2        = stick2.y;

            if (Input.GetMouseButton(0))
            {
                if (input.bShiftKeyDown)
                {
                    if (UseAdaptive)
                    {
                        mainCamera.Manipulator().SceneAdaptivePan(scene, mainCamera, MousePanSpeed * dx, MousePanSpeed * dy);
                    }
                    else
                    {
                        mainCamera.Manipulator().ScenePan(scene, mainCamera, MousePanSpeed * dx, MousePanSpeed * dy);
                    }
                }
                else if (input.bCtrlKeyDown || input.bCmdKeyDown)
                {
                    if (UseAdaptive)
                    {
                        mainCamera.Manipulator().SceneAdaptiveZoom(scene, mainCamera, -MouseZoomSpeed * dy);
                    }
                    else
                    {
                        mainCamera.Manipulator().SceneZoom(scene, mainCamera, -MouseZoomSpeed * dy);
                    }
                }
                else
                {
                    mainCamera.Manipulator().SceneOrbit(scene, mainCamera, MouseOrbitSpeed * dx, MouseOrbitSpeed * dy);
                }
            }
            else if (Input.GetMouseButton(1))
            {
                if (UseAdaptive)
                {
                    mainCamera.Manipulator().SceneAdaptiveZoom(scene, mainCamera, -MouseZoomSpeed * dy);
                }
                else
                {
                    mainCamera.Manipulator().SceneZoom(scene, mainCamera, -MouseZoomSpeed * dy);
                }
            }
            else if (Input.GetMouseButton(2))
            {
                if (UseAdaptive)
                {
                    mainCamera.Manipulator().SceneAdaptivePan(scene, mainCamera, MousePanSpeed * dx, MousePanSpeed * dy);
                }
                else
                {
                    mainCamera.Manipulator().ScenePan(scene, mainCamera, MousePanSpeed * dx, MousePanSpeed * dy);
                }
            }
            else if (InputExtension.Get.GamepadRightShoulder.Down)
            {
                mainCamera.Manipulator().SceneZoom(scene, mainCamera, GamepadZoomSpeed * dy);
                mainCamera.Manipulator().ScenePan(scene, mainCamera, (-0.5f * GamepadPanSpeed * dx) + (-GamepadPanSpeed * dx2), -GamepadPanSpeed * dy2);
            }
            else if (InputExtension.Get.GamepadLeftShoulder.Down)
            {
                mainCamera.Manipulator().SceneOrbit(scene, mainCamera, GamepadOrbitSpeed * dx, GamepadOrbitSpeed * dy);
                mainCamera.Manipulator().ScenePan(scene, mainCamera, -GamepadPanSpeed * dx2, -GamepadPanSpeed * dy2);
            }
        }
예제 #9
0
 void TerminateHovers(InputState input)
 {
     inputBehaviors.EndHover(input);
 }
예제 #10
0
        void HandleInput_MouseOrGamepad()
        {
            // update mouse/gamepad cursor
            MouseController.Update();

            // have to do this after cursor update in case hotkey uses mouse position
            HandleKeyboardInput();

            // create our super-input object  (wraps all supported input types)
            InputState input = new InputState();

            input.Initialize_MouseGamepad(this);
            lastInputState = input;

            CameraInteractionState eCamState = (MouseCameraController != null)
                ? MouseCameraController.CheckCameraControls(input) : CameraInteractionState.Ignore;

            if (eCamState == CameraInteractionState.BeginCameraAction)
            {
                TerminateHovers(input);

                bInCameraControl = true;
                ActiveCamera.SetTargetVisible(true);
            }
            else if (eCamState == CameraInteractionState.EndCameraAction)
            {
                bInCameraControl = false;
                ActiveCamera.SetTargetVisible(false);
            }
            else if (bInCameraControl)
            {
                ActiveCamera.SetTargetVisible(true);
                MouseCameraController.DoCameraControl(Scene, ActiveCamera, input);
            }
            else
            {
                // run override behaviors
                overrideBehaviors.SendOverrideInputs(input);

                input.MouseGamepadCaptureActive = (captureMouse != null);

                if (InCaptureMouse)
                {
                    Capture cap = captureMouse.element.UpdateCapture(input, captureMouse.data);
                    if (cap.state == CaptureState.Continue)
                    {
                        // (carry on)
                    }
                    else if (cap.state == CaptureState.End)
                    {
                        captureMouse = null;
                    }
                }
                else
                {
                    // this is very simplistic...needs to be rewritten like space controllers

                    List <CaptureRequest> vRequests = new List <CaptureRequest>();
                    inputBehaviors.CollectWantsCapture(input, vRequests);
                    if (vRequests.Count > 0)
                    {
                        // end outstanding hovers
                        TerminateHovers(input);

                        // select one of the capture requests. technically we could end
                        //  up with none successfully Begin'ing, but behaviors should be
                        //  doing those checks in WantCapture, not BeginCapture !!
                        vRequests.OrderBy(x => x.element.Priority);
                        Capture capReq = null;
                        for (int i = 0; i < vRequests.Count && capReq == null; ++i)
                        {
                            if (vRequests[i].side != CaptureSide.Any)
                            {
                                continue;       // not possible in mouse paths...
                            }
                            // before we actually begin capture we will complete any text editing
                            // [RMS] perhaps this should be configurable for behavior? Some behaviors
                            // do not require this (eg view controls...)
                            completeTextEntryOnFocusChange();

                            Capture c = vRequests[i].element.BeginCapture(input, vRequests[i].side);
                            if (c.state == CaptureState.Begin)
                            {
                                capReq = c;
                            }
                        }

                        captureMouse = capReq;
                    }
                }

                // if we don't have a capture, do hover
                if (captureMouse == null)
                {
                    inputBehaviors.UpdateHover(input);
                }
            }
        }
예제 #11
0
        void HandleInput_Touch()
        {
            // update mouse/gamepad cursor
            MouseController.Update();

            // create our super-input object  (wraps all supported input types)
            InputState input = new InputState();

            input.Initialize_TouchInput(this);
            lastInputState = input;

            // run override behaviors
            overrideBehaviors.SendOverrideInputs(input);

            input.TouchCaptureActive = (captureTouch != null);

            // update left-capture
            if (captureTouch != null)
            {
                Capture cap = captureTouch.element.UpdateCapture(input, captureTouch.data);
                if (cap.state == CaptureState.Continue)
                {
                    // (carry on)
                }
                else if (cap.state == CaptureState.End)
                {
                    DebugUtil.Log(10, "[SceneController] released touch capture " + captureTouch.element.CaptureIdentifier);
                    captureTouch = null;
                }
            }

            // if we have a free device, check for capture.
            bool bCanCapture = (bInCameraControl == false);

            if (bCanCapture && captureTouch == null)
            {
                // collect up capture requests
                List <CaptureRequest> vRequests = new List <CaptureRequest>();
                inputBehaviors.CollectWantsCapture(input, vRequests);
                if (vRequests.Count > 0)
                {
                    // select one of the capture requests. technically we could end
                    //  up with none successfully Begin'ing, but behaviors should be
                    //  doing those checks in WantCapture, not BeginCapture !!
                    vRequests.OrderBy(x => x.element.Priority);
                    Capture capReq = null;
                    for (int i = 0; i < vRequests.Count && capReq == null; ++i)
                    {
                        // filter out invalid requests
                        //  (??)

                        // before we actually begin capture we will complete any text editing
                        // [RMS] perhaps this should be configurable for behavior? Some behaviors
                        // do not require this (eg view controls...)
                        completeTextEntryOnFocusChange();

                        Capture c = vRequests[i].element.BeginCapture(input, CaptureSide.Any);
                        if (c.state == CaptureState.Begin)
                        {
                            capReq = c;
                        }
                    }
                    if (capReq != null)
                    {
                        captureTouch = capReq;
                    }
                }
            }
        }
예제 #12
0
        void HandleInput_SpaceControllers()
        {
            // update cursors
            SpatialController.Update();
            MouseController.HideCursor();

            // have to do this after cursor update in case hotkey uses mouse position
            HandleKeyboardInput();

            // create our super-input object  (wraps all supported input types)
            InputState input = new InputState();

            input.Initialize_SpatialController(this);
            lastInputState = input;

            // run override behaviors
            overrideBehaviors.SendOverrideInputs(input);


            input.LeftCaptureActive  = (captureLeft != null);
            input.RightCaptureActive = (captureRight != null);

            // update left-capture
            if (captureLeft != null)
            {
                Capture cap = captureLeft.element.UpdateCapture(input, captureLeft.data);
                if (cap.state == CaptureState.Continue)
                {
                    // (carry on)
                }
                else if (cap.state == CaptureState.End)
                {
                    DebugUtil.Log(10, "[SceneController] released left capture " + captureLeft.element.CaptureIdentifier);
                    if (captureRight == captureLeft)
                    {
                        captureRight = null;        // if we are doing a dual-capture, we only want to end once!!
                    }
                    captureLeft = null;
                }
            }

            // update right-capture
            // if we are doing a both-capture, we only want to send update once
            if (captureRight != null && captureRight != captureLeft)
            {
                Capture cap = captureRight.element.UpdateCapture(input, captureRight.data);
                if (cap.state == CaptureState.Continue)
                {
                    // (carry on)
                }
                else if (cap.state == CaptureState.End)
                {
                    DebugUtil.Log(10, "[SceneController] released right capture " + captureRight.element.CaptureIdentifier);
                    captureRight = null;
                }
            }

            // if we have a free device, check for capture.
            bool bCanCapture = (bInCameraControl == false);

            if (bCanCapture && (captureLeft == null || captureRight == null))
            {
                // collect up capture requests
                List <CaptureRequest> vRequests = new List <CaptureRequest>();
                inputBehaviors.CollectWantsCapture(input, vRequests);
                if (vRequests.Count > 0)
                {
                    // end outstanding hovers
                    TerminateHovers(input);

                    // select one of the capture requests. technically we could end
                    //  up with none successfully Begin'ing, but behaviors should be
                    //  doing those checks in WantCapture, not BeginCapture !!
                    vRequests.OrderBy(x => x.element.Priority);
                    Capture capReq = null;
                    for (int i = 0; i < vRequests.Count && capReq == null; ++i)
                    {
                        // filter out invalid requests
                        CaptureSide eUseSide = vRequests[i].side;
                        if (eUseSide == CaptureSide.Any)        // replace Any with Both. Does that make sense??
                        {
                            eUseSide = CaptureSide.Both;
                        }
                        if ((eUseSide == CaptureSide.Left || eUseSide == CaptureSide.Both) &&
                            captureLeft != null)
                        {
                            continue;
                        }
                        if ((eUseSide == CaptureSide.Right || eUseSide == CaptureSide.Both) &&
                            captureRight != null)
                        {
                            continue;
                        }

                        Capture c = vRequests[i].element.BeginCapture(input, eUseSide);
                        if (c.state == CaptureState.Begin)
                        {
                            capReq = c;
                        }
                    }

                    if (capReq != null)
                    {
                        // technically we only should terminate hover on capture controller,
                        // but that seems really hard. This will clear hovers but they will
                        // come back next frame. Perhaps revisit if this is causing flicker...
                        TerminateHovers(input);

                        // [RMS] most of this checking is redundant now, but leaving because of debug logging
                        if (capReq.data.which == CaptureSide.Left)
                        {
                            if (captureLeft != null)
                            {
                                DebugUtil.Warning("[SceneController.HandleInput_SpaceControllers] received Capture request for Left side from {0}, but already capturing! Ignoring.", capReq.element.CaptureIdentifier);
                            }
                            else
                            {
                                captureLeft = capReq;
                                DebugUtil.Log(10, "[SceneController] began left-capture" + captureLeft.element.CaptureIdentifier);
                            }
                        }
                        else if (capReq.data.which == CaptureSide.Right)
                        {
                            if (captureRight != null)
                            {
                                DebugUtil.Warning("[SceneController.HandleInput_SpaceControllers] received Capture request for Right side from {0}, but already capturing! Ignoring.", capReq.element.CaptureIdentifier);
                            }
                            else
                            {
                                captureRight = capReq;
                                DebugUtil.Log(10, "[SceneController] began right-capture" + captureRight.element.CaptureIdentifier);
                            }
                        }
                        else if (capReq.data.which == CaptureSide.Both || capReq.data.which == CaptureSide.Any)
                        {
                            if (captureLeft != null || captureRight != null)
                            {
                                DebugUtil.Warning("[SceneController.HandleInput_SpaceControllers] received Capture request for both sides from {0}, but already capturing! Ignoring.", capReq.element.CaptureIdentifier);
                            }
                            else
                            {
                                captureLeft = captureRight = capReq;
                                DebugUtil.Log(10, "[SceneController] began both-capture " + captureLeft.element.CaptureIdentifier);
                            }
                        }
                    }
                }
            }

            // update hover if we have a free device
            if (captureLeft == null || captureRight == null)
            {
                inputBehaviors.UpdateHover(input);
            }
        }