Ejemplo n.º 1
0
        /* Interface Implementation */
        public ButtonSet GetButtons()
        {
            try
            {
                var buttonSet = new ButtonSet();
                var state     = Joystick.GetCurrentState();

                int currentButtonIndex = 0;
                foreach (var button in state.Buttons)
                {
                    buttonSet.SetButton(currentButtonIndex, button);
                    currentButtonIndex += 1;
                }

                // Handle the DPad
                var povDirections = EnumsNET.Enums.GetMembers <DpadDirection>();
                foreach (var povController in state.PointOfViewControllers)
                {
                    foreach (var direction in povDirections)
                    {
                        buttonSet.SetButton(currentButtonIndex, povController == (int)direction.Value);
                        currentButtonIndex += 1;
                    }
                }

                return(buttonSet);
            }
            catch (SharpDXException e)
            {
                return(new ButtonSet());
            }
        }
Ejemplo n.º 2
0
        /* Interface Implementation */
        public ButtonSet GetButtons()
        {
            var buttonSet = new ButtonSet();

            Controller.GetState(out var state);

            var buttons = state.Gamepad.Buttons;
            var flags   = Enums.GetMembers <GamepadButtonFlags>();

            for (int x = 0; x < flags.Count; x++)
            {
                buttonSet.SetButton(x, buttons.HasAllFlags(flags[x].Value));
            }

            return(buttonSet);
        }