bk2 progress - proof of concept for new mnemonics system
This commit is contained in:
parent
6b73891a91
commit
1a4e6efcb4
|
@ -77,7 +77,17 @@ namespace BizHawk.Client.Common
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void SetControllersAsMnemonic(string mnemonic)
|
public void SetControllersAsMnemonic(string mnemonic)
|
||||||
{
|
{
|
||||||
// TODO
|
/*
|
||||||
|
* This doesn't work because the working dictionary is populated by setting things by name, it will always be 0 in this context
|
||||||
|
* Need some sort of reverse lookup
|
||||||
|
var segments = mnemonic.Split(new[] { "|" }, StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
|
||||||
|
var keys = MyBoolButtons.Keys.Select(x => x).ToList();
|
||||||
|
for (int i = 0; i < segments.Length; i++)
|
||||||
|
{
|
||||||
|
MyBoolButtons[keys[i]] = !(segments[0][i] == '.');
|
||||||
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
|
@ -11,6 +11,11 @@ namespace BizHawk.Client.Common
|
||||||
{
|
{
|
||||||
private IController _source;
|
private IController _source;
|
||||||
|
|
||||||
|
public IMovieController MovieControllerAdapter
|
||||||
|
{
|
||||||
|
get { return new Bk2ControllerAdapter(); }
|
||||||
|
}
|
||||||
|
|
||||||
public void SetSource(IController source)
|
public void SetSource(IController source)
|
||||||
{
|
{
|
||||||
_source = source;
|
_source = source;
|
||||||
|
@ -36,42 +41,45 @@ namespace BizHawk.Client.Common
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
var sb = new StringBuilder('|');
|
return CreateLogEntry(createEmpty: true);
|
||||||
foreach (var button in _source.Type.BoolButtons)
|
|
||||||
{
|
|
||||||
sb.Append('.');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_source.Type.FloatControls.Any())
|
|
||||||
{
|
|
||||||
foreach (var floatBtn in _source.Type.FloatControls)
|
|
||||||
{
|
|
||||||
sb.Append(" 000,");
|
|
||||||
}
|
|
||||||
|
|
||||||
sb.Remove(sb.Length - 1, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
sb.Append('|');
|
|
||||||
return sb.ToString();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GenerateLogEntry()
|
public string GenerateLogEntry()
|
||||||
|
{
|
||||||
|
return CreateLogEntry();
|
||||||
|
}
|
||||||
|
|
||||||
|
private string CreateLogEntry(bool createEmpty = false)
|
||||||
{
|
{
|
||||||
var sb = new StringBuilder();
|
var sb = new StringBuilder();
|
||||||
sb.Append('|');
|
sb.Append('|');
|
||||||
|
|
||||||
foreach (var button in _source.Type.BoolButtons)
|
foreach (var button in _source.Type.BoolButtons)
|
||||||
{
|
{
|
||||||
sb.Append(_source.IsPressed(button) ? '1' : '.');
|
if (createEmpty)
|
||||||
|
{
|
||||||
|
sb.Append('.');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sb.Append(_source.IsPressed(button) ? Mnemonics[button] : '.');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_source.Type.FloatControls.Any())
|
if (_source.Type.FloatControls.Any())
|
||||||
{
|
{
|
||||||
foreach (var floatBtn in _source.Type.FloatControls)
|
foreach (var floatBtn in _source.Type.FloatControls)
|
||||||
{
|
{
|
||||||
var val = (int)_source.GetFloat(floatBtn);
|
if (createEmpty)
|
||||||
sb.Append(' ').Append(val).Append(',');
|
{
|
||||||
|
sb.Append(" 000,");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var val = (int)_source.GetFloat(floatBtn);
|
||||||
|
sb.Append(' ').Append(val).Append(',');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sb.Remove(sb.Length - 1, 1);
|
sb.Remove(sb.Length - 1, 1);
|
||||||
|
@ -81,12 +89,58 @@ namespace BizHawk.Client.Common
|
||||||
return sb.ToString();
|
return sb.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IMovieController MovieControllerAdapter
|
private readonly Bk2MnemonicsLookup Mnemonics = new Bk2MnemonicsLookup();
|
||||||
|
|
||||||
|
public class Bk2MnemonicsLookup
|
||||||
{
|
{
|
||||||
get
|
public char this[string button]
|
||||||
{
|
{
|
||||||
return new Bk2ControllerAdapter();
|
get
|
||||||
|
{
|
||||||
|
if (SystemOverrides.ContainsKey(Global.Emulator.SystemId) && SystemOverrides[Global.Emulator.SystemId].ContainsKey(button))
|
||||||
|
{
|
||||||
|
return SystemOverrides[Global.Emulator.SystemId][button];
|
||||||
|
}
|
||||||
|
else if (BaseMnemonicLookupTable.ContainsKey(button))
|
||||||
|
{
|
||||||
|
return BaseMnemonicLookupTable[button];
|
||||||
|
}
|
||||||
|
|
||||||
|
return '!';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private readonly Dictionary<string, char> BaseMnemonicLookupTable = new Dictionary<string, char>
|
||||||
|
{
|
||||||
|
{ "P1 Up", 'U' },
|
||||||
|
{ "P1 Down", 'D' },
|
||||||
|
{ "P1 Left", 'L' },
|
||||||
|
{ "P1 Right", 'R' },
|
||||||
|
{ "P1 B", 'B' },
|
||||||
|
{ "P1 A", 'A' },
|
||||||
|
{ "P1 Select", 's' },
|
||||||
|
{ "P1 Start", 'S' },
|
||||||
|
|
||||||
|
{ "P2 Up", 'U' },
|
||||||
|
{ "P2 Down", 'D' },
|
||||||
|
{ "P2 Left", 'L' },
|
||||||
|
{ "P2 Right", 'R' },
|
||||||
|
{ "P2 B", 'B' },
|
||||||
|
{ "P2 A", 'A' },
|
||||||
|
{ "P2 Select", 's' },
|
||||||
|
{ "P2 Start", 'S' },
|
||||||
|
};
|
||||||
|
|
||||||
|
private readonly Dictionary<string, Dictionary<string, char>> SystemOverrides = new Dictionary<string, Dictionary<string, char>>
|
||||||
|
{
|
||||||
|
{
|
||||||
|
"NES",
|
||||||
|
new Dictionary<string, char>
|
||||||
|
{
|
||||||
|
{ "P1 Up", 'Q' }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue