simplify SimpleController API
This commit is contained in:
parent
049a79c996
commit
8d5cbd728e
|
@ -31,14 +31,11 @@ namespace BizHawk.Client.Common
|
|||
|
||||
public float AxisValue(string name) => Axes[name];
|
||||
|
||||
public IEnumerable<KeyValuePair<string, bool>> BoolButtons()
|
||||
{
|
||||
return Buttons;
|
||||
}
|
||||
public IDictionary<string, bool> BoolButtons() => Buttons;
|
||||
|
||||
public void AcceptNewAxes((string AxisID, float Value) newValue)
|
||||
public void AcceptNewAxis(string axisId, float value)
|
||||
{
|
||||
Axes[newValue.AxisID] = newValue.Value;
|
||||
Axes[axisId] = value;
|
||||
}
|
||||
|
||||
public void AcceptNewAxes(IEnumerable<(string AxisID, float Value)> newValues)
|
||||
|
|
|
@ -313,7 +313,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
return _inputEvents.Count == 0 ? null : _inputEvents.Dequeue();
|
||||
}
|
||||
}
|
||||
void EnqueueEvent(InputEvent ie)
|
||||
|
||||
private void EnqueueEvent(InputEvent ie)
|
||||
{
|
||||
lock (this)
|
||||
{
|
||||
|
@ -321,18 +322,11 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
}
|
||||
|
||||
public List<(string AxisID, float Value)> GetAxisValues()
|
||||
public IDictionary<string, float> GetAxisValues()
|
||||
{
|
||||
var axisValuesCopy = new List<(string, float)>();
|
||||
lock (_axisValues)
|
||||
{
|
||||
foreach (var kvp in _axisValues)
|
||||
{
|
||||
axisValuesCopy.Add((kvp.Key, kvp.Value));
|
||||
}
|
||||
}
|
||||
|
||||
return axisValuesCopy;
|
||||
// TODO: this is a refactor of code that was making a copy of the input
|
||||
// Probably just returning the dictionary is all that is actually needed
|
||||
return _axisValues.ToDictionary(k => k.Key, v => v.Value);
|
||||
}
|
||||
|
||||
private void UpdateThreadProc()
|
||||
|
|
|
@ -943,15 +943,14 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
//also handle floats
|
||||
//we'll need to isolate the mouse coordinates so we can translate them
|
||||
(string AxisID, float Value)? mouseX = null, mouseY = null;
|
||||
var floats = Input.Instance.GetAxisValues();
|
||||
KeyValuePair<string, float>? mouseX = null, mouseY = null;
|
||||
foreach (var f in Input.Instance.GetAxisValues())
|
||||
{
|
||||
if (f.AxisID == "WMouse X")
|
||||
if (f.Key == "WMouse X")
|
||||
mouseX = f;
|
||||
else if (f.AxisID == "WMouse Y")
|
||||
else if (f.Key == "WMouse Y")
|
||||
mouseY = f;
|
||||
else conInput.AcceptNewAxes(f);
|
||||
else conInput.AcceptNewAxis(f.Key, f.Value);
|
||||
}
|
||||
|
||||
//if we found mouse coordinates (and why wouldn't we?) then translate them now
|
||||
|
@ -961,8 +960,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
var p = DisplayManager.UntransformPoint(new Point((int) mouseX.Value.Value, (int) mouseY.Value.Value));
|
||||
float x = p.X / (float)_currentVideoProvider.BufferWidth;
|
||||
float y = p.Y / (float)_currentVideoProvider.BufferHeight;
|
||||
conInput.AcceptNewAxes(("WMouse X", (x * 20000) - 10000));
|
||||
conInput.AcceptNewAxes(("WMouse Y", (y * 20000) - 10000));
|
||||
conInput.AcceptNewAxis("WMouse X", (x * 20000) - 10000);
|
||||
conInput.AcceptNewAxis("WMouse Y", (y * 20000) - 10000);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ namespace BizHawk.Tests.Client.Common.Display
|
|||
[TestMethod]
|
||||
public void Generate_MidRangeDisplaysEmpty()
|
||||
{
|
||||
_floatController.AcceptNewAxes(("StickX", MidValue));
|
||||
_floatController.AcceptNewAxis("StickX", MidValue);
|
||||
var displayGenerator = new Bk2InputDisplayGenerator("NES", _floatController);
|
||||
var actual = displayGenerator.Generate();
|
||||
Assert.AreEqual(" 0,", actual);
|
||||
|
|
Loading…
Reference in New Issue