Ejemplo n.º 1
0
        protected override async Task LoadContent()
        {
            await base.LoadContent();

            // activate the gesture recognitions
            Input.Gestures.Add(new GestureConfigDrag());
            Input.Gestures.Add(new GestureConfigFlick());
            Input.Gestures.Add(new GestureConfigLongPress());
            Input.Gestures.Add(new GestureConfigComposite());
            Input.Gestures.Add(new GestureConfigTap());

            // add a task to the task scheduler that will be executed asynchronously
            Script.AddTask(UpdateInputStates);

            // Create a new VirtualButtonConfigSet if none exists.
            Input.VirtualButtonConfigSet = Input.VirtualButtonConfigSet ?? new VirtualButtonConfigSet();

            //Bind "M" key, GamePad "Start" button and left mouse button to a virtual button "MyButton".
            b1 = new VirtualButtonBinding("M Key", VirtualButton.Keyboard.M);
            b2 = new VirtualButtonBinding("GamePad Start", VirtualButton.GamePad.Start);
            b3 = new VirtualButtonBinding("Mouse Left Button", VirtualButton.Mouse.Left);

            virtualButtonConfig = new VirtualButtonConfig();

            virtualButtonConfig.Add(b1);
            virtualButtonConfig.Add(b2);
            virtualButtonConfig.Add(b3);

            Input.VirtualButtonConfigSet.Add(virtualButtonConfig);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates an instance of <see cref="VirtualButtonConfig"/> from the <see cref="ButtonBindings"/>.
        /// </summary>
        public VirtualButtonConfig CreateVirtualButtonConfig()
        {
            var config = new VirtualButtonConfig();

            foreach (var kvp in ButtonBindings)
            {
                var virtualButtonName = kvp.Key;
                foreach (var physicalButton in kvp.Value)
                {
                    config.Add(new VirtualButtonBinding(virtualButtonName, physicalButton.ToVirtual(this)));
                }
            }

            return(config);
        }
        public override void Start()
        {
            // Create a new VirtualButtonConfigSet if none exists.
            Input.VirtualButtonConfigSet = Input.VirtualButtonConfigSet ?? new VirtualButtonConfigSet();

            // Bind the "W" key and "Up arrow" to a virtual button called "Forward".
            var forwardW         = new VirtualButtonBinding("Forward", VirtualButton.Keyboard.W);
            var forwardUpArrow   = new VirtualButtonBinding("Forward", VirtualButton.Keyboard.Up);
            var forwardLeftMouse = new VirtualButtonBinding("Forward", VirtualButton.Mouse.Left);

            // Create a new virtual button configuration and add the virtual button bindings
            var virtualButtonForward = new VirtualButtonConfig();

            virtualButtonForward.Add(forwardW);
            virtualButtonForward.Add(forwardUpArrow);
            virtualButtonForward.Add(forwardLeftMouse);

            // Add the virtual button binding to the virtual button configuration
            Input.VirtualButtonConfigSet.Add(virtualButtonForward);
        }