diff --git a/src/BizHawk.Client.EmuHawk/tools/VirtualPads/VirtualPad.cs b/src/BizHawk.Client.EmuHawk/tools/VirtualPads/VirtualPad.cs index 203dae8747..d3604e6b6a 100644 --- a/src/BizHawk.Client.EmuHawk/tools/VirtualPads/VirtualPad.cs +++ b/src/BizHawk.Client.EmuHawk/tools/VirtualPads/VirtualPad.cs @@ -51,10 +51,11 @@ namespace BizHawk.Client.EmuHawk private void VirtualPadControl_Load(object sender, EventArgs e) { - static VirtualPadButton GenVirtualPadButton(ButtonSchema button) + static VirtualPadButton GenVirtualPadButton(InputManager inputManager, ButtonSchema button) { var buttonControl = new VirtualPadButton { + InputManager = inputManager, Name = button.Name, Text = button.Icon != null ? null : button.DisplayName, Location = UIHelper.Scale(button.Location), @@ -82,7 +83,7 @@ namespace BizHawk.Client.EmuHawk { PadBox.Controls.Add(controlSchema switch { - ButtonSchema button => GenVirtualPadButton(button), + ButtonSchema button => GenVirtualPadButton(_inputManager, button), SingleAxisSchema singleAxis => new VirtualPadAnalogButton( _inputManager.StickyXorAdapter, singleAxis.Name, @@ -118,7 +119,7 @@ namespace BizHawk.Client.EmuHawk TargetSize = targetedPair.TargetSize, }, DiscManagerSchema discManager => new VirtualPadDiscManager( - _inputManager.StickyXorAdapter, + _inputManager, discManager.OwnerEmulator, discManager.Name, discManager.SecondaryNames diff --git a/src/BizHawk.Client.EmuHawk/tools/VirtualPads/controls/VirtualPadButton.cs b/src/BizHawk.Client.EmuHawk/tools/VirtualPads/controls/VirtualPadButton.cs index 8a36d5a23c..72c7eced5f 100644 --- a/src/BizHawk.Client.EmuHawk/tools/VirtualPads/controls/VirtualPadButton.cs +++ b/src/BizHawk.Client.EmuHawk/tools/VirtualPads/controls/VirtualPadButton.cs @@ -1,6 +1,8 @@ using System; using System.Windows.Forms; using System.Drawing; + +using BizHawk.Client.Common; using BizHawk.Emulation.Common; namespace BizHawk.Client.EmuHawk @@ -10,6 +12,8 @@ namespace BizHawk.Client.EmuHawk private bool _rightClicked; private bool _readonly; + public InputManager InputManager; + public VirtualPadButton() { SetStyle(ControlStyles.AllPaintingInWmPaint, true); @@ -28,8 +32,8 @@ namespace BizHawk.Client.EmuHawk RightClicked = false; Checked = false; //HOOMOO - GlobalWin.InputManager.AutofireStickyXorAdapter.SetSticky(Name, false); - GlobalWin.InputManager.StickyXorAdapter.SetSticky(Name, false); + InputManager.AutofireStickyXorAdapter.SetSticky(Name, false); + InputManager.StickyXorAdapter.SetSticky(Name, false); } } @@ -130,7 +134,7 @@ namespace BizHawk.Client.EmuHawk { if (RightClicked) { - GlobalWin.InputManager.AutofireStickyXorAdapter.SetSticky(Name, Checked); + InputManager.AutofireStickyXorAdapter.SetSticky(Name, Checked); if (Checked == false) { @@ -139,7 +143,7 @@ namespace BizHawk.Client.EmuHawk } else { - GlobalWin.InputManager.StickyXorAdapter.SetSticky(Name, Checked); + InputManager.StickyXorAdapter.SetSticky(Name, Checked); if (Checked == false) { diff --git a/src/BizHawk.Client.EmuHawk/tools/VirtualPads/controls/VirtualPadDiscManager.cs b/src/BizHawk.Client.EmuHawk/tools/VirtualPads/controls/VirtualPadDiscManager.cs index 0b9ac0d467..4825036f52 100644 --- a/src/BizHawk.Client.EmuHawk/tools/VirtualPads/controls/VirtualPadDiscManager.cs +++ b/src/BizHawk.Client.EmuHawk/tools/VirtualPads/controls/VirtualPadDiscManager.cs @@ -9,18 +9,20 @@ namespace BizHawk.Client.EmuHawk { public partial class VirtualPadDiscManager : UserControl, IVirtualPadControl { - private readonly StickyXorAdapter _stickyXorAdapter; + private readonly InputManager _inputManager; public VirtualPadDiscManager( - StickyXorAdapter stickyXorAdapter, + InputManager inputManager, IEmulator ownerEmulator, string name, IReadOnlyList buttonNames) { - _stickyXorAdapter = stickyXorAdapter; + _inputManager = inputManager; _ownerEmulator = ownerEmulator; Name = name; InitializeComponent(); + btnOpen.InputManager = _inputManager; + btnClose.InputManager = _inputManager; btnOpen.Name = buttonNames[0]; btnClose.Name = buttonNames[1]; _discSelectName = buttonNames[2]; @@ -124,7 +126,7 @@ namespace BizHawk.Client.EmuHawk private void lvDiscs_SelectedIndexChanged(object sender, EventArgs e) { // emergency measure: if no selection, set no disc - _stickyXorAdapter.SetAxis(_discSelectName, lvDiscs.SelectedIndices.Count == 0 ? 0 : lvDiscs.SelectedIndices[0]); + _inputManager.StickyXorAdapter.SetAxis(_discSelectName, lvDiscs.SelectedIndices.Count == 0 ? 0 : lvDiscs.SelectedIndices[0]); } private void btnClose_Click(object sender, EventArgs e)