From 5a73fc03ad351ee99f1f4a726dd05b3e85c5f3ca Mon Sep 17 00:00:00 2001 From: beirich Date: Fri, 10 Jun 2011 04:14:21 +0000 Subject: [PATCH] u+d/l+r toggle implemented --- BizHawk.Emulation/Util.cs | 27 ++++++++++--------- .../Input/ControllerBinding.cs | 22 +++++++++++++-- 2 files changed, 35 insertions(+), 14 deletions(-) diff --git a/BizHawk.Emulation/Util.cs b/BizHawk.Emulation/Util.cs index c9e511cd54..b32efd8e8f 100644 --- a/BizHawk.Emulation/Util.cs +++ b/BizHawk.Emulation/Util.cs @@ -55,6 +55,16 @@ namespace BizHawk return true; } + public static string GetPrecedingString(this string str, string value) + { + int index = str.IndexOf(value); + if (index < 0) + return null; + if (index == 0) + return ""; + return str.Substring(0, index); + } + public static bool In(this string str, params string[] options) { foreach (string opt in options) @@ -534,7 +544,6 @@ namespace BizHawk string precision = "2"; return String.Format("{0:N" + precision + "}{1}", size, suffix); } - } public unsafe class Serializer @@ -584,7 +593,7 @@ namespace BizHawk else tr.ReadLine(); } - public unsafe void SyncEnum(string name, ref T val) where T : struct + public void SyncEnum(string name, ref T val) where T : struct { if (typeof(T).BaseType != typeof(System.Enum)) throw new InvalidOperationException(); @@ -593,13 +602,13 @@ namespace BizHawk else bw.Write(Convert.ToInt32(val)); } - public unsafe void SyncEnumText(string name, ref T val) where T : struct + public void SyncEnumText(string name, ref T val) where T : struct { if (IsReader) val = (T)Enum.Parse(typeof(T), tr.ReadLine().Split(' ')[1]); else tw.WriteLine("{0} {1}", name, val.ToString()); } - unsafe void SyncBuffer(string name, int elemsize, int len, void* ptr) + void SyncBuffer(string name, int elemsize, int len, void* ptr) { if (IsReader) { @@ -617,12 +626,12 @@ namespace BizHawk } } - public unsafe void Sync(string name, ref ByteBuffer byteBuf) + public void Sync(string name, ref ByteBuffer byteBuf) { SyncBuffer(name, 1, byteBuf.len, byteBuf.ptr); } - public unsafe void Sync(string name, ref IntBuffer byteBuf) + public void Sync(string name, ref IntBuffer byteBuf) { SyncBuffer(name, 4, byteBuf.len, byteBuf.ptr); } @@ -843,8 +852,6 @@ namespace BizHawk void Write(ref bool val) { bw.Write(val); } void ReadText(string name, ref bool val) { val = bool.Parse(tr.ReadLine().Split(' ')[1]); } void WriteText(string name, ref bool val) { tw.WriteLine("{0} {1}", name, val); } - - } @@ -945,8 +952,6 @@ namespace BizHawk /// public IList Keys { get { return new List(dictionary.Keys); } } - - public L this[K key] { get @@ -962,6 +967,4 @@ namespace BizHawk } } } - - } diff --git a/BizHawk.MultiClient/Input/ControllerBinding.cs b/BizHawk.MultiClient/Input/ControllerBinding.cs index 5a350e04e4..3dc87be1af 100644 --- a/BizHawk.MultiClient/Input/ControllerBinding.cs +++ b/BizHawk.MultiClient/Input/ControllerBinding.cs @@ -75,7 +75,7 @@ namespace BizHawk.MultiClient removeFromForcePressedButtons.Add(button); return true; } - if (unpressedButtons.Contains(button)) + if (unpressedButtons.Contains(button)) { if (IsPressedActually(button) == false) unpressedButtons.Remove(button); @@ -83,6 +83,24 @@ namespace BizHawk.MultiClient return false; } + if (Global.Config.AllowUD_LR == false) + { + string prefix; + + if (button.Contains("Down")) + { + prefix = button.GetPrecedingString("Down"); + if (IsPressed(prefix + "Up")) + return false; + } + if (button.Contains("Right")) + { + prefix = button.GetPrecedingString("Right"); + if (IsPressed(prefix + "Left")) + return false; + } + } + return IsPressedActually(button); } @@ -164,7 +182,7 @@ namespace BizHawk.MultiClient if (type.Name == "PC Engine Controller") { - input.Append("."); //TODO: reset goes here + input.Append("."); //TODO: reset goes here - the turbografx DOES NOT HAVE A RESET BUTTON. but I assume this is for pcejin movie file compatibility, which is a fools errand anyway......... I'll leave it for now, but marked for deletion input.Append("|"); for (int player = 1; player < 6; player++) {