From 51f480901b5be498b6726fd383a5490a730d263f Mon Sep 17 00:00:00 2001 From: adelikat Date: Thu, 27 Mar 2014 00:53:22 +0000 Subject: [PATCH] a slight cleanup of the JoyPad.Set method to make it not so annoying to understand --- .../lua/EmuLuaLibrary.Joypad.cs | 51 +++++-------------- 1 file changed, 13 insertions(+), 38 deletions(-) diff --git a/BizHawk.Client.Common/lua/EmuLuaLibrary.Joypad.cs b/BizHawk.Client.Common/lua/EmuLuaLibrary.Joypad.cs index cfc8785a46..0d5f73b523 100644 --- a/BizHawk.Client.Common/lua/EmuLuaLibrary.Joypad.cs +++ b/BizHawk.Client.Common/lua/EmuLuaLibrary.Joypad.cs @@ -102,57 +102,32 @@ namespace BizHawk.Client.Common theValue = null; } + var toPress = button; + if (controller != null) + { + toPress = "P" + controller + " " + button; + } + if (!invert) { - if (theValue == true) + if (theValue == true) // Force On { - if (controller == null) // Force On - { - Global.ClickyVirtualPadController.Click(button.ToString()); - Global.ForceOffAdaptor.SetSticky(button.ToString(), false); - } - else - { - Global.ClickyVirtualPadController.Click("P" + controller + " " + button); - Global.ForceOffAdaptor.SetSticky("P" + controller + " " + button, false); - } + Global.ClickyVirtualPadController.Click(button.ToString()); + Global.ForceOffAdaptor.SetSticky(button.ToString(), false); } else if (theValue == false) // Force off { - if (controller == null) - { - Global.ForceOffAdaptor.SetSticky(button.ToString(), true); - } - else - { - Global.ForceOffAdaptor.SetSticky("P" + controller + " " + button, true); - } + Global.ForceOffAdaptor.SetSticky(button.ToString(), true); } else { - // Turn everything off - if (controller == null) - { - Global.ForceOffAdaptor.SetSticky(button.ToString(), false); - } - else - { - Global.ForceOffAdaptor.SetSticky("P" + controller + " " + button, false); - } + Global.ForceOffAdaptor.SetSticky(button.ToString(), false); } } else // Inverse { - if (controller == null) - { - Global.StickyXORAdapter.SetSticky(button.ToString(), true); - Global.ForceOffAdaptor.SetSticky(button.ToString(), false); - } - else - { - Global.StickyXORAdapter.SetSticky("P" + controller + " " + button, true); - Global.ForceOffAdaptor.SetSticky("P" + controller + " " + button, false); - } + Global.StickyXORAdapter.SetSticky(button.ToString(), true); + Global.ForceOffAdaptor.SetSticky(button.ToString(), false); } } }