Пример #1
0
 public RunCommandAction(InputCore core, string cmd, string args, bool onRelease)
 {
     Core         = core;
     RunOnRelease = onRelease;
     Command      = cmd;
     Arguments    = args;
 }
Пример #2
0
        public static RunCommandAction Parse(InputCore core, string parseable)
        {
            // Command,Arguments,WorkingDirectory,ErrorDialog,WindowStyle,RunOnRelease
            string[] props = parseable.Split(',');

            if (props.Length < 6)
            {
                throw new FormatException("Invalid property data for action 'Run Command'");
            }

            string             cmd          = props[0].Replace("%comma;", ",");
            string             args         = props[1].Replace("%comma;", ",");
            string             wd           = props[2].Replace("%comma;", ",");
            bool               ed           = bool.Parse(props[3]);
            ProcessWindowStyle pws          = (ProcessWindowStyle)Enum.Parse(typeof(ProcessWindowStyle), props[4]);
            bool               runOnRelease = bool.Parse(props[5]);

            var a = new RunCommandAction(core, cmd, args, runOnRelease);

            a.WorkingDirectory = wd;
            a.ErrorDialog      = ed;
            a.WindowStyle      = pws;
            a.RunOnRelease     = runOnRelease;
            return(a);
        }
Пример #3
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);
            }
        }
Пример #4
0
 public OpenFileAction(InputCore core, string file, bool onRelease, bool showErrors)
 {
     Core = core;
     FileName = file;
     OpenOnRelease = onRelease;
     ErrorDialog = showErrors;
 }
Пример #5
0
 public OpenFileAction(InputCore core, string file, bool onRelease, bool showErrors)
 {
     Core          = core;
     FileName      = file;
     OpenOnRelease = onRelease;
     ErrorDialog   = showErrors;
 }
Пример #6
0
 public MousePointerAction(InputCore core, int x, int y)
 {
     Core = core;
     X = x;
     Y = y;
     UseIntensity = true;
     Continuous = true;
 }
Пример #7
0
        public ButtonActions(InputCore core, bool enableGestures)
        {
            if (core == null) throw new ArgumentNullException("core");

            Core = core;
            EnableGestures = enableGestures;
            Intensity = 1;
        }
Пример #8
0
 public MousePointerAction(InputCore core, int x, int y)
 {
     Core         = core;
     X            = x;
     Y            = y;
     UseIntensity = true;
     Continuous   = true;
 }
Пример #9
0
        public VirtualController(InputCore core)
        {
            if (core == null)
            {
                throw new ArgumentNullException("core");
            }

            Core = core;
            Reset();
        }
Пример #10
0
        public static OpenFileAction Parse(InputCore core, string parseable)
        {
            string[] props = parseable.Split(',');

            if (props.Length < 3)
                throw new FormatException("Invalid property data for action 'Open File'");

            var a = new OpenFileAction(core, props[0], bool.Parse(props[1]), bool.Parse(props[2]));
            return a;
        }
Пример #11
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);
        }
Пример #12
0
        public ButtonActions(InputCore core, bool enableGestures)
        {
            if (core == null)
            {
                throw new ArgumentNullException("core");
            }

            Core           = core;
            EnableGestures = enableGestures;
            Intensity      = 1;
        }
Пример #13
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);
        }
Пример #14
0
        public static MousePointerAction Parse(InputCore core, string parseable)
        {
            string[] parts = parseable.Split(',');

            var mpa = new MousePointerAction(core, int.Parse(parts[0]), int.Parse(parts[1]));

            if (parts.Length > 2) {
                mpa.Continuous = bool.Parse(parts[2]);
                mpa.UseIntensity = bool.Parse(parts[3]);
            }

            return mpa;
        }
Пример #15
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;
     }
 }
Пример #16
0
        public static MouseWheelAction Parse(InputCore core, string parseable)
        {
            string[] parts = parseable.Split(',');

            var mwa = new MouseWheelAction(core, short.Parse(parts[0]));

            if (parts.Length > 1) {
                mwa.Continuous = bool.Parse(parts[1]);
                mwa.UseIntensity = bool.Parse(parts[2]);
            }

            return mwa;
        }
Пример #17
0
        public static OpenFileAction Parse(InputCore core, string parseable)
        {
            string[] props = parseable.Split(',');

            if (props.Length < 3)
            {
                throw new FormatException("Invalid property data for action 'Open File'");
            }

            var a = new OpenFileAction(core, props[0], bool.Parse(props[1]), bool.Parse(props[2]));

            return(a);
        }
Пример #18
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;
     }
 }
Пример #19
0
        public static MouseWheelAction Parse(InputCore core, string parseable)
        {
            string[] parts = parseable.Split(',');

            var mwa = new MouseWheelAction(core, short.Parse(parts[0]));

            if (parts.Length > 1)
            {
                mwa.Continuous   = bool.Parse(parts[1]);
                mwa.UseIntensity = bool.Parse(parts[2]);
            }

            return(mwa);
        }
Пример #20
0
        public static MousePointerAction Parse(InputCore core, string parseable)
        {
            string[] parts = parseable.Split(',');

            var mpa = new MousePointerAction(core, int.Parse(parts[0]), int.Parse(parts[1]));

            if (parts.Length > 2)
            {
                mpa.Continuous   = bool.Parse(parts[2]);
                mpa.UseIntensity = bool.Parse(parts[3]);
            }

            return(mpa);
        }
Пример #21
0
        public static KeyAction Parse(InputCore core, string parseable)
        {
            string[] parts = parseable.Split(',');
            string[] modChunks = parts[1].Split('|');
            List<Keys> mods = new List<Keys> ();

            if (!string.IsNullOrEmpty(parts[1]))
                foreach (string modChunk in modChunks)
                    mods.Add((Keys)Enum.Parse(typeof(Keys), modChunk));
            var key = (Keys)Enum.Parse(typeof(Keys), parts[0]);
            var keyAction = new KeyAction(key, mods.ToArray());
            if (parts.Length > 2 && !string.IsNullOrEmpty(parts[2])) {
                keyAction.Continuous = bool.Parse(parts[2]);
            }
            return keyAction;
        }
Пример #22
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);
        }
Пример #23
0
        public static KeyAction Parse(InputCore core, string parseable)
        {
            string[]    parts     = parseable.Split(',');
            string[]    modChunks = parts[1].Split('|');
            List <Keys> mods      = new List <Keys> ();

            if (!string.IsNullOrEmpty(parts[1]))
            {
                foreach (string modChunk in modChunks)
                {
                    mods.Add((Keys)Enum.Parse(typeof(Keys), modChunk));
                }
            }
            var key       = (Keys)Enum.Parse(typeof(Keys), parts[0]);
            var keyAction = new KeyAction(key, mods.ToArray());

            if (parts.Length > 2 && !string.IsNullOrEmpty(parts[2]))
            {
                keyAction.Continuous = bool.Parse(parts[2]);
            }
            return(keyAction);
        }
Пример #24
0
 public MouseButtonAction(InputCore core, Buttons button)
 {
     Core   = core;
     Button = button;
 }
Пример #25
0
 public MouseWheelAction(InputCore core, short value, bool continuous)
     : this(core, value)
 {
     Continuous = continuous;
 }
Пример #26
0
 public RunCommandAction(InputCore core, string cmd, string args, bool onRelease)
 {
     Core = core;
     RunOnRelease = onRelease;
     Command = cmd;
     Arguments = args;
 }
Пример #27
0
        public static MouseButtonAction Parse(InputCore core, string parseable)
        {
            Buttons b = (Buttons)Enum.Parse(typeof(Buttons), parseable);

            return(new MouseButtonAction(core, b));
        }
Пример #28
0
 public MouseWheelAction(InputCore core, int amount) :
     this(core, amount, false)
 {
 }
Пример #29
0
 public ButtonActions(InputCore core, bool enableGestures, object id)
     : this(core, enableGestures)
 {
     Identifier = id;
 }
Пример #30
0
 public MouseWheelAction(InputCore core, int amount, bool continuous)
 {
     Core = core;
     Amount = amount;
     Continuous = continuous;
 }
Пример #31
0
 public MouseWheelAction(InputCore core, int amount, bool continuous)
 {
     Core       = core;
     Amount     = amount;
     Continuous = continuous;
 }
Пример #32
0
        public static RunCommandAction Parse(InputCore core, string parseable)
        {
            // Command,Arguments,WorkingDirectory,ErrorDialog,WindowStyle,RunOnRelease
            string[] props = parseable.Split(',');

            if (props.Length < 6)
                throw new FormatException("Invalid property data for action 'Run Command'");

            string cmd = props[0].Replace("%comma;", ",");
            string args = props[1].Replace("%comma;", ",");
            string wd = props[2].Replace("%comma;", ",");
            bool ed = bool.Parse(props[3]);
            ProcessWindowStyle pws = (ProcessWindowStyle)Enum.Parse(typeof(ProcessWindowStyle), props[4]);
            bool runOnRelease = bool.Parse(props[5]);

            var a = new RunCommandAction(core, cmd, args, runOnRelease);
            a.WorkingDirectory = wd;
            a.ErrorDialog = ed;
            a.WindowStyle = pws;
            a.RunOnRelease = runOnRelease;
            return a;
        }
Пример #33
0
 public ButtonActions(InputCore core, bool enableGestures, object id) :
     this(core, enableGestures)
 {
     Identifier = id;
 }
Пример #34
0
        public void Initialize(PadTieForm form, InputCore core, Controller cc, int padNum)
        {
            mainForm = form;
            this.core = core;
            controller = cc;
            padNumber = padNum;

            padView.SelectedItemChanged += ControllerClick;

            deviceName.Text = cc.Device.Name;
            deviceGUID.Text = cc.Device.ProductGUID.ToUpper();
            deviceInstanceGUID.Text = cc.Device.InstanceGUID.ToUpper();
            deviceVendorID.Text = "0x" + cc.Device.VendorID.ToString("X4");
            deviceProductID.Text = "0x" + cc.Device.ProductID.ToString("X4");

            UpdateDeviceInfo();

            deviceButtons.Text = string.Format("{0} buttons, {1} axes, {2} hats, force feedback: {3}",
                cc.Device.ButtonCount.ToString(),
                (cc.Device.AxisCount - cc.Device.HatCount).ToString(),
                cc.Device.HatCount.ToString(),
                cc.Device.ForceFeedback ? "yes" : "no");

            cc.Virtual.AxisAnalogReceived += Analog;
            cc.Virtual.ButtonActiveReceived += Active;
            cc.Virtual.ButtonPressReceived += Press;
            cc.Virtual.ButtonReleaseReceived += Release;

            actionTree.ExpandAll();
            currentMappings.Nodes.Clear();

            foreach (var b in VirtualController.ButtonList)
                SetupButton(b);

            SetupAxisGesture(AxisGesture.LeftXNeg);
            SetupAxisGesture(AxisGesture.LeftXPos);
            SetupAxisGesture(AxisGesture.LeftYNeg);
            SetupAxisGesture(AxisGesture.LeftYPos);
            SetupAxisGesture(AxisGesture.RightXNeg);
            SetupAxisGesture(AxisGesture.RightXPos);
            SetupAxisGesture(AxisGesture.RightYNeg);
            SetupAxisGesture(AxisGesture.RightYPos);
            SetupAxisGesture(AxisGesture.DigitalXNeg);
            SetupAxisGesture(AxisGesture.DigitalXPos);
            SetupAxisGesture(AxisGesture.DigitalYNeg);
            SetupAxisGesture(AxisGesture.DigitalYPos);
            SetupAxisGesture(AxisGesture.TriggerNeg);
            SetupAxisGesture(AxisGesture.TriggerPos);

            currentMappings.ExpandAll();
            RefreshDeviceMappings();
        }
Пример #35
0
 public AxisActions(InputCore core, bool enableGestures, bool enableDeadzone, object id) :
     this(core, enableGestures, id)
 {
     EnableDeadzone = enableDeadzone;
 }
Пример #36
0
 public AxisActions(InputCore core, bool enableGestures, AxisActions importMonitors, object id)
     : this(core, enableGestures, importMonitors)
 {
     Identifier = id;
 }
Пример #37
0
 public static MouseButtonAction Parse(InputCore core, string parseable)
 {
     Buttons b = (Buttons)Enum.Parse(typeof (Buttons), parseable);
     return new MouseButtonAction(core, b);
 }
Пример #38
0
 public MouseController(InputCore core)
 {
     this.core = core;
 }
Пример #39
0
 public AxisActions(InputCore core, bool enableGestures, AxisActions importMonitors, object id) :
     this(core, enableGestures, importMonitors)
 {
     Identifier = id;
 }
Пример #40
0
        public VirtualController(InputCore core)
        {
            if (core == null)
                throw new ArgumentNullException("core");

            Core = core;
            Reset();
        }
Пример #41
0
 public MouseController(InputCore core)
 {
     this.core = core;
 }
Пример #42
0
 public MouseWheelAction(InputCore core, int amount)
     : this(core, amount, false)
 {
 }
Пример #43
0
 public MouseWheelAction(InputCore core, short value)
 {
     Core = core;
     Value = value;
 }
Пример #44
0
        static void Main(string[] args)
        {
            Console.WriteLine("Initializing PadTie...");
            var core = new InputCore(IntPtr.Zero);

            if (core.Controllers.Count == 0) {
                Console.WriteLine("No gamepads detected.");
            } else {
                var vc = new VirtualController(core);
                var pad = core.Controllers[0];

                pad.Axes[0].Analog = new VirtualController.AxisAction(vc, VirtualController.Axis.LeftX);
                pad.Axes[1].Analog = new VirtualController.AxisAction(vc, VirtualController.Axis.LeftX);
                pad.Axes[2].Analog = new VirtualController.AxisAction(vc, VirtualController.Axis.RightX);
                pad.Axes[3].Analog = new VirtualController.AxisAction(vc, VirtualController.Axis.RightY);

                // Face buttons
                pad.Buttons[0].Raw = new VirtualController.ButtonAction(vc, VirtualController.Button.X);
                pad.Buttons[1].Raw = new VirtualController.ButtonAction(vc, VirtualController.Button.A);
                pad.Buttons[2].Raw = new VirtualController.ButtonAction(vc, VirtualController.Button.B);
                pad.Buttons[3].Raw = new VirtualController.ButtonAction(vc, VirtualController.Button.Y);

                // Shoulder buttons
                pad.Buttons[4].Raw = new VirtualController.ButtonAction(vc, VirtualController.Button.Bl);
                pad.Buttons[5].Raw = new VirtualController.ButtonAction(vc, VirtualController.Button.Br);
                pad.Buttons[6].Raw = new VirtualController.ButtonAction(vc, VirtualController.Button.Tl);
                pad.Buttons[7].Raw = new VirtualController.ButtonAction(vc, VirtualController.Button.Tr);
                pad.Buttons[8].Raw = new VirtualController.ButtonAction(vc, VirtualController.Button.Back);
                pad.Buttons[9].Raw = new VirtualController.ButtonAction(vc, VirtualController.Button.Start);
                pad.Buttons[10].Raw = new VirtualController.ButtonAction(vc, VirtualController.Button.LeftAnalog);
                pad.Buttons[11].Raw = new VirtualController.ButtonAction(vc, VirtualController.Button.RightAnalog);

                /// *************** Real mapping (to virtual controller) **************** ///

                vc.LeftXAxis.Positive.Link = new KeyAction(User32InputHook.VK.VK_RIGHT);
                vc.LeftXAxis.Negative.Link = new KeyAction(User32InputHook.VK.VK_LEFT);
                vc.LeftYAxis.Positive.Link = new KeyAction(User32InputHook.VK.VK_DOWN);
                vc.LeftYAxis.Negative.Link = new KeyAction(User32InputHook.VK.VK_UP);

                vc.LeftXAxis.Positive.Link = new KeyAction('d');
                vc.LeftXAxis.Negative.Link = new KeyAction('a');
                vc.LeftYAxis.Positive.Link = new KeyAction('s');
                vc.LeftYAxis.Negative.Link = new KeyAction('w');

                vc.RightXAxis.Positive.Link  = new MousePointerAction(core,  20,  0 );
                vc.RightXAxis.Negative.Link = new MousePointerAction(core, -20, 0);
                vc.RightYAxis.Positive.Link = new MousePointerAction(core, 0, 20);
                vc.RightYAxis.Negative.Link = new MousePointerAction(core, 0, -20);

                vc.Br.Link = new MouseButtonAction(core, MouseButtonAction.Buttons.Left);
                vc.Tr.Link = new MouseButtonAction(core, MouseButtonAction.Buttons.Right);
                vc.X.Link = new KeyAction(User32InputHook.VK.VK_SPACE);
                vc.A.Link = new KeyAction('e');
                vc.Bl.Link = new MouseWheelAction(core, 26, true);
                vc.Tl.Link = new MouseWheelAction(core, -26, true);
                vc.Start.Link = new KeyAction(User32InputHook.VK.VK_RETURN);
                vc.Back.Link = new KeyAction(User32InputHook.VK.VK_ESCAPE);
                vc.Back.Hold = new KeyAction(User32InputHook.VK.VK_TAB, User32InputHook.VK.VK_MENU);

                Console.WriteLine("Press keys...");
                while (true) {
                    core.RunIteration();
                    Thread.Sleep(0);
                }
            }
            Console.WriteLine("Press enter to exit.");
            Console.ReadLine();
        }
Пример #45
0
 public MouseWheelAction(InputCore core, short value)
 {
     Core  = core;
     Value = value;
 }
Пример #46
0
 public AxisActions(InputCore core, bool enableGestures, bool enableDeadzone, object id)
     : this(core, enableGestures, id)
 {
     EnableDeadzone = enableDeadzone;
 }
Пример #47
0
 public MouseWheelAction(InputCore core, short value, bool continuous) :
     this(core, value)
 {
     Continuous = continuous;
 }
Пример #48
0
 public MouseButtonAction(InputCore core, Buttons button)
 {
     Core = core;
     Button = button;
 }