Move IController.ToDictionary extension to BizHawk.Emulation.Common
This commit is contained in:
parent
848eaabf46
commit
e5da8c765a
|
@ -1,6 +1,8 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using BizHawk.Emulation.Common;
|
||||
|
||||
namespace BizHawk.Client.Common
|
||||
{
|
||||
public sealed class JoypadApi : IJoypad
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
using BizHawk.Emulation.Common;
|
||||
|
||||
namespace BizHawk.Client.Common
|
||||
{
|
||||
public sealed class MovieApi : IInputMovie
|
||||
|
|
|
@ -60,37 +60,5 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
return table;
|
||||
}
|
||||
|
||||
public static IDictionary<string, dynamic> ToDictionary(this IController controller, int? controllerNum = null)
|
||||
{
|
||||
var buttons = new Dictionary<string, dynamic>();
|
||||
|
||||
foreach (var button in controller.Definition.BoolButtons)
|
||||
{
|
||||
if (controllerNum == null)
|
||||
{
|
||||
buttons[button] = controller.IsPressed(button);
|
||||
}
|
||||
else if (button.Length > 2 && button.Substring(0, 2) == $"P{controllerNum}")
|
||||
{
|
||||
var sub = button.Substring(3);
|
||||
buttons[sub] = controller.IsPressed($"P{controllerNum} {sub}");
|
||||
}
|
||||
}
|
||||
foreach (var button in controller.Definition.FloatControls)
|
||||
{
|
||||
if (controllerNum == null)
|
||||
{
|
||||
buttons[button] = controller.GetFloat(button);
|
||||
}
|
||||
else if (button.Length > 2 && button.Substring(0, 2) == $"P{controllerNum}")
|
||||
{
|
||||
var sub = button.Substring(3);
|
||||
buttons[sub] = controller.GetFloat($"P{controllerNum} {sub}");
|
||||
}
|
||||
}
|
||||
|
||||
return buttons;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
@ -276,5 +277,37 @@ namespace BizHawk.Emulation.Common
|
|||
{
|
||||
return !info.GetCustomAttributes(false).Any(a => a is FeatureNotImplementedAttribute);
|
||||
}
|
||||
|
||||
public static IDictionary<string, dynamic> ToDictionary(this IController controller, int? controllerNum = null)
|
||||
{
|
||||
var buttons = new Dictionary<string, dynamic>();
|
||||
|
||||
foreach (var button in controller.Definition.BoolButtons)
|
||||
{
|
||||
if (controllerNum == null)
|
||||
{
|
||||
buttons[button] = controller.IsPressed(button);
|
||||
}
|
||||
else if (button.Length > 2 && button.Substring(0, 2) == $"P{controllerNum}")
|
||||
{
|
||||
var sub = button.Substring(3);
|
||||
buttons[sub] = controller.IsPressed($"P{controllerNum} {sub}");
|
||||
}
|
||||
}
|
||||
foreach (var button in controller.Definition.FloatControls)
|
||||
{
|
||||
if (controllerNum == null)
|
||||
{
|
||||
buttons[button] = controller.GetFloat(button);
|
||||
}
|
||||
else if (button.Length > 2 && button.Substring(0, 2) == $"P{controllerNum}")
|
||||
{
|
||||
var sub = button.Substring(3);
|
||||
buttons[sub] = controller.GetFloat($"P{controllerNum} {sub}");
|
||||
}
|
||||
}
|
||||
|
||||
return buttons;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue