BizHawk/BizHawk.Client.Common/inputAdapters/BitwiseAdapters.cs

51 lines
1.2 KiB
C#
Raw Normal View History

using BizHawk.Emulation.Common;
2014-06-26 19:19:26 +00:00
namespace BizHawk.Client.Common
{
public class AndAdapter : IController
{
public ControllerDefinition Definition => Source.Definition;
2014-06-26 19:19:26 +00:00
2017-04-15 20:37:30 +00:00
public bool IsPressed(string button)
2014-06-26 19:19:26 +00:00
{
if (Source != null && SourceAnd != null)
2014-06-26 19:19:26 +00:00
{
return Source.IsPressed(button) & SourceAnd.IsPressed(button);
2014-06-26 19:19:26 +00:00
}
return false;
}
// pass floats solely from the original source
// this works in the code because SourceOr is the autofire controller
public float GetFloat(string name)
{
return Source.GetFloat(name);
2014-06-26 19:19:26 +00:00
}
internal IController Source { get; set; }
internal IController SourceAnd { get; set; }
2014-06-26 19:19:26 +00:00
}
public class ORAdapter : IController
{
public ControllerDefinition Definition => Source.Definition;
2017-04-15 20:37:30 +00:00
public bool IsPressed(string button)
2014-06-26 19:19:26 +00:00
{
return (Source?.IsPressed(button) ?? false)
| (SourceOr?.IsPressed(button) ?? false);
2014-06-26 19:19:26 +00:00
}
// pass floats solely from the original source
// this works in the code because SourceOr is the autofire controller
public float GetFloat(string name)
{
return Source.GetFloat(name);
}
2014-06-26 19:19:26 +00:00
internal IController Source { get; set; }
internal IController SourceOr { get; set; }
2014-06-26 19:19:26 +00:00
}
}