Skip to content

Commit be57529

Browse files
authored
Add analog keybinds for Ares64 (squashed PR #4611)
* Add analog key support for Ares64 * Refactor stick reading into a static helper method * Fix casing for GetStickValues return names * Update doc comments
1 parent 3e6951d commit be57529

2 files changed

Lines changed: 24 additions & 12 deletions

File tree

src/BizHawk.Emulation.Cores/Consoles/Nintendo/Ares64/Ares64.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using BizHawk.Emulation.Common;
66
using BizHawk.Emulation.Cores.Properties;
77
using BizHawk.Emulation.Cores.Waterbox;
8+
using BizHawk.Emulation.Cores.Nintendo.N64;
89

910
namespace BizHawk.Emulation.Cores.Consoles.Nintendo.Ares64
1011
{
@@ -215,6 +216,10 @@ private static ControllerDefinition CreateControllerDefinition(LibAres64.Control
215216
}
216217
else if (controllerSettings[i] != LibAres64.ControllerType.Unplugged)
217218
{
219+
ret.BoolButtons.Add($"P{i + 1} A Up");
220+
ret.BoolButtons.Add($"P{i + 1} A Down");
221+
ret.BoolButtons.Add($"P{i + 1} A Left");
222+
ret.BoolButtons.Add($"P{i + 1} A Right");
218223
ret.BoolButtons.Add($"P{i + 1} DPad U");
219224
ret.BoolButtons.Add($"P{i + 1} DPad D");
220225
ret.BoolButtons.Add($"P{i + 1} DPad L");
@@ -299,8 +304,7 @@ protected override LibWaterboxCore.FrameInfo FrameAdvancePrep(IController contro
299304
controller.SetHapticChannelStrength($"P{num} Rumble Pak", _core.GetRumbleStatus(i) ? int.MaxValue : 0);
300305
}
301306
var buttonsState = GetButtons(controller, num);
302-
var stickXState = unchecked((short) controller.AxisValue($"P{num} X Axis"));
303-
var stickYState = unchecked((short) controller.AxisValue($"P{num} Y Axis"));
307+
(short stickXState, short stickYState) = N64Input.GetStickValues(controller, num);
304308
switch (num)
305309
{
306310
case 1:

src/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64Input.cs

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,12 @@ public void ShiftInputPolledBools()
3939
private const sbyte _maxAnalogY = 127;
4040
private const sbyte _minAnalogY = -128;
4141

42-
/// <summary>
43-
/// Translates controller input from EmuHawk into
44-
/// N64 controller data
45-
/// </summary>
46-
/// <param name="i">Id of controller to update and shove</param>
47-
public int GetControllerInput(int i)
42+
/// <param name="i">player number (from 1)</param>
43+
public static (sbyte X, sbyte Y) GetStickValues(IController Controller, int i)
4844
{
49-
_emuCore.InputCallbacks.Call();
50-
ThisFrameInputPolled = true;
51-
5245
// Analog stick right = +X
5346
// Analog stick up = +Y
54-
string p = "P" + (i + 1);
47+
string p = "P" + i;
5548
sbyte x;
5649
if (Controller.IsPressed(p + " A Left"))
5750
{
@@ -80,6 +73,21 @@ public int GetControllerInput(int i)
8073
y = (sbyte)Controller.AxisValue(p + " Y Axis");
8174
}
8275

76+
return (x, y);
77+
}
78+
79+
/// <summary>
80+
/// Translates controller input from EmuHawk into
81+
/// N64 controller data
82+
/// </summary>
83+
/// <param name="i">index (from 0) of controller to update and shove</param>
84+
public int GetControllerInput(int i)
85+
{
86+
_emuCore.InputCallbacks.Call();
87+
ThisFrameInputPolled = true;
88+
89+
(sbyte x, sbyte y) = GetStickValues(Controller, i + 1);
90+
8391
int value = ReadController(i + 1);
8492
value |= (x & 0xFF) << 16;
8593
value |= (y & 0xFF) << 24;

0 commit comments

Comments
 (0)