mirror of
https://github.com/SourMesen/Mesen.git
synced 2025-04-02 10:52:48 -04:00
Input: Fixed input config window issues
This commit is contained in:
parent
0a81ecd0b3
commit
cd38eed36e
2 changed files with 79 additions and 72 deletions
13
GUI.NET/Forms/Config/frmInputConfig.Designer.cs
generated
13
GUI.NET/Forms/Config/frmInputConfig.Designer.cs
generated
|
@ -167,7 +167,6 @@
|
|||
this.btnSetupP4.Text = "Setup";
|
||||
this.btnSetupP4.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText;
|
||||
this.btnSetupP4.UseVisualStyleBackColor = true;
|
||||
this.btnSetupP4.Click += new System.EventHandler(this.btnSetup_Click);
|
||||
//
|
||||
// btnSetupP3
|
||||
//
|
||||
|
@ -179,7 +178,6 @@
|
|||
this.btnSetupP3.Text = "Setup";
|
||||
this.btnSetupP3.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText;
|
||||
this.btnSetupP3.UseVisualStyleBackColor = true;
|
||||
this.btnSetupP3.Click += new System.EventHandler(this.btnSetup_Click);
|
||||
//
|
||||
// lblPlayer1
|
||||
//
|
||||
|
@ -210,7 +208,6 @@
|
|||
this.cboPlayer4.Name = "cboPlayer4";
|
||||
this.cboPlayer4.Size = new System.Drawing.Size(201, 21);
|
||||
this.cboPlayer4.TabIndex = 8;
|
||||
this.cboPlayer4.SelectedIndexChanged += new System.EventHandler(this.cboPlayerController_SelectedIndexChanged);
|
||||
//
|
||||
// cboPlayer3
|
||||
//
|
||||
|
@ -221,7 +218,6 @@
|
|||
this.cboPlayer3.Name = "cboPlayer3";
|
||||
this.cboPlayer3.Size = new System.Drawing.Size(201, 21);
|
||||
this.cboPlayer3.TabIndex = 7;
|
||||
this.cboPlayer3.SelectedIndexChanged += new System.EventHandler(this.cboPlayerController_SelectedIndexChanged);
|
||||
//
|
||||
// cboPlayer1
|
||||
//
|
||||
|
@ -232,7 +228,6 @@
|
|||
this.cboPlayer1.Name = "cboPlayer1";
|
||||
this.cboPlayer1.Size = new System.Drawing.Size(201, 21);
|
||||
this.cboPlayer1.TabIndex = 4;
|
||||
this.cboPlayer1.SelectedIndexChanged += new System.EventHandler(this.cboPlayerController_SelectedIndexChanged);
|
||||
//
|
||||
// lblPlayer4
|
||||
//
|
||||
|
@ -253,7 +248,6 @@
|
|||
this.cboPlayer2.Name = "cboPlayer2";
|
||||
this.cboPlayer2.Size = new System.Drawing.Size(201, 21);
|
||||
this.cboPlayer2.TabIndex = 6;
|
||||
this.cboPlayer2.SelectedIndexChanged += new System.EventHandler(this.cboPlayerController_SelectedIndexChanged);
|
||||
//
|
||||
// lblPlayer3
|
||||
//
|
||||
|
@ -275,7 +269,6 @@
|
|||
this.btnSetupP1.Text = "Setup";
|
||||
this.btnSetupP1.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText;
|
||||
this.btnSetupP1.UseVisualStyleBackColor = true;
|
||||
this.btnSetupP1.Click += new System.EventHandler(this.btnSetup_Click);
|
||||
//
|
||||
// btnSetupP2
|
||||
//
|
||||
|
@ -287,7 +280,6 @@
|
|||
this.btnSetupP2.Text = "Setup";
|
||||
this.btnSetupP2.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText;
|
||||
this.btnSetupP2.UseVisualStyleBackColor = true;
|
||||
this.btnSetupP2.Click += new System.EventHandler(this.btnSetup_Click);
|
||||
//
|
||||
// lblNesType
|
||||
//
|
||||
|
@ -310,7 +302,6 @@
|
|||
this.cboConsoleType.Name = "cboConsoleType";
|
||||
this.cboConsoleType.Size = new System.Drawing.Size(109, 21);
|
||||
this.cboConsoleType.TabIndex = 14;
|
||||
this.cboConsoleType.SelectedIndexChanged += new System.EventHandler(this.cboNesType_SelectedIndexChanged);
|
||||
//
|
||||
// lblExpansionPort
|
||||
//
|
||||
|
@ -331,7 +322,6 @@
|
|||
this.cboExpansionPort.Name = "cboExpansionPort";
|
||||
this.cboExpansionPort.Size = new System.Drawing.Size(201, 21);
|
||||
this.cboExpansionPort.TabIndex = 17;
|
||||
this.cboExpansionPort.SelectedIndexChanged += new System.EventHandler(this.cboExpansionPort_SelectedIndexChanged);
|
||||
//
|
||||
// chkFourScore
|
||||
//
|
||||
|
@ -344,7 +334,6 @@
|
|||
this.chkFourScore.TabIndex = 15;
|
||||
this.chkFourScore.Text = "Use Four Score accessory";
|
||||
this.chkFourScore.UseVisualStyleBackColor = true;
|
||||
this.chkFourScore.CheckedChanged += new System.EventHandler(this.chkFourScore_CheckedChanged);
|
||||
//
|
||||
// chkAutoConfigureInput
|
||||
//
|
||||
|
@ -416,7 +405,6 @@
|
|||
this.btnSetupExp.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText;
|
||||
this.btnSetupExp.UseVisualStyleBackColor = true;
|
||||
this.btnSetupExp.Visible = false;
|
||||
this.btnSetupExp.Click += new System.EventHandler(this.btnSetup_Click);
|
||||
//
|
||||
// lblCartridge
|
||||
//
|
||||
|
@ -448,7 +436,6 @@
|
|||
this.btnSetupCartridge.Text = "Setup";
|
||||
this.btnSetupCartridge.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText;
|
||||
this.btnSetupCartridge.UseVisualStyleBackColor = true;
|
||||
this.btnSetupCartridge.Click += new System.EventHandler(this.btnSetupCartridge_Click);
|
||||
//
|
||||
// tpgAdvanced
|
||||
//
|
||||
|
|
|
@ -51,6 +51,22 @@ namespace Mesen.GUI.Forms.Config
|
|||
UpdateConflictWarning();
|
||||
}
|
||||
|
||||
protected override void OnLoad(EventArgs e)
|
||||
{
|
||||
base.OnLoad(e);
|
||||
|
||||
btnSetupP1.Click += btnSetup_Click;
|
||||
btnSetupP2.Click += btnSetup_Click;
|
||||
btnSetupP3.Click += btnSetup_Click;
|
||||
btnSetupP4.Click += btnSetup_Click;
|
||||
|
||||
cboConsoleType.SelectedIndexChanged += cboNesType_SelectedIndexChanged;
|
||||
cboExpansionPort.SelectedIndexChanged += cboExpansionPort_SelectedIndexChanged;
|
||||
chkFourScore.CheckedChanged += chkFourScore_CheckedChanged;
|
||||
btnSetupExp.Click += btnSetup_Click;
|
||||
btnSetupCartridge.Click += btnSetupCartridge_Click;
|
||||
}
|
||||
|
||||
private void UpdateCartridgeInputUi()
|
||||
{
|
||||
ConsoleFeatures features = InteropEmu.GetAvailableFeatures();
|
||||
|
@ -102,23 +118,28 @@ namespace Mesen.GUI.Forms.Config
|
|||
|
||||
private void UpdateAvailableControllerTypes()
|
||||
{
|
||||
cboPlayer1.SelectedIndexChanged -= cboPlayerController_SelectedIndexChanged;
|
||||
cboPlayer2.SelectedIndexChanged -= cboPlayerController_SelectedIndexChanged;
|
||||
cboPlayer3.SelectedIndexChanged -= cboPlayerController_SelectedIndexChanged;
|
||||
cboPlayer4.SelectedIndexChanged -= cboPlayerController_SelectedIndexChanged;
|
||||
|
||||
bool isNes = ((InputInfo)Entity).ConsoleType == ConsoleType.Nes;
|
||||
bool p3and4visible = (isNes && chkFourScore.Checked) || (!isNes && ((InputInfo)Entity).ExpansionPortDevice == InteropEmu.ExpansionPortDevice.FourPlayerAdapter);
|
||||
bool isOriginalFamicom = !isNes && !ConfigManager.Config.EmulationInfo.UseNes101Hvc101Behavior;
|
||||
|
||||
List<InteropEmu.ControllerType> controllerTypes = new List<InteropEmu.ControllerType>() { InteropEmu.ControllerType.StandardController };
|
||||
if(!isOriginalFamicom) {
|
||||
controllerTypes.Add(InteropEmu.ControllerType.None);
|
||||
controllerTypes.Add(InteropEmu.ControllerType.SnesMouse);
|
||||
controllerTypes.Add(InteropEmu.ControllerType.SuborMouse);
|
||||
if(!isNes) {
|
||||
controllerTypes.Add(InteropEmu.ControllerType.SnesController);
|
||||
}
|
||||
List<InteropEmu.ControllerType> controllerTypes = new List<InteropEmu.ControllerType>() { InteropEmu.ControllerType.None, InteropEmu.ControllerType.StandardController };
|
||||
controllerTypes.Add(InteropEmu.ControllerType.SnesMouse);
|
||||
controllerTypes.Add(InteropEmu.ControllerType.SuborMouse);
|
||||
if(!isNes) {
|
||||
controllerTypes.Add(InteropEmu.ControllerType.SnesController);
|
||||
}
|
||||
SetAvailableControllerTypes(cboPlayer3, controllerTypes.ToArray());
|
||||
SetAvailableControllerTypes(cboPlayer4, controllerTypes.ToArray());
|
||||
|
||||
if(isNes && !chkFourScore.Checked) {
|
||||
if(isOriginalFamicom) {
|
||||
//Original famicom only allows standard controllers in port 1/2
|
||||
controllerTypes = new List<InteropEmu.ControllerType>() { InteropEmu.ControllerType.StandardController };
|
||||
} else if(isNes && !chkFourScore.Checked) {
|
||||
//These use more than just bit 0, and won't work on the four score
|
||||
controllerTypes.Add(InteropEmu.ControllerType.ArkanoidController);
|
||||
controllerTypes.Add(InteropEmu.ControllerType.PowerPad);
|
||||
|
@ -128,6 +149,11 @@ namespace Mesen.GUI.Forms.Config
|
|||
|
||||
SetAvailableControllerTypes(cboPlayer1, controllerTypes.ToArray());
|
||||
SetAvailableControllerTypes(cboPlayer2, controllerTypes.ToArray());
|
||||
|
||||
cboPlayer1.SelectedIndexChanged += cboPlayerController_SelectedIndexChanged;
|
||||
cboPlayer2.SelectedIndexChanged += cboPlayerController_SelectedIndexChanged;
|
||||
cboPlayer3.SelectedIndexChanged += cboPlayerController_SelectedIndexChanged;
|
||||
cboPlayer4.SelectedIndexChanged += cboPlayerController_SelectedIndexChanged;
|
||||
}
|
||||
|
||||
private void SetAvailableControllerTypes(ComboBox comboBox, InteropEmu.ControllerType[] controllerTypes)
|
||||
|
@ -170,24 +196,23 @@ namespace Mesen.GUI.Forms.Config
|
|||
|
||||
private void UpdateInterface()
|
||||
{
|
||||
if(!this.Updating) {
|
||||
bool isNes = ((InputInfo)Entity).ConsoleType == ConsoleType.Nes;
|
||||
cboExpansionPort.Visible = !isNes;
|
||||
lblExpansionPort.Visible = !isNes;
|
||||
btnSetupExp.Visible = !isNes;
|
||||
chkFourScore.Visible = isNes;
|
||||
bool isNes = ((InputInfo)Entity).ConsoleType == ConsoleType.Nes;
|
||||
cboExpansionPort.Visible = !isNes;
|
||||
lblExpansionPort.Visible = !isNes;
|
||||
btnSetupExp.Visible = !isNes;
|
||||
chkFourScore.Visible = isNes;
|
||||
|
||||
UpdatePlayer3And4Visibility();
|
||||
UpdateAvailableControllerTypes();
|
||||
UpdatePlayer3And4Visibility();
|
||||
UpdateAvailableControllerTypes();
|
||||
UpdateSetupButtons();
|
||||
|
||||
if(ConfigManager.Config.PreferenceInfo.DisableGameDatabase) {
|
||||
//This option requires the game DB to be active
|
||||
chkAutoConfigureInput.Enabled = false;
|
||||
chkAutoConfigureInput.Checked = false;
|
||||
}
|
||||
|
||||
UpdateConflictWarning();
|
||||
if(ConfigManager.Config.PreferenceInfo.DisableGameDatabase) {
|
||||
//This option requires the game DB to be active
|
||||
chkAutoConfigureInput.Enabled = false;
|
||||
chkAutoConfigureInput.Checked = false;
|
||||
}
|
||||
|
||||
UpdateConflictWarning();
|
||||
}
|
||||
|
||||
private bool FourScoreAttached
|
||||
|
@ -215,29 +240,42 @@ namespace Mesen.GUI.Forms.Config
|
|||
|
||||
private void cboNesType_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if(!this.Updating) {
|
||||
UpdateObject();
|
||||
if(((InputInfo)Entity).ConsoleType == ConsoleType.Famicom) {
|
||||
((InputInfo)Entity).Controllers[0].ControllerType = InteropEmu.ControllerType.StandardController;
|
||||
((InputInfo)Entity).Controllers[1].ControllerType = InteropEmu.ControllerType.StandardController;
|
||||
}
|
||||
UpdateInterface();
|
||||
UpdateObject();
|
||||
if(((InputInfo)Entity).ConsoleType == ConsoleType.Famicom) {
|
||||
((InputInfo)Entity).Controllers[0].ControllerType = InteropEmu.ControllerType.StandardController;
|
||||
((InputInfo)Entity).Controllers[1].ControllerType = InteropEmu.ControllerType.StandardController;
|
||||
}
|
||||
UpdateInterface();
|
||||
}
|
||||
|
||||
private void chkFourScore_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
if(!this.Updating) {
|
||||
UpdateObject();
|
||||
UpdateInterface();
|
||||
}
|
||||
UpdateObject();
|
||||
UpdateInterface();
|
||||
}
|
||||
|
||||
private void cboExpansionPort_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if(!this.Updating) {
|
||||
UpdateObject();
|
||||
UpdateInterface();
|
||||
UpdateObject();
|
||||
UpdateInterface();
|
||||
}
|
||||
|
||||
private void UpdateSetupButtons()
|
||||
{
|
||||
List<ComboBox> dropdowns = new List<ComboBox>() { cboPlayer1, cboPlayer2, cboPlayer3, cboPlayer4 };
|
||||
List<Button> buttons = new List<Button>() { btnSetupP1, btnSetupP2, btnSetupP3, btnSetupP4 };
|
||||
|
||||
for(int i = 0; i < 4; i++) {
|
||||
object selectedItem = dropdowns[i].SelectedItem;
|
||||
bool enableButton = selectedItem.Equals(ResourceHelper.GetEnumText(InteropEmu.ControllerType.StandardController)) ||
|
||||
selectedItem.Equals(ResourceHelper.GetEnumText(InteropEmu.ControllerType.Zapper)) ||
|
||||
selectedItem.Equals(ResourceHelper.GetEnumText(InteropEmu.ControllerType.SnesController)) ||
|
||||
selectedItem.Equals(ResourceHelper.GetEnumText(InteropEmu.ControllerType.SnesMouse)) ||
|
||||
selectedItem.Equals(ResourceHelper.GetEnumText(InteropEmu.ControllerType.SuborMouse)) ||
|
||||
selectedItem.Equals(ResourceHelper.GetEnumText(InteropEmu.ControllerType.ArkanoidController)) ||
|
||||
selectedItem.Equals(ResourceHelper.GetEnumText(InteropEmu.ControllerType.PowerPad));
|
||||
|
||||
buttons[i].Enabled = enableButton;
|
||||
}
|
||||
|
||||
btnSetupExp.Enabled = cboExpansionPort.SelectedItem.Equals(ResourceHelper.GetEnumText(InteropEmu.ExpansionPortDevice.Zapper)) ||
|
||||
|
@ -254,26 +292,8 @@ namespace Mesen.GUI.Forms.Config
|
|||
|
||||
private void cboPlayerController_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
object selectedItem = ((ComboBox)sender).SelectedItem;
|
||||
|
||||
bool enableButton = selectedItem.Equals(ResourceHelper.GetEnumText(InteropEmu.ControllerType.StandardController)) ||
|
||||
selectedItem.Equals(ResourceHelper.GetEnumText(InteropEmu.ControllerType.Zapper)) ||
|
||||
selectedItem.Equals(ResourceHelper.GetEnumText(InteropEmu.ControllerType.SnesController)) ||
|
||||
selectedItem.Equals(ResourceHelper.GetEnumText(InteropEmu.ControllerType.SnesMouse)) ||
|
||||
selectedItem.Equals(ResourceHelper.GetEnumText(InteropEmu.ControllerType.SuborMouse)) ||
|
||||
selectedItem.Equals(ResourceHelper.GetEnumText(InteropEmu.ControllerType.ArkanoidController)) ||
|
||||
selectedItem.Equals(ResourceHelper.GetEnumText(InteropEmu.ControllerType.PowerPad));
|
||||
|
||||
if(sender == cboPlayer1) {
|
||||
btnSetupP1.Enabled = enableButton;
|
||||
} else if(sender == cboPlayer2) {
|
||||
btnSetupP2.Enabled = enableButton;
|
||||
} else if(sender == cboPlayer3) {
|
||||
btnSetupP3.Enabled = enableButton;
|
||||
} else if(sender == cboPlayer4) {
|
||||
btnSetupP4.Enabled = enableButton;
|
||||
}
|
||||
UpdateConflictWarning();
|
||||
UpdateObject();
|
||||
UpdateInterface();
|
||||
}
|
||||
|
||||
private void btnSetup_Click(object sender, EventArgs e)
|
||||
|
@ -404,7 +424,7 @@ namespace Mesen.GUI.Forms.Config
|
|||
frm.Top = point.Y;
|
||||
frm.Left = point.X;
|
||||
if(frm.ShowDialog(this) == DialogResult.OK) {
|
||||
UpdateConflictWarning();
|
||||
UpdateInterface();
|
||||
}
|
||||
frm.Dispose();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue