dsda: doom doesn't have potentiometers

potentiometers are hardware devices used in some controllers, but doom is pure software so it only has axes
This commit is contained in:
feos 2025-03-19 19:50:46 +03:00
parent 008911a6d9
commit e79ab84d98
3 changed files with 68 additions and 55 deletions

View File

@ -29,29 +29,29 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
Definition.MakeImmutable();
}
public byte ReadPort1(IController c)
=> Port1.Read(c);
public byte ReadButtons1(IController c)
=> Port1.ReadButtons(c);
public byte ReadPort2(IController c)
=> Port2.Read(c);
public byte ReadButtons2(IController c)
=> Port2.ReadButtons(c);
public byte ReadPort3(IController c)
=> Port3.Read(c);
public byte ReadButtons3(IController c)
=> Port3.ReadButtons(c);
public byte ReadPort4(IController c)
=> Port4.Read(c);
public byte ReadButtons4(IController c)
=> Port4.ReadButtons(c);
public int ReadPot1(IController c, int pot)
=> Port1.Read_Pot(c, pot);
public int ReadAxis1(IController c, int axis)
=> Port1.ReadAxis(c, axis);
public int ReadPot2(IController c, int pot)
=> Port2.Read_Pot(c, pot);
public int ReadAxis2(IController c, int axis)
=> Port2.ReadAxis(c, axis);
public int ReadPot3(IController c, int pot)
=> Port3.Read_Pot(c, pot);
public int ReadAxis3(IController c, int axis)
=> Port3.ReadAxis(c, axis);
public int ReadPot4(IController c, int pot)
=> Port4.Read_Pot(c, pot);
public int ReadAxis4(IController c, int axis)
=> Port4.ReadAxis(c, axis);
public ControllerDefinition Definition { get; }

View File

@ -23,20 +23,20 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
new PackedPlayerInput()
];
ReadPot[] potReaders =
ReadPot[] axisReaders =
[
_controllerDeck.ReadPot1,
_controllerDeck.ReadPot2,
_controllerDeck.ReadPot3,
_controllerDeck.ReadPot4,
_controllerDeck.ReadAxis1,
_controllerDeck.ReadAxis2,
_controllerDeck.ReadAxis3,
_controllerDeck.ReadAxis4,
];
ReadPort[] portReaders =
ReadPort[] buttonsReaders =
[
_controllerDeck.ReadPort1,
_controllerDeck.ReadPort2,
_controllerDeck.ReadPort3,
_controllerDeck.ReadPort4,
_controllerDeck.ReadButtons1,
_controllerDeck.ReadButtons2,
_controllerDeck.ReadButtons3,
_controllerDeck.ReadButtons4,
];
int playersPresent = Convert.ToInt32(_syncSettings.Player1Present)
@ -64,10 +64,10 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
}
// initial axis read
players[i].RunSpeed = potReaders[i](controller, 0);
players[i].StrafingSpeed = potReaders[i](controller, 1);
players[i].TurningSpeed = potReaders[i](controller, 2);
players[i].WeaponSelect = potReaders[i](controller, 3);
players[i].RunSpeed = axisReaders[i](controller, (int)AxisType.RunSpeed);
players[i].StrafingSpeed = axisReaders[i](controller, (int)AxisType.StrafingSpeed);
players[i].TurningSpeed = axisReaders[i](controller, (int)AxisType.TurningSpeed);
players[i].WeaponSelect = axisReaders[i](controller, (int)AxisType.WeaponSelect);
// override axis based on movement buttons (turning is reversed upstream)
if (controller.IsPressed($"P{i + 1} Forward")) players[i].RunSpeed = _runSpeeds[speedIndex];
@ -79,12 +79,12 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
// mouse-driven running
// divider matches the core
players[i].RunSpeed -= (int)(potReaders[i](controller, 4) * _syncSettings.MouseRunSensitivity / 8.0);
players[i].RunSpeed -= (int)(axisReaders[i](controller, (int)AxisType.MouseRunning) * _syncSettings.MouseRunSensitivity / 8.0);
players[i].RunSpeed = players[i].RunSpeed.Clamp<int>(-_runSpeeds[1], _runSpeeds[1]);
// mouse-driven turning
// divider recalibrates minimal mouse movement to be 1 (requires global setting)
players[i].TurningSpeed -= (int)(potReaders[i](controller, 5) * _syncSettings.MouseTurnSensitivity / 272.0);
players[i].TurningSpeed -= (int)(axisReaders[i](controller, (int)AxisType.MouseTurning) * _syncSettings.MouseTurnSensitivity / 272.0);
if (_syncSettings.TurningResolution == TurningResolution.Shorttics)
{
// calc matches the core
@ -92,7 +92,7 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
}
// bool buttons
var actionsBitfield = portReaders[i](controller);
var actionsBitfield = buttonsReaders[i](controller);
players[i].Fire = actionsBitfield & 0b00001;
players[i].Action = (actionsBitfield & 0b00010) >> 1;
players[i].Automap = (actionsBitfield & 0b00100) >> 2;
@ -100,8 +100,8 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
// Raven Games
if (_syncSettings.InputFormat is DoomControllerTypes.Heretic or DoomControllerTypes.Hexen)
{
players[i].FlyLook = potReaders[i](controller, 6);
players[i].ArtifactUse = potReaders[i](controller, 7);
players[i].FlyLook = axisReaders[i](controller, (int)AxisType.FlyLook);
players[i].ArtifactUse = axisReaders[i](controller, (int)AxisType.UseArtifact);
if (_syncSettings.InputFormat is DoomControllerTypes.Hexen)
{
players[i].Jump = (actionsBitfield & 0b01000) >> 3;

View File

@ -12,11 +12,24 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
Hexen
}
// must match the order of axes added
public enum AxisType : int
{
RunSpeed,
StrafingSpeed,
TurningSpeed,
WeaponSelect,
MouseRunning,
MouseTurning,
FlyLook,
UseArtifact
}
public interface IPort
{
byte Read(IController c);
byte ReadButtons(IController c);
int Read_Pot(IController c, int pot);
int ReadAxis(IController c, int axis);
ControllerDefinition Definition { get; }
@ -67,7 +80,7 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
"Weapon Select 7",
];
public byte Read(IController c)
public byte ReadButtons(IController c)
{
byte result = 0;
@ -78,12 +91,12 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
return result;
}
public int Read_Pot(IController c, int pot)
public int ReadAxis(IController c, int axis)
{
int x = c.AxisValue(Definition.Axes[pot]);
int x = c.AxisValue(Definition.Axes[axis]);
// Handling weapon select keys overriding axes values
if (Definition.Axes[pot] == $"P{PortNum} Weapon Select")
if (Definition.Axes[axis] == $"P{PortNum} Weapon Select")
{
if (c.IsPressed($"P{PortNum} Weapon Select 1")) x = 1;
if (c.IsPressed($"P{PortNum} Weapon Select 2")) x = 2;
@ -143,7 +156,7 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
"Weapon Select 7",
];
public byte Read(IController c)
public byte ReadButtons(IController c)
{
byte result = 0;
@ -153,12 +166,12 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
return result;
}
public int Read_Pot(IController c, int pot)
public int ReadAxis(IController c, int axis)
{
int x = c.AxisValue(Definition.Axes[pot]);
int x = c.AxisValue(Definition.Axes[axis]);
// Handling running keys overriding axes values
if (Definition.Axes[pot] == $"P{PortNum} Run Speed")
if (Definition.Axes[axis] == $"P{PortNum} Run Speed")
{
if (c.IsPressed($"P{PortNum} Forward"))
{
@ -172,7 +185,7 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
}
// Handling strafing keys overriding axes values
if (Definition.Axes[pot] == $"P{PortNum} Strafing Speed")
if (Definition.Axes[axis] == $"P{PortNum} Strafing Speed")
{
if (c.IsPressed($"P{PortNum} Strafe Right"))
{
@ -186,7 +199,7 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
}
// Handling turning keys overriding axes values
if (Definition.Axes[pot] == $"P{PortNum} Turning Speed")
if (Definition.Axes[axis] == $"P{PortNum} Turning Speed")
{
if (c.IsPressed($"P{PortNum} Turn Left"))
{
@ -200,7 +213,7 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
}
// Handling weapon select keys overriding axes values
if (Definition.Axes[pot] == $"P{PortNum} Weapon Select")
if (Definition.Axes[axis] == $"P{PortNum} Weapon Select")
{
if (c.IsPressed($"P{PortNum} Weapon Select 1")) x = 1;
if (c.IsPressed($"P{PortNum} Weapon Select 2")) x = 2;
@ -260,7 +273,7 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
"Weapon Select 4"
];
public byte Read(IController c)
public byte ReadButtons(IController c)
{
byte result = 0;
@ -272,12 +285,12 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
return result;
}
public int Read_Pot(IController c, int pot)
public int ReadAxis(IController c, int axis)
{
int x = c.AxisValue(Definition.Axes[pot]);
int x = c.AxisValue(Definition.Axes[axis]);
// Handling running keys overriding axes values
if (Definition.Axes[pot] == $"P{PortNum} Run Speed")
if (Definition.Axes[axis] == $"P{PortNum} Run Speed")
{
if (c.IsPressed($"P{PortNum} Forward"))
{
@ -291,7 +304,7 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
}
// Handling strafing keys overriding axes values
if (Definition.Axes[pot] == $"P{PortNum} Strafing Speed")
if (Definition.Axes[axis] == $"P{PortNum} Strafing Speed")
{
if (c.IsPressed($"P{PortNum} Strafe Right"))
{
@ -305,7 +318,7 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
}
// Handling turning keys overriding axes values
if (Definition.Axes[pot] == $"P{PortNum} Turning Speed")
if (Definition.Axes[axis] == $"P{PortNum} Turning Speed")
{
if (c.IsPressed($"P{PortNum} Turn Left"))
{
@ -319,7 +332,7 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
}
// Handling weapon select keys overriding axes values
if (Definition.Axes[pot] == $"P{PortNum} Weapon Select")
if (Definition.Axes[axis] == $"P{PortNum} Weapon Select")
{
if (c.IsPressed($"P{PortNum} Weapon Select 1")) x = 1;
if (c.IsPressed($"P{PortNum} Weapon Select 2")) x = 2;