Input adpaters - some reorg and add extensions for create And and Or adapters and simplify some calling code
This commit is contained in:
parent
c58141034b
commit
721dbe8d3b
|
@ -111,7 +111,10 @@
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Global.cs" />
|
<Compile Include="Global.cs" />
|
||||||
<Compile Include="helpers\InputValidate.cs" />
|
<Compile Include="helpers\InputValidate.cs" />
|
||||||
<Compile Include="InputManager.cs" />
|
<Compile Include="inputAdapters\BitwiseAdapters.cs" />
|
||||||
|
<Compile Include="inputAdapters\InputAdapterExtensions.cs" />
|
||||||
|
<Compile Include="inputAdapters\InputAdapters.cs" />
|
||||||
|
<Compile Include="inputAdapters\InputManager.cs" />
|
||||||
<Compile Include="IPS.cs" />
|
<Compile Include="IPS.cs" />
|
||||||
<Compile Include="KeyTurbo.cs" />
|
<Compile Include="KeyTurbo.cs" />
|
||||||
<Compile Include="lua\EmuLuaLibrary.Bit.cs" />
|
<Compile Include="lua\EmuLuaLibrary.Bit.cs" />
|
||||||
|
@ -153,7 +156,6 @@
|
||||||
<Compile Include="movie\bkm\BkmMovie.ModeApi.cs" />
|
<Compile Include="movie\bkm\BkmMovie.ModeApi.cs" />
|
||||||
<Compile Include="movie\conversions\MovieConversionExtensions.cs" />
|
<Compile Include="movie\conversions\MovieConversionExtensions.cs" />
|
||||||
<Compile Include="movie\HeaderKeys.cs" />
|
<Compile Include="movie\HeaderKeys.cs" />
|
||||||
<Compile Include="movie\InputAdapters.cs" />
|
|
||||||
<Compile Include="movie\interfaces\ILogEntryGenerator.cs" />
|
<Compile Include="movie\interfaces\ILogEntryGenerator.cs" />
|
||||||
<Compile Include="movie\interfaces\IMovie.cs" />
|
<Compile Include="movie\interfaces\IMovie.cs" />
|
||||||
<Compile Include="movie\interfaces\IMovieController.cs" />
|
<Compile Include="movie\interfaces\IMovieController.cs" />
|
||||||
|
@ -215,6 +217,7 @@
|
||||||
<Name>BizHawk.Bizware.BizwareGL</Name>
|
<Name>BizHawk.Bizware.BizwareGL</Name>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup />
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<PreBuildEvent>"$(SolutionDir)subwcrev.bat" "$(ProjectDir)"</PreBuildEvent>
|
<PreBuildEvent>"$(SolutionDir)subwcrev.bat" "$(ProjectDir)"</PreBuildEvent>
|
||||||
|
|
|
@ -55,11 +55,6 @@ namespace BizHawk.Client.Common
|
||||||
|
|
||||||
public static AutoFireStickyXorAdapter AutofireStickyXORAdapter = new AutoFireStickyXorAdapter();
|
public static AutoFireStickyXorAdapter AutofireStickyXORAdapter = new AutoFireStickyXorAdapter();
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// will OR together two IControllers
|
|
||||||
/// </summary>
|
|
||||||
public static ORAdapter OrControllerAdapter = new ORAdapter();
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// provides an opportunity to mutate the player's input in an autohold style
|
/// provides an opportunity to mutate the player's input in an autohold style
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -1,13 +1,11 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using BizHawk.Common;
|
using BizHawk.Common;
|
||||||
using BizHawk.Emulation.Common;
|
using BizHawk.Emulation.Common;
|
||||||
|
|
||||||
namespace BizHawk.Client.Common
|
namespace BizHawk.Client.Common
|
||||||
{
|
{
|
||||||
using System.Linq;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// will hold buttons for 1 frame and then release them. (Calling Click() from your button click is what you want to do)
|
/// will hold buttons for 1 frame and then release them. (Calling Click() from your button click is what you want to do)
|
||||||
/// TODO - should the duration be controllable?
|
/// TODO - should the duration be controllable?
|
||||||
|
@ -173,70 +171,6 @@ namespace BizHawk.Client.Common
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ORAdapter : IController
|
|
||||||
{
|
|
||||||
public bool IsPressed(string button)
|
|
||||||
{
|
|
||||||
return this[button];
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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); }
|
|
||||||
|
|
||||||
public IController Source { get; set; }
|
|
||||||
public IController SourceOr { get; set; }
|
|
||||||
public ControllerDefinition Type { get { return Source.Type; } set { throw new InvalidOperationException(); } }
|
|
||||||
|
|
||||||
public bool this[string button]
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return (Source != null ? Source[button] : false) |
|
|
||||||
(SourceOr != null ? SourceOr[button] : false);
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
throw new InvalidOperationException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public class AndAdapter : IController
|
|
||||||
{
|
|
||||||
public bool IsPressed(string button)
|
|
||||||
{
|
|
||||||
return this[button];
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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); }
|
|
||||||
|
|
||||||
public IController Source { get; set; }
|
|
||||||
public IController SourceAnd { get; set; }
|
|
||||||
public ControllerDefinition Type { get { return Source.Type; } set { throw new InvalidOperationException(); } }
|
|
||||||
|
|
||||||
public bool this[string button]
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (Source != null && SourceAnd != null)
|
|
||||||
{
|
|
||||||
return Source[button] & SourceAnd[button];
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
set
|
|
||||||
{
|
|
||||||
throw new InvalidOperationException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Used by input display, to determine if either autofire or regular stickies are "in effect" because we color this scenario differently
|
// Used by input display, to determine if either autofire or regular stickies are "in effect" because we color this scenario differently
|
||||||
public class StickyOrAdapter : IController
|
public class StickyOrAdapter : IController
|
||||||
{
|
{
|
|
@ -1,7 +1,7 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
using BizHawk.Emulation.Common;
|
using BizHawk.Emulation.Common;
|
||||||
|
using BizHawk.Client.Common.InputAdapterExtensions;
|
||||||
namespace BizHawk.Client.Common
|
namespace BizHawk.Client.Common
|
||||||
{
|
{
|
||||||
public static class InputManager
|
public static class InputManager
|
||||||
|
@ -11,9 +11,7 @@ namespace BizHawk.Client.Common
|
||||||
Global.ControllerInputCoalescer.Clear();
|
Global.ControllerInputCoalescer.Clear();
|
||||||
Global.ControllerInputCoalescer.Type = Global.ActiveController.Type;
|
Global.ControllerInputCoalescer.Type = Global.ActiveController.Type;
|
||||||
|
|
||||||
Global.OrControllerAdapter.Source = Global.ActiveController;
|
Global.UD_LR_ControllerAdapter.Source = Global.ActiveController.Or(Global.AutoFireController);
|
||||||
Global.OrControllerAdapter.SourceOr = Global.AutoFireController;
|
|
||||||
Global.UD_LR_ControllerAdapter.Source = Global.OrControllerAdapter;
|
|
||||||
|
|
||||||
Global.StickyXORAdapter.Source = Global.UD_LR_ControllerAdapter;
|
Global.StickyXORAdapter.Source = Global.UD_LR_ControllerAdapter;
|
||||||
Global.AutofireStickyXORAdapter.Source = Global.StickyXORAdapter;
|
Global.AutofireStickyXORAdapter.Source = Global.StickyXORAdapter;
|
|
@ -5,7 +5,7 @@ using System.Drawing;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
using BizHawk.Client.Common;
|
using BizHawk.Client.Common;
|
||||||
|
using BizHawk.Client.Common.InputAdapterExtensions;
|
||||||
using BizHawk.Bizware.BizwareGL;
|
using BizHawk.Bizware.BizwareGL;
|
||||||
|
|
||||||
namespace BizHawk.Client.EmuHawk
|
namespace BizHawk.Client.EmuHawk
|
||||||
|
@ -261,16 +261,9 @@ namespace BizHawk.Client.EmuHawk
|
||||||
Global.MovieSession.Movie.GetInputState(Global.Emulator.Frame - 1) :
|
Global.MovieSession.Movie.GetInputState(Global.Emulator.Frame - 1) :
|
||||||
Global.MovieSession.MovieControllerInstance();
|
Global.MovieSession.MovieControllerInstance();
|
||||||
|
|
||||||
var orAdaptor = new ORAdapter()
|
|
||||||
{
|
|
||||||
Source = Global.AutofireStickyXORAdapter,
|
|
||||||
SourceOr = m
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
var lg = Global.MovieSession.LogGeneratorInstance();
|
var lg = Global.MovieSession.LogGeneratorInstance();
|
||||||
|
|
||||||
lg.SetSource(orAdaptor);
|
lg.SetSource(Global.AutofireStickyXORAdapter.Or(m));
|
||||||
return lg.GenerateInputDisplay();
|
return lg.GenerateInputDisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -293,17 +286,11 @@ namespace BizHawk.Client.EmuHawk
|
||||||
if (Global.MovieSession.Movie.IsActive)
|
if (Global.MovieSession.Movie.IsActive)
|
||||||
{
|
{
|
||||||
var m = Global.MovieSession.Movie.IsActive && !Global.MovieSession.Movie.IsFinished ?
|
var m = Global.MovieSession.Movie.IsActive && !Global.MovieSession.Movie.IsFinished ?
|
||||||
Global.MovieSession.Movie.GetInputState(Global.Emulator.Frame - 1) :
|
Global.MovieSession.Movie.GetInputState(Global.Emulator.Frame - 1) :
|
||||||
Global.MovieSession.MovieControllerInstance();
|
Global.MovieSession.MovieControllerInstance();
|
||||||
|
|
||||||
var andAdaptor = new AndAdapter
|
|
||||||
{
|
|
||||||
Source = Global.AutofireStickyXORAdapter,
|
|
||||||
SourceAnd = m
|
|
||||||
};
|
|
||||||
|
|
||||||
var lg = Global.MovieSession.LogGeneratorInstance();
|
var lg = Global.MovieSession.LogGeneratorInstance();
|
||||||
lg.SetSource(andAdaptor);
|
lg.SetSource(Global.AutofireStickyXORAdapter.And(m));
|
||||||
return lg.GenerateInputDisplay();
|
return lg.GenerateInputDisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue