feos, i dont know, try this

This commit is contained in:
zeromus 2018-03-14 16:49:19 -04:00
parent 0a18040aff
commit 053ee9a45e
3 changed files with 41 additions and 1 deletions

View File

@ -27,6 +27,32 @@ namespace BizHawk.Client.Common
internal IController SourceAnd { get; set; }
}
public class XorAdapter : IController
{
public ControllerDefinition Definition => Source.Definition;
public bool IsPressed(string button)
{
if (Source != null && SourceXor != null)
{
return Source.IsPressed(button) ^ SourceXor.IsPressed(button);
}
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);
}
internal IController Source { get; set; }
internal IController SourceXor { get; set; }
}
public class ORAdapter : IController
{
public ControllerDefinition Definition => Source.Definition;

View File

@ -16,6 +16,19 @@ namespace BizHawk.Client.Common.InputAdapterExtensions
};
}
/// <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>

View File

@ -369,6 +369,7 @@ namespace BizHawk.Client.EmuHawk
//next, draw the immediate input.
//that is, whatever's being held down interactively right this moment even if the game is paused
//this includes things held down due to autohold or autofire
//I know, this is all really confusing
var immediate = InputStrImmediate();
g.DrawString(immediate, MessageFont, immediateColor, x, y);
@ -377,7 +378,7 @@ namespace BizHawk.Client.EmuHawk
//basically we're tinting whatever's pressed because it's sticky specially
//in order to achieve this we want to avoid drawing anything pink that isnt actually held down right now
//so we make an AND adapter and combine it using immediate & sticky
var autoString = MakeStringFor(Global.AutofireStickyXORAdapter.And(Global.StickyXORAdapter.Or(Global.AutofireStickyXORAdapter)));
var autoString = MakeStringFor(Global.StickyXORAdapter.Source.Xor(Global.AutofireStickyXORAdapter).And(Global.AutofireStickyXORAdapter));
g.DrawString(autoString, MessageFont, autoColor, x, y);
//recolor everything that's changed from the previous input