psx: support negcon (c# side)

This commit is contained in:
zeromus 2017-04-25 22:59:37 -05:00
parent ae672044c3
commit 507ca1db27
3 changed files with 118 additions and 55 deletions

View File

@ -31,6 +31,7 @@ namespace BizHawk.Client.EmuHawk
combo.Items.Add("Gamepad");
combo.Items.Add("Dual Shock");
combo.Items.Add("Dual Analog");
combo.Items.Add("neGcon");
combo.SelectedIndex = 0;
}
@ -55,6 +56,7 @@ namespace BizHawk.Client.EmuHawk
if (user.Devices8[i] == OctoshockDll.ePeripheralType.Pad) combo.SelectedIndex = 1;
if (user.Devices8[i] == OctoshockDll.ePeripheralType.DualShock) combo.SelectedIndex = 2;
if (user.Devices8[i] == OctoshockDll.ePeripheralType.DualAnalog) combo.SelectedIndex = 3;
if (user.Devices8[i] == OctoshockDll.ePeripheralType.NegCon) combo.SelectedIndex = 4;
}
}
@ -76,6 +78,7 @@ namespace BizHawk.Client.EmuHawk
if (combo.SelectedIndex == 1) uc.Devices8[i] = OctoshockDll.ePeripheralType.Pad;
if (combo.SelectedIndex == 2) uc.Devices8[i] = OctoshockDll.ePeripheralType.DualShock;
if (combo.SelectedIndex == 3) uc.Devices8[i] = OctoshockDll.ePeripheralType.DualAnalog;
if (combo.SelectedIndex == 4) uc.Devices8[i] = OctoshockDll.ePeripheralType.NegCon;
}
return uc;

View File

@ -46,6 +46,37 @@ namespace BizHawk.Emulation.Cores.Sony.PSX
for (int i = 0; i < cfg.NumPlayers; i++)
{
int pnum = i + 1;
var type = cfg.DevicesPlayer[i];
if (type == OctoshockDll.ePeripheralType.NegCon)
{
definition.BoolButtons.AddRange(new[]
{
"P" + pnum + " Up",
"P" + pnum + " Down",
"P" + pnum + " Left",
"P" + pnum + " Right",
"P" + pnum + " Start",
"P" + pnum + " R",
"P" + pnum + " B",
"P" + pnum + " A",
});
definition.FloatControls.AddRange(new[]
{
"P" + pnum + " Twist",
"P" + pnum + " 1",
"P" + pnum + " 2",
"P" + pnum + " L"
});
definition.FloatRanges.Add(new[] { 0.0f, 128.0f, 255.0f });
definition.FloatRanges.Add(new[] { 0.0f, 128.0f, 255.0f });
definition.FloatRanges.Add(new[] { 0.0f, 128.0f, 255.0f });
definition.FloatRanges.Add(new[] { 0.0f, 128.0f, 255.0f });
}
else
{
definition.BoolButtons.AddRange(new[]
{
"P" + pnum + " Up",
@ -64,7 +95,6 @@ namespace BizHawk.Emulation.Cores.Sony.PSX
"P" + pnum + " R2",
});
var type = cfg.DevicesPlayer[i];
if (type == OctoshockDll.ePeripheralType.DualShock || type == OctoshockDll.ePeripheralType.DualAnalog)
{
@ -86,6 +116,7 @@ namespace BizHawk.Emulation.Cores.Sony.PSX
definition.FloatRanges.Add(new[] { 255.0f, 128.0f, 0.0f });
}
}
}
definition.BoolButtons.AddRange(new[]
{
@ -435,6 +466,28 @@ namespace BizHawk.Emulation.Cores.Sony.PSX
uint buttons = 0;
string pstring = "P" + fioCfg.PlayerAssignments[slot] + " ";
if (fioCfg.Devices8[slot] == OctoshockDll.ePeripheralType.NegCon)
{
//1,2,4 skipped (would be Select, L3, R3 on other pads)
if (Controller.IsPressed(pstring + "Start")) buttons |= 8;
if (Controller.IsPressed(pstring + "Up")) buttons |= 16;
if (Controller.IsPressed(pstring + "Right")) buttons |= 32;
if (Controller.IsPressed(pstring + "Down")) buttons |= 64;
if (Controller.IsPressed(pstring + "Left")) buttons |= 128;
//256,512,1024 skipped (would be L2, R2, L1 on other pads)
if (Controller.IsPressed(pstring + "R")) buttons |= 2048;
if (Controller.IsPressed(pstring + "B")) buttons |= 4096;
if (Controller.IsPressed(pstring + "A")) buttons |= 8192;
byte twist = (byte)Controller.GetFloat(pstring + "Twist");
byte analog1 = (byte)Controller.GetFloat(pstring + "1");
byte analog2 = (byte)Controller.GetFloat(pstring + "2");
byte analogL = (byte)Controller.GetFloat(pstring + "L");
OctoshockDll.shock_Peripheral_SetPadInput(psx, portNum, buttons, twist, analog1, analog2, analogL);
}
else
{
if (Controller.IsPressed(pstring + "Select")) buttons |= 1;
if (Controller.IsPressed(pstring + "Start")) buttons |= 8;
if (Controller.IsPressed(pstring + "Up")) buttons |= 16;
@ -464,6 +517,8 @@ namespace BizHawk.Emulation.Cores.Sony.PSX
}
OctoshockDll.shock_Peripheral_SetPadInput(psx, portNum, buttons, left_x, left_y, right_x, right_y);
}
portNum <<= 1;
}
}

View File

@ -74,6 +74,8 @@ namespace BizHawk.Emulation.Cores.Sony.PSX
DualShock = 2, //SCPH-1200
DualAnalog = 3, //SCPH-1180
NegCon = 4,
Multitap = 10,
};
@ -222,6 +224,9 @@ namespace BizHawk.Emulation.Cores.Sony.PSX
[DllImport(dd, CallingConvention = cc)]
public static extern int shock_Peripheral_SetPadInput(IntPtr psx, int address, uint buttons, byte left_x, byte left_y, byte right_x, byte right_y);
[DllImport(dd, CallingConvention = cc)]
public static extern int shock_Peripheral_SetNegconInput(IntPtr psx, int address, uint buttons, byte twist, byte analog1, byte analog2, byte analogL);
[DllImport(dd, CallingConvention = cc)]
public static extern int shock_Peripheral_MemcardTransact(IntPtr psx, int address, ref ShockMemcardTransaction transaction);