Beispiel #1
0
 public override void Activate()
 {
     if (!KeyboardInterface.Send("Key_Escape"))
     {
         Debug.LogWarning("Could not send keypress Key_Escape, did not understand the key");
     }
 }
Beispiel #2
0
 private void NavigateDirection(Direction direction)
 {
     if (directionKeys.ContainsKey(direction))
     {
         var key = directionKeys[direction];
         KeyboardInterface.Send(key);
     }
 }
        private IEnumerator WhileTouchingTouchpadAxis0(uint deviceIndex, Hand hand, short coroutineId)
        {
            var vr    = OpenVR.System;
            var state = new VRControllerState_t();
            var size  = (uint)System.Runtime.InteropServices.Marshal.SizeOf(typeof(VRControllerState_t));

            bool    started   = false;
            Vector2 anchorPos = Vector2.zero;

            while (vr.GetControllerState(deviceIndex, ref state, size))
            {
                var pos = ControllerAxisToVector2(state.rAxis0);
                if (started)
                {
                    var       deltaPos  = pos - anchorPos;
                    float     magnitude = 0;
                    Direction dir       = GetLargestVectorDirection(deltaPos, ref magnitude);
                    if (magnitude >= trackpadDirectionInterval)
                    {
                        anchorPos = pos;
                        var btn = new DirectionActionsPress(hand, DirectionAction.D2, dir, true);
                        DirectionActionPress.Send(btn);

                        // Wait long enough for ED to recieve any keypresses
                        yield return(KeyboardInterface.WaitForKeySent());

                        new DirectionActionsPress(hand, DirectionAction.D2, dir, false);
                        DirectionActionUnpress.Send(btn);
                    }
                }
                else
                {
                    started   = true;
                    anchorPos = pos;
                }

                yield return(null);

                if (trackpadTouchingCoroutineId[hand] != coroutineId)
                {
                    yield break;
                }
            }

            Debug.LogWarningFormat("Failed to get controller state for device {0}", deviceIndex);
        }
        public static IKeyPress GetControlButton(EDControlButton control, KeyboardInterface.KeyCombo?defaultKeycombo = null)
        {
            var bindings = EDStateManager.instance.controlBindings;

            if (bindings == null)
            {
                Debug.LogWarning("Control bindings not loaded");
                return(null);
            }
            else
            {
                var      keyBinding = bindings.GetKeyboardKeybinding(control);
                string   key        = "";
                string[] modifiers  = null;
                if (keyBinding == null)
                {
                    if (defaultKeycombo == null)
                    {
                        // XXX: Make this an error and add a warning that emits even when there is a default keycombo
                        Debug.LogWarningFormat("The \"{0}\" Elite Dangerous control has no keyboard binding and there is no default keycombo to fallback to", Enum.GetName(typeof(EDControlButton), control));
                        return(null);
                    }
                }
                else
                {
                    key       = keyBinding.Value.Key;
                    modifiers = keyBinding.Value.Modifiers.Select(mod => mod.Key).ToArray();
                }

                // @todo Implement this as a press and release
                var keyPress = KeyboardInterface.Key(key, modifiers);
                if (keyPress == null)
                {
                    Debug.LogWarningFormat(
                        "Could not send keypress {0}, did not understand one or more of the keys",
                        KeyboardInterface.KeyComboDebugString(key, modifiers));
                }

                return(keyPress);
            }
        }
        public static IKeyPress GetControlButton(EDControlButton control, KeyboardInterface.KeyCombo?defaultKeycombo = null)
        {
            var bindings = EDStateManager.instance.controlBindings;

            if (bindings == null)
            {
                Debug.LogWarning("Control bindings not loaded");
                return(null);
            }
            else
            {
                var      keyBinding = bindings.GetKeyboardKeybinding(control);
                string   key        = "";
                string[] modifiers  = null;
                if (keyBinding == null)
                {
                    if (defaultKeycombo == null)
                    {
                        Debug.LogWarningFormat("Control was not bound and there is no default keycombo to fallback to");
                        return(null);
                    }
                }
                else
                {
                    key       = keyBinding.Value.Key;
                    modifiers = keyBinding.Value.Modifiers.Select(mod => mod.Key).ToArray();
                }

                // @todo Implement this as a press and release
                var keyPress = KeyboardInterface.Key(key, modifiers);
                if (keyPress == null)
                {
                    Debug.LogWarningFormat(
                        "Could not send keypress {0}, did not understand one or more of the keys",
                        KeyboardInterface.KeyComboDebugString(key, modifiers));
                }

                return(keyPress);
            }
        }
Beispiel #6
0
        public override void Activate()
        {
            var control = controlButtonAsset.GetControl();

            var bindings = EDStateManager.instance.controlBindings;

            if (bindings == null)
            {
                Debug.LogWarning("Control bindings not loaded");
            }
            else
            {
                var      keyBinding = bindings.GetKeyboardKeybinding(control);
                string   key        = "";
                string[] modifiers  = null;
                if (keyBinding == null)
                {
                    if (!controlButtonAsset.GetDefaultKeycombo(ref key, ref modifiers))
                    {
                        Debug.LogWarningFormat("Control was not bound and there is no default keycombo to fallback to");
                        return;
                    }
                }
                else
                {
                    key       = keyBinding.Value.Key;
                    modifiers = keyBinding.Value.Modifiers.Select(mod => mod.Key).ToArray();
                }

                if (!KeyboardInterface.Send(key, modifiers))
                {
                    Debug.LogWarningFormat(
                        "Could not send keypress {0}, did not understand one or more of the keys",
                        KeyboardInterface.KeyComboDebugString(key, modifiers));
                }
            }
        }
        protected override Unpress Activate()
        {
            var unpress = KeyboardInterface.CallbackPress(KeyboardInterface.Escape());

            return(() => unpress());
        }
Beispiel #8
0
 private void Back()
 {
     KeyboardInterface.SendEscape();
 }
Beispiel #9
0
 private void Select()
 {
     KeyboardInterface.Send("Key_Space");
 }
Beispiel #10
0
 public override void Activate()
 {
     KeyboardInterface.SendEscape();
 }
Beispiel #11
0
 public WaitForSecondsRealtime WaitForKeySent()
 {
     return(KeyboardInterface.WaitForKeySent());
 }