Use props on GamePad/GamePad360 for pad prefixes

This commit is contained in:
YoshiRulz 2021-03-29 09:27:10 +10:00
parent d02863e491
commit bdfc54443f
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
3 changed files with 10 additions and 6 deletions

View File

@ -41,15 +41,13 @@ namespace BizHawk.Bizware.DirectX
{
foreach (var pad in GamePad360.EnumerateDevices())
{
var inputNamePrefix = $"X{pad.PlayerNumber} ";
for (int b = 0, n = pad.NumButtons; b < n; b++) handleButton(inputNamePrefix + pad.ButtonName(b), pad.Pressed(b), ClientInputFocus.Pad);
foreach (var (axisName, f) in pad.GetAxes()) handleAxis(inputNamePrefix + axisName, (int) f);
for (int b = 0, n = pad.NumButtons; b < n; b++) handleButton(pad.InputNamePrefix + pad.ButtonName(b), pad.Pressed(b), ClientInputFocus.Pad);
foreach (var (axisName, f) in pad.GetAxes()) handleAxis(pad.InputNamePrefix + axisName, (int) f);
}
foreach (var pad in GamePad.EnumerateDevices())
{
var inputNamePrefix = $"J{pad.PlayerNumber} ";
for (int b = 0, n = pad.NumButtons; b < n; b++) handleButton(inputNamePrefix + pad.ButtonName(b), pad.Pressed(b), ClientInputFocus.Pad);
foreach (var (axisName, f) in pad.GetAxes()) handleAxis(inputNamePrefix + axisName, (int) f);
for (int b = 0, n = pad.NumButtons; b < n; b++) handleButton(pad.InputNamePrefix + pad.ButtonName(b), pad.Pressed(b), ClientInputFocus.Pad);
foreach (var (axisName, f) in pad.GetAxes()) handleAxis(pad.InputNamePrefix + axisName, (int) f);
}
}

View File

@ -96,6 +96,7 @@ namespace BizHawk.Bizware.DirectX
{
_joystick = joystick;
PlayerNumber = index + 1;
InputNamePrefix = $"J{PlayerNumber} ";
Update();
InitializeCallbacks();
}
@ -141,6 +142,8 @@ namespace BizHawk.Bizware.DirectX
public int PlayerNumber { get; }
public readonly string InputNamePrefix;
public string ButtonName(int index)
{
return _names[index];

View File

@ -122,10 +122,13 @@ namespace BizHawk.Bizware.DirectX
public int PlayerNumber => (int)_index0 + 1;
public readonly string InputNamePrefix;
private GamePad360(uint index0, Controller c)
{
this._index0 = index0;
_controller = c;
InputNamePrefix = $"X{PlayerNumber} ";
InitializeButtons();
Update();
}