refactor psx controller P# assignment to reusable code
This commit is contained in:
parent
b0ff8d586c
commit
8a1fd67497
|
@ -64,28 +64,33 @@ namespace BizHawk.Client.EmuHawk
|
|||
combo_2_4.Enabled = b2;
|
||||
lbl_p_2_2.Visible = b2;
|
||||
lbl_p_2_3.Visible = b2;
|
||||
lbl_p_2_4.Visible = b2;
|
||||
lbl_p_2_4.Visible = b2;
|
||||
|
||||
OctoshockControlUserConfig uc = new OctoshockControlUserConfig();
|
||||
|
||||
uc.Multitaps[0] = multitap_1;
|
||||
uc.Multitaps[1] = multitap_2;
|
||||
|
||||
int id = 1;
|
||||
List<int> Assignments = new List<int>();
|
||||
if (combo_1_1.SelectedIndex == 0) Assignments.Add(-1); else Assignments.Add(id++);
|
||||
if (combo_1_2.SelectedIndex == 0 || !multitap_1) Assignments.Add(-1); else Assignments.Add(id++);
|
||||
if (combo_1_3.SelectedIndex == 0 || !multitap_1) Assignments.Add(-1); else Assignments.Add(id++);
|
||||
if (combo_1_4.SelectedIndex == 0 || !multitap_1) Assignments.Add(-1); else Assignments.Add(id++);
|
||||
if (combo_2_1.SelectedIndex == 0) Assignments.Add(-1); else Assignments.Add(id++);
|
||||
if (combo_2_2.SelectedIndex == 0 || !multitap_2) Assignments.Add(-1); else Assignments.Add(id++);
|
||||
if (combo_2_3.SelectedIndex == 0 || !multitap_2) Assignments.Add(-1); else Assignments.Add(id++);
|
||||
if (combo_2_4.SelectedIndex == 0 || !multitap_2) Assignments.Add(-1); else Assignments.Add(id++);
|
||||
var combos = new[] { combo_1_1, combo_1_2, combo_1_3, combo_1_4, combo_2_1, combo_2_2, combo_2_3, combo_2_4};
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
var combo = combos[i];
|
||||
if (combo.SelectedIndex == 0) uc.Devices8[i] = OctoshockDll.ePeripheralType.None;
|
||||
if (combo.SelectedIndex == 1) uc.Devices8[i] = OctoshockDll.ePeripheralType.DualAnalog;
|
||||
if (combo.SelectedIndex == 2) uc.Devices8[i] = OctoshockDll.ePeripheralType.DualShock;
|
||||
}
|
||||
|
||||
var LC = uc.ToLogicalConfig();
|
||||
|
||||
var p_labels = new[] { lbl_p_1_1,lbl_p_1_2,lbl_p_1_3,lbl_p_1_4,lbl_p_2_1,lbl_p_2_2,lbl_p_2_3,lbl_p_2_4};
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
var lbl = p_labels[i];
|
||||
if (Assignments[i] == -1)
|
||||
if (LC.PlayerAssignments[i] == -1)
|
||||
lbl.Visible = false;
|
||||
else
|
||||
{
|
||||
lbl.Text = "P" + Assignments[i];
|
||||
lbl.Text = "P" + LC.PlayerAssignments[i];
|
||||
lbl.Visible = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -772,7 +772,10 @@
|
|||
<Compile Include="Consoles\Sega\SMS\VDP.Tables.cs" />
|
||||
<Compile Include="Consoles\Sony\PSP\PPSSPPDll.cs" />
|
||||
<Compile Include="Consoles\Sony\PSP\PSP.cs" />
|
||||
<Compile Include="Consoles\Sony\PSX\Octoshock.cs" />
|
||||
<Compile Include="Consoles\Sony\PSX\Octoshock.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Consoles\Sony\PSX\OctoshockControlConfig.cs" />
|
||||
<Compile Include="Consoles\Sony\PSX\OctoshockDll.cs" />
|
||||
<Compile Include="Consoles\Sony\PSX\PSF.cs" />
|
||||
<Compile Include="Consoles\WonderSwan\BizSwan.cs" />
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace BizHawk.Emulation.Cores.Sony.PSX
|
||||
{
|
||||
public class OctoshockControlUserConfig
|
||||
{
|
||||
public bool[] Multitaps = new bool[2];
|
||||
public OctoshockDll.ePeripheralType[] Devices8 = new OctoshockDll.ePeripheralType[8];
|
||||
|
||||
public OctoshockControlLogicalConfig ToLogicalConfig()
|
||||
{
|
||||
var lc = new OctoshockControlLogicalConfig();
|
||||
lc.PopulateFrom(this);
|
||||
return lc;
|
||||
}
|
||||
}
|
||||
|
||||
public class OctoshockControlLogicalConfig
|
||||
{
|
||||
public int[] PlayerAssignments = new int[8];
|
||||
public bool[] Multitaps;
|
||||
public OctoshockDll.ePeripheralType[] Devices8;
|
||||
|
||||
internal void PopulateFrom(OctoshockControlUserConfig userConfig)
|
||||
{
|
||||
Multitaps = (bool[])userConfig.Multitaps.Clone();
|
||||
Devices8 = (OctoshockDll.ePeripheralType[])userConfig.Devices8.Clone();
|
||||
|
||||
int id = 1;
|
||||
|
||||
if (userConfig.Devices8[0] == OctoshockDll.ePeripheralType.None) PlayerAssignments[0] = -1; else PlayerAssignments[0] = id++;
|
||||
if (userConfig.Devices8[1] == OctoshockDll.ePeripheralType.None || !userConfig.Multitaps[0]) PlayerAssignments[1] = -1; else PlayerAssignments[1] = id++;
|
||||
if (userConfig.Devices8[2] == OctoshockDll.ePeripheralType.None || !userConfig.Multitaps[0]) PlayerAssignments[2] = -1; else PlayerAssignments[2] = id++;
|
||||
if (userConfig.Devices8[3] == OctoshockDll.ePeripheralType.None || !userConfig.Multitaps[0]) PlayerAssignments[3] = -1; else PlayerAssignments[3] = id++;
|
||||
|
||||
if (userConfig.Devices8[4] == OctoshockDll.ePeripheralType.None) PlayerAssignments[4] = -1; else PlayerAssignments[4] = id++;
|
||||
if (userConfig.Devices8[5] == OctoshockDll.ePeripheralType.None || !userConfig.Multitaps[1]) PlayerAssignments[5] = -1; else PlayerAssignments[5] = id++;
|
||||
if (userConfig.Devices8[6] == OctoshockDll.ePeripheralType.None || !userConfig.Multitaps[1]) PlayerAssignments[6] = -1; else PlayerAssignments[6] = id++;
|
||||
if (userConfig.Devices8[7] == OctoshockDll.ePeripheralType.None || !userConfig.Multitaps[1]) PlayerAssignments[7] = -1; else PlayerAssignments[7] = id++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue