-As much as I dislike the new joypad.set() setup, the least I could do is make it consistent with joypad.get().
--If there is no controller parameter, then all of the buttons are returned as they are stored in the system, just like joypad.set(input) takes button names as is. --If there is a controller parameter, all of the buttons for that controller are returned without the "PX ", just like joypad.set(input, controller) takes button names without the "PX " and assigns them to the matching buttons for that controller. --No one approved this change, but seriously, this is common sense. I expect some "change denied" April Fool's stuff tomorrow... -Implemented a blacklist for ButtonCount. By default, Lag, Pause, and Reset are blacklisted. I don't think any of these buttons should be tracked.
This commit is contained in:
parent
9f51732765
commit
557f437195
|
@ -1223,14 +1223,15 @@ namespace BizHawk.MultiClient
|
|||
//----------------------------------------------------
|
||||
|
||||
//Currently sends all controllers, needs to control which ones it sends
|
||||
public LuaTable joypad_get(object controller)
|
||||
public LuaTable joypad_get(object controller = null)
|
||||
{
|
||||
LuaTable buttons = lua.NewTable();
|
||||
foreach (string button in Global.ControllerOutput.Source.Type.BoolButtons)
|
||||
if (button.Substring(0, 2) == "P" + LuaInt(controller).ToString())
|
||||
buttons[button] = Global.ControllerOutput[button];
|
||||
foreach (string button in Global.ControllerOutput.Source.Type.BoolButtons)
|
||||
if (controller == null)
|
||||
buttons[button] = Global.ControllerOutput[button];
|
||||
else if (button.Length >= 3 && button.Substring(0, 2) == "P" + LuaInt(controller).ToString())
|
||||
buttons[button.Substring(3)] = Global.ControllerOutput["P" + LuaInt(controller) + " " + button.Substring(3)];
|
||||
|
||||
//zero 23-mar-2012 - wtf is this??????
|
||||
buttons["clear"] = null;
|
||||
buttons["getluafunctionslist"] = null;
|
||||
buttons["output"] = null;
|
||||
|
@ -1246,15 +1247,15 @@ namespace BizHawk.MultiClient
|
|||
return buttons;
|
||||
}
|
||||
|
||||
public void joypad_set(LuaTable buttons, object slot = null)
|
||||
public void joypad_set(LuaTable buttons, object controller = null)
|
||||
{
|
||||
foreach (var button in buttons.Keys)
|
||||
{
|
||||
if (Convert.ToBoolean(buttons[button]) == true)
|
||||
if (slot == null)
|
||||
if (controller == null)
|
||||
Global.ClickyVirtualPadController.Click(button.ToString());
|
||||
else
|
||||
Global.ClickyVirtualPadController.Click("P" + slot.ToString() + " " + button.ToString());
|
||||
Global.ClickyVirtualPadController.Click("P" + controller.ToString() + " " + button.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,9 @@
|
|||
local x = 0
|
||||
local y = 36
|
||||
|
||||
--You can blacklist buttons from being recorded here.
|
||||
local blacklist = {'Lag', 'Pause', 'Reset'}
|
||||
|
||||
local data = {}
|
||||
local registered = false
|
||||
local state = {}
|
||||
|
@ -12,7 +15,7 @@ local states = {}
|
|||
function deepcopy(object)
|
||||
local lookup_table = {}
|
||||
local function _copy(object)
|
||||
if type(object) ~= "table" then
|
||||
if type(object) ~= 'table' then
|
||||
return object
|
||||
elseif lookup_table[object] then
|
||||
return lookup_table[object]
|
||||
|
@ -64,7 +67,13 @@ end
|
|||
|
||||
function record(buttons)
|
||||
for button, value in pairs(buttons) do
|
||||
if value then
|
||||
local blacklisted = false
|
||||
for index, name in pairs(blacklist) do
|
||||
if name == button then
|
||||
blacklisted = true
|
||||
end
|
||||
end
|
||||
if value and not blacklisted then
|
||||
data.holds = data.holds + 1
|
||||
if not data.pressed[button] then
|
||||
data.presses = data.presses + 1
|
||||
|
|
Loading…
Reference in New Issue