From fe09e0e83efdb1d65249cd0ef31c28d459cbcf15 Mon Sep 17 00:00:00 2001 From: adelikat Date: Tue, 30 Jul 2013 18:39:10 +0000 Subject: [PATCH] Lua - add float controls to joypad.get() --- BizHawk.MultiClient/LuaImplementation.cs | 28 +++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/BizHawk.MultiClient/LuaImplementation.cs b/BizHawk.MultiClient/LuaImplementation.cs index 462ca0ca40..386f1af16e 100644 --- a/BizHawk.MultiClient/LuaImplementation.cs +++ b/BizHawk.MultiClient/LuaImplementation.cs @@ -2155,11 +2155,29 @@ namespace BizHawk.MultiClient public LuaTable joypad_get(object controller = null) { LuaTable buttons = _lua.NewTable(); - foreach (string button in Global.ControllerOutput.Source.Type.BoolButtons) - if (controller == null) - buttons[button] = Global.ControllerOutput[button]; - else if (button.Length >= 3 && button.Substring(0, 2) == "P" + LuaInt(controller).ToString()) - buttons[button.Substring(3)] = Global.ControllerOutput["P" + LuaInt(controller) + " " + button.Substring(3)]; + foreach (string button in Global.ControllerOutput.Source.Type.BoolButtons) + { + if (controller == null) + { + buttons[button] = Global.ControllerOutput[button]; + } + else if (button.Length >= 3 && button.Substring(0, 2) == "P" + LuaInt(controller).ToString()) + { + buttons[button.Substring(3)] = Global.ControllerOutput["P" + LuaInt(controller) + " " + button.Substring(3)]; + } + } + + foreach (string button in Global.ControllerOutput.Source.Type.FloatControls) + { + if (controller == null) + { + buttons[button] = Global.ControllerOutput.GetFloat(button); + } + else if (button.Length >= 3 && button.Substring(0, 2) == "P" + LuaInt(controller).ToString()) + { + buttons[button.Substring(3)] = Global.ControllerOutput.GetFloat("P" + LuaInt(controller) + " " + button.Substring(3)); + } + } buttons["clear"] = null; buttons["getluafunctionslist"] = null;