From ed7ce612340c9976a2c5719319ee42ef15c63ae8 Mon Sep 17 00:00:00 2001 From: adelikat Date: Sun, 13 Apr 2014 18:46:06 +0000 Subject: [PATCH] Lua - joypad.get() strongly type the controller parameter to nullable int --- BizHawk.Client.Common/lua/EmuLuaLibrary.Joypad.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/BizHawk.Client.Common/lua/EmuLuaLibrary.Joypad.cs b/BizHawk.Client.Common/lua/EmuLuaLibrary.Joypad.cs index 6fa147ba76..ab56e20875 100644 --- a/BizHawk.Client.Common/lua/EmuLuaLibrary.Joypad.cs +++ b/BizHawk.Client.Common/lua/EmuLuaLibrary.Joypad.cs @@ -18,18 +18,18 @@ namespace BizHawk.Client.Common "get", "returns a lua table of the controller buttons pressed. If supplied, it will only return a table of buttons for the given controller" )] - public LuaTable Get(object controller = null) + public LuaTable Get(int? controller = null) { var buttons = _lua.NewTable(); foreach (var button in Global.ControllerOutput.Source.Type.BoolButtons) { - if (controller == null) + if (!controller.HasValue) { buttons[button] = Global.ControllerOutput[button]; } - else if (button.Length >= 3 && button.Substring(0, 2) == "P" + LuaInt(controller)) + else if (button.Length >= 3 && button.Substring(0, 2) == "P" + controller) { - buttons[button.Substring(3)] = Global.ControllerOutput["P" + LuaInt(controller) + " " + button.Substring(3)]; + buttons[button.Substring(3)] = Global.ControllerOutput["P" + controller + " " + button.Substring(3)]; } } @@ -39,9 +39,9 @@ namespace BizHawk.Client.Common { buttons[button] = Global.ControllerOutput.GetFloat(button); } - else if (button.Length >= 3 && button.Substring(0, 2) == "P" + LuaInt(controller)) + else if (button.Length >= 3 && button.Substring(0, 2) == "P" + controller) { - buttons[button.Substring(3)] = Global.ControllerOutput.GetFloat("P" + LuaInt(controller) + " " + button.Substring(3)); + buttons[button.Substring(3)] = Global.ControllerOutput.GetFloat("P" + controller + " " + button.Substring(3)); } }