fix input.get

This commit is contained in:
zeromus 2012-03-24 18:39:55 +00:00
parent 0bb9f65038
commit e7eb6d8dcd
7 changed files with 22 additions and 17 deletions

View File

@ -1109,19 +1109,11 @@ namespace BizHawk.MultiClient
//----------------------------------------------------
public LuaTable input_get()
{
LuaTable keys = new LuaTable(1, lua);
string[] keystrings = Global.MainForm.lastKeyboard.Split(' ');
foreach (string keypress in keystrings)
{
if (keypress.Contains("Press:"))
{
string key = keypress.Replace("Press:", "");
keys[key] = key;
}
}
return keys;
LuaTable buttons = lua.NewTable();
foreach (var kvp in Global.ControllerInputCoalescer.BoolButtons())
if (kvp.Value)
buttons[kvp.Key] = true;
return buttons;
}
//----------------------------------------------------
@ -1131,7 +1123,7 @@ namespace BizHawk.MultiClient
//Currently sends all controllers, needs to control which ones it sends
public LuaTable joypad_get()
{
LuaTable buttons = new LuaTable(1, lua);
LuaTable buttons = lua.NewTable();
foreach (string button in Global.ControllerOutput.Source.Type.BoolButtons)
buttons[button] = Global.ControllerOutput[button];
@ -1145,7 +1137,7 @@ namespace BizHawk.MultiClient
public LuaTable joypad_getimmediate()
{
LuaTable buttons = new LuaTable(1, lua);
LuaTable buttons = lua.NewTable();
foreach (string button in Global.ActiveController.Type.BoolButtons)
buttons[button] = Global.ActiveController[button];
return buttons;

Binary file not shown.

View File

@ -376,6 +376,7 @@ namespace BizHawk.MultiClient
LuaConsole1.ResumeScripts(false);
#endif
Global.RenderPanel.ClearGUIText();
StepRunLoop_Core();
//if(!IsNullEmulator())
StepRunLoop_Throttle();
@ -1678,7 +1679,6 @@ namespace BizHawk.MultiClient
bool genSound = false;
if (runFrame)
{
Global.RenderPanel.ClearGUIText();
//client input-related duties
#if WINDOWS

Binary file not shown.

View File

@ -82,6 +82,11 @@ namespace BizHawk.MultiClient
public float GetFloat(string name) { return 0.0f; } //TODO
public void UpdateControls(int frame) { }
public IEnumerable<KeyValuePair<string, bool>> BoolButtons()
{
foreach (var kvp in Buttons) yield return kvp;
}
public virtual void LatchFrom(IController source)
{
foreach (string button in source.Type.BoolButtons)

View File

@ -647,6 +647,14 @@ namespace LuaInterface
translator.push(luaState,val);
LuaDLL.lua_settable(luaState,-3);
}
//zero 24-mar-2012 added
public LuaTable NewTable()
{
NewTable("_TEMP_BIZHAWK_RULES_");
return GetTable("_TEMP_BIZHAWK_RULES_");
}
/*
* Creates a new table as a global variable or as a field
* inside an existing table

View File

@ -16,7 +16,7 @@ namespace LuaInterface
{
//internal int _Reference;
//private Lua _Interpreter;
public LuaTable(int reference, Lua interpreter)
internal LuaTable(int reference, Lua interpreter)
{
_Reference = reference;
_Interpreter = interpreter;