From 37d6e0b8de722eea2afb74eb71721967ff4f2a78 Mon Sep 17 00:00:00 2001 From: adelikat Date: Mon, 16 Jun 2014 16:56:09 +0000 Subject: [PATCH] Finish up Bk2 Mnemonic lookup --- .../BizHawk.Client.Common.csproj | 1 + .../movie/bk2/Bk2LogEntryGenerator.cs | 55 +---- .../movie/bk2/Bk2MnemonicConstants.cs | 208 ++++++++++++++++++ 3 files changed, 210 insertions(+), 54 deletions(-) create mode 100644 BizHawk.Client.Common/movie/bk2/Bk2MnemonicConstants.cs diff --git a/BizHawk.Client.Common/BizHawk.Client.Common.csproj b/BizHawk.Client.Common/BizHawk.Client.Common.csproj index d3a5931c11..f551a77dd7 100644 --- a/BizHawk.Client.Common/BizHawk.Client.Common.csproj +++ b/BizHawk.Client.Common/BizHawk.Client.Common.csproj @@ -136,6 +136,7 @@ + diff --git a/BizHawk.Client.Common/movie/bk2/Bk2LogEntryGenerator.cs b/BizHawk.Client.Common/movie/bk2/Bk2LogEntryGenerator.cs index 785c7e72ef..3b282fdd40 100644 --- a/BizHawk.Client.Common/movie/bk2/Bk2LogEntryGenerator.cs +++ b/BizHawk.Client.Common/movie/bk2/Bk2LogEntryGenerator.cs @@ -9,6 +9,7 @@ namespace BizHawk.Client.Common { public class Bk2LogEntryGenerator : ILogEntryGenerator { + private readonly Bk2MnemonicConstants Mnemonics = new Bk2MnemonicConstants(); private IController _source; public IMovieController MovieControllerAdapter @@ -88,59 +89,5 @@ namespace BizHawk.Client.Common sb.Append('|'); return sb.ToString(); } - - private readonly Bk2MnemonicsLookup Mnemonics = new Bk2MnemonicsLookup(); - - public class Bk2MnemonicsLookup - { - public char this[string button] - { - 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 BaseMnemonicLookupTable = new Dictionary - { - { "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> SystemOverrides = new Dictionary> - { - { - "NES", - new Dictionary - { - { "P1 Up", 'Q' } - } - } - }; - } } } diff --git a/BizHawk.Client.Common/movie/bk2/Bk2MnemonicConstants.cs b/BizHawk.Client.Common/movie/bk2/Bk2MnemonicConstants.cs new file mode 100644 index 0000000000..88b757614f --- /dev/null +++ b/BizHawk.Client.Common/movie/bk2/Bk2MnemonicConstants.cs @@ -0,0 +1,208 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace BizHawk.Client.Common +{ + public class Bk2MnemonicConstants + { + public char this[string button] + { + get + { + var key = button + .Replace("P1 ", "") + .Replace("P2 ", "") + .Replace("P3 ", "") + .Replace("P4 ", "") + .Replace("Key", "") + .Replace("Key ", ""); + + if (SystemOverrides.ContainsKey(Global.Emulator.SystemId) && SystemOverrides[Global.Emulator.SystemId].ContainsKey(key)) + { + return SystemOverrides[Global.Emulator.SystemId][key]; + } + else if (BaseMnemonicLookupTable.ContainsKey(key)) + { + return BaseMnemonicLookupTable[key]; + } + else if (key.Length == 1) + { + return key[0]; + } + + return '!'; + } + } + + private readonly Dictionary BaseMnemonicLookupTable = new Dictionary + { + { "Power", 'P' }, + { "Reset", 'r' }, + { "Pause", 'p' }, + { "Rotate", 'R' }, + + { "Up", 'U' }, + { "Down", 'D' }, + { "Left", 'L' }, + { "Right", 'R' }, + + { "A", 'A' }, + { "B", 'B' }, + { "C", 'C' }, + + { "X", 'X' }, + { "Y", 'Y' }, + { "Z", 'Z' }, + + { "Select", 's' }, + { "Start", 'S' }, + + { "L", 'l' }, + { "R", 'r' }, + + { "L1", 'l' }, + { "R1", 'r' }, + + { "Button", 'B' }, + { "B1", '1' }, + { "B2", '2' }, + + { "Trigger", '1' }, + { "Trigger 1", '1' }, + { "Trigger 2", '2' }, + + {"Mode", 'M'}, + + { "Fire", 'F' }, + { "Microphone", 'M' }, + + { "Star", '*' }, + { "Pound", '#' }, + + { "P2 X1", '1' }, + { "P2 X2", '2' }, + { "P2 X3", '3' }, + { "P2 X4", '4' }, + + { "P2 Y1", '1' }, + { "P2 Y2", '2' }, + { "P2 Y3", '3' }, + { "P2 Y4", '4' }, + }; + + private readonly Dictionary> SystemOverrides = new Dictionary> + { + { + "NES", + new Dictionary + { + { "FDS Eject", 'E' }, + { "FDS Insert 0", '0' }, + { "FDS Insert 1", '1' }, + { "VS Coin 1", 'c' }, + { "VS Coin 2", 'C' }, + } + }, + { + "TI-83", + new Dictionary + { + { "DOT", '`' }, + { "ON", 'O' }, + { "ENTER", '=' }, + { "PLUS", '+' }, + { "MINUS", '_' }, + { "MULTIPLY", '*' }, + { "DIVIDE", '/' }, + { "CLEAR", 'c' }, + { "EXP", '^' }, + { "DASH", '-' }, + { "PARAOPEN", '('}, + { "PARACLOSE", ')'}, + { "TAN", 'T' }, + { "VARS", 'V' }, + { "COS", 'C' }, + { "PRGM", 'P' }, + { "STAT", 's' }, + { "MATRIX", 'm' }, + { "X", 'X' }, + { "STO", '>' }, + { "LN", 'n' }, + { "LOG", 'L' }, + { "SQUARED", '2' }, + { "NEG1", '1' }, + { "MATH", 'H' }, + { "ALPHA", 'A' }, + { "GRAPH", 'G' }, + { "TRACE", 't' }, + { "ZOOM", 'Z' }, + { "WINDOW", 'W' }, + { "Y", 'Y' }, + { "2ND", '&' }, + { "MODE", 'O' }, + { "DEL", 'D' }, + { "COMMA", ',' }, + { "SIN", 'S' } + } + }, + { + "C64", + new Dictionary + { + {"Key F1", '1' }, + {"Key F3", '3' }, + {"Key F5", '5' }, + {"Key F7", '7' }, + {"Key Left Arrow", 'l' }, + {"Key Plus", '+' }, + {"Key Minus", '-' }, + {"Key Pound", 'l' }, + {"Key Clear/Home", 'c' }, + {"Key Insert/Delete", 'i' }, + {"Key Control", 'c' }, + {"Key At", '@' }, + {"Key Asterisk", '*' }, + {"Key Up Arrow", 'u' }, + {"Key Restore", 'r' }, + {"Key Run/Stop", 's' }, + {"Key Lck", 'k' }, + {"Key Colon", ':' }, + {"Key Semicolon", ';' }, + {"Key Equal", '=' }, + {"Key Return", 'e'}, + {"Key Commodore", 'o' }, + {"Key Left Shift", 's' }, + {"Key Comma", ',' }, + {"Key Period", '>' }, + {"Key Slash", '/' }, + {"Key Right Shift", 's' }, + {"Key Cursor Up/Down", 'u' }, + {"Key Cursor Left/Right", 'l' }, + {"Key Space", '_' } + } + }, + { + "N64", + new Dictionary + { + { "C Up", 'u' }, + { "C Down", 'd' }, + { "C Left", 'l' }, + { "C Right", 'r' }, + + { "A Up", 'U' }, + { "A Down", 'D' }, + { "A Left", 'L' }, + { "A Right", 'R' }, + + { "DPad Up", 'U' }, + { "DPad Down", 'D' }, + { "DPad Left", 'L' }, + { "DPad Right", 'R' }, + } + } + }; + } +}