예제 #1
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);
            }
        }
예제 #2
0
 public AxisActions(InputCore core, bool enableGestures, AxisActions importMonitors)
     : this(core, enableGestures)
 {
     Deadzone = -1;
     PoleSize = -1;
     if (importMonitors != null) {
         NegativePress += importMonitors.NegativePress;
         NegativeRelease += importMonitors.NegativeRelease;
         PositivePress += importMonitors.PositivePress;
         PositiveRelease += importMonitors.PositiveRelease;
         Identifier = importMonitors.Identifier;
     }
 }
예제 #3
0
 public AxisActions(InputCore core, bool enableGestures, AxisActions importMonitors) :
     this(core, enableGestures)
 {
     Deadzone = -1;
     PoleSize = -1;
     if (importMonitors != null)
     {
         NegativePress   += importMonitors.NegativePress;
         NegativeRelease += importMonitors.NegativeRelease;
         PositivePress   += importMonitors.PositivePress;
         PositiveRelease += importMonitors.PositiveRelease;
         Identifier       = importMonitors.Identifier;
     }
 }
예제 #4
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);
        }
예제 #5
0
 public AxisActions(InputCore core, bool enableGestures, AxisActions importMonitors, object id)
     : this(core, enableGestures, importMonitors)
 {
     Identifier = id;
 }
예제 #6
0
 public AxisActions(InputCore core, bool enableGestures, AxisActions importMonitors, object id) :
     this(core, enableGestures, importMonitors)
 {
     Identifier = id;
 }
예제 #7
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;
                    }
                };
            }
        }
예제 #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;
                    }
                };
            }
        }