Ejemplo n.º 1
0
 public RunCommandAction(InputCore core, string cmd, string args, bool onRelease)
 {
     Core         = core;
     RunOnRelease = onRelease;
     Command      = cmd;
     Arguments    = args;
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 4
0
 public OpenFileAction(InputCore core, string file, bool onRelease, bool showErrors)
 {
     Core = core;
     FileName = file;
     OpenOnRelease = onRelease;
     ErrorDialog = showErrors;
 }
Ejemplo n.º 5
0
 public OpenFileAction(InputCore core, string file, bool onRelease, bool showErrors)
 {
     Core          = core;
     FileName      = file;
     OpenOnRelease = onRelease;
     ErrorDialog   = showErrors;
 }
Ejemplo n.º 6
0
 public MousePointerAction(InputCore core, int x, int y)
 {
     Core = core;
     X = x;
     Y = y;
     UseIntensity = true;
     Continuous = true;
 }
Ejemplo n.º 7
0
        public ButtonActions(InputCore core, bool enableGestures)
        {
            if (core == null) throw new ArgumentNullException("core");

            Core = core;
            EnableGestures = enableGestures;
            Intensity = 1;
        }
Ejemplo n.º 8
0
 public MousePointerAction(InputCore core, int x, int y)
 {
     Core         = core;
     X            = x;
     Y            = y;
     UseIntensity = true;
     Continuous   = true;
 }
Ejemplo n.º 9
0
        public VirtualController(InputCore core)
        {
            if (core == null)
            {
                throw new ArgumentNullException("core");
            }

            Core = core;
            Reset();
        }
Ejemplo n.º 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;
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 12
0
        public ButtonActions(InputCore core, bool enableGestures)
        {
            if (core == null)
            {
                throw new ArgumentNullException("core");
            }

            Core           = core;
            EnableGestures = enableGestures;
            Intensity      = 1;
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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;
        }
Ejemplo n.º 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;
     }
 }
Ejemplo n.º 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;
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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;
     }
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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;
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 24
0
 public MouseButtonAction(InputCore core, Buttons button)
 {
     Core   = core;
     Button = button;
 }
Ejemplo n.º 25
0
 public MouseWheelAction(InputCore core, short value, bool continuous)
     : this(core, value)
 {
     Continuous = continuous;
 }
Ejemplo n.º 26
0
 public RunCommandAction(InputCore core, string cmd, string args, bool onRelease)
 {
     Core = core;
     RunOnRelease = onRelease;
     Command = cmd;
     Arguments = args;
 }
Ejemplo n.º 27
0
        public static MouseButtonAction Parse(InputCore core, string parseable)
        {
            Buttons b = (Buttons)Enum.Parse(typeof(Buttons), parseable);

            return(new MouseButtonAction(core, b));
        }
Ejemplo n.º 28
0
 public MouseWheelAction(InputCore core, int amount) :
     this(core, amount, false)
 {
 }
Ejemplo n.º 29
0
 public ButtonActions(InputCore core, bool enableGestures, object id)
     : this(core, enableGestures)
 {
     Identifier = id;
 }
Ejemplo n.º 30
0
 public MouseWheelAction(InputCore core, int amount, bool continuous)
 {
     Core = core;
     Amount = amount;
     Continuous = continuous;
 }
Ejemplo n.º 31
0
 public MouseWheelAction(InputCore core, int amount, bool continuous)
 {
     Core       = core;
     Amount     = amount;
     Continuous = continuous;
 }
Ejemplo n.º 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;
        }
Ejemplo n.º 33
0
 public ButtonActions(InputCore core, bool enableGestures, object id) :
     this(core, enableGestures)
 {
     Identifier = id;
 }
Ejemplo n.º 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();
        }
Ejemplo n.º 35
0
 public AxisActions(InputCore core, bool enableGestures, bool enableDeadzone, object id) :
     this(core, enableGestures, id)
 {
     EnableDeadzone = enableDeadzone;
 }
Ejemplo n.º 36
0
 public AxisActions(InputCore core, bool enableGestures, AxisActions importMonitors, object id)
     : this(core, enableGestures, importMonitors)
 {
     Identifier = id;
 }
Ejemplo n.º 37
0
 public static MouseButtonAction Parse(InputCore core, string parseable)
 {
     Buttons b = (Buttons)Enum.Parse(typeof (Buttons), parseable);
     return new MouseButtonAction(core, b);
 }
Ejemplo n.º 38
0
 public MouseController(InputCore core)
 {
     this.core = core;
 }
Ejemplo n.º 39
0
 public AxisActions(InputCore core, bool enableGestures, AxisActions importMonitors, object id) :
     this(core, enableGestures, importMonitors)
 {
     Identifier = id;
 }
Ejemplo n.º 40
0
        public VirtualController(InputCore core)
        {
            if (core == null)
                throw new ArgumentNullException("core");

            Core = core;
            Reset();
        }
Ejemplo n.º 41
0
 public MouseController(InputCore core)
 {
     this.core = core;
 }
Ejemplo n.º 42
0
 public MouseWheelAction(InputCore core, int amount)
     : this(core, amount, false)
 {
 }
Ejemplo n.º 43
0
 public MouseWheelAction(InputCore core, short value)
 {
     Core = core;
     Value = value;
 }
Ejemplo n.º 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();
        }
Ejemplo n.º 45
0
 public MouseWheelAction(InputCore core, short value)
 {
     Core  = core;
     Value = value;
 }
Ejemplo n.º 46
0
 public AxisActions(InputCore core, bool enableGestures, bool enableDeadzone, object id)
     : this(core, enableGestures, id)
 {
     EnableDeadzone = enableDeadzone;
 }
Ejemplo n.º 47
0
 public MouseWheelAction(InputCore core, short value, bool continuous) :
     this(core, value)
 {
     Continuous = continuous;
 }
Ejemplo n.º 48
0
 public MouseButtonAction(InputCore core, Buttons button)
 {
     Core = core;
     Button = button;
 }