simplify AutoFireController - no need to pass in an emulator and the emulator's definition separately
This commit is contained in:
parent
96fa84ff8b
commit
34acead9b5
|
@ -9,11 +9,10 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
public class AutofireController : IController
|
||||
{
|
||||
public AutofireController(ControllerDefinition definition, IEmulator emulator, int on, int off)
|
||||
public AutofireController(IEmulator emulator, int on, int off)
|
||||
{
|
||||
On = on < 1 ? 0 : on;
|
||||
Off = off < 1 ? 0 : off;
|
||||
Definition = definition;
|
||||
_emulator = emulator;
|
||||
}
|
||||
|
||||
|
@ -28,7 +27,7 @@ namespace BizHawk.Client.Common
|
|||
public int On { get; set; }
|
||||
public int Off { get; set; }
|
||||
|
||||
public ControllerDefinition Definition { get; }
|
||||
public ControllerDefinition Definition => _emulator.ControllerDefinition;
|
||||
|
||||
public bool IsPressed(string button)
|
||||
{
|
||||
|
|
|
@ -84,7 +84,7 @@ namespace BizHawk.Client.Common
|
|||
var def = emulator.ControllerDefinition;
|
||||
|
||||
ActiveController = BindToDefinition(def, config.AllTrollers, config.AllTrollersAnalog);
|
||||
AutoFireController = BindToDefinitionAF(def, emulator, config.AllTrollersAutoFire, config.AutofireOn, config.AutofireOff);
|
||||
AutoFireController = BindToDefinitionAF(emulator, config.AllTrollersAutoFire, config.AutofireOn, config.AutofireOff);
|
||||
|
||||
// allow propagating controls that are in the current controller definition but not in the prebaked one
|
||||
// these two lines shouldn't be required anymore under the new system?
|
||||
|
@ -122,16 +122,15 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
|
||||
private static AutofireController BindToDefinitionAF(
|
||||
ControllerDefinition def,
|
||||
IEmulator emulator,
|
||||
IDictionary<string, Dictionary<string, string>> allBinds,
|
||||
int on,
|
||||
int off)
|
||||
{
|
||||
var ret = new AutofireController(def, emulator, on, off);
|
||||
if (allBinds.TryGetValue(def.Name, out var binds))
|
||||
var ret = new AutofireController(emulator, on, off);
|
||||
if (allBinds.TryGetValue(emulator.ControllerDefinition.Name, out var binds))
|
||||
{
|
||||
foreach (var btn in def.BoolButtons)
|
||||
foreach (var btn in emulator.ControllerDefinition.BoolButtons)
|
||||
{
|
||||
if (binds.TryGetValue(btn, out var bind))
|
||||
{
|
||||
|
|
|
@ -1948,7 +1948,6 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
Global.InputManager.ClientControls = controls;
|
||||
_autofireNullControls = new AutofireController(
|
||||
NullController.Instance.Definition,
|
||||
Emulator,
|
||||
Config.AutofireOn,
|
||||
Config.AutofireOff);
|
||||
|
|
Loading…
Reference in New Issue