2015-07-10 21:07:24 -04:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using Mesen.GUI.Config;
|
|
|
|
|
|
|
|
|
|
namespace Mesen.GUI.Forms.Config
|
|
|
|
|
{
|
|
|
|
|
public partial class frmInputConfig : BaseConfigForm
|
|
|
|
|
{
|
2017-12-25 23:26:35 -05:00
|
|
|
|
private bool _hasCartridgeInput = false;
|
|
|
|
|
|
2015-07-10 21:07:24 -04:00
|
|
|
|
public frmInputConfig()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
|
2017-02-25 15:15:44 -05:00
|
|
|
|
tlpControllers.Enabled = !InteropEmu.MoviePlaying() && !InteropEmu.MovieRecording();
|
|
|
|
|
|
2016-07-16 16:25:57 -04:00
|
|
|
|
InteropEmu.UpdateInputDevices();
|
|
|
|
|
|
2016-02-05 23:14:27 -05:00
|
|
|
|
Entity = ConfigManager.Config.InputInfo;
|
|
|
|
|
|
2017-02-25 14:20:30 -05:00
|
|
|
|
for(int i = 0; i < 4; i++) {
|
|
|
|
|
ConfigManager.Config.InputInfo.Controllers[i].ControllerType = InteropEmu.GetControllerType(i);
|
2016-07-09 15:58:49 -04:00
|
|
|
|
}
|
2017-02-25 14:20:30 -05:00
|
|
|
|
ConfigManager.Config.InputInfo.ExpansionPortDevice = InteropEmu.GetExpansionDevice();
|
|
|
|
|
ConfigManager.Config.InputInfo.ConsoleType = InteropEmu.GetConsoleType();
|
|
|
|
|
ConfigManager.Config.InputInfo.UseFourScore = InteropEmu.HasFourScore();
|
2016-07-09 15:58:49 -04:00
|
|
|
|
|
2016-02-05 23:14:27 -05:00
|
|
|
|
AddBinding("ExpansionPortDevice", cboExpansionPort);
|
|
|
|
|
AddBinding("ConsoleType", cboConsoleType);
|
|
|
|
|
AddBinding("UseFourScore", chkFourScore);
|
2016-07-09 15:58:49 -04:00
|
|
|
|
AddBinding("AutoConfigureInput", chkAutoConfigureInput);
|
2016-07-19 16:30:18 -04:00
|
|
|
|
|
|
|
|
|
AddBinding("DisplayInputPort1", chkDisplayPort1);
|
|
|
|
|
AddBinding("DisplayInputPort2", chkDisplayPort2);
|
|
|
|
|
AddBinding("DisplayInputPort3", chkDisplayPort3);
|
|
|
|
|
AddBinding("DisplayInputPort4", chkDisplayPort4);
|
|
|
|
|
AddBinding("DisplayInputPosition", cboDisplayInputPosition);
|
|
|
|
|
AddBinding("DisplayInputHorizontally", chkDisplayInputHorizontally);
|
2018-12-22 16:05:12 -05:00
|
|
|
|
AddBinding("HideMousePointerForZapper", chkHideMousePointerForZapper);
|
2017-05-02 23:16:26 -04:00
|
|
|
|
|
2017-12-16 14:06:00 -05:00
|
|
|
|
//Sort expansion port dropdown alphabetically, but keep the "None" option at the top
|
|
|
|
|
SortDropdown(cboExpansionPort, ResourceHelper.GetEnumText(InteropEmu.ExpansionPortDevice.None));
|
2017-12-25 23:26:35 -05:00
|
|
|
|
|
|
|
|
|
UpdateCartridgeInputUi();
|
|
|
|
|
UpdateConflictWarning();
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-28 18:15:25 -05:00
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-25 23:26:35 -05:00
|
|
|
|
private void UpdateCartridgeInputUi()
|
|
|
|
|
{
|
|
|
|
|
ConsoleFeatures features = InteropEmu.GetAvailableFeatures();
|
|
|
|
|
bool hasCartridgeInput = features.HasFlag(ConsoleFeatures.BandaiMicrophone) || features.HasFlag(ConsoleFeatures.DatachBarcodeReader);
|
|
|
|
|
_hasCartridgeInput = hasCartridgeInput;
|
|
|
|
|
lblCartridge.Visible = hasCartridgeInput;
|
|
|
|
|
cboCartridge.Visible = hasCartridgeInput;
|
|
|
|
|
btnSetupCartridge.Visible = hasCartridgeInput;
|
|
|
|
|
btnSetupCartridge.Enabled = features.HasFlag(ConsoleFeatures.BandaiMicrophone);
|
|
|
|
|
if(hasCartridgeInput) {
|
|
|
|
|
if(features.HasFlag(ConsoleFeatures.BandaiMicrophone)) {
|
|
|
|
|
cboCartridge.Items.Add(ResourceHelper.GetMessage("BandaiMicrophone"));
|
|
|
|
|
cboCartridge.SelectedIndex = 0;
|
|
|
|
|
} else if(features.HasFlag(ConsoleFeatures.DatachBarcodeReader)) {
|
|
|
|
|
cboCartridge.Items.Add(ResourceHelper.GetMessage("DatachBarcodeReader"));
|
|
|
|
|
cboCartridge.SelectedIndex = 0;
|
|
|
|
|
}
|
|
|
|
|
this.Height += (int)(30 * _yFactor);
|
|
|
|
|
}
|
2017-12-16 14:06:00 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void SortDropdown(ComboBox dropdown, string optionAtTop)
|
|
|
|
|
{
|
|
|
|
|
dropdown.Sorted = true;
|
|
|
|
|
dropdown.Sorted = false;
|
|
|
|
|
int index = dropdown.FindStringExact(optionAtTop);
|
|
|
|
|
|
|
|
|
|
if(index >= 0) {
|
|
|
|
|
object topOption = dropdown.Items[index];
|
|
|
|
|
dropdown.Items.RemoveAt(index);
|
|
|
|
|
dropdown.Items.Insert(0, topOption);
|
|
|
|
|
}
|
2016-02-05 23:14:27 -05:00
|
|
|
|
}
|
2017-11-19 23:08:23 -05:00
|
|
|
|
|
2017-02-25 14:20:30 -05:00
|
|
|
|
protected override void OnFormClosed(FormClosedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
base.OnFormClosed(e);
|
2017-11-19 23:08:23 -05:00
|
|
|
|
if(DialogResult == DialogResult.OK) {
|
|
|
|
|
InputInfo.ApplyConfig();
|
|
|
|
|
}
|
2017-02-25 14:20:30 -05:00
|
|
|
|
}
|
2016-02-05 23:14:27 -05:00
|
|
|
|
|
|
|
|
|
protected override void AfterUpdateUI()
|
|
|
|
|
{
|
|
|
|
|
base.AfterUpdateUI();
|
|
|
|
|
|
|
|
|
|
this.UpdateInterface();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void UpdateAvailableControllerTypes()
|
|
|
|
|
{
|
2017-12-28 18:15:25 -05:00
|
|
|
|
cboPlayer1.SelectedIndexChanged -= cboPlayerController_SelectedIndexChanged;
|
|
|
|
|
cboPlayer2.SelectedIndexChanged -= cboPlayerController_SelectedIndexChanged;
|
|
|
|
|
cboPlayer3.SelectedIndexChanged -= cboPlayerController_SelectedIndexChanged;
|
|
|
|
|
cboPlayer4.SelectedIndexChanged -= cboPlayerController_SelectedIndexChanged;
|
|
|
|
|
|
2016-02-05 23:14:27 -05:00
|
|
|
|
bool isNes = ((InputInfo)Entity).ConsoleType == ConsoleType.Nes;
|
2017-12-28 17:13:45 -05:00
|
|
|
|
bool isOriginalFamicom = !isNes && !ConfigManager.Config.EmulationInfo.UseNes101Hvc101Behavior;
|
2016-02-05 23:14:27 -05:00
|
|
|
|
|
2017-12-28 18:15:25 -05:00
|
|
|
|
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);
|
2016-02-05 23:14:27 -05:00
|
|
|
|
}
|
2017-12-28 17:13:45 -05:00
|
|
|
|
SetAvailableControllerTypes(cboPlayer3, controllerTypes.ToArray());
|
|
|
|
|
SetAvailableControllerTypes(cboPlayer4, controllerTypes.ToArray());
|
2017-02-25 10:56:38 -05:00
|
|
|
|
|
2017-12-28 18:15:25 -05:00
|
|
|
|
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) {
|
2017-12-28 17:13:45 -05:00
|
|
|
|
//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);
|
|
|
|
|
controllerTypes.Add(InteropEmu.ControllerType.Zapper);
|
|
|
|
|
controllerTypes.Add(InteropEmu.ControllerType.SnesController);
|
|
|
|
|
}
|
2017-02-25 10:56:38 -05:00
|
|
|
|
|
2017-12-28 17:13:45 -05:00
|
|
|
|
SetAvailableControllerTypes(cboPlayer1, controllerTypes.ToArray());
|
|
|
|
|
SetAvailableControllerTypes(cboPlayer2, controllerTypes.ToArray());
|
2017-12-28 18:15:25 -05:00
|
|
|
|
|
|
|
|
|
cboPlayer1.SelectedIndexChanged += cboPlayerController_SelectedIndexChanged;
|
|
|
|
|
cboPlayer2.SelectedIndexChanged += cboPlayerController_SelectedIndexChanged;
|
|
|
|
|
cboPlayer3.SelectedIndexChanged += cboPlayerController_SelectedIndexChanged;
|
|
|
|
|
cboPlayer4.SelectedIndexChanged += cboPlayerController_SelectedIndexChanged;
|
2016-02-05 23:14:27 -05:00
|
|
|
|
}
|
|
|
|
|
|
2017-12-28 17:13:45 -05:00
|
|
|
|
private void SetAvailableControllerTypes(ComboBox comboBox, InteropEmu.ControllerType[] controllerTypes)
|
2016-02-05 23:14:27 -05:00
|
|
|
|
{
|
|
|
|
|
comboBox.Items.Clear();
|
|
|
|
|
foreach(InteropEmu.ControllerType type in controllerTypes) {
|
2016-02-19 13:05:04 -05:00
|
|
|
|
comboBox.Items.Add(ResourceHelper.GetEnumText(type));
|
2016-02-05 23:14:27 -05:00
|
|
|
|
}
|
|
|
|
|
|
2017-09-06 00:22:46 -04:00
|
|
|
|
InputInfo inputInfo = (InputInfo)Entity;
|
|
|
|
|
string currentSelection = null;
|
|
|
|
|
if(comboBox == cboPlayer1) {
|
|
|
|
|
currentSelection = ResourceHelper.GetEnumText(inputInfo.Controllers[0].ControllerType);
|
|
|
|
|
} else if(comboBox == cboPlayer2) {
|
|
|
|
|
currentSelection = ResourceHelper.GetEnumText(inputInfo.Controllers[1].ControllerType);
|
|
|
|
|
} else if(comboBox == cboPlayer3) {
|
|
|
|
|
currentSelection = ResourceHelper.GetEnumText(inputInfo.Controllers[2].ControllerType);
|
|
|
|
|
} else if(comboBox == cboPlayer4) {
|
|
|
|
|
currentSelection = ResourceHelper.GetEnumText(inputInfo.Controllers[3].ControllerType);
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-16 14:06:00 -05:00
|
|
|
|
SortDropdown(comboBox, ResourceHelper.GetEnumText(InteropEmu.ControllerType.None));
|
|
|
|
|
|
2017-09-06 00:22:46 -04:00
|
|
|
|
if(currentSelection != null && comboBox.Items.Contains(currentSelection)) {
|
|
|
|
|
comboBox.SelectedItem = currentSelection;
|
|
|
|
|
} else {
|
2016-02-05 23:14:27 -05:00
|
|
|
|
comboBox.SelectedIndex = 0;
|
|
|
|
|
}
|
2015-07-10 21:07:24 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void UpdateConfig()
|
|
|
|
|
{
|
2016-02-05 23:14:27 -05:00
|
|
|
|
InputInfo inputInfo = (InputInfo)Entity;
|
|
|
|
|
|
2016-05-22 19:29:51 -04:00
|
|
|
|
inputInfo.Controllers[0].ControllerType = cboPlayer1.GetEnumValue<InteropEmu.ControllerType>();
|
|
|
|
|
inputInfo.Controllers[1].ControllerType = cboPlayer2.GetEnumValue<InteropEmu.ControllerType>();
|
|
|
|
|
inputInfo.Controllers[2].ControllerType = cboPlayer3.GetEnumValue<InteropEmu.ControllerType>();
|
|
|
|
|
inputInfo.Controllers[3].ControllerType = cboPlayer4.GetEnumValue<InteropEmu.ControllerType>();
|
2016-02-05 23:14:27 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void UpdateInterface()
|
|
|
|
|
{
|
2017-12-28 18:15:25 -05:00
|
|
|
|
bool isNes = ((InputInfo)Entity).ConsoleType == ConsoleType.Nes;
|
|
|
|
|
cboExpansionPort.Visible = !isNes;
|
|
|
|
|
lblExpansionPort.Visible = !isNes;
|
|
|
|
|
btnSetupExp.Visible = !isNes;
|
|
|
|
|
chkFourScore.Visible = isNes;
|
|
|
|
|
|
|
|
|
|
UpdatePlayer3And4Visibility();
|
|
|
|
|
UpdateAvailableControllerTypes();
|
|
|
|
|
UpdateSetupButtons();
|
2016-07-09 15:58:49 -04:00
|
|
|
|
|
2017-12-28 18:15:25 -05:00
|
|
|
|
if(ConfigManager.Config.PreferenceInfo.DisableGameDatabase) {
|
|
|
|
|
//This option requires the game DB to be active
|
|
|
|
|
chkAutoConfigureInput.Enabled = false;
|
|
|
|
|
chkAutoConfigureInput.Checked = false;
|
2017-05-02 23:16:26 -04:00
|
|
|
|
}
|
2017-12-28 18:15:25 -05:00
|
|
|
|
|
|
|
|
|
UpdateConflictWarning();
|
2017-05-02 23:16:26 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private bool FourScoreAttached
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
bool isNes = ((InputInfo)Entity).ConsoleType == ConsoleType.Nes;
|
|
|
|
|
return (isNes && chkFourScore.Checked) || (!isNes && ((InputInfo)Entity).ExpansionPortDevice == InteropEmu.ExpansionPortDevice.FourPlayerAdapter);
|
2016-02-05 23:14:27 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void UpdatePlayer3And4Visibility()
|
|
|
|
|
{
|
2017-05-02 23:16:26 -04:00
|
|
|
|
bool visible = this.FourScoreAttached;
|
2016-02-05 23:14:27 -05:00
|
|
|
|
|
2017-09-06 00:22:46 -04:00
|
|
|
|
if(lblPlayer3.Visible != visible) {
|
|
|
|
|
lblPlayer3.Visible = visible;
|
|
|
|
|
lblPlayer4.Visible = visible;
|
|
|
|
|
cboPlayer3.Visible = visible;
|
|
|
|
|
cboPlayer4.Visible = visible;
|
|
|
|
|
btnSetupP3.Visible = visible;
|
|
|
|
|
btnSetupP4.Visible = visible;
|
|
|
|
|
}
|
2016-02-05 23:14:27 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void cboNesType_SelectedIndexChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
2017-12-28 18:15:25 -05:00
|
|
|
|
UpdateObject();
|
|
|
|
|
if(((InputInfo)Entity).ConsoleType == ConsoleType.Famicom) {
|
|
|
|
|
((InputInfo)Entity).Controllers[0].ControllerType = InteropEmu.ControllerType.StandardController;
|
|
|
|
|
((InputInfo)Entity).Controllers[1].ControllerType = InteropEmu.ControllerType.StandardController;
|
2017-02-25 14:20:30 -05:00
|
|
|
|
}
|
2017-12-28 18:15:25 -05:00
|
|
|
|
UpdateInterface();
|
2016-02-05 23:14:27 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void chkFourScore_CheckedChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
2017-12-28 18:15:25 -05:00
|
|
|
|
UpdateObject();
|
|
|
|
|
UpdateInterface();
|
2016-02-05 23:14:27 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void cboExpansionPort_SelectedIndexChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
2017-12-28 18:15:25 -05:00
|
|
|
|
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;
|
2017-02-25 14:20:30 -05:00
|
|
|
|
}
|
2017-07-30 19:22:01 -04:00
|
|
|
|
|
2017-11-19 23:08:23 -05:00
|
|
|
|
btnSetupExp.Enabled = cboExpansionPort.SelectedItem.Equals(ResourceHelper.GetEnumText(InteropEmu.ExpansionPortDevice.Zapper)) ||
|
2017-12-16 14:06:00 -05:00
|
|
|
|
cboExpansionPort.SelectedItem.Equals(ResourceHelper.GetEnumText(InteropEmu.ExpansionPortDevice.FamilyTrainerMat)) ||
|
|
|
|
|
cboExpansionPort.SelectedItem.Equals(ResourceHelper.GetEnumText(InteropEmu.ExpansionPortDevice.ExcitingBoxing)) ||
|
|
|
|
|
cboExpansionPort.SelectedItem.Equals(ResourceHelper.GetEnumText(InteropEmu.ExpansionPortDevice.JissenMahjong)) ||
|
|
|
|
|
cboExpansionPort.SelectedItem.Equals(ResourceHelper.GetEnumText(InteropEmu.ExpansionPortDevice.FamilyBasicKeyboard)) ||
|
|
|
|
|
cboExpansionPort.SelectedItem.Equals(ResourceHelper.GetEnumText(InteropEmu.ExpansionPortDevice.SuborKeyboard)) ||
|
2017-12-19 11:00:48 -05:00
|
|
|
|
cboExpansionPort.SelectedItem.Equals(ResourceHelper.GetEnumText(InteropEmu.ExpansionPortDevice.Pachinko)) ||
|
2017-12-21 21:31:42 -05:00
|
|
|
|
cboExpansionPort.SelectedItem.Equals(ResourceHelper.GetEnumText(InteropEmu.ExpansionPortDevice.ArkanoidController)) ||
|
|
|
|
|
cboExpansionPort.SelectedItem.Equals(ResourceHelper.GetEnumText(InteropEmu.ExpansionPortDevice.HoriTrack)) ||
|
2017-12-16 14:06:00 -05:00
|
|
|
|
cboExpansionPort.SelectedItem.Equals(ResourceHelper.GetEnumText(InteropEmu.ExpansionPortDevice.PartyTap));
|
2016-02-05 23:14:27 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void cboPlayerController_SelectedIndexChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
2017-12-28 18:15:25 -05:00
|
|
|
|
UpdateObject();
|
|
|
|
|
UpdateInterface();
|
2016-02-05 23:14:27 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnSetup_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
int index = 0;
|
2017-07-30 19:22:01 -04:00
|
|
|
|
object selectedItem = null;
|
2017-12-21 21:31:42 -05:00
|
|
|
|
string selectedText = "";
|
2016-02-05 23:14:27 -05:00
|
|
|
|
if(sender == btnSetupP1) {
|
2017-11-19 23:08:23 -05:00
|
|
|
|
selectedItem = cboPlayer1.GetEnumValue<InteropEmu.ControllerType>();
|
2017-12-21 21:31:42 -05:00
|
|
|
|
selectedText = cboPlayer1.SelectedItem.ToString();
|
2016-02-05 23:14:27 -05:00
|
|
|
|
index = 0;
|
|
|
|
|
} else if(sender == btnSetupP2) {
|
2017-11-19 23:08:23 -05:00
|
|
|
|
selectedItem = cboPlayer2.GetEnumValue<InteropEmu.ControllerType>();
|
2017-12-21 21:31:42 -05:00
|
|
|
|
selectedText = cboPlayer2.SelectedItem.ToString();
|
2016-02-05 23:14:27 -05:00
|
|
|
|
index = 1;
|
|
|
|
|
} else if(sender == btnSetupP3) {
|
2017-11-19 23:08:23 -05:00
|
|
|
|
selectedItem = cboPlayer3.GetEnumValue<InteropEmu.ControllerType>();
|
2017-12-21 21:31:42 -05:00
|
|
|
|
selectedText = cboPlayer3.SelectedItem.ToString();
|
2016-02-05 23:14:27 -05:00
|
|
|
|
index = 2;
|
|
|
|
|
} else if(sender == btnSetupP4) {
|
2017-11-19 23:08:23 -05:00
|
|
|
|
selectedItem = cboPlayer4.GetEnumValue<InteropEmu.ControllerType>();
|
2017-12-21 21:31:42 -05:00
|
|
|
|
selectedText = cboPlayer4.SelectedItem.ToString();
|
2016-02-05 23:14:27 -05:00
|
|
|
|
index = 3;
|
2017-07-30 19:22:01 -04:00
|
|
|
|
} else if(sender == btnSetupExp) {
|
2017-11-19 23:08:23 -05:00
|
|
|
|
selectedItem = cboExpansionPort.GetEnumValue<InteropEmu.ExpansionPortDevice>();
|
2017-12-21 21:31:42 -05:00
|
|
|
|
selectedText = cboExpansionPort.SelectedItem.ToString();
|
2017-07-30 19:22:01 -04:00
|
|
|
|
index = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Form frm = null;
|
2017-09-06 00:22:46 -04:00
|
|
|
|
InputInfo inputInfo = (InputInfo)Entity;
|
2017-11-19 23:08:23 -05:00
|
|
|
|
if(selectedItem is InteropEmu.ControllerType) {
|
|
|
|
|
InteropEmu.ControllerType type = (InteropEmu.ControllerType)selectedItem;
|
|
|
|
|
switch(type) {
|
|
|
|
|
case InteropEmu.ControllerType.StandardController:
|
|
|
|
|
case InteropEmu.ControllerType.SnesController:
|
|
|
|
|
frm = new frmControllerConfig(inputInfo.Controllers[index], index, cboConsoleType.GetEnumValue<ConsoleType>(), type);
|
|
|
|
|
break;
|
|
|
|
|
|
2017-12-16 14:06:00 -05:00
|
|
|
|
case InteropEmu.ControllerType.PowerPad:
|
|
|
|
|
frm = new frmPowerPadConfig(inputInfo.Controllers[index], index);
|
|
|
|
|
break;
|
|
|
|
|
|
2017-11-19 23:08:23 -05:00
|
|
|
|
case InteropEmu.ControllerType.Zapper:
|
|
|
|
|
frm = new frmZapperConfig(inputInfo.Zapper);
|
|
|
|
|
break;
|
2017-12-21 21:31:42 -05:00
|
|
|
|
|
|
|
|
|
case InteropEmu.ControllerType.SnesMouse:
|
|
|
|
|
frm = new frmMouseConfig(inputInfo.SnesMouse);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case InteropEmu.ControllerType.SuborMouse:
|
|
|
|
|
frm = new frmMouseConfig(inputInfo.SuborMouse);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case InteropEmu.ControllerType.ArkanoidController:
|
|
|
|
|
frm = new frmMouseConfig(inputInfo.ArkanoidController);
|
|
|
|
|
break;
|
2017-11-19 23:08:23 -05:00
|
|
|
|
}
|
|
|
|
|
} else if(selectedItem is InteropEmu.ExpansionPortDevice) {
|
|
|
|
|
InteropEmu.ExpansionPortDevice device = (InteropEmu.ExpansionPortDevice)selectedItem;
|
|
|
|
|
switch(device) {
|
|
|
|
|
case InteropEmu.ExpansionPortDevice.FamilyTrainerMat:
|
2017-12-16 14:06:00 -05:00
|
|
|
|
frm = new frmPowerPadConfig(inputInfo.Controllers[index], index);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case InteropEmu.ExpansionPortDevice.PartyTap:
|
|
|
|
|
frm = new frmPartytapConfig(inputInfo.Controllers[index]);
|
|
|
|
|
break;
|
|
|
|
|
|
2017-12-19 11:00:48 -05:00
|
|
|
|
case InteropEmu.ExpansionPortDevice.Pachinko:
|
|
|
|
|
frm = new frmPachinkoConfig(inputInfo.Controllers[index]);
|
|
|
|
|
break;
|
|
|
|
|
|
2017-12-16 14:06:00 -05:00
|
|
|
|
case InteropEmu.ExpansionPortDevice.ExcitingBoxing:
|
|
|
|
|
frm = new frmExcitingBoxingConfig(inputInfo.Controllers[index]);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case InteropEmu.ExpansionPortDevice.JissenMahjong:
|
|
|
|
|
frm = new frmJissenMahjongConfig(inputInfo.Controllers[index]);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case InteropEmu.ExpansionPortDevice.FamilyBasicKeyboard:
|
|
|
|
|
frm = new frmFamilyBasicKeyboardConfig(inputInfo.Controllers[index]);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case InteropEmu.ExpansionPortDevice.SuborKeyboard:
|
|
|
|
|
frm = new frmSuborKeyboardConfig(inputInfo.Controllers[index]);
|
2017-11-19 23:08:23 -05:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case InteropEmu.ExpansionPortDevice.Zapper:
|
2017-12-21 21:31:42 -05:00
|
|
|
|
case InteropEmu.ExpansionPortDevice.BandaiHyperShot:
|
2017-11-19 23:08:23 -05:00
|
|
|
|
frm = new frmZapperConfig(inputInfo.Zapper);
|
|
|
|
|
break;
|
2017-12-21 21:31:42 -05:00
|
|
|
|
|
|
|
|
|
case InteropEmu.ExpansionPortDevice.HoriTrack:
|
|
|
|
|
frm = new frmMouseConfig(inputInfo.HoriTrack);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case InteropEmu.ExpansionPortDevice.ArkanoidController:
|
|
|
|
|
frm = new frmMouseConfig(inputInfo.ArkanoidController);
|
|
|
|
|
break;
|
2017-11-19 23:08:23 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
2016-02-05 23:14:27 -05:00
|
|
|
|
|
2017-07-30 19:22:01 -04:00
|
|
|
|
if(frm != null) {
|
2017-12-25 23:26:35 -05:00
|
|
|
|
OpenSetupWindow(frm, (Button)sender, selectedText);
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-05-02 23:16:26 -04:00
|
|
|
|
|
2017-12-25 23:26:35 -05:00
|
|
|
|
private void OpenSetupWindow(Form frm, Button btn, string title)
|
|
|
|
|
{
|
|
|
|
|
Point point = btn.PointToScreen(new Point(0, btn.Height));
|
|
|
|
|
Rectangle screen = Screen.FromControl(btn).Bounds;
|
2017-05-02 23:16:26 -04:00
|
|
|
|
|
2017-12-25 23:26:35 -05:00
|
|
|
|
if(frm.Height + point.Y > screen.Bottom) {
|
|
|
|
|
//Show on top instead
|
|
|
|
|
point.Y -= btn.Height + frm.Height;
|
2019-01-03 18:14:14 -05:00
|
|
|
|
|
|
|
|
|
if(point.Y < 0) {
|
|
|
|
|
point.Y = 0;
|
|
|
|
|
}
|
2017-12-25 23:26:35 -05:00
|
|
|
|
}
|
2016-02-05 23:14:27 -05:00
|
|
|
|
|
2017-12-25 23:26:35 -05:00
|
|
|
|
if(frm.Width + point.X > screen.Right) {
|
|
|
|
|
//Show on left instead
|
|
|
|
|
point.X -= frm.Width - btn.Width;
|
2019-01-03 18:14:14 -05:00
|
|
|
|
if(point.X < 0) {
|
|
|
|
|
point.X = 0;
|
|
|
|
|
}
|
2016-02-05 23:14:27 -05:00
|
|
|
|
}
|
2017-12-25 23:26:35 -05:00
|
|
|
|
|
|
|
|
|
frm.Text = title;
|
|
|
|
|
frm.StartPosition = FormStartPosition.Manual;
|
|
|
|
|
frm.Top = point.Y;
|
|
|
|
|
frm.Left = point.X;
|
2018-07-02 21:59:00 -04:00
|
|
|
|
|
|
|
|
|
Configuration configBackup = ConfigManager.Config.Clone();
|
2017-12-25 23:26:35 -05:00
|
|
|
|
if(frm.ShowDialog(this) == DialogResult.OK) {
|
2017-12-28 18:15:25 -05:00
|
|
|
|
UpdateInterface();
|
2018-07-02 21:59:00 -04:00
|
|
|
|
} else {
|
|
|
|
|
ConfigManager.RevertDirtyToBackup(configBackup);
|
|
|
|
|
Entity = ConfigManager.Config.InputInfo;
|
2017-12-25 23:26:35 -05:00
|
|
|
|
}
|
2018-07-02 21:59:00 -04:00
|
|
|
|
|
2017-12-25 23:26:35 -05:00
|
|
|
|
frm.Dispose();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnSetupCartridge_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Form frm = new frmBandaiMicrophone(((InputInfo)Entity).Controllers[0]);
|
|
|
|
|
OpenSetupWindow(frm, (Button)sender, cboCartridge.SelectedItem.ToString());
|
2017-05-02 23:16:26 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void UpdateConflictWarning()
|
|
|
|
|
{
|
|
|
|
|
bool needWarning = false;
|
2017-12-25 23:59:22 -05:00
|
|
|
|
bool[] portConflicts = new bool[6];
|
|
|
|
|
Dictionary<uint, List<int>> mappedKeys = new Dictionary<uint, List<int>>();
|
2017-05-02 23:16:26 -04:00
|
|
|
|
Action<int, uint> countMapping = (int port, uint keyCode) => {
|
|
|
|
|
if(keyCode > 0) {
|
|
|
|
|
if(mappedKeys.ContainsKey(keyCode)) {
|
|
|
|
|
needWarning = true;
|
2017-12-25 23:59:22 -05:00
|
|
|
|
mappedKeys[keyCode].Add(port);
|
|
|
|
|
foreach(int conflictingPorts in mappedKeys[keyCode]) {
|
|
|
|
|
portConflicts[conflictingPorts] = true;
|
|
|
|
|
}
|
2017-05-02 23:16:26 -04:00
|
|
|
|
} else {
|
2017-12-25 23:59:22 -05:00
|
|
|
|
mappedKeys.Add(keyCode, new List<int>() { port });
|
2017-05-02 23:16:26 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
2016-02-05 23:14:27 -05:00
|
|
|
|
|
2017-12-25 23:59:22 -05:00
|
|
|
|
InputInfo inputInfo = (InputInfo)Entity;
|
2017-05-02 23:16:26 -04:00
|
|
|
|
for(int i = 0; i < 4; i++) {
|
2017-12-25 23:59:22 -05:00
|
|
|
|
ControllerInfo controllerInfo = inputInfo.Controllers[i];
|
2017-05-02 23:16:26 -04:00
|
|
|
|
if(i < 2 || this.FourScoreAttached && ((i == 2 && btnSetupP3.Enabled) || (i == 3 && btnSetupP4.Enabled))) {
|
2017-12-25 23:59:22 -05:00
|
|
|
|
foreach(KeyMappings mappings in controllerInfo.Keys) {
|
|
|
|
|
switch(controllerInfo.ControllerType) {
|
|
|
|
|
case InteropEmu.ControllerType.StandardController:
|
|
|
|
|
case InteropEmu.ControllerType.SnesController:
|
|
|
|
|
countMapping(i, mappings.A);
|
|
|
|
|
countMapping(i, mappings.B);
|
|
|
|
|
countMapping(i, mappings.Select);
|
|
|
|
|
countMapping(i, mappings.Start);
|
|
|
|
|
countMapping(i, mappings.TurboA);
|
|
|
|
|
countMapping(i, mappings.TurboB);
|
|
|
|
|
countMapping(i, mappings.TurboSelect);
|
|
|
|
|
countMapping(i, mappings.TurboStart);
|
|
|
|
|
countMapping(i, mappings.Up);
|
|
|
|
|
countMapping(i, mappings.Down);
|
|
|
|
|
countMapping(i, mappings.Left);
|
|
|
|
|
countMapping(i, mappings.Right);
|
|
|
|
|
if(i == 1 && inputInfo.ConsoleType == ConsoleType.Famicom && controllerInfo.ControllerType == InteropEmu.ControllerType.StandardController) {
|
|
|
|
|
countMapping(i, mappings.Microphone);
|
|
|
|
|
}
|
|
|
|
|
if(controllerInfo.ControllerType == InteropEmu.ControllerType.SnesController) {
|
|
|
|
|
countMapping(i, mappings.LButton);
|
|
|
|
|
countMapping(i, mappings.RButton);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case InteropEmu.ControllerType.PowerPad:
|
2018-06-03 18:05:17 -04:00
|
|
|
|
foreach(UInt32 button in mappings.PowerPadButtons.Values) {
|
2017-12-25 23:59:22 -05:00
|
|
|
|
countMapping(i, button);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(inputInfo.ConsoleType == ConsoleType.Famicom) {
|
|
|
|
|
foreach(KeyMappings mappings in inputInfo.Controllers[0].Keys) {
|
|
|
|
|
switch(inputInfo.ExpansionPortDevice) {
|
|
|
|
|
case InteropEmu.ExpansionPortDevice.ExcitingBoxing:
|
2018-06-03 18:05:17 -04:00
|
|
|
|
foreach(UInt32 button in mappings.ExcitingBoxingButtons.Values) {
|
2017-12-25 23:59:22 -05:00
|
|
|
|
countMapping(4, button);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case InteropEmu.ExpansionPortDevice.FamilyTrainerMat:
|
2018-06-03 18:05:17 -04:00
|
|
|
|
foreach(UInt32 button in mappings.PowerPadButtons.Values) {
|
2017-12-25 23:59:22 -05:00
|
|
|
|
countMapping(4, button);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case InteropEmu.ExpansionPortDevice.JissenMahjong:
|
2018-06-03 18:05:17 -04:00
|
|
|
|
foreach(UInt32 button in mappings.JissenMahjongButtons.Values) {
|
2017-12-25 23:59:22 -05:00
|
|
|
|
countMapping(4, button);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case InteropEmu.ExpansionPortDevice.Pachinko:
|
2018-06-03 18:05:17 -04:00
|
|
|
|
foreach(UInt32 button in mappings.PachinkoButtons.Values) {
|
2017-12-25 23:59:22 -05:00
|
|
|
|
countMapping(4, button);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case InteropEmu.ExpansionPortDevice.PartyTap:
|
2018-06-03 18:05:17 -04:00
|
|
|
|
foreach(UInt32 button in mappings.PartyTapButtons.Values) {
|
2017-12-25 23:59:22 -05:00
|
|
|
|
countMapping(4, button);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(_hasCartridgeInput && btnSetupCartridge.Enabled) {
|
|
|
|
|
//Bandai microphone
|
|
|
|
|
foreach(KeyMappings mappings in inputInfo.Controllers[0].Keys) {
|
2018-06-03 18:05:17 -04:00
|
|
|
|
foreach(UInt32 button in mappings.BandaiMicrophoneButtons.Values) {
|
2017-12-25 23:59:22 -05:00
|
|
|
|
countMapping(5, button);
|
2017-05-02 23:16:26 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
2016-02-05 23:14:27 -05:00
|
|
|
|
}
|
2015-07-10 21:07:24 -04:00
|
|
|
|
|
2017-09-06 00:22:46 -04:00
|
|
|
|
if(pnlConflictWarning.Visible != needWarning) {
|
|
|
|
|
pnlConflictWarning.Visible = needWarning;
|
2017-12-25 23:26:35 -05:00
|
|
|
|
this.Height = (int)(((needWarning ? 360 : 310) + (_hasCartridgeInput ? 30 : 0)) * _yFactor);
|
2017-11-19 23:08:23 -05:00
|
|
|
|
}
|
|
|
|
|
if(portConflicts[0] == (btnSetupP1.Image == null)) {
|
2017-09-06 00:22:46 -04:00
|
|
|
|
btnSetupP1.Image = portConflicts[0] ? Properties.Resources.Warning : null;
|
2017-11-19 23:08:23 -05:00
|
|
|
|
}
|
2017-12-25 23:59:22 -05:00
|
|
|
|
if(portConflicts[1] == (btnSetupP2.Image == null)) {
|
2017-09-06 00:22:46 -04:00
|
|
|
|
btnSetupP2.Image = portConflicts[1] ? Properties.Resources.Warning : null;
|
2017-11-19 23:08:23 -05:00
|
|
|
|
}
|
|
|
|
|
if(portConflicts[2] == (btnSetupP3.Image == null)) {
|
2017-09-06 00:22:46 -04:00
|
|
|
|
btnSetupP3.Image = portConflicts[2] ? Properties.Resources.Warning : null;
|
2017-11-19 23:08:23 -05:00
|
|
|
|
}
|
|
|
|
|
if(portConflicts[3] == (btnSetupP4.Image == null)) {
|
2017-09-06 00:22:46 -04:00
|
|
|
|
btnSetupP4.Image = portConflicts[3] ? Properties.Resources.Warning : null;
|
|
|
|
|
}
|
2017-12-25 23:59:22 -05:00
|
|
|
|
if(portConflicts[4] == (btnSetupExp.Image == null)) {
|
|
|
|
|
btnSetupExp.Image = portConflicts[4] ? Properties.Resources.Warning : null;
|
|
|
|
|
}
|
|
|
|
|
if(portConflicts[5] == (btnSetupCartridge.Image == null)) {
|
|
|
|
|
btnSetupCartridge.Image = portConflicts[5] ? Properties.Resources.Warning : null;
|
|
|
|
|
}
|
2015-07-10 21:07:24 -04:00
|
|
|
|
}
|
2017-09-17 01:29:17 -04:00
|
|
|
|
|
|
|
|
|
float _yFactor = 1;
|
|
|
|
|
protected override void ScaleControl(SizeF factor, BoundsSpecified specified)
|
|
|
|
|
{
|
|
|
|
|
_yFactor = factor.Height;
|
|
|
|
|
base.ScaleControl(factor, specified);
|
|
|
|
|
}
|
2015-07-10 21:07:24 -04:00
|
|
|
|
}
|
|
|
|
|
}
|