예제 #1
0
        public bool GetCommandHeld(SketchCommands rCommand)
        {
            // Here you can limit the given command to a specific scope, e.g. only allowing it on the Wand
            // or Brush, but the the controller info is responsible for how that command is mapped to the
            // hardware.

            switch (rCommand)
            {
            case SketchCommands.Confirm:
            case SketchCommands.Cancel:
            case SketchCommands.Share:
            case SketchCommands.Trash:
                return(Brush.GetCommandHeld(rCommand));

            case SketchCommands.DuplicateSelection:
                if (SketchControlsScript.m_Instance.OneHandGrabController != InputManager.ControllerName.None)
                {
                    return(Controllers[(int)SketchControlsScript.m_Instance.OneHandGrabController]
                           .GetCommandHeld(rCommand));
                }
                else
                {
                    return(Brush.GetCommandHeld(rCommand));
                }
            }

            return(false);
        }
예제 #2
0
        public ControllerName GetDominantController(SketchCommands rCommand)
        {
            switch (rCommand)
            {
            case SketchCommands.Activate:
                for (int i = 0; i < (int)ControllerName.Num; ++i)
                {
                    if (m_ControllerInfos[i].GetVrInput(VrInput.Trigger))
                    {
                        return((ControllerName)i);
                    }
                }
                break;

            case SketchCommands.LockToController:
                for (int i = 0; i < (int)ControllerName.Num; ++i)
                {
                    var controller = (ControllerName)i;
                    if (m_ControllerInfos[i].GetControllerGrip())
                    {
                        return(controller);
                    }
                }
                break;
            }

            return(ControllerName.Num);
        }
예제 #3
0
        /// Returns true if the current command *just* became active (rising-edge trigger).
        public bool GetCommandUp(SketchCommands rCommand)
        {
            if (App.Config.m_IsExperimental)
            {
                switch (rCommand)
                {
                case SketchCommands.AltActivate:
                case SketchCommands.Activate:
                    return(IsTriggerUp());

                case SketchCommands.RewindTimeline:
                    return(GetVrInputUp(VrInput.Button06 /*quad_down*/));

                case SketchCommands.AdvanceTimeline:
                    return(GetVrInputUp(VrInput.Button05 /*quad_up*/));

                case SketchCommands.TimelineHome:
                    return(IsTrigger() && GetVrInputUp(VrInput.Button06 /*quad_down*/));

                case SketchCommands.TimelineEnd:
                    return(IsTrigger() && GetVrInputUp(VrInput.Button05 /*quad_up*/));

                case SketchCommands.Reset:
                    return(GetVrInputUp(VrInput.Button05 /*quad_up*/));

                case SketchCommands.Undo:
                    return(GetVrInputUp(VrInput.Button01 /*half_left*/));

                case SketchCommands.Redo:
                    return(GetVrInputUp(VrInput.Button02 /*half_right*/));

                case SketchCommands.Teleport:
                    return(IsTriggerUp());

#if (UNITY_EDITOR || EXPERIMENTAL_ENABLED)
                case SketchCommands.ShowPinCushion:
#endif
                case SketchCommands.ToggleDefaultTool:
                    return(GetVrInputUp(VrInput.Button03 /*app button*/));

                case SketchCommands.MenuContextClick:
                    return(GetVrInputUp(VrInput.Button04 /*full-pad-button*/));

                case SketchCommands.WorldTransformReset:
                    return(GetVrInputUp(VrInput.Button04 /*full-pad-button*/));

                case SketchCommands.PinWidget:
                    return(IsTriggerUp());

                case SketchCommands.DuplicateSelection:
                    return(GetVrInputUp(VrInput.Button04));

                case SketchCommands.ToggleSelection:
                    return(GetVrInputUp(VrInput.Button04));
                }
            }
            return(false);
        }
예제 #4
0
        public bool GetCommand(SketchCommands rCommand)
        {
            // Here you can limit the given command to a specific scope, e.g. only allowing it on the Wand
            // or Brush, but the the controller info is responsible for how that command is mapped to the
            // hardware.

            KeyboardShortcut?shortcut   = MapCommandToKeyboard(rCommand);
            bool             isDemoMode = DemoManager.m_Instance.DemoModeEnabled;

            switch (rCommand)
            {
            case SketchCommands.Activate:
                return(Brush.GetCommand(rCommand) || (!isDemoMode && GetMouseButton(0)));

            case SketchCommands.AltActivate:
                return(GetMouseButton(1) || Wand.GetCommand(rCommand));

            case SketchCommands.LockToHead:
                return(GetKeyboardShortcut(shortcut.Value));

            case SketchCommands.PivotRotation:
                return(GetKeyboardShortcut(shortcut.Value));

            case SketchCommands.WandRotation:
                return(Wand.GetCommand(rCommand));

            case SketchCommands.LockToController:
                return(Wand.GetCommand(rCommand) || Brush.GetCommand(rCommand));

            case SketchCommands.Scale:
                return(GetKeyboardShortcut(shortcut.Value) || Brush.GetCommand(rCommand));

            case SketchCommands.Sensitivity:
                return(Mathf.Abs(Input.GetAxis("Mouse ScrollWheel")) > m_InputThreshold);

            case SketchCommands.Panic:
                return(GetMouseButton(1) || Wand.GetCommand(rCommand));

            case SketchCommands.MultiCamSelection:
                return(Brush.GetCommand(rCommand));

            case SketchCommands.ShowPinCushion:
                return(Brush.GetCommand(rCommand));

            case SketchCommands.DuplicateSelection:
                return(Brush.GetCommand(rCommand));

            case SketchCommands.Undo:
            case SketchCommands.Redo:
                return(Wand.GetCommand(rCommand));

            case SketchCommands.Fly:
                return(Brush.GetCommand(rCommand));
            }


            return(false);
        }
예제 #5
0
        /// Returns true if the given command was held for longer than the threshold.
        /// To get the current progress, see GetCommandHoldProgress.
        public bool GetCommandHeld(SketchCommands rCommand)
        {
            VrInput?vrInput = GetCommandHoldInput(rCommand);

            if (!vrInput.HasValue)
            {
                return(false);
            }
            return(UpdateCommandHold(vrInput.Value));
        }
예제 #6
0
        public bool GetCommandDown(SketchCommands rCommand)
        {
            // Here you can limit the given command to a specific scope, e.g. only allowing it on the Wand
            // or Brush, but the the controller info is responsible for how that command is mapped to the
            // hardware.

            KeyboardShortcut?shortcut = MapCommandToKeyboard(rCommand);

            switch (rCommand)
            {
            case SketchCommands.Activate:
                return(GetMouseButtonDown(0) || Brush.GetCommandDown(rCommand));

            case SketchCommands.RewindTimeline:
            case SketchCommands.AdvanceTimeline:
            case SketchCommands.TimelineHome:
            case SketchCommands.TimelineEnd:
            case SketchCommands.Reset:
            case SketchCommands.Undo:
            case SketchCommands.Redo:
                return(GetKeyboardShortcutDown(shortcut.Value) || Wand.GetCommandDown(rCommand));

            case SketchCommands.DuplicateSelection:
                return((SketchControlsScript.m_Instance.OneHandGrabController != ControllerName.None &&
                        Controllers[(int)SketchControlsScript.m_Instance.OneHandGrabController]
                        .GetCommandDown(rCommand)) ||
                       Brush.GetCommandDown(rCommand));

            // Keyboard only:
            case SketchCommands.Delete:
            case SketchCommands.Abort:
                return(GetKeyboardShortcutDown(shortcut.Value));

            // Brush only
            case SketchCommands.Teleport:
            case SketchCommands.ToggleDefaultTool:
            case SketchCommands.MenuContextClick:
            case SketchCommands.ToggleSelection:
                return(Brush.GetCommandDown(rCommand));

            // Misc
            case SketchCommands.SwapControls:
                return(HasSwapGestureCompleted());

            case SketchCommands.AltActivate:
                return(GetMouseButtonDown(1) || Wand.GetCommandDown(rCommand));

#if (UNITY_EDITOR || EXPERIMENTAL_ENABLED)
            case SketchCommands.ShowPinCushion:
                return(Brush.GetCommandDown(rCommand));
#endif
            }

            return(false);
        }
예제 #7
0
        /// Returns true if the current command *just* became active (rising-edge trigger).
        public bool GetCommandDown(SketchCommands rCommand)
        {
            switch (rCommand)
            {
            case SketchCommands.AltActivate:
            case SketchCommands.Activate:
                return(IsTriggerDown());

            case SketchCommands.RewindTimeline:
                return(GetVrInputDown(VrInput.Button06 /*quad_down*/));

            case SketchCommands.AdvanceTimeline:
                return(GetVrInputDown(VrInput.Button05 /*quad_up*/));

            case SketchCommands.TimelineHome:
                return(IsTrigger() && GetVrInputDown(VrInput.Button06 /*quad_down*/));

            case SketchCommands.TimelineEnd:
                return(IsTrigger() && GetVrInputDown(VrInput.Button05 /*quad_up*/));

            case SketchCommands.Reset:
                return(GetVrInputDown(VrInput.Button05 /*quad_up*/));

            case SketchCommands.Undo:
                return(GetVrInputDown(VrInput.Button01 /*half_left*/));

            case SketchCommands.Redo:
                return(GetVrInputDown(VrInput.Button02 /*half_right*/));

            case SketchCommands.Teleport:
                return(IsTriggerDown());

            case SketchCommands.ShowPinCushion:
            case SketchCommands.ToggleDefaultTool:
                return(GetVrInputDown(VrInput.Button03 /*app button*/));

            case SketchCommands.MenuContextClick:
                return(GetVrInputDown(VrInput.Button04 /*full-pad-button*/));

            case SketchCommands.WorldTransformReset:
                return(GetVrInputDown(VrInput.Button04 /*full-pad-button*/));

            case SketchCommands.PinWidget:
                return(IsTriggerDown());

            case SketchCommands.DuplicateSelection:
                return(GetVrInputDown(VrInput.Button04));

            case SketchCommands.ToggleSelection:
                return(GetVrInputDown(VrInput.Button04));
            }
            return(false);
        }
예제 #8
0
        // -------------------------------------------------------------------------------------------- //
        // Command/CommandDown support
        // -------------------------------------------------------------------------------------------- //
        // Maps commands to VR Inputs and returns true if the input is actively pressed

        /// Returns true if the current command is active (e.g. the button is being pressed).
        public bool GetCommand(SketchCommands rCommand)
        {
            switch (rCommand)
            {
            case SketchCommands.Activate:
                return(IsTrigger());

            case SketchCommands.AltActivate:
                return(IsTrigger());

            case SketchCommands.WandRotation:
                return(GetPadTouch() || GetThumbStickTouch());

            case SketchCommands.LockToController:
                return(GetControllerGrip());

            case SketchCommands.Scale:
                return(GetPadTouch() || GetThumbStickTouch());

            case SketchCommands.Panic:
                return(IsTrigger());

            case SketchCommands.MultiCamSelection:
                return(GetVrInput(VrInput.Button04 /*full-pad-button*/));

            case SketchCommands.MenuContextClick:
                return(GetVrInput(VrInput.Button04 /*full-pad-button*/));

            case SketchCommands.ShowPinCushion:
                return(GetVrInput(VrInput.Button03));

            case SketchCommands.DuplicateSelection:
                return(GetVrInput(VrInput.Button04));

            case SketchCommands.Undo:
                return(GetVrInput(VrInput.Button01 /*half_left*/));

            case SketchCommands.Redo:
                return(GetVrInput(VrInput.Button02 /*half_right*/));

            case SketchCommands.Fly:
                return(IsTrigger());
            }

            return(false);
        }
예제 #9
0
        private KeyboardShortcut?MapCommandToKeyboard(SketchCommands rCommand)
        {
            // We could cache this into a map, if needed.
            KeyboardShortcut?value;

            if (!m_SketchToKeyboardCommandMap.TryGetValue((int)rCommand, out value))
            {
                try {
                    value = (KeyboardShortcut)Enum.Parse(typeof(KeyboardShortcut),
                                                         rCommand.ToString(),
                                                         ignoreCase: false);
                } catch (ArgumentException) {
                    value = null;
                }
                m_SketchToKeyboardCommandMap.Add((int)rCommand, value);
            }
            return(value);
        }
예제 #10
0
        // -------------------------------------------------------------------------------------------- //
        // Command/Input Held support
        // -------------------------------------------------------------------------------------------- //
        // Useful in scenarios where a button should be held for a timeout period, e.g. when sharing
        // videos or trashing gifs.

        /// Helper function to translate commands to VR Inputs.
        public VrInput?GetCommandHoldInput(SketchCommands rCommand)
        {
            switch (rCommand)
            {
            case SketchCommands.Confirm:
                return(VrInput.Button01 /*half_left*/);

            case SketchCommands.Cancel:
                return(VrInput.Button02 /*half_right*/);

            case SketchCommands.Share:
                return(VrInput.Button04 /*full pad*/);

            case SketchCommands.Trash:
                return(VrInput.Button04 /*full pad*/);

            case SketchCommands.DuplicateSelection:
                return(VrInput.Button04 /*full pad*/);
            }

            return(null);
        }