Lua - implement input.get()
This commit is contained in:
parent
d0995970fc
commit
96fc783107
|
@ -90,6 +90,13 @@ namespace BizHawk.MultiClient
|
||||||
LuaLibraryList += "movie." + MovieFunctions[i] + "\n";
|
LuaLibraryList += "movie." + MovieFunctions[i] + "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lua.NewTable("input");
|
||||||
|
for (int i = 0; i < InputFunctions.Length; i++)
|
||||||
|
{
|
||||||
|
lua.RegisterFunction("input." + InputFunctions[i], this, this.GetType().GetMethod("input_" + InputFunctions[i]));
|
||||||
|
LuaLibraryList += "input." + InputFunctions[i] + "\n";
|
||||||
|
}
|
||||||
|
|
||||||
lua.NewTable("joypad");
|
lua.NewTable("joypad");
|
||||||
for (int i = 0; i < JoypadFunctions.Length; i++)
|
for (int i = 0; i < JoypadFunctions.Length; i++)
|
||||||
{
|
{
|
||||||
|
@ -291,6 +298,10 @@ namespace BizHawk.MultiClient
|
||||||
//"rerecordcounting",
|
//"rerecordcounting",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public static string[] InputFunctions = new string[] {
|
||||||
|
"get",
|
||||||
|
};
|
||||||
|
|
||||||
public static string[] JoypadFunctions = new string[] {
|
public static string[] JoypadFunctions = new string[] {
|
||||||
"set",
|
"set",
|
||||||
"get",
|
"get",
|
||||||
|
@ -1093,6 +1104,26 @@ namespace BizHawk.MultiClient
|
||||||
Global.MainForm.SetReadOnly(false);
|
Global.MainForm.SetReadOnly(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------
|
||||||
|
//Input library
|
||||||
|
//----------------------------------------------------
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------
|
//----------------------------------------------------
|
||||||
//Joypad library
|
//Joypad library
|
||||||
//----------------------------------------------------
|
//----------------------------------------------------
|
||||||
|
|
|
@ -1334,20 +1334,24 @@ namespace BizHawk.MultiClient
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string lastKeyboard = "";
|
||||||
|
|
||||||
public void ProcessInput()
|
public void ProcessInput()
|
||||||
{
|
{
|
||||||
for (; ; )
|
for (; ; )
|
||||||
{
|
{
|
||||||
//loop through all available events
|
//loop through all available events
|
||||||
var ie = Input.Instance.DequeueEvent();
|
var ie = Input.Instance.DequeueEvent();
|
||||||
if (ie == null) break;
|
if (ie == null) { break; }
|
||||||
|
|
||||||
//useful debugging:
|
//useful debugging:
|
||||||
//Console.WriteLine(ie);
|
//Console.WriteLine(ie);
|
||||||
|
|
||||||
//TODO - wonder what happens if we pop up something interactive as a response to one of these hotkeys? may need to purge further processing
|
//TODO - wonder what happens if we pop up something interactive as a response to one of these hotkeys? may need to purge further processing
|
||||||
|
|
||||||
//look for client control bindings for this key
|
lastKeyboard += " " + ie.ToString();
|
||||||
|
|
||||||
|
//look for client cntrol bindings for this key
|
||||||
var triggers = Global.ClientControls.SearchBindings(ie.LogicalButton.ToString());
|
var triggers = Global.ClientControls.SearchBindings(ie.LogicalButton.ToString());
|
||||||
if (triggers.Count == 0)
|
if (triggers.Count == 0)
|
||||||
{
|
{
|
||||||
|
@ -1469,21 +1473,11 @@ namespace BizHawk.MultiClient
|
||||||
case "LoadSlot7": if (!IsNullEmulator()) LoadState("QuickSave7"); break;
|
case "LoadSlot7": if (!IsNullEmulator()) LoadState("QuickSave7"); break;
|
||||||
case "LoadSlot8": if (!IsNullEmulator()) LoadState("QuickSave8"); break;
|
case "LoadSlot8": if (!IsNullEmulator()) LoadState("QuickSave8"); break;
|
||||||
case "LoadSlot9": if (!IsNullEmulator()) LoadState("QuickSave9"); break;
|
case "LoadSlot9": if (!IsNullEmulator()) LoadState("QuickSave9"); break;
|
||||||
case "SelectSlot0":
|
case "SelectSlot0": OnSelectSlot(0); break;
|
||||||
OnSelectSlot(0);
|
case "SelectSlot1": OnSelectSlot(1); break;
|
||||||
break;
|
case "SelectSlot2": OnSelectSlot(2); break;
|
||||||
case "SelectSlot1":
|
case "SelectSlot3": OnSelectSlot(3); break;
|
||||||
OnSelectSlot(1);
|
case "SelectSlot4": OnSelectSlot(4); break;
|
||||||
break;
|
|
||||||
case "SelectSlot2":
|
|
||||||
OnSelectSlot(2);
|
|
||||||
break;
|
|
||||||
case "SelectSlot3":
|
|
||||||
OnSelectSlot(3);
|
|
||||||
break;
|
|
||||||
case "SelectSlot4":
|
|
||||||
OnSelectSlot(4);
|
|
||||||
break;
|
|
||||||
case "SelectSlot5": OnSelectSlot(5); break;
|
case "SelectSlot5": OnSelectSlot(5); break;
|
||||||
case "SelectSlot6": OnSelectSlot(6); break;
|
case "SelectSlot6": OnSelectSlot(6); break;
|
||||||
case "SelectSlot7": OnSelectSlot(7); break;
|
case "SelectSlot7": OnSelectSlot(7); break;
|
||||||
|
@ -1774,7 +1768,7 @@ namespace BizHawk.MultiClient
|
||||||
Global.Emulator.FrameAdvance(!throttle.skipnextframe);
|
Global.Emulator.FrameAdvance(!throttle.skipnextframe);
|
||||||
MemoryPulse.Pulse();
|
MemoryPulse.Pulse();
|
||||||
//=======================================
|
//=======================================
|
||||||
|
lastKeyboard = "";
|
||||||
if (CurrAviWriter != null)
|
if (CurrAviWriter != null)
|
||||||
{
|
{
|
||||||
//TODO - this will stray over time! have AviWriter keep an accumulation!
|
//TODO - this will stray over time! have AviWriter keep an accumulation!
|
||||||
|
|
Loading…
Reference in New Issue