public CapturedInput(VirtualController.Axis axis, bool isPos, ButtonActions.Gesture gesture) { IsAxisGesture = true; Axis = axis; IsPositive = isPos; ButtonGesture = gesture; }
void AddDirectionNode(TreeNode root, Controller cc, VirtualController.Axis axis, bool pos, string name) { var cap = new CapturedInput(axis, false); var n = root.Nodes.Add(name); n.Tag = new SlotNodeTag { cc = cc, slot = cap }; if (IncludeGestures) AddGestureNodes(n, cc, cap); }
public SlotOverlay FindOverlay(VirtualController.Axis a, bool isPos) { foreach (var o in slotOverlays) { if (!o.IsAxisGesture) continue; if (o.Axis == a && o.IsPositive == isPos) return o; } return null; }
public SlotOverlay FindOverlay(VirtualController.Button b) { foreach (var o in slotOverlays) { if (o.IsAxisGesture) continue; if (o.Button == b) return o; } return null; }
public AxisAction(VirtualController vc, Axis a) { if (vc == null) { throw new ArgumentNullException("vc"); } Controller = vc; Axis = a; AcceptAnalog = true; }
public ButtonAction(VirtualController vc, Button b) { if (vc == null) { throw new ArgumentNullException("vc"); } Controller = vc; Button = b; AcceptAnalog = true; }
public static void Map(PadTieForm form, VirtualController vc, CapturedInput slot, InputAction action) { if (slot.IsAxisGesture) { form.MapAxisGesture(vc, slot.Axis, slot.IsPositive ? AxisActions.Gestures.Positive : AxisActions.Gestures.Negative, slot.ButtonGesture, action); } else { var gesture = slot.ButtonGesture; form.MapButton(vc, slot.Button, gesture, action); } }
public SlotOverlay(VirtualController.Button b, Rectangle m, Color c, SlotShape shape) : base(b) { Metrics = m; Color = c; Shape = shape; }
public SlotOverlay(VirtualController.Axis a, bool isPos, Rectangle m, Color c, SlotShape shape) : base(a, isPos) { Metrics = m; Color = c; Shape = shape; }
public void SetOverlay(VirtualController.Axis a, bool isPos, bool visible) { var o = FindOverlay(a, isPos); if (o != null) o.Visible = visible; else Console.WriteLine("Error: could not find overlay for axis gesture " + a + "/" + (isPos ? "Pos" : "Neg")); Render(); }
private void SetupButton(VirtualController.Button button, Panel panel) { string name = button.ToString(); SlotShape shape = SlotShape.Rounded; if (panel.Tag is string) try { shape = (SlotShape)Enum.Parse(typeof(SlotShape), panel.Tag as string); } catch (FormatException) { } RegisterOverlay(button, panel.Bounds, panel.BackColor, shape); panel.Tag = button; panel.Hide(); }
public CapturedInput(VirtualController.Button button) { Button = button; }
public void SetOverlay(VirtualController.Button b, bool visible) { var o = FindOverlay(b); if (o != null) o.Visible = visible; else Console.WriteLine("Error: could not find overlay for button " + b); Render(); }
public CapturedInput(VirtualController.Button button, ButtonActions.Gesture gesture) { Button = button; ButtonGesture = gesture; }
public AxisAction(VirtualController vc, Axis a) { if (vc == null) throw new ArgumentNullException("vc"); Controller = vc; Axis = a; AcceptAnalog = true; }
public CapturedInput(VirtualController.Axis axis, bool isPos) : this(axis, isPos, ButtonActions.Gesture.Link) { }
public ButtonOptionItem(VirtualController.Button b) { Button = b; Name = Util.GetButtonDisplayName(b); }
private void Analog(object sender, VirtualController.AxisEventArgs e) { }
private void Active(object sender, VirtualController.ButtonEventArgs e) { }
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(); }
public ButtonActions GetSlot(VirtualController c) { if (IsAxisGesture) return c.GetAxis(Axis).GetPole(AxisGesture); else return c.GetButton(Button); }
public ButtonActionsConfig GetButton(VirtualController.Button button) { switch (button) { case VirtualController.Button.A: return this.A; case VirtualController.Button.B: return this.B; case VirtualController.Button.X: return this.X; case VirtualController.Button.Y: return this.Y; case VirtualController.Button.Bl: return this.Bl; case VirtualController.Button.Br: return this.Br; case VirtualController.Button.Tl: return this.Tl; case VirtualController.Button.Tr: return this.Tr; case VirtualController.Button.Start: return this.Start; case VirtualController.Button.Back: return this.Back; case VirtualController.Button.System: return this.System; case VirtualController.Button.LeftAnalog: return this.LeftAnalogButton; case VirtualController.Button.RightAnalog: return this.RightAnalogButton; } return null; }
private void Press(object sender, VirtualController.ButtonEventArgs e) { padView.SetOverlay(e.Button, true); if (padView.AutoSelectInput) { var node = buttonMapNodes[e.Button.ToString() + "/link"]; currentMappings.SelectedNode = node; //currentMappings_AfterSelect(this, EventArgs.Empty); if (node != null) { node.Expand(); } } }
public ButtonAction(VirtualController vc, Button b) { if (vc == null) throw new ArgumentNullException("vc"); Controller = vc; Button = b; AcceptAnalog = true; }
public AxisOptionItem(VirtualController.Axis a) { Axis = a; Name = Util.GetAxisDisplayName(a); }
private void Release(object sender, VirtualController.ButtonEventArgs e) { padView.SetOverlay(e.Button, false); }
void AddStickDirections(TreeNode root, Controller cc, VirtualController.Axis stick) { string prefix = stick.ToString(); prefix = prefix.Substring (0, prefix.Length - 1); var y = Util.ParseEnum<VirtualController.Axis>(prefix + "Y"); var x = stick; AddDirectionNode(root, cc, x, false, "Left"); AddDirectionNode(root, cc, x, true, "Right"); AddDirectionNode(root, cc, y, false, "Up"); AddDirectionNode(root, cc, y, true, "Down"); }
private void SetupButton(VirtualController.Button button) { string name = button.ToString(); if (button == VirtualController.Button.Bl) name = "Left Bumper"; else if (button == VirtualController.Button.Br) name = "Right Bumper"; else if (button == VirtualController.Button.Tl) name = "Left Trigger"; else if (button == VirtualController.Button.Tr) name = "Right Trigger"; TreeNode n; if (button == VirtualController.Button.LeftAnalog) { TreeNode root; if (axisPortNodes.ContainsKey(VirtualController.Axis.LeftX)) { root = axisPortNodes[VirtualController.Axis.LeftX]; } else { root = axisPortNodes[VirtualController.Axis.LeftX] = buttonMapNodes["left-analog"] = currentMappings.Nodes.Add("Left Analog"); } buttonMapNodes["left-analog/button"] = n = root.Nodes.Add("Push"); } else if (button == VirtualController.Button.RightAnalog) { TreeNode root; if (axisPortNodes.ContainsKey(VirtualController.Axis.RightX)) { root = axisPortNodes[VirtualController.Axis.RightX]; } else { root = axisPortNodes[VirtualController.Axis.RightX] = buttonMapNodes["right-analog"] = currentMappings.Nodes.Add("Right Analog"); } buttonMapNodes["right-analog/button"] = n = root.Nodes.Add("Push"); } else { n = currentMappings.Nodes.Add(name); } buttonMapNodes[button.ToString()] = n; buttonMapNodes[button.ToString() + "/link"] = n.Nodes.Add("Link"); buttonMapNodes[button.ToString() + "/tap"] = n.Nodes.Add("Tap"); buttonMapNodes[button.ToString() + "/dtap"] = n.Nodes.Add("Double Tap"); buttonMapNodes[button.ToString() + "/hold"] = n.Nodes.Add("Hold"); }
public AxisActionsConfig GetAxisGesture(VirtualController.Axis axis, bool pos) { switch (axis) { case VirtualController.Axis.LeftX: if (pos) return LeftAnalogRight; else return LeftAnalogLeft; case VirtualController.Axis.LeftY: if (pos) return LeftAnalogDown; else return LeftAnalogUp; case VirtualController.Axis.RightX: if (pos) return RightAnalogRight; else return RightAnalogLeft; case VirtualController.Axis.RightY: if (pos) return RightAnalogDown; else return RightAnalogUp; case VirtualController.Axis.DigitalX: if (pos) return DigitalRight; else return DigitalLeft; case VirtualController.Axis.DigitalY: if (pos) return DigitalDown; else return DigitalUp; case VirtualController.Axis.Trigger: if (pos) return LeftAnalogRight; else return LeftAnalogLeft; } return null; }
public void RegisterOverlay(VirtualController.Button b, Rectangle m, Color c, SlotShape shape) { slotOverlays.Add(new SlotOverlay(b, m, c, shape)); }
public void RegisterOverlay(VirtualController.Axis a, bool isPos, Rectangle m, Color c, SlotShape shape) { slotOverlays.Add(new SlotOverlay(a, isPos, m, c, shape)); }
public ButtonSpot(VirtualController.Button button, int x, int y) { Button = button; X = x; Y = y; }