Add a payload controller for the new bsnes core
This commit is contained in:
parent
817701856c
commit
359657c29a
|
@ -27,7 +27,8 @@
|
|||
SuperMultitap,
|
||||
SuperScope,
|
||||
Justifier,
|
||||
Justifiers
|
||||
Justifiers,
|
||||
Payload
|
||||
}
|
||||
|
||||
public enum ENTROPY
|
||||
|
|
|
@ -25,6 +25,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.BSNES
|
|||
BSNES_INPUT_DEVICE.SuperScope => new BsnesSuperScopeController(),
|
||||
BSNES_INPUT_DEVICE.Justifier => new BsnesJustifierController(false),
|
||||
BSNES_INPUT_DEVICE.Justifiers => new BsnesJustifierController(true),
|
||||
BSNES_INPUT_DEVICE.Payload => new BsnesPayloadController(),
|
||||
_ => throw new InvalidOperationException()
|
||||
};
|
||||
}
|
||||
|
@ -306,4 +307,32 @@ namespace BizHawk.Emulation.Cores.Nintendo.BSNES
|
|||
return _state[index * 4 + id];
|
||||
}
|
||||
}
|
||||
|
||||
internal class BsnesPayloadController : IBsnesController
|
||||
{
|
||||
private readonly bool[] _state = new bool[32];
|
||||
|
||||
private static readonly ControllerDefinition _definition = new()
|
||||
{
|
||||
BoolButtons = Enumerable.Range(0, 32).Select(i => $"0B{i}").ToList()
|
||||
};
|
||||
|
||||
public ControllerDefinition Definition => _definition;
|
||||
|
||||
public void UpdateState(IController controller)
|
||||
{
|
||||
for (int i = 0; i < 32; i++)
|
||||
{
|
||||
_state[i] = controller.IsPressed(Definition.BoolButtons[i]);
|
||||
}
|
||||
}
|
||||
|
||||
public short GetState(int index, int id)
|
||||
{
|
||||
if (index >= 2 || id >= 16)
|
||||
return 0;
|
||||
|
||||
return (short) (_state[index * 2 + id] ? 1 : 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,7 +66,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.BSNES
|
|||
generate_palette();
|
||||
// TODO: massive random hack till waterboxhost gets fixed to support 5+ args
|
||||
ushort mergedBools = (ushort) ((_syncSettings.Hotfixes ? 1 << 8 : 0) | (_syncSettings.FastPPU ? 1 : 0));
|
||||
Api.core.snes_init(_syncSettings.Entropy, _syncSettings.LeftPort, _syncSettings.RightPort, mergedBools);
|
||||
BsnesApi.BSNES_INPUT_DEVICE rightPort = _syncSettings.RightPort == BsnesApi.BSNES_INPUT_DEVICE.Payload
|
||||
? BsnesApi.BSNES_INPUT_DEVICE.SuperMultitap
|
||||
: _syncSettings.RightPort;
|
||||
Api.core.snes_init(_syncSettings.Entropy, _syncSettings.LeftPort, rightPort, mergedBools);
|
||||
Api.SetCallbacks(callbacks);
|
||||
|
||||
// start up audio resampler
|
||||
|
|
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using BizHawk.Emulation.Common;
|
||||
using BizHawk.Emulation.Cores.Nintendo.BSNES;
|
||||
using BizHawk.Emulation.Cores.Nintendo.SNES;
|
||||
using BizHawk.Emulation.Cores.Nintendo.SNES9X;
|
||||
using BizHawk.Emulation.Cores.Waterbox;
|
||||
|
@ -15,17 +16,13 @@ namespace BizHawk.Emulation.Cores
|
|||
{
|
||||
public IEnumerable<PadSchema> GetPadSchemas(IEmulator core, Action<string> showMessageBox)
|
||||
{
|
||||
if (core is LibsnesCore bsnes)
|
||||
return core switch
|
||||
{
|
||||
return GetBsnesPadSchemas(bsnes);
|
||||
}
|
||||
|
||||
if (core is NymaCore nyma)
|
||||
{
|
||||
return GetFaustSchemas(nyma, showMessageBox);
|
||||
}
|
||||
|
||||
return GetSnes9xPadSchemas((Snes9x)core);
|
||||
LibsnesCore libsnes => GetLibsnesPadSchemas(libsnes),
|
||||
BsnesCore bsnes => GetBsnesPadSchemas(bsnes),
|
||||
NymaCore nyma => GetFaustSchemas(nyma, showMessageBox),
|
||||
_ => GetSnes9xPadSchemas((Snes9x) core)
|
||||
};
|
||||
}
|
||||
private IEnumerable<PadSchema> GetSnes9xPadSchemas(Snes9x core)
|
||||
{
|
||||
|
@ -61,7 +58,7 @@ namespace BizHawk.Emulation.Cores
|
|||
yield return ConsoleButtons();
|
||||
}
|
||||
|
||||
private IEnumerable<PadSchema> GetBsnesPadSchemas(LibsnesCore core)
|
||||
private IEnumerable<PadSchema> GetLibsnesPadSchemas(LibsnesCore core)
|
||||
{
|
||||
var syncSettings = core.GetSyncSettings();
|
||||
|
||||
|
@ -115,6 +112,58 @@ namespace BizHawk.Emulation.Cores
|
|||
yield return ConsoleButtons();
|
||||
}
|
||||
|
||||
private IEnumerable<PadSchema> GetBsnesPadSchemas(BsnesCore core)
|
||||
{
|
||||
var syncSettings = core.GetSyncSettings();
|
||||
|
||||
var ports = new[]
|
||||
{
|
||||
syncSettings.LeftPort,
|
||||
syncSettings.RightPort
|
||||
};
|
||||
|
||||
int playerNum = 0;
|
||||
for (int i = 0; i < 2; i++, playerNum++)
|
||||
{
|
||||
switch (ports[i])
|
||||
{
|
||||
default:
|
||||
case BsnesApi.BSNES_INPUT_DEVICE.None:
|
||||
playerNum--;
|
||||
break;
|
||||
case BsnesApi.BSNES_INPUT_DEVICE.Gamepad:
|
||||
yield return StandardController(playerNum);
|
||||
break;
|
||||
case BsnesApi.BSNES_INPUT_DEVICE.Mouse:
|
||||
yield return Mouse(playerNum);
|
||||
break;
|
||||
case BsnesApi.BSNES_INPUT_DEVICE.SuperMultitap:
|
||||
for (int j = 0; j < 4; j++)
|
||||
{
|
||||
yield return StandardController(playerNum++);
|
||||
}
|
||||
break;
|
||||
case BsnesApi.BSNES_INPUT_DEVICE.SuperScope:
|
||||
yield return SuperScope(playerNum);
|
||||
break;
|
||||
case BsnesApi.BSNES_INPUT_DEVICE.Justifier:
|
||||
yield return Justifier(playerNum);
|
||||
break;
|
||||
case BsnesApi.BSNES_INPUT_DEVICE.Justifiers:
|
||||
for (int j = 0; j < 2; j++)
|
||||
{
|
||||
yield return Justifier(playerNum++);
|
||||
}
|
||||
break;
|
||||
case BsnesApi.BSNES_INPUT_DEVICE.Payload:
|
||||
yield return Payload(playerNum);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
yield return ConsoleButtons();
|
||||
}
|
||||
|
||||
private static IEnumerable<PadSchema> GetFaustSchemas(NymaCore nyma, Action<string> showMessageBox)
|
||||
{
|
||||
foreach (NymaCore.PortResult result in nyma.ActualPortData)
|
||||
|
@ -269,4 +318,4 @@ namespace BizHawk.Emulation.Cores
|
|||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue