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

57 lines
1.3 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
2014-06-26 19:19:26 +00:00
{
get { return Source.Definition; }
2014-06-26 19:19:26 +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
{
get { return Source.Definition; }
}
2014-06-26 19:19:26 +00:00
public bool IsPressed(string button)
{
return (Source != null ? Source.IsPressed(button) : false)
| (SourceOr != null ? 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
}
}