reorg controller and input adapter classes
This commit is contained in:
parent
6db1d7e61d
commit
c64eff6baf
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace BizHawk.Client.Common
|
||||
{
|
||||
public class AndAdapter : IController
|
||||
public class AndAdapter : IInputAdapter
|
||||
{
|
||||
public ControllerDefinition Definition => Source.Definition;
|
||||
|
||||
|
@ -20,11 +20,11 @@ namespace BizHawk.Client.Common
|
|||
// this works in the code because SourceOr is the autofire controller
|
||||
public int AxisValue(string name) => Source.AxisValue(name);
|
||||
|
||||
internal IController Source { get; set; }
|
||||
public IController Source { get; set; }
|
||||
internal IController SourceAnd { get; set; }
|
||||
}
|
||||
|
||||
public class XorAdapter : IController
|
||||
public class XorAdapter : IInputAdapter
|
||||
{
|
||||
public ControllerDefinition Definition => Source.Definition;
|
||||
|
||||
|
@ -42,11 +42,11 @@ namespace BizHawk.Client.Common
|
|||
// this works in the code because SourceOr is the autofire controller
|
||||
public int AxisValue(string name) => Source.AxisValue(name);
|
||||
|
||||
internal IController Source { get; set; }
|
||||
public IController Source { get; set; }
|
||||
internal IController SourceXor { get; set; }
|
||||
}
|
||||
|
||||
public class ORAdapter : IController
|
||||
public class ORAdapter : IInputAdapter
|
||||
{
|
||||
public ControllerDefinition Definition => Source.Definition;
|
||||
|
||||
|
@ -60,7 +60,7 @@ namespace BizHawk.Client.Common
|
|||
// this works in the code because SourceOr is the autofire controller
|
||||
public int AxisValue(string name) => Source.AxisValue(name);
|
||||
|
||||
internal IController Source { get; set; }
|
||||
public IController Source { get; set; }
|
||||
internal IController SourceOr { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,4 +10,44 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
IController Source { get; set; }
|
||||
}
|
||||
|
||||
public static class InputAdapterExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new IController that is in a state of a bitwise And of the source and target controllers
|
||||
/// </summary>
|
||||
public static IController And(this IController source, IController target)
|
||||
{
|
||||
return new AndAdapter
|
||||
{
|
||||
Source = source,
|
||||
SourceAnd = target
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new IController that is in a state of a bitwise Xor of the source and target controllers
|
||||
/// </summary>
|
||||
public static IController Xor(this IController source, IController target)
|
||||
{
|
||||
return new XorAdapter
|
||||
{
|
||||
Source = source,
|
||||
SourceXor = target
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new IController that is in a state of a bitwise Or of the source and target controllers
|
||||
/// </summary>
|
||||
public static IController Or(this IController source, IController target)
|
||||
{
|
||||
return new ORAdapter
|
||||
{
|
||||
Source = source,
|
||||
SourceOr = target
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,44 +0,0 @@
|
|||
using BizHawk.Emulation.Common;
|
||||
|
||||
namespace BizHawk.Client.Common.InputAdapterExtensions
|
||||
{
|
||||
public static class InputAdapterExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new IController that is in a state of a bitwise And of the source and target controllers
|
||||
/// </summary>
|
||||
public static IController And(this IController source, IController target)
|
||||
{
|
||||
return new AndAdapter
|
||||
{
|
||||
Source = source,
|
||||
SourceAnd = target
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new IController that is in a state of a bitwise Xor of the source and target controllers
|
||||
/// </summary>
|
||||
public static IController Xor(this IController source, IController target)
|
||||
{
|
||||
return new XorAdapter
|
||||
{
|
||||
Source = source,
|
||||
SourceXor = target
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new IController that is in a state of a bitwise Or of the source and target controllers
|
||||
/// </summary>
|
||||
public static IController Or(this IController source, IController target)
|
||||
{
|
||||
return new ORAdapter
|
||||
{
|
||||
Source = source,
|
||||
SourceOr = target
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,7 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
using BizHawk.Emulation.Common;
|
||||
using BizHawk.Client.Common.InputAdapterExtensions;
|
||||
|
||||
namespace BizHawk.Client.Common
|
||||
{
|
||||
|
|
|
@ -6,7 +6,7 @@ using BizHawk.Emulation.Common;
|
|||
|
||||
namespace BizHawk.Client.Common
|
||||
{
|
||||
public interface IStickyController : IController
|
||||
public interface IStickyController : IInputAdapter
|
||||
{
|
||||
bool IsSticky(string button);
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ namespace BizHawk.Client.Common
|
|||
/// Filters input for things called Up and Down while considering the client's AllowUD_LR option.
|
||||
/// This is a bit gross but it is unclear how to do it more nicely
|
||||
/// </summary>
|
||||
public class UdlrControllerAdapter : IController
|
||||
public class UdlrControllerAdapter : IInputAdapter
|
||||
{
|
||||
public IController Source { get; set; }
|
||||
|
||||
|
|
|
@ -6,7 +6,6 @@ using System.Collections.Generic;
|
|||
|
||||
using BizHawk.Emulation.Common;
|
||||
using BizHawk.Client.Common;
|
||||
using BizHawk.Client.Common.InputAdapterExtensions;
|
||||
|
||||
namespace BizHawk.Client.EmuHawk
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue