N64: Added X and Y axises to the mnemonic, which now get saved and replayed in movies. Fixed an issue in the virtual pad which caused the Y axis to go from -127 to 128 instead of -128 to 127

This commit is contained in:
pjgat09 2013-05-11 02:04:55 +00:00
parent f8f9c3ea4a
commit fd26695fff
3 changed files with 35 additions and 3 deletions

View File

@ -194,6 +194,11 @@ namespace BizHawk.MultiClient
} }
}; };
public static readonly Dictionary<string, Dictionary<string, string>> ANALOGS = new Dictionary<string, Dictionary<string, string>>
{
{"Nintento 64 Controller", new Dictionary<string, string> {{"X Axis", "X"}, {"Y Axis", "Y"}}}
};
public static readonly Dictionary<string, Dictionary<string, string>> COMMANDS = new Dictionary<string, Dictionary<string, string>> public static readonly Dictionary<string, Dictionary<string, string>> COMMANDS = new Dictionary<string, Dictionary<string, string>>
{ {
{"Atari 2600 Basic Controller", new Dictionary<string, string> {{"Reset", "r"}, {"Select", "s"}}}, {"Atari 2600 Basic Controller", new Dictionary<string, string> {{"Reset", "r"}, {"Select", "s"}}},

View File

@ -398,6 +398,11 @@ namespace BizHawk.MultiClient
return ret; return ret;
} }
float GetBaseFloat(string name)
{
return Source.GetFloat(name);
}
public bool IsEmpty public bool IsEmpty
{ {
get get
@ -595,6 +600,12 @@ namespace BizHawk.MultiClient
{ {
input.Append(IsBasePressed("P" + player + " " + button) ? Global.BUTTONS[ControlType][button] : "."); input.Append(IsBasePressed("P" + player + " " + button) ? Global.BUTTONS[ControlType][button] : ".");
} }
foreach (string name in Global.ANALOGS[ControlType].Keys)
{
input.Append(String.Format("{0:000}", (int)GetBaseFloat("P" + player + " " + name) + 128));
}
input.Append('|'); input.Append('|');
} }
@ -880,6 +891,11 @@ namespace BizHawk.MultiClient
MyBoolButtons[button] = state; MyBoolButtons[button] = state;
} }
void Force(string name, float state)
{
MyFloatControls[name] = state;
}
string ControlType { get { return Type.Name; } } string ControlType { get { return Type.Name; } }
class MnemonicChecker class MnemonicChecker
@ -1006,7 +1022,7 @@ namespace BizHawk.MultiClient
for (int player = 1; player <= Global.PLAYERS[ControlType]; player++) for (int player = 1; player <= Global.PLAYERS[ControlType]; player++)
{ {
int srcindex = (player - 1) * (Global.BUTTONS[ControlType].Count + 1); int srcindex = (player - 1) * (Global.BUTTONS[ControlType].Count + Global.ANALOGS[ControlType].Count * 3 + 1);
if (mnemonic.Length < srcindex + 3 + Global.BUTTONS[ControlType].Count - 1) if (mnemonic.Length < srcindex + 3 + Global.BUTTONS[ControlType].Count - 1)
{ {
@ -1018,6 +1034,17 @@ namespace BizHawk.MultiClient
{ {
Force("P" + player + " " + button, c[srcindex + start++]); Force("P" + player + " " + button, c[srcindex + start++]);
} }
foreach (string name in Global.ANALOGS[ControlType].Keys)
{
if (InputValidate.IsValidUnsignedNumber(mnemonic.Substring(srcindex + start, 3)))
{
Console.WriteLine((float)(Int32.Parse(mnemonic.Substring(srcindex + start, 3)) - 128));
Force("P" + player + " " + name, Int32.Parse(mnemonic.Substring(srcindex + start, 3)) - 128);
}
start += 3;
}
} }
} }

View File

@ -160,13 +160,13 @@ namespace BizHawk.MultiClient
private void AnalogControl1_MouseClick(object sender, MouseEventArgs e) private void AnalogControl1_MouseClick(object sender, MouseEventArgs e)
{ {
Global.StickyXORAdapter.SetFloat("P1 X Axis", AnalogControl1.X); Global.StickyXORAdapter.SetFloat("P1 X Axis", AnalogControl1.X);
Global.StickyXORAdapter.SetFloat("P1 Y Axis", -AnalogControl1.Y); Global.StickyXORAdapter.SetFloat("P1 Y Axis", -AnalogControl1.Y - 1);
} }
private void AnalogControl1_MouseMove(object sender, MouseEventArgs e) private void AnalogControl1_MouseMove(object sender, MouseEventArgs e)
{ {
Global.StickyXORAdapter.SetFloat("P1 X Axis", AnalogControl1.X); Global.StickyXORAdapter.SetFloat("P1 X Axis", AnalogControl1.X);
Global.StickyXORAdapter.SetFloat("P1 Y Axis", -AnalogControl1.Y); Global.StickyXORAdapter.SetFloat("P1 Y Axis", -AnalogControl1.Y - 1);
} }
} }
} }