add a Lua method to get inputs from the movie (#2526)

This commit is contained in:
SuuperW 2020-12-20 13:16:28 -06:00 committed by GitHub
parent 2b5d0b6219
commit 3d84812341
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 0 deletions

View File

@ -25,6 +25,11 @@ namespace BizHawk.Client.Common
return _inputManager.AutofireStickyXorAdapter.ToDictionary(controller);
}
public IDictionary<string, object> GetWithMovie(int? controller = null)
{
return _inputManager.ControllerOutput.ToDictionary(controller);
}
public IDictionary<string, object> GetImmediate(int? controller = null)
{
return _inputManager.ActiveController.ToDictionary(controller);

View File

@ -5,6 +5,7 @@ namespace BizHawk.Client.Common
public interface IJoypadApi : IExternalApi
{
IDictionary<string, object> Get(int? controller = null);
IDictionary<string, object> GetWithMovie(int? controller = null);
IDictionary<string, object> GetImmediate(int? controller = null);
void SetFromMnemonicStr(string inputLogEntry);
void Set(IDictionary<string, bool> buttons, int? controller = null);

View File

@ -24,6 +24,17 @@ namespace BizHawk.Client.Common
return table;
}
[LuaMethodExample("local nljoyget = joypad.getwithmovie( 1 );")]
[LuaMethod("getwithmovie", "returns a lua table of the controller buttons pressed, including ones pressed by the current movie. If supplied, it will only return a table of buttons for the given controller")]
public LuaTable GetWithMovie(int? controller = null)
{
var table = _th.DictToTable(APIs.Joypad.GetWithMovie(controller));
table["clear"] = null;
table["getluafunctionslist"] = null;
table["output"] = null;
return table;
}
[LuaMethodExample("local nljoyget = joypad.getimmediate( );")]
[LuaMethod("getimmediate", "returns a lua table of any controller buttons currently pressed by the user")]
public LuaTable GetImmediate(int? controller = null) => _th.DictToTable(APIs.Joypad.GetImmediate(controller));