Exemplo n.º 1
0
        public static EDControlBindings ParseFile(string customBindingsOptionsPath)
        {
            var bindings = new EDControlBindings();

            var doc = XDocument.Load(customBindingsOptionsPath);

            foreach (var control in doc.Descendants())
            {
                if (Enum.IsDefined(typeof(EDControlButton), control.Name.LocalName))
                {
                    var controlButton = (EDControlButton)Enum.Parse(typeof(EDControlButton), control.Name.LocalName);

                    var controlBinding = new ControlButtonBinding
                    {
                        Primary   = ParseControlBinding(control, "Primary"),
                        Secondary = ParseControlBinding(control, "Secondary")
                    };

                    if (!bindings.buttonBindings.ContainsKey(controlButton))
                    {
                        bindings.buttonBindings.Add(controlButton, controlBinding);
                    }
                }

                // @todo Parse axis and options if we ever have a use for them
            }

            return(bindings);
        }
Exemplo n.º 2
0
        protected override Action NavigateDirection(Direction direction, ActionsController.DirectionAction button)
        {
            if (button == ActionsController.DirectionAction.D1)
            {
                // @fixme On the Vive D1 is trackpad press which works for category switch
                //        however this may be different for Touch/WMR/Knuckles.
                //        This should probably be dealt with by adding Menu Up/Down/Left/Right
                //        and Menu Select, Menu Back, Menu Category Prev/Next as actions
                //        in SteamVR Input when we implement it.
                if (specialDirectionControlButtons.ContainsKey(direction))
                {
                    var control = specialDirectionControlButtons[direction];
                    return(CallbackPress(EDControlBindings.GetControlButton(control)));
                }
            }
            else
            {
                if (directionControlButtons.ContainsKey(direction))
                {
                    var control = directionControlButtons[direction];
                    return(CallbackPress(EDControlBindings.GetControlButton(control)));
                }
            }

            return(() => { });
        }
Exemplo n.º 3
0
        protected override Unpress Activate()
        {
            var      control         = controlButtonAsset.GetControl();
            KeyCombo?defaultKeycombo = controlButtonAsset.GetDefaultKeycombo();
            var      unpress         = CallbackPress(EDControlBindings.GetControlButton(control, defaultKeycombo));

            return(() => unpress());
        }
        protected override Action NavigateDirection(Direction direction)
        {
            if (directionControlButtons.ContainsKey(direction))
            {
                var control = directionControlButtons[direction];
                return(CallbackPress(EDControlBindings.GetControlButton(control)));
            }

            return(() => { });
        }
Exemplo n.º 5
0
        private DirectionActionChangeUnpressHandler OnSteppedZoom(DirectionActionChange pEv)
        {
            if (steppedZoomDirectionBindings.ContainsKey(pEv.direction))
            {
                var button  = steppedZoomDirectionBindings[pEv.direction];
                var unpress = CallbackPress(EDControlBindings.GetControlButton(button));
                return((uEv) => unpress());
            }

            return((uEv) => { });
        }
        protected override void Back()
        {
            var bindings = EDStateManager.instance.controlBindings;

            if (bindings != null && bindings.HasKeyboardKeybinding(EDControlButton.GalaxyMapOpen))
            {
                // @fixme See if it's reasonable to swap this with a CallbackPress using pattern like Select()
                EDControlBindings.GetControlButton(EDControlButton.UI_Back)?.Send();
            }
            else
            {
                SendEscape();
            }
        }
        protected override void Back()
        {
            var bindings = EDStateManager.instance.controlBindings;

            if (bindings != null && bindings.HasKeyboardKeybinding(EDControlButton.GalaxyMapOpen))
            {
                // On the Galaxy map this will exit
                // On the System map/orrery this will go to the galaxy map, from where you can exit
                EDControlBindings.GetControlButton(EDControlButton.GalaxyMapOpen)?.Send();
            }
            else
            {
                SendEscape();
            }
        }
Exemplo n.º 8
0
        /**
         * Read the user's Custom.3.0.binds and parse the control bindings from it
         */
        private void LoadControlBindings()
        {
            foreach (var bindingsPath in CustomBindingsOptionsPaths)
            {
                if (File.Exists(bindingsPath))
                {
                    UnityEngine.Debug.LogFormat("Reading keyboard bindings from {0}", bindingsPath);
                    controlBindings = EDControlBindings.ParseFile(bindingsPath);
                    return;
                }
            }

            UnityEngine.Debug.LogWarning("No custom bindings found for ED, using an empty controls list");
            controlBindings = EDControlBindings.Empty();
        }
Exemplo n.º 9
0
        protected ActionChangeUnpressHandler OnTargetCurrentSignal(ActionChange pEv)
        {
            var unpress = CallbackPress(EDControlBindings.GetControlButton(EDControlButton.ExplorationFSSTarget));

            return((uEv) => unpress());
        }
Exemplo n.º 10
0
        protected ActionChangeUnpressHandler OnExit(ActionChange pEv)
        {
            var unpress = CallbackPress(EDControlBindings.GetControlButton(EDControlButton.ExplorationFSSQuit));

            return((uEv) => unpress());
        }
Exemplo n.º 11
0
        protected ActionChangeUnpressHandler OnNestedToggle(ActionChange pEv)
        {
            var unpress = CallbackPress(EDControlBindings.GetControlButton(EDControlButton.UI_Toggle));

            return((uEv) => unpress());
        }
        protected ActionChangeUnpressHandler OnTabNext(ActionChange pEv)
        {
            var unpress = CallbackPress(EDControlBindings.GetControlButton(EDControlButton.CycleNextPanel));

            return((uEv) => unpress());
        }
 protected override Action Select()
 {
     return(CallbackPress(EDControlBindings.GetControlButton(EDControlButton.UI_Select)));
 }
        protected override Unpress Activate()
        {
            var unpress = CallbackPress(EDControlBindings.GetControlButton(buttonBinding, null));

            return(() => unpress());
        }