private void SetDualGameBoyControllerAsMnemonic(string mnemonic) { var checker = new MnemonicChecker(mnemonic); MyBoolButtons.Clear(); for (int i = 0; i < BkmMnemonicConstants.DGBMnemonic.Length; i++) { var t = BkmMnemonicConstants.DGBMnemonic[i]; if (t.Item1 != null) { Force(t.Item1, checker[i]); } } }
private void SetAtari7800AsMnemonic(string mnemonic) { var c = new MnemonicChecker(mnemonic); _myBoolButtons.Clear(); if (mnemonic.Length < 5) { return; } if (mnemonic[1] == 'P') { Force("Power", true); } if (mnemonic[2] == 'r') { Force("Reset", true); } if (mnemonic[3] == 's') { Force("Select", true); } if (mnemonic[4] == 'p') { Force("Pause", true); } for (int player = 1; player <= BkmMnemonicConstants.Players[ControlType]; player++) { int srcIndex = (player - 1) * (BkmMnemonicConstants.Buttons[ControlType].Count + 1); int start = 6; if (mnemonic.Length < srcIndex + start + BkmMnemonicConstants.Buttons[ControlType].Count) { return; } foreach (string button in BkmMnemonicConstants.Buttons[ControlType].Keys) { Force($"P{player} {button}", c[srcIndex + start++]); } } }
private void SetN64ControllersAsMnemonic(string mnemonic) { var c = new MnemonicChecker(mnemonic); _myBoolButtons.Clear(); if (mnemonic.Length < 2) { return; } if (mnemonic[1] == 'P') { Force("Power", true); } else if (mnemonic[1] != '.' && mnemonic[1] != '0') { Force("Reset", true); } for (int player = 1; player <= BkmMnemonicConstants.Players[ControlType]; player++) { int srcIndex = (player - 1) * (BkmMnemonicConstants.Buttons[ControlType].Count + (BkmMnemonicConstants.Analogs[ControlType].Count * 4) + 1 + 1); if (mnemonic.Length < srcIndex + 3 + BkmMnemonicConstants.Buttons[ControlType].Count - 1) { return; } int start = 3; foreach (string button in BkmMnemonicConstants.Buttons[ControlType].Keys) { Force($"P{player} {button}", c[srcIndex + start++]); } foreach (string name in BkmMnemonicConstants.Analogs[ControlType].Keys) { Force($"P{player} {name}", int.Parse(mnemonic.Substring(srcIndex + start, 4))); start += 5; } } }
private void SetN64ControllersAsMnemonic(string mnemonic) { MnemonicChecker c = new MnemonicChecker(mnemonic); MyBoolButtons.Clear(); if (mnemonic.Length < 2) { return; } if (mnemonic[1] == 'P') { Force("Power", true); } else if (mnemonic[1] != '.' && mnemonic[1] != '0') { Force("Reset", true); } for (int player = 1; player <= BkmMnemonicConstants.PLAYERS[ControlType]; player++) { int srcindex = (player - 1) * (BkmMnemonicConstants.BUTTONS[ControlType].Count + BkmMnemonicConstants.ANALOGS[ControlType].Count * 4 + 1 + 1); if (mnemonic.Length < srcindex + 3 + BkmMnemonicConstants.BUTTONS[ControlType].Count - 1) { return; } int start = 3; foreach (string button in BkmMnemonicConstants.BUTTONS[ControlType].Keys) { Force("P" + player + " " + button, c[srcindex + start++]); } foreach (string name in BkmMnemonicConstants.ANALOGS[ControlType].Keys) { Force("P" + player + " " + name, Int32.Parse(mnemonic.Substring(srcindex + start, 4))); start += 5; } } }
private void SetGBAControllersAsMnemonic(string mnemonic) { MnemonicChecker c = new MnemonicChecker(mnemonic); MyBoolButtons.Clear(); if (mnemonic.Length < 2) { return; } if (mnemonic[1] == 'P') { Force("Power", true); } int start = 3; foreach (string button in BkmMnemonicConstants.BUTTONS[ControlType].Keys) { Force(button, c[start++]); } }
private void SetGenesis3ControllersAsMnemonic(string mnemonic) { var c = new MnemonicChecker(mnemonic); _myBoolButtons.Clear(); if (mnemonic.Length < 2) { return; } if (mnemonic[1] == 'P') { Force("Power", true); } else if (mnemonic[1] != '.' && mnemonic[1] != '0') { Force("Reset", true); } if (mnemonic.Length < 9) { return; } for (int player = 1; player <= BkmMnemonicConstants.Players[ControlType]; player++) { int srcIndex = (player - 1) * (BkmMnemonicConstants.Buttons["GPGX 3-Button Controller"].Count + 1); if (mnemonic.Length < srcIndex + 3 + BkmMnemonicConstants.Buttons["GPGX 3-Button Controller"].Count - 1) { return; } int start = 3; foreach (string button in BkmMnemonicConstants.Buttons["GPGX 3-Button Controller"].Keys) { Force($"P{player} {button}", c[srcIndex + start++]); } } }
private void SetSNESControllersAsMnemonic(string mnemonic) { var c = new MnemonicChecker(mnemonic); MyBoolButtons.Clear(); if (mnemonic.Length < 2) { return; } if (mnemonic[1] == 'P') { Force("Power", true); } else if (mnemonic[1] != '.' && mnemonic[1] != '0') { Force("Reset", true); } for (int player = 1; player <= BkmMnemonicConstants.PLAYERS[ControlType]; player++) { int srcindex = (player - 1) * (BkmMnemonicConstants.BUTTONS[ControlType].Count + 1); if (mnemonic.Length < srcindex + 3 + BkmMnemonicConstants.BUTTONS[ControlType].Count - 1) { return; } int start = 3; foreach (var button in BkmMnemonicConstants.BUTTONS[ControlType].Keys) { Force("P" + player + " " + button, c[srcindex + start++]); } } }
/// <summary> /// latches all buttons from the supplied mnemonic string /// </summary> public void SetControllersAsMnemonic(string mnemonic) { switch (ControlType) { case "Null Controller": return; case "Lynx Controller": SetLynxControllersAsMnemonic(mnemonic); return; case "SNES Controller": SetSNESControllersAsMnemonic(mnemonic); return; case "Commodore 64 Controller": SetC64ControllersAsMnemonic(mnemonic); return; case "GBA Controller": SetGBAControllersAsMnemonic(mnemonic); return; case "Atari 7800 ProLine Joystick Controller": SetAtari7800AsMnemonic(mnemonic); return; case "Dual Gameboy Controller": SetDualGameBoyControllerAsMnemonic(mnemonic); return; case "WonderSwan Controller": SetWonderSwanControllerAsMnemonic(mnemonic); return; case "Nintendo 64 Controller": SetN64ControllersAsMnemonic(mnemonic); return; case "Saturn Controller": SetSaturnControllersAsMnemonic(mnemonic); return; case "GPGX Genesis Controller": { if (IsGenesis6Button()) { SetGenesis6ControllersAsMnemonic(mnemonic); } else { SetGenesis3ControllersAsMnemonic(mnemonic); } return; } } var c = new MnemonicChecker(mnemonic); _myBoolButtons.Clear(); int start = 3; if (ControlType == "NES Controller") { if (mnemonic.Length < 2) { return; } switch (mnemonic[1]) { case 'P': Force("Power", true); break; case 'E': Force("FDS Eject", true); break; case '0': Force("FDS Insert 0", true); break; case '1': Force("FDS Insert 1", true); break; case '2': Force("FDS Insert 2", true); break; case '3': Force("FDS Insert 3", true); break; case 'c': Force("VS Coin 1", true); break; case 'C': Force("VS Coin 2", true); break; default: { if (mnemonic[1] != '.') { Force("Reset", true); } break; } } } if (ControlType == "Gameboy Controller") { if (mnemonic.Length < 2) { return; } Force("Power", mnemonic[1] != '.'); } if (ControlType == "Genesis 3-Button Controller") { if (mnemonic.Length < 2) { return; } Force("Reset", mnemonic[1] != '.'); } if (ControlType == "SMS Controller" || ControlType == "TI83 Controller" || ControlType == "ColecoVision Basic Controller") { start = 1; } if (ControlType == "Atari 2600 Basic Controller") { if (mnemonic.Length < 2) { return; } Force("Reset", mnemonic[1] != '.' && mnemonic[1] != '0'); Force("Select", mnemonic[2] != '.' && mnemonic[2] != '0'); start = 4; } for (int player = 1; player <= BkmMnemonicConstants.Players[ControlType]; player++) { int srcIndex = (player - 1) * (BkmMnemonicConstants.Buttons[ControlType].Count + 1); int ctr = start; if (mnemonic.Length < srcIndex + ctr + BkmMnemonicConstants.Buttons[ControlType].Count - 1) { return; } string prefix = ""; if (ControlType != "Gameboy Controller" && ControlType != "TI83 Controller") { prefix = $"P{player} "; } foreach (string button in BkmMnemonicConstants.Buttons[ControlType].Keys) { Force(prefix + button, c[srcIndex + ctr++]); } } if (ControlType == "SMS Controller") { int srcIndex = BkmMnemonicConstants.Players[ControlType] * (BkmMnemonicConstants.Buttons[ControlType].Count + 1); int ctr = start; foreach (var command in BkmMnemonicConstants.Commands[ControlType].Keys) { Force(command, c[srcIndex + ctr++]); } } }
/// <summary> /// latches all buttons from the supplied mnemonic string /// </summary> public void SetControllersAsMnemonic(string mnemonic) { if (ControlType == "Null Controller") { return; } if (ControlType == "Lynx Controller") { SetLynxControllersAsMnemonic(mnemonic); return; } if (ControlType == "SNES Controller") { SetSNESControllersAsMnemonic(mnemonic); return; } if (ControlType == "Commodore 64 Controller") { SetC64ControllersAsMnemonic(mnemonic); return; } if (ControlType == "GBA Controller") { SetGBAControllersAsMnemonic(mnemonic); return; } if (ControlType == "Atari 7800 ProLine Joystick Controller") { SetAtari7800AsMnemonic(mnemonic); return; } if (ControlType == "Dual Gameboy Controller") { SetDualGameBoyControllerAsMnemonic(mnemonic); return; } if (ControlType == "WonderSwan Controller") { SetWonderSwanControllerAsMnemonic(mnemonic); return; } if (ControlType == "Nintento 64 Controller") { SetN64ControllersAsMnemonic(mnemonic); return; } if (ControlType == "Saturn Controller") { SetSaturnControllersAsMnemonic(mnemonic); return; } if (ControlType == "PSP Controller") { // TODO return; } if (ControlType == "GPGX Genesis Controller") { if (IsGenesis6Button()) { SetGenesis6ControllersAsMnemonic(mnemonic); } else { SetGenesis3ControllersAsMnemonic(mnemonic); } return; } var c = new MnemonicChecker(mnemonic); MyBoolButtons.Clear(); int start = 3; if (ControlType == "NES Controller") { if (mnemonic.Length < 2) { return; } else if (mnemonic[1] == 'P') { Force("Power", true); } else if (mnemonic[1] == 'E') { Force("FDS Eject", true); } else if (mnemonic[1] == '0') { Force("FDS Insert 0", true); } else if (mnemonic[1] == '1') { Force("FDS Insert 1", true); } else if (mnemonic[1] == '2') { Force("FDS Insert 2", true); } else if (mnemonic[1] == '3') { Force("FDS Insert 3", true); } else if (mnemonic[1] == 'c') { Force("VS Coin 1", true); } else if (mnemonic[1] == 'C') { Force("VS Coin 2", true); } else if (mnemonic[1] != '.') { Force("Reset", true); } } if (ControlType == "Gameboy Controller") { if (mnemonic.Length < 2) return; Force("Power", mnemonic[1] != '.'); } if (ControlType == "Genesis 3-Button Controller") { if (mnemonic.Length < 2) return; Force("Reset", mnemonic[1] != '.'); } if (ControlType == "SMS Controller" || ControlType == "TI83 Controller" || ControlType == "ColecoVision Basic Controller") { start = 1; } if (ControlType == "Atari 2600 Basic Controller") { if (mnemonic.Length < 2) return; Force("Reset", mnemonic[1] != '.' && mnemonic[1] != '0'); Force("Select", mnemonic[2] != '.' && mnemonic[2] != '0'); start = 4; } for (int player = 1; player <= BkmMnemonicConstants.PLAYERS[ControlType]; player++) { int srcindex = (player - 1) * (BkmMnemonicConstants.BUTTONS[ControlType].Count + 1); int ctr = start; if (mnemonic.Length < srcindex + ctr + BkmMnemonicConstants.BUTTONS[ControlType].Count - 1) { return; } string prefix = ""; if (ControlType != "Gameboy Controller" && ControlType != "TI83 Controller") { prefix = "P" + player + " "; } foreach (string button in BkmMnemonicConstants.BUTTONS[ControlType].Keys) { Force(prefix + button, c[srcindex + ctr++]); } } if (ControlType == "SMS Controller") { int srcindex = BkmMnemonicConstants.PLAYERS[ControlType] * (BkmMnemonicConstants.BUTTONS[ControlType].Count + 1); int ctr = start; foreach (var command in BkmMnemonicConstants.COMMANDS[ControlType].Keys) { Force(command, c[srcindex + ctr++]); } } }
private void SetC64ControllersAsMnemonic(string mnemonic) { var c = new MnemonicChecker(mnemonic); MyBoolButtons.Clear(); for (int player = 1; player <= BkmMnemonicConstants.PLAYERS[ControlType]; player++) { int srcindex = (player - 1) * (BkmMnemonicConstants.BUTTONS[ControlType].Count + 1); if (mnemonic.Length < srcindex + 1 + BkmMnemonicConstants.BUTTONS[ControlType].Count - 1) { return; } int start = 1; foreach (var button in BkmMnemonicConstants.BUTTONS[ControlType].Keys) { Force("P" + player + " " + button, c[srcindex + start++]); } } int startk = 13; foreach (string button in BkmMnemonicConstants.BUTTONS["Commodore 64 Keyboard"].Keys) { Force(button, c[startk++]); } }
private void SetWonderSwanControllerAsMnemonic(string mnemonic) { var checker = new MnemonicChecker(mnemonic); MyBoolButtons.Clear(); for (int i = 0; i < BkmMnemonicConstants.WSMnemonic.Length; i++) { var t = BkmMnemonicConstants.WSMnemonic[i]; if (t.Item1 != null) { Force(t.Item1, checker[i]); } } }
private void SetAtari7800AsMnemonic(string mnemonic) { MnemonicChecker c = new MnemonicChecker(mnemonic); MyBoolButtons.Clear(); if (mnemonic.Length < 5) { return; } if (mnemonic[1] == 'P') { Force("Power", true); } if (mnemonic[2] == 'r') { Force("Reset", true); } if (mnemonic[3] == 's') { Force("Select", true); } if (mnemonic[4] == 'p') { Force("Pause", true); } for (int player = 1; player <= BkmMnemonicConstants.PLAYERS[ControlType]; player++) { int srcindex = (player - 1) * (BkmMnemonicConstants.BUTTONS[ControlType].Count + 1); int start = 6; if (mnemonic.Length < srcindex + start + BkmMnemonicConstants.BUTTONS[ControlType].Count) { return; } foreach (string button in BkmMnemonicConstants.BUTTONS[ControlType].Keys) { Force("P" + player + " " + button, c[srcindex + start++]); } } }
private void SetSaturnControllersAsMnemonic(string mnemonic) { MnemonicChecker c = new MnemonicChecker(mnemonic); MyBoolButtons.Clear(); if (mnemonic.Length < 2) { return; } if (mnemonic[1] == 'P') { Force("Power", true); } else if (mnemonic[1] != '.' && mnemonic[1] != '0') { Force("Reset", true); } for (int player = 1; player <= BkmMnemonicConstants.PLAYERS[ControlType]; player++) { int srcindex = (player - 1) * (BkmMnemonicConstants.BUTTONS[ControlType].Count + 1); if (mnemonic.Length < srcindex + 3 + BkmMnemonicConstants.BUTTONS[ControlType].Count - 1) { return; } int start = 3; foreach (string button in BkmMnemonicConstants.BUTTONS[ControlType].Keys) { Force("P" + player + " " + button, c[srcindex + start++]); } } }
private void SetGBAControllersAsMnemonic(string mnemonic) { MnemonicChecker c = new MnemonicChecker(mnemonic); MyBoolButtons.Clear(); if (mnemonic.Length < 2) { return; } if (mnemonic[1] == 'P') { Force("Power", true); } int start = 3; foreach (string button in BkmMnemonicConstants.BUTTONS[ControlType].Keys) { Force(button, c[start++]); } }
/// <summary> /// latches all buttons from the supplied mnemonic string /// </summary> public void SetControllersAsMnemonic(string mnemonic) { if (ControlType == "Null Controller") { return; } if (ControlType == "Lynx Controller") { SetLynxControllersAsMnemonic(mnemonic); return; } if (ControlType == "SNES Controller") { SetSNESControllersAsMnemonic(mnemonic); return; } if (ControlType == "Commodore 64 Controller") { SetC64ControllersAsMnemonic(mnemonic); return; } if (ControlType == "GBA Controller") { SetGBAControllersAsMnemonic(mnemonic); return; } if (ControlType == "Atari 7800 ProLine Joystick Controller") { SetAtari7800AsMnemonic(mnemonic); return; } if (ControlType == "Dual Gameboy Controller") { SetDualGameBoyControllerAsMnemonic(mnemonic); return; } if (ControlType == "WonderSwan Controller") { SetWonderSwanControllerAsMnemonic(mnemonic); return; } if (ControlType == "Nintento 64 Controller") { SetN64ControllersAsMnemonic(mnemonic); return; } if (ControlType == "Saturn Controller") { SetSaturnControllersAsMnemonic(mnemonic); return; } if (ControlType == "PSP Controller") { // TODO return; } if (ControlType == "GPGX Genesis Controller") { if (IsGenesis6Button()) { SetGenesis6ControllersAsMnemonic(mnemonic); } else { SetGenesis3ControllersAsMnemonic(mnemonic); } return; } var c = new MnemonicChecker(mnemonic); MyBoolButtons.Clear(); int start = 3; if (ControlType == "NES Controller") { if (mnemonic.Length < 2) { return; } else if (mnemonic[1] == 'P') { Force("Power", true); } else if (mnemonic[1] == 'E') { Force("FDS Eject", true); } else if (mnemonic[1] == '0') { Force("FDS Insert 0", true); } else if (mnemonic[1] == '1') { Force("FDS Insert 1", true); } else if (mnemonic[1] == '2') { Force("FDS Insert 2", true); } else if (mnemonic[1] == '3') { Force("FDS Insert 3", true); } else if (mnemonic[1] == 'c') { Force("VS Coin 1", true); } else if (mnemonic[1] == 'C') { Force("VS Coin 2", true); } else if (mnemonic[1] != '.') { Force("Reset", true); } } if (ControlType == "Gameboy Controller") { if (mnemonic.Length < 2) { return; } Force("Power", mnemonic[1] != '.'); } if (ControlType == "Genesis 3-Button Controller") { if (mnemonic.Length < 2) { return; } Force("Reset", mnemonic[1] != '.'); } if (ControlType == "SMS Controller" || ControlType == "TI83 Controller" || ControlType == "ColecoVision Basic Controller") { start = 1; } if (ControlType == "Atari 2600 Basic Controller") { if (mnemonic.Length < 2) { return; } Force("Reset", mnemonic[1] != '.' && mnemonic[1] != '0'); Force("Select", mnemonic[2] != '.' && mnemonic[2] != '0'); start = 4; } for (int player = 1; player <= BkmMnemonicConstants.PLAYERS[ControlType]; player++) { int srcindex = (player - 1) * (BkmMnemonicConstants.BUTTONS[ControlType].Count + 1); int ctr = start; if (mnemonic.Length < srcindex + ctr + BkmMnemonicConstants.BUTTONS[ControlType].Count - 1) { return; } string prefix = ""; if (ControlType != "Gameboy Controller" && ControlType != "TI83 Controller") { prefix = "P" + player + " "; } foreach (string button in BkmMnemonicConstants.BUTTONS[ControlType].Keys) { Force(prefix + button, c[srcindex + ctr++]); } } if (ControlType == "SMS Controller") { int srcindex = BkmMnemonicConstants.PLAYERS[ControlType] * (BkmMnemonicConstants.BUTTONS[ControlType].Count + 1); int ctr = start; foreach (var command in BkmMnemonicConstants.COMMANDS[ControlType].Keys) { Force(command, c[srcindex + ctr++]); } } }