Some more moving code around related to multitrack
This commit is contained in:
parent
71a564b1cf
commit
066b072627
|
@ -577,56 +577,6 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// rewires player1 controls to playerN
|
||||
/// </summary>
|
||||
public class MultitrackRewiringControllerAdapter : IController
|
||||
{
|
||||
public IController Source { get; set; }
|
||||
public int PlayerSource = 1;
|
||||
public int PlayerTargetMask = 0;
|
||||
|
||||
public ControllerDefinition Type { get { return Source.Type; } }
|
||||
public bool this[string button] { get { return IsPressed(button); } }
|
||||
|
||||
// floats can be player number remapped just like boolbuttons
|
||||
public float GetFloat(string name) { return Source.GetFloat(RemapButtonName(name)); }
|
||||
|
||||
private string RemapButtonName(string button)
|
||||
{
|
||||
// Do we even have a source?
|
||||
if (PlayerSource == -1)
|
||||
{
|
||||
return button;
|
||||
}
|
||||
|
||||
// See if we're being asked for a button that we know how to rewire
|
||||
var bnp = ButtonNameParser.Parse(button);
|
||||
|
||||
if (bnp == null)
|
||||
{
|
||||
return button;
|
||||
}
|
||||
|
||||
// Ok, this looks like a normal `P1 Button` type thing. we can handle it
|
||||
// Were we supposed to replace this one?
|
||||
int foundPlayerMask = (1 << bnp.PlayerNum);
|
||||
if ((PlayerTargetMask & foundPlayerMask) == 0)
|
||||
{
|
||||
return button;
|
||||
}
|
||||
|
||||
// Ok, we were. swap out the source player and then grab his button
|
||||
bnp.PlayerNum = PlayerSource;
|
||||
return bnp.ToString();
|
||||
}
|
||||
|
||||
public bool IsPressed(string button)
|
||||
{
|
||||
return Source.IsPressed(RemapButtonName(button));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Used to pass into an Override method to manage the logic overriding input
|
||||
/// This only works with bool buttons!
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
namespace BizHawk.Client.Common
|
||||
using BizHawk.Emulation.Common;
|
||||
|
||||
namespace BizHawk.Client.Common
|
||||
{
|
||||
public class MultitrackRecorder
|
||||
{
|
||||
|
@ -79,4 +81,54 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// rewires player1 controls to playerN
|
||||
/// </summary>
|
||||
public class MultitrackRewiringControllerAdapter : IController
|
||||
{
|
||||
public IController Source { get; set; }
|
||||
public int PlayerSource = 1;
|
||||
public int PlayerTargetMask = 0;
|
||||
|
||||
public ControllerDefinition Type { get { return Source.Type; } }
|
||||
public bool this[string button] { get { return IsPressed(button); } }
|
||||
|
||||
// floats can be player number remapped just like boolbuttons
|
||||
public float GetFloat(string name) { return Source.GetFloat(RemapButtonName(name)); }
|
||||
|
||||
private string RemapButtonName(string button)
|
||||
{
|
||||
// Do we even have a source?
|
||||
if (PlayerSource == -1)
|
||||
{
|
||||
return button;
|
||||
}
|
||||
|
||||
// See if we're being asked for a button that we know how to rewire
|
||||
var bnp = ButtonNameParser.Parse(button);
|
||||
|
||||
if (bnp == null)
|
||||
{
|
||||
return button;
|
||||
}
|
||||
|
||||
// Ok, this looks like a normal `P1 Button` type thing. we can handle it
|
||||
// Were we supposed to replace this one?
|
||||
int foundPlayerMask = (1 << bnp.PlayerNum);
|
||||
if ((PlayerTargetMask & foundPlayerMask) == 0)
|
||||
{
|
||||
return button;
|
||||
}
|
||||
|
||||
// Ok, we were. swap out the source player and then grab his button
|
||||
bnp.PlayerNum = PlayerSource;
|
||||
return bnp.ToString();
|
||||
}
|
||||
|
||||
public bool IsPressed(string button)
|
||||
{
|
||||
return Source.IsPressed(RemapButtonName(button));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue