Hack to fix Nymashock analog stick range (see #3528)
This commit is contained in:
parent
c66d0c746e
commit
95001d0baa
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using BizHawk.Common;
|
||||
using BizHawk.Emulation.Common;
|
||||
using BizHawk.Emulation.Cores.Waterbox;
|
||||
|
||||
|
@ -9,6 +10,29 @@ namespace BizHawk.Emulation.Cores.Sony.PSX
|
|||
[PortedCore(CoreNames.Nymashock, "Mednafen Team", "1.29.0", "https://mednafen.github.io/releases/")]
|
||||
public class Nymashock : NymaCore, IRegionable, ICycleTiming
|
||||
{
|
||||
protected override void AddAxis(
|
||||
ControllerDefinition ret,
|
||||
string name,
|
||||
bool isReversed,
|
||||
ref ControllerThunk thunk,
|
||||
int thunkWriteOffset)
|
||||
{
|
||||
if (name.EndsWith(" Left Stick Up / Down") || name.EndsWith(" Left Stick Left / Right")
|
||||
|| name.EndsWith(" Right Stick Up / Down") || name.EndsWith(" Right Stick Left / Right"))
|
||||
{
|
||||
ret.AddAxis(name, 0.RangeTo(0xFF), 0x80, isReversed);
|
||||
thunk = (c, b) =>
|
||||
{
|
||||
b[thunkWriteOffset] = 0;
|
||||
b[thunkWriteOffset + 1] = (byte) c.AxisValue(name);
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
base.AddAxis(ret, name, isReversed: isReversed, ref thunk, thunkWriteOffset);
|
||||
}
|
||||
}
|
||||
|
||||
private Nymashock(CoreComm comm)
|
||||
: base(comm, VSystemID.Raw.NULL, null, null, null)
|
||||
{
|
||||
|
|
|
@ -19,10 +19,31 @@ namespace BizHawk.Emulation.Cores.Waterbox
|
|||
private readonly byte[] _inputPortData = new byte[MAX_INPUT_DATA];
|
||||
private readonly string _controllerDeckName;
|
||||
|
||||
protected delegate void AddAxisHook(
|
||||
ControllerDefinition ret,
|
||||
string name,
|
||||
bool isReversed,
|
||||
ref ControllerThunk thunk,
|
||||
int thunkWriteOffset);
|
||||
|
||||
protected virtual void AddAxis(
|
||||
ControllerDefinition ret,
|
||||
string name,
|
||||
bool isReversed,
|
||||
ref ControllerThunk thunk,
|
||||
int thunkWriteOffset)
|
||||
=> ret.AddAxis(name, 0.RangeTo(0xFFFF), 0x8000, isReversed);
|
||||
|
||||
private void InitControls(List<NPortInfoT> allPorts, int numCds, ref SystemInfo si)
|
||||
{
|
||||
_controllerAdapter = new ControllerAdapter(
|
||||
allPorts, _syncSettingsActual.PortDevices, OverrideButtonName, numCds, ref si, ComputeHiddenPorts(),
|
||||
allPorts,
|
||||
_syncSettingsActual.PortDevices,
|
||||
OverrideButtonName,
|
||||
numCds,
|
||||
ref si,
|
||||
ComputeHiddenPorts(),
|
||||
AddAxis,
|
||||
_controllerDeckName);
|
||||
_nyma.SetInputDevices(_controllerAdapter.Devices);
|
||||
ControllerDefinition = _controllerAdapter.Definition;
|
||||
|
@ -45,6 +66,7 @@ namespace BizHawk.Emulation.Cores.Waterbox
|
|||
int numCds,
|
||||
ref SystemInfo systemInfo,
|
||||
HashSet<string> hiddenPorts,
|
||||
AddAxisHook addAxisHook,
|
||||
string controllerDeckName)
|
||||
{
|
||||
ControllerDefinition ret = new(controllerDeckName)
|
||||
|
@ -178,15 +200,15 @@ namespace BizHawk.Emulation.Cores.Waterbox
|
|||
{
|
||||
var data = input.Extra.AsAxis();
|
||||
var fullName = $"{name} {overrideName(data.NameNeg)} / {overrideName(data.NamePos)}";
|
||||
|
||||
ret.AddAxis(fullName, 0.RangeTo(0xFFFF), 0x8000, (input.Flags & AxisFlags.InvertCo) != 0);
|
||||
ret.CategoryLabels[fullName] = category;
|
||||
_thunks.Add((c, b) =>
|
||||
ControllerThunk thunk = (c, b) =>
|
||||
{
|
||||
var val = c.AxisValue(fullName);
|
||||
b[byteStart] = (byte)val;
|
||||
b[byteStart + 1] = (byte)(val >> 8);
|
||||
});
|
||||
};
|
||||
addAxisHook(ret, fullName, (input.Flags & AxisFlags.InvertCo) is not 0, ref thunk, byteStart);
|
||||
ret.CategoryLabels[fullName] = category;
|
||||
_thunks.Add(thunk);
|
||||
break;
|
||||
}
|
||||
case InputType.AxisRel:
|
||||
|
|
|
@ -111,7 +111,7 @@ namespace BizHawk.Emulation.Cores
|
|||
|
||||
private static PadSchema NymaDualShockController(int controller)
|
||||
{
|
||||
var stickRanges = new[] { new AxisSpec(0.RangeTo(0xFFFF), 0x8000), new AxisSpec(0.RangeTo(0xFFFF), 0x8000, isReversed: true) };
|
||||
var stickRanges = new[] { new AxisSpec(0.RangeTo(0xFF), 0x80), new AxisSpec(0.RangeTo(0xFF), 0x80, isReversed: true) };
|
||||
return new PadSchema
|
||||
{
|
||||
Size = new Size(500, 290),
|
||||
|
|
Loading…
Reference in New Issue