Fixes to bkm for supporting 3 button controllers, this is needed since bkm is still used for the import process. Also, don't save 2 copies of the bk2 after importing a movie, one is sufficient
This commit is contained in:
parent
6e50c1b3a9
commit
1a64af9bc5
|
@ -55,18 +55,13 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
else
|
||||
{
|
||||
messageCallback(Path.GetFileName(fn) + " imported as " + "Movies\\" +
|
||||
Path.GetFileName(fn) + "." + Global.MovieSession.Movie.PreferredExtension);
|
||||
messageCallback(Path.GetFileName(fn) + " imported as " + m.Filename);
|
||||
}
|
||||
|
||||
if (!Directory.Exists(d))
|
||||
{
|
||||
Directory.CreateDirectory(d);
|
||||
}
|
||||
|
||||
var outPath = Path.Combine(d, Path.GetFileName(fn) + "." + Global.MovieSession.Movie.PreferredExtension);
|
||||
m.Filename = outPath;
|
||||
m.Save();
|
||||
}
|
||||
|
||||
// Attempt to import another type of movie file into a movie object.
|
||||
|
@ -953,7 +948,7 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
else
|
||||
{
|
||||
controllers.Type.Name = "Genesis 3-Button Controller";
|
||||
controllers.Type.Name = "GPGX 3-Button Controller";
|
||||
}
|
||||
// 016 special flags (Version A and up only)
|
||||
byte flags = r.ReadByte();
|
||||
|
|
|
@ -135,7 +135,15 @@ namespace BizHawk.Client.Common
|
|||
|
||||
if (ControlType == "GPGX Genesis Controller")
|
||||
{
|
||||
SetGensis6ControllersAsMnemonic(mnemonic);
|
||||
if (IsGenesis6Button())
|
||||
{
|
||||
SetGenesis6ControllersAsMnemonic(mnemonic);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetGenesis3ControllersAsMnemonic(mnemonic);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -242,6 +250,11 @@ namespace BizHawk.Client.Common
|
|||
private readonly WorkingDictionary<string, bool> MyBoolButtons = new WorkingDictionary<string, bool>();
|
||||
private readonly WorkingDictionary<string, float> MyFloatControls = new WorkingDictionary<string, float>();
|
||||
|
||||
private bool IsGenesis6Button()
|
||||
{
|
||||
return this.Type.BoolButtons.Contains("P1 X");
|
||||
}
|
||||
|
||||
private void Force(string button, bool state)
|
||||
{
|
||||
MyBoolButtons[button] = state;
|
||||
|
@ -273,7 +286,7 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
}
|
||||
|
||||
private void SetGensis6ControllersAsMnemonic(string mnemonic)
|
||||
private void SetGenesis6ControllersAsMnemonic(string mnemonic)
|
||||
{
|
||||
MnemonicChecker c = new MnemonicChecker(mnemonic);
|
||||
MyBoolButtons.Clear();
|
||||
|
@ -314,6 +327,47 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
}
|
||||
|
||||
private void SetGenesis3ControllersAsMnemonic(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);
|
||||
}
|
||||
|
||||
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);
|
||||
|
|
|
@ -72,6 +72,11 @@ namespace BizHawk.Client.Common
|
|||
return GetGeneis6ButtonControllersAsMnemonic();
|
||||
}
|
||||
|
||||
if (_controlType == "GPGX 3-Button Controller")
|
||||
{
|
||||
return GetGeneis3ButtonControllersAsMnemonic();
|
||||
}
|
||||
|
||||
var input = new StringBuilder("|");
|
||||
|
||||
if (_controlType == "PC Engine Controller")
|
||||
|
@ -557,6 +562,38 @@ namespace BizHawk.Client.Common
|
|||
return input.ToString();
|
||||
}
|
||||
|
||||
private string GetGeneis3ButtonControllersAsMnemonic()
|
||||
{
|
||||
var input = new StringBuilder("|");
|
||||
|
||||
if (IsBasePressed("Power"))
|
||||
{
|
||||
input.Append(BkmMnemonicConstants.COMMANDS[_controlType]["Power"]);
|
||||
}
|
||||
else if (IsBasePressed("Reset"))
|
||||
{
|
||||
input.Append(BkmMnemonicConstants.COMMANDS[_controlType]["Reset"]);
|
||||
}
|
||||
else
|
||||
{
|
||||
input.Append('.');
|
||||
}
|
||||
|
||||
input.Append("|");
|
||||
for (int player = 1; player <= BkmMnemonicConstants.PLAYERS[_controlType]; player++)
|
||||
{
|
||||
foreach (var button in BkmMnemonicConstants.BUTTONS[_controlType].Keys)
|
||||
{
|
||||
input.Append(IsBasePressed("P" + player + " " + button) ? BkmMnemonicConstants.BUTTONS[_controlType][button] : ".");
|
||||
}
|
||||
|
||||
input.Append("|");
|
||||
}
|
||||
|
||||
input.Append("|");
|
||||
return input.ToString();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,6 +35,13 @@ namespace BizHawk.Client.Common
|
|||
{"Start", "S"}, {"X", "X"}, {"Y", "Y"}, {"Z", "Z"}, {"Mode", "M"}
|
||||
}
|
||||
},
|
||||
{
|
||||
"GPGX 3-Button Controller", new Dictionary<string, string>
|
||||
{
|
||||
{"Up", "U"}, {"Down", "D"}, {"Left", "L"}, {"Right", "R"}, {"A", "A"}, {"B", "B"},
|
||||
{"C", "C"}, {"Start", "S"},
|
||||
}
|
||||
},
|
||||
{
|
||||
"NES Controller", new Dictionary<string, string>
|
||||
{
|
||||
|
@ -150,13 +157,15 @@ namespace BizHawk.Client.Common
|
|||
{"TI83 Controller", new Dictionary<string, string>()},
|
||||
{"Nintento 64 Controller", new Dictionary<string, string> {{"Power", "P"}, {"Reset", "r"}}},
|
||||
{"Saturn Controller", new Dictionary<string, string> {{"Power", "P"}, {"Reset", "r"}}},
|
||||
{"GPGX 3-Button Controller", new Dictionary<string, string> {{"Power", "P"}, {"Reset", "r"}}},
|
||||
};
|
||||
|
||||
public static readonly Dictionary<string, int> PLAYERS = new Dictionary<string, int>
|
||||
{
|
||||
{"Gameboy Controller", 1}, {"GBA Controller", 1}, {"Genesis 3-Button Controller", 2}, {"GPGX Genesis Controller", 2}, {"NES Controller", 4},
|
||||
{"SNES Controller", 4}, {"PC Engine Controller", 5}, {"SMS Controller", 2}, {"TI83 Controller", 1}, {"Atari 2600 Basic Controller", 2}, {"Atari 7800 ProLine Joystick Controller", 2},
|
||||
{"ColecoVision Basic Controller", 2}, {"Commodore 64 Controller", 2}, {"Nintento 64 Controller", 4}, {"Saturn Controller", 2}
|
||||
{"ColecoVision Basic Controller", 2}, {"Commodore 64 Controller", 2}, {"Nintento 64 Controller", 4}, {"Saturn Controller", 2},
|
||||
{"GPGX 3-Button Controller", 2}
|
||||
};
|
||||
|
||||
// just experimenting with different possibly more painful ways to handle mnemonics
|
||||
|
|
|
@ -2327,8 +2327,6 @@ namespace BizHawk.Client.EmuHawk
|
|||
// fix movie extension to something palatable for these purposes.
|
||||
// for instance, something which doesnt clobber movies you already may have had.
|
||||
// i'm evenly torn between this, and a file in %TEMP%, but since we dont really have a way to clean up this tempfile, i choose this:
|
||||
movie.Filename = Path.ChangeExtension(movie.Filename, ".autoimported." + MovieService.DefaultExtension);
|
||||
movie.Save();
|
||||
StartNewMovie(movie, false);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue