SNES - support the Justifier, because why not

This commit is contained in:
adelikat 2017-04-22 08:55:39 -05:00
parent 7d60049b86
commit 242b0e09ab
4 changed files with 52 additions and 3 deletions

View File

@ -16,6 +16,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
Multitap,
Mouse,
SuperScope,
Justifier,
Payload
}
@ -37,7 +38,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
LimitAnalogChangeSensitivity = ss.LimitAnalogChangeSensitivity
};
case ControllerType.SuperScope:
return new SnesSuperScopeController();
return new SnesSuperScopeController();
case ControllerType.Justifier:
return new SnesJustifierController();
default:
throw new InvalidOperationException();
}
@ -371,4 +374,51 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
}
}
}
public class SnesJustifierController : ILibsnesController
{
public LibsnesApi.SNES_INPUT_PORT PortType => LibsnesApi.SNES_INPUT_PORT.Justifier;
private static readonly ControllerDefinition _definition = new ControllerDefinition
{
BoolButtons = new List<string>
{
"0Trigger",
"0Start"
},
FloatControls =
{
"0Justifier X",
"0Justifier Y"
},
FloatRanges =
{
// problem: when you're in 240 line mode, the limit on Y needs to be 240.
// when you're in 224 mode, it needs to be 224. perhaps the deck needs to account for this...
new[] { 0f, 128f, 256f },
new[] { 0f, 0f, 240f }
}
};
public ControllerDefinition Definition => _definition;
public short GetState(IController controller, int index, int id)
{
switch (id)
{
default:
return 0;
case 0:
var x = (int)controller.GetFloat("0Justifier X");
return (short)x;
case 1:
var y = (int)controller.GetFloat("0Justifier Y");
return (short)y;
case 2:
return (short)(controller.IsPressed("0Trigger") ? 1 : 0);
case 3:
return (short)(controller.IsPressed("0Start") ? 1 : 0);
}
}
}
}

View File

@ -29,8 +29,7 @@ void Justifier::enter() {
if(next < prev && chained) {
int nx2 = interface()->inputPoll(port, Input::Device::Justifiers, 1, (unsigned)Input::JustifierID::X);
int ny2 = interface()->inputPoll(port, Input::Device::Justifiers, 1, (unsigned)Input::JustifierID::Y);
nx2 += player2.x;
ny2 += player2.y;
player2.x = max(-16, min(256 + 16, nx2));
player2.y = max(-16, min(240 + 16, ny2));
}