Pass global InputManager to remaining Virtual Pads controls

This commit is contained in:
YoshiRulz 2020-11-30 15:39:37 +10:00
parent e3f7519e15
commit b9a5c5796d
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
3 changed files with 18 additions and 11 deletions

View File

@ -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

View File

@ -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)
{

View File

@ -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<string> 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)