Exemple #1
0
 public CapturedInput(VirtualController.Axis axis, bool isPos, ButtonActions.Gesture gesture)
 {
     IsAxisGesture = true;
     Axis = axis;
     IsPositive = isPos;
     ButtonGesture = gesture;
 }
Exemple #2
0
        public InputController(InputCore core, DI.Joystick dev, int index)
        {
            if (core == null)
            {
                throw new ArgumentNullException("core");
            }
            if (dev == null)
            {
                throw new ArgumentNullException("dev");
            }
            if (index < 0)
            {
                throw new ArgumentOutOfRangeException("index", "assertion failed: index >= 0");
            }

            Core   = core;
            Device = dev;

            ApplyExclusivity();
            Device.Acquire();

            ID      = index;
            Buttons = new ButtonActions[ButtonCount];
            Axes    = new AxisActions[AxisCount];

            for (int i = 0, max = Buttons.Length; i < max; ++i)
            {
                Buttons[i] = new ButtonActions(Core, false, i + 1);
            }
            for (int i = 0, max = Axes.Length; i < max; ++i)
            {
                Axes[i] = new AxisActions(Core, false, true, i + 1);
            }
        }
Exemple #3
0
 public InputActionConfig GetGesture(ButtonActions.Gesture g)
 {
     switch (g) {
         case ButtonActions.Gesture.Link: return Link;
         case ButtonActions.Gesture.Tap: return Tap;
         case ButtonActions.Gesture.DoubleTap: return DoubleTap;
         case ButtonActions.Gesture.Hold: return Hold;
     }
     return null;
 }
Exemple #4
0
        public AxisActions(InputCore core, bool enableGestures)
        {
            if (core == null)
                throw new ArgumentNullException("core");

            Core = core;
            EnableGestures = enableGestures;
            Positive = new ButtonActions(core, enableGestures);
            Negative = new ButtonActions(core, enableGestures);
        }
Exemple #5
0
        public AxisActions(InputCore core, bool enableGestures)
        {
            if (core == null)
            {
                throw new ArgumentNullException("core");
            }

            Core           = core;
            EnableGestures = enableGestures;
            Positive       = new ButtonActions(core, enableGestures);
            Negative       = new ButtonActions(core, enableGestures);
        }
Exemple #6
0
        public InputController(InputCore core, DI.Joystick dev, int index)
        {
            if (core == null)
                throw new ArgumentNullException("core");
            if (dev == null)
                throw new ArgumentNullException("dev");
            if (index < 0)
                throw new ArgumentOutOfRangeException("index", "assertion failed: index >= 0");

            Core = core;
            Device = dev;

            ApplyExclusivity();
            Device.Acquire();

            ID = index;
            Buttons = new ButtonActions[ButtonCount];
            Axes = new AxisActions[AxisCount];

            for (int i = 0, max = Buttons.Length; i < max; ++i) Buttons[i] = new ButtonActions(Core, false, i + 1);
            for (int i = 0, max = Axes.Length; i < max; ++i) Axes[i] = new AxisActions(Core, false, true, i + 1);
        }
        void ReplaceGesture(ButtonActions.Gesture gesture)
        {
            var d = new ActionSelectDialog();
            var slot = (slotMenu.Tag as CapturedInput).Clone();

            slot.ButtonGesture = gesture;
            d.ActionSelect.MainForm = mainForm;
            d.ActionSelect.Controller = controller;
            d.ActionSelect.Slot = slot;

            d.ShowDialog(this.ParentForm);
        }
Exemple #8
0
        public void Reset()
        {
            A                 = new ButtonActions(Core, true, VirtualController.Button.A);
            B                 = new ButtonActions(Core, true, VirtualController.Button.B);
            X                 = new ButtonActions(Core, true, VirtualController.Button.X);
            Y                 = new ButtonActions(Core, true, VirtualController.Button.Y);
            Br                = new ButtonActions(Core, true, VirtualController.Button.Br);
            Bl                = new ButtonActions(Core, true, VirtualController.Button.Bl);
            Tl                = new ButtonActions(Core, true, VirtualController.Button.Tl);
            Tr                = new ButtonActions(Core, true, VirtualController.Button.Tr);
            Back              = new ButtonActions(Core, true, VirtualController.Button.Back);
            Start             = new ButtonActions(Core, true, VirtualController.Button.Start);
            System            = new ButtonActions(Core, true, VirtualController.Button.System);
            LeftAnalogButton  = new ButtonActions(Core, true, VirtualController.Button.LeftAnalog);
            RightAnalogButton = new ButtonActions(Core, true, VirtualController.Button.RightAnalog);

            bool needsCapture = (LeftXAxis == null);

            LeftXAxis    = new AxisActions(Core, true, LeftXAxis, VirtualController.Axis.LeftX);
            LeftYAxis    = new AxisActions(Core, true, LeftYAxis, VirtualController.Axis.LeftY);
            RightXAxis   = new AxisActions(Core, true, RightXAxis, VirtualController.Axis.RightX);
            RightYAxis   = new AxisActions(Core, true, RightYAxis, VirtualController.Axis.RightY);
            DigitalXAxis = new AxisActions(Core, true, DigitalXAxis, VirtualController.Axis.DigitalX);
            DigitalYAxis = new AxisActions(Core, true, DigitalYAxis, VirtualController.Axis.DigitalY);
            Trigger      = new AxisActions(Core, true, Trigger, VirtualController.Axis.Trigger);

            if (needsCapture)
            {
                LeftXAxis.PositiveRelease += delegate(object sender, EventArgs e)
                {
                    if (capture != null)
                    {
                        capture(new CapturedInput(Axis.LeftX, true));
                        capture = null;
                    }
                };
                LeftXAxis.NegativeRelease += delegate(object sender, EventArgs e)
                {
                    if (capture != null)
                    {
                        capture(new CapturedInput(Axis.LeftX, false));
                        capture = null;
                    }
                };
                LeftYAxis.PositiveRelease += delegate(object sender, EventArgs e)
                {
                    if (capture != null)
                    {
                        capture(new CapturedInput(Axis.LeftY, true));
                        capture = null;
                    }
                };
                LeftYAxis.NegativeRelease += delegate(object sender, EventArgs e)
                {
                    if (capture != null)
                    {
                        capture(new CapturedInput(Axis.LeftY, false));
                        capture = null;
                    }
                };
                RightXAxis.PositiveRelease += delegate(object sender, EventArgs e)
                {
                    if (capture != null)
                    {
                        capture(new CapturedInput(Axis.RightX, true));
                        capture = null;
                    }
                };
                RightXAxis.NegativeRelease += delegate(object sender, EventArgs e)
                {
                    if (capture != null)
                    {
                        capture(new CapturedInput(Axis.RightX, false));
                        capture = null;
                    }
                };
                RightYAxis.PositiveRelease += delegate(object sender, EventArgs e)
                {
                    if (capture != null)
                    {
                        capture(new CapturedInput(Axis.RightY, true));
                        capture = null;
                    }
                };
                RightYAxis.NegativeRelease += delegate(object sender, EventArgs e)
                {
                    if (capture != null)
                    {
                        capture(new CapturedInput(Axis.RightY, false));
                        capture = null;
                    }
                };

                DigitalXAxis.PositiveRelease += delegate(object sender, EventArgs e)
                {
                    if (capture != null)
                    {
                        capture(new CapturedInput(Axis.DigitalX, true));
                        capture = null;
                    }
                };
                DigitalXAxis.NegativeRelease += delegate(object sender, EventArgs e)
                {
                    if (capture != null)
                    {
                        capture(new CapturedInput(Axis.DigitalX, false));
                        capture = null;
                    }
                };
                DigitalYAxis.PositiveRelease += delegate(object sender, EventArgs e)
                {
                    if (capture != null)
                    {
                        capture(new CapturedInput(Axis.DigitalY, true));
                        capture = null;
                    }
                };
                DigitalYAxis.NegativeRelease += delegate(object sender, EventArgs e)
                {
                    if (capture != null)
                    {
                        capture(new CapturedInput(Axis.DigitalY, false));
                        capture = null;
                    }
                };
                Trigger.PositiveRelease += delegate(object sender, EventArgs e)
                {
                    if (capture != null)
                    {
                        capture(new CapturedInput(Axis.Trigger, true));
                        capture = null;
                    }
                };
                Trigger.NegativeRelease += delegate(object sender, EventArgs e)
                {
                    if (capture != null)
                    {
                        capture(new CapturedInput(Axis.Trigger, false));
                        capture = null;
                    }
                };
            }
        }
Exemple #9
0
        public void Reset()
        {
            A = new ButtonActions(Core, true, VirtualController.Button.A);
            B = new ButtonActions(Core, true, VirtualController.Button.B);
            X = new ButtonActions(Core, true, VirtualController.Button.X);
            Y = new ButtonActions(Core, true, VirtualController.Button.Y);
            Br = new ButtonActions(Core, true, VirtualController.Button.Br);
            Bl = new ButtonActions(Core, true, VirtualController.Button.Bl);
            Tl = new ButtonActions(Core, true, VirtualController.Button.Tl);
            Tr = new ButtonActions(Core, true, VirtualController.Button.Tr);
            Back = new ButtonActions(Core, true, VirtualController.Button.Back);
            Start = new ButtonActions(Core, true, VirtualController.Button.Start);
            System = new ButtonActions(Core, true, VirtualController.Button.System);
            LeftAnalogButton = new ButtonActions(Core, true, VirtualController.Button.LeftAnalog);
            RightAnalogButton = new ButtonActions(Core, true, VirtualController.Button.RightAnalog);

            bool needsCapture = (LeftXAxis == null);

            LeftXAxis = new AxisActions(Core, true, LeftXAxis, VirtualController.Axis.LeftX);
            LeftYAxis = new AxisActions(Core, true, LeftYAxis, VirtualController.Axis.LeftY);
            RightXAxis = new AxisActions(Core, true, RightXAxis, VirtualController.Axis.RightX);
            RightYAxis = new AxisActions(Core, true, RightYAxis, VirtualController.Axis.RightY);
            DigitalXAxis = new AxisActions(Core, true, DigitalXAxis, VirtualController.Axis.DigitalX);
            DigitalYAxis = new AxisActions(Core, true, DigitalYAxis, VirtualController.Axis.DigitalY);
            Trigger = new AxisActions(Core, true, Trigger, VirtualController.Axis.Trigger);

            if (needsCapture) {
                LeftXAxis.PositiveRelease += delegate(object sender, EventArgs e)
                {
                    if (capture != null) {
                        capture(new CapturedInput(Axis.LeftX, true));
                        capture = null;
                    }
                };
                LeftXAxis.NegativeRelease += delegate(object sender, EventArgs e)
                {
                    if (capture != null) {
                        capture(new CapturedInput(Axis.LeftX, false));
                        capture = null;
                    }
                };
                LeftYAxis.PositiveRelease += delegate(object sender, EventArgs e)
                {
                    if (capture != null) {
                        capture(new CapturedInput(Axis.LeftY, true));
                        capture = null;
                    }
                };
                LeftYAxis.NegativeRelease += delegate(object sender, EventArgs e)
                {
                    if (capture != null) {
                        capture(new CapturedInput(Axis.LeftY, false));
                        capture = null;
                    }
                };
                RightXAxis.PositiveRelease += delegate(object sender, EventArgs e)
                {
                    if (capture != null) {
                        capture(new CapturedInput(Axis.RightX, true));
                        capture = null;
                    }
                };
                RightXAxis.NegativeRelease += delegate(object sender, EventArgs e)
                {
                    if (capture != null) {
                        capture(new CapturedInput(Axis.RightX, false));
                        capture = null;
                    }
                };
                RightYAxis.PositiveRelease += delegate(object sender, EventArgs e)
                {
                    if (capture != null) {
                        capture(new CapturedInput(Axis.RightY, true));
                        capture = null;
                    }
                };
                RightYAxis.NegativeRelease += delegate(object sender, EventArgs e)
                {
                    if (capture != null) {
                        capture(new CapturedInput(Axis.RightY, false));
                        capture = null;
                    }
                };

                DigitalXAxis.PositiveRelease += delegate(object sender, EventArgs e)
                {
                    if (capture != null) {
                        capture(new CapturedInput(Axis.DigitalX, true));
                        capture = null;
                    }
                };
                DigitalXAxis.NegativeRelease += delegate(object sender, EventArgs e)
                {
                    if (capture != null) {
                        capture(new CapturedInput(Axis.DigitalX, false));
                        capture = null;
                    }
                };
                DigitalYAxis.PositiveRelease += delegate(object sender, EventArgs e)
                {
                    if (capture != null) {
                        capture(new CapturedInput(Axis.DigitalY, true));
                        capture = null;
                    }
                };
                DigitalYAxis.NegativeRelease += delegate(object sender, EventArgs e)
                {
                    if (capture != null) {
                        capture(new CapturedInput(Axis.DigitalY, false));
                        capture = null;
                    }
                };
                Trigger.PositiveRelease += delegate(object sender, EventArgs e)
                {
                    if (capture != null)
                    {
                        capture(new CapturedInput(Axis.Trigger, true));
                        capture = null;
                    }
                };
                Trigger.NegativeRelease += delegate(object sender, EventArgs e)
                {
                    if (capture != null)
                    {
                        capture(new CapturedInput(Axis.Trigger, false));
                        capture = null;
                    }
                };
            }
        }
Exemple #10
0
 public CapturedInput(VirtualController.Button button, ButtonActions.Gesture gesture)
 {
     Button = button;
     ButtonGesture = gesture;
 }