Lua - joypad.get() strongly type the controller parameter to nullable int
This commit is contained in:
parent
6adde23553
commit
ed7ce61234
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue