diff --git a/BizHawk.MultiClient/Global.cs b/BizHawk.MultiClient/Global.cs index 0695dace93..a04bc4f7d3 100644 --- a/BizHawk.MultiClient/Global.cs +++ b/BizHawk.MultiClient/Global.cs @@ -39,6 +39,7 @@ namespace BizHawk.MultiClient public static IController ControllerOutput; public static Input.InputCoalescer InputCoalescer; + public static UD_LR_ControllerAdapter UD_LR_ControllerAdapter = new UD_LR_ControllerAdapter(); public static string GetOutputControllersAsMnemonic() { diff --git a/BizHawk.MultiClient/Input/ControllerBinding.cs b/BizHawk.MultiClient/Input/ControllerBinding.cs index 12606acf82..b0c929d024 100644 --- a/BizHawk.MultiClient/Input/ControllerBinding.cs +++ b/BizHawk.MultiClient/Input/ControllerBinding.cs @@ -81,53 +81,9 @@ namespace BizHawk.MultiClient public bool IsPressed(string button) { - //if (forcePressedButtons.Contains(button)) - //{ - // removeFromForcePressedButtons.Add(button); - // return true; - //} - //if (unpressedButtons.Contains(button)) - //{ - // if (IsPressedActually(button) == false) - // unpressedButtons.Remove(button); - - // return false; - //} - - ////zeromus - TODO - this is gross!!! - //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); return stickyButtons[button]; } - //public bool IsPressedActually(string button) - //{ - // bool sticky = stickyButtons[button]; - - // foreach (var control in bindings[button]) - // if (Input.Instance.IsPressed(control)) - // return sticky ? false : true; - - // return sticky ? true : false; - //} - public float GetFloat(string name) { throw new NotImplementedException(); @@ -138,18 +94,8 @@ namespace BizHawk.MultiClient unpressedButtons.Add(name); } - private int frameNumber; - public void UpdateControls(int frame) { - //if (frame != frameNumber) - //{ - // // update - // unpressedButtons.RemoveAll(button => IsPressedActually(button) == false); - // forcePressedButtons.RemoveAll(button => removeFromForcePressedButtons.Contains(button)); - // removeFromForcePressedButtons.Clear(); - //} - //frameNumber = frame; } public void SetSticky(string button, bool sticky) diff --git a/BizHawk.MultiClient/Input/Keyboard.cs b/BizHawk.MultiClient/Input/Keyboard.cs index 8ad272fadb..2aa2800ee2 100644 --- a/BizHawk.MultiClient/Input/Keyboard.cs +++ b/BizHawk.MultiClient/Input/Keyboard.cs @@ -10,7 +10,6 @@ namespace BizHawk.MultiClient private static DirectInput dinput; private static Keyboard keyboard; private static KeyboardState state = new KeyboardState(); - private static List unpressedKeys = new List(); public static void Initialize() { @@ -32,23 +31,13 @@ namespace BizHawk.MultiClient state = keyboard.GetCurrentState(); if (Result.Last.IsFailure) return; - - unpressedKeys.RemoveAll(key => state.IsReleased(key)); } public static KeyboardState State { get { return state; } } - public static void Unpress(Key key) - { - if (unpressedKeys.Contains(key)) - return; - unpressedKeys.Add(key); - } - + public static bool IsPressed(Key key) { - if (unpressedKeys.Contains(key)) - return false; if (state.IsPressed(key)) return true; diff --git a/BizHawk.MultiClient/MainForm.cs b/BizHawk.MultiClient/MainForm.cs index e637641d24..87a68c0464 100644 --- a/BizHawk.MultiClient/MainForm.cs +++ b/BizHawk.MultiClient/MainForm.cs @@ -281,6 +281,7 @@ namespace BizHawk.MultiClient } bool _HACK_KEY_FF; + bool _HACK_KEY_REWIND; void SyncThrottle() { @@ -779,7 +780,8 @@ namespace BizHawk.MultiClient //insert turbo and lua here? Global.InputCoalescer = new Input.InputCoalescer(); Global.InputCoalescer.Type = Global.ActiveController.Type; - Global.MultitrackRewiringControllerAdapter.Source = Global.ActiveController; + Global.UD_LR_ControllerAdapter.Source = Global.ActiveController; + Global.MultitrackRewiringControllerAdapter.Source = Global.UD_LR_ControllerAdapter; Global.MovieInputSourceAdapter.Source = Global.MultitrackRewiringControllerAdapter; Global.MovieControllerAdapter.SetSource(Global.MovieInputSourceAdapter); Global.ControllerOutput = Global.MovieControllerAdapter; @@ -993,6 +995,11 @@ namespace BizHawk.MultiClient _HACK_KEY_FF = ie.EventType == Input.InputEventType.Press; continue; } + if (trigger == "Rewind") + { + _HACK_KEY_REWIND = ie.EventType == Input.InputEventType.Press; + continue; + } if(ie.EventType == Input.InputEventType.Release) continue; @@ -1160,6 +1167,10 @@ namespace BizHawk.MultiClient Global.RenderPanel.MT = "Recording None"; break; } + case "Emulator Pause": + //used to be here: (the pause hotkey is ignored when we are frame advancing) + TogglePause(); + break; } //switch(trigger) @@ -1167,20 +1178,6 @@ namespace BizHawk.MultiClient } //foreach event - //TODO - - //the pause hotkey is ignored when we are frame advancing - //if (!Input.Instance.IsPressed("Frame Advance")) - //{ - // if (Global.ClientControls["Emulator Pause"]) - // { - // Global.ClientControls.UnpressButton("Emulator Pause"); - // if (EmulatorPaused) - // UnpauseEmulator(); - // else - // PauseEmulator(); - // } - //} - } void StepRunLoop_Throttle() @@ -1241,7 +1238,7 @@ namespace BizHawk.MultiClient runFrame = true; } - if (Global.Config.RewindEnabled && Global.ClientControls["Rewind"] || PressRewind) + if (Global.Config.RewindEnabled && _HACK_KEY_REWIND || PressRewind) { rewindCredits += Global.Config.SpeedPercent; int rewindTodo = rewindCredits / 100; diff --git a/BizHawk.MultiClient/movie/InputAdapters.cs b/BizHawk.MultiClient/movie/InputAdapters.cs index a157bbfc75..5cadd165d5 100644 --- a/BizHawk.MultiClient/movie/InputAdapters.cs +++ b/BizHawk.MultiClient/movie/InputAdapters.cs @@ -4,6 +4,39 @@ using System.Collections.Generic; namespace BizHawk.MultiClient { + //filters input for things called Up and Down while considering the client's AllowUD_LR option. + //this is a bit gross but it is unclear how to do it more nicely + public class UD_LR_ControllerAdapter : IController + { + public ControllerDefinition Type { get { return Source.Type; } } + public IController Source; + + public bool this[string button] { get { return IsPressed(button); } } + public float GetFloat(string name) { return 0.0f; } //TODO + public void UpdateControls(int frame) { } + public bool IsPressed(string button) + { + if (Global.Config.AllowUD_LR == true) + return Source.IsPressed(button); + + string prefix; + + if (button.Contains("Down")) + { + prefix = button.GetPrecedingString("Down"); + if (Source.IsPressed(prefix + "Up")) + return false; + } + if (button.Contains("Right")) + { + prefix = button.GetPrecedingString("Right"); + if (Source.IsPressed(prefix + "Left")) + return false; + } + + return Source.IsPressed(button); + } + } public class SimpleController : IController {