summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author cracyc <cracyc@users.noreply.github.com>2017-06-02 17:59:55 -0500
committer cracyc <cracyc@users.noreply.github.com>2017-06-02 18:03:25 -0500
commit33c65a2afccb8031e5c929498cdbdb6c83bb645e (patch)
treee91bc89b1ffdaac44a8f4bbb2fb135e1221db597
parente6ee45d670bc54cf033a2d71454095b0392bbf3b (diff)
plugins/cheat: add hotkey support [Carl]
-rw-r--r--plugins/cheat/cheat_json.lua12
-rw-r--r--plugins/cheat/cheat_simple.lua (renamed from plugins/cheat/simple_conv.lua)11
-rw-r--r--plugins/cheat/cheat_xml.lua (renamed from plugins/cheat/xml_conv.lua)4
-rw-r--r--plugins/cheat/init.lua274
-rw-r--r--plugins/cheat/keycodemap.lua241
-rw-r--r--plugins/cheat/xml_to_json.lua (renamed from plugins/cheat/conv_cheat.lua)2
-rw-r--r--src/frontend/mame/luaengine.cpp31
-rw-r--r--src/mame/layout/mdndclab.lay2
8 files changed, 514 insertions, 63 deletions
diff --git a/plugins/cheat/cheat_json.lua b/plugins/cheat/cheat_json.lua
new file mode 100644
index 00000000000..fd2778be63d
--- /dev/null
+++ b/plugins/cheat/cheat_json.lua
@@ -0,0 +1,12 @@
+local jsoncheat = {}
+
+function jsoncheat.filename(name)
+ return name .. ".json"
+end
+
+function jsoncheat.conv_cheat(data)
+ local json = require("json")
+ return json.parse(data)
+end
+
+return jsoncheat
diff --git a/plugins/cheat/simple_conv.lua b/plugins/cheat/cheat_simple.lua
index bb209d7af86..68c46598f75 100644
--- a/plugins/cheat/simple_conv.lua
+++ b/plugins/cheat/cheat_simple.lua
@@ -1,15 +1,22 @@
local simple = {}
+simple.romset = "????"
+
+function simple.filename(name)
+ simple.romset = name
+ return "cheat.simple"
+end
+
-- converter for simple cheats
-- simple cheats are single address every frame ram cheats in one file called cheat.simple
-- format: <set name>,<cputag>,<hex offset>,<b|w|d|q - size>,<hex value>,<desc>
-- only program address space is supported, comments are prepended with ;
-- size is b - u8, w - u16, d - u32, q - u64
-function simple.conv_cheat(romset, data)
+function simple.conv_cheat(data)
local cheats = {}
for line in data:gmatch('([^\n;]+)') do
local set, cputag, offset, size, val, name = line:match('([^,]+),([^,]+),([^,]+),([^,]+),([^,]+),(.+)')
- if set == romset then
+ if set == simple.romset then
local cheat = {}
cheat.desc = name
cheat.space = { cpup = { tag = cputag, type = "program" } }
diff --git a/plugins/cheat/xml_conv.lua b/plugins/cheat/cheat_xml.lua
index 0a35f9875f9..a14aee034cb 100644
--- a/plugins/cheat/xml_conv.lua
+++ b/plugins/cheat/cheat_xml.lua
@@ -1,5 +1,9 @@
local xml = {}
+function xml.filename(name)
+ return name .. ".xml"
+end
+
-- basic xml parser for mamecheat only
local function xml_parse(data)
local function fix_gt(str)
diff --git a/plugins/cheat/init.lua b/plugins/cheat/init.lua
index 7b85697fc48..1990fbca86a 100644
--- a/plugins/cheat/init.lua
+++ b/plugins/cheat/init.lua
@@ -62,12 +62,17 @@ exports.author = { name = "Carl" }
local cheat = exports
+function cheat.set_folder(path)
+ cheat.path = path
+end
+
function cheat.startplugin()
local cheats = {}
local output = {}
local line = 0
local start_time = 0
local stop = true
+ local cheatname = ""
local function load_cheats()
local filename = emu.romname()
@@ -80,6 +85,7 @@ function cheat.startplugin()
end
end
end
+ cheatname = filename
local function add(addcheats)
if not next(newcheats) then
newcheats = addcheats
@@ -89,25 +95,65 @@ function cheat.startplugin()
end
end
end
+ for scrfile in lfs.dir(cheat.path) do
+ local name = string.match(scrfile, "^(cheat_.*).lua$")
+ if name then
+ local conv = require("cheat/" .. name)
+ if conv then
+ local ret = file:open(conv.filename(filename))
+ while not ret do
+ add(conv.conv_cheat(file:read(file:size())))
+ ret = file:open_next()
+ end
+ end
+ end
+ end
+ return newcheats
+ end
+
+ local function load_hotkeys()
local json = require("json")
- local ret = file:open(filename .. ".json")
- while not ret do
- add(json.parse(file:read(file:size())))
- ret = file:open_next()
- end
- local xml = require("cheat/xml_conv")
- ret = file:open(filename .. ".xml")
- while not ret do
- add(xml.conv_cheat(file:read(file:size())))
- ret = file:open_next()
- end
- local simp = require("cheat/simple_conv")
- ret = file:open("cheat.simple")
- while not ret do
- add(simp.conv_cheat(filename, file:read(file:size())))
- ret = file:open_next()
+ local hotkeys = json.parse(io.open(manager:machine():options().entries.cheatpath:value():match("([^;]+)") .. "/" .. cheatname .. "_hotkeys.json", "r"):read("a"))
+ for num, val in ipairs(hotkeys) do
+ for num, cheat in pairs(cheats) do
+ if val.desc == cheat.desc then
+ cheat.hotkeys = {}
+ local keymap = require("cheat/keycodemap")
+ cheat.hotkeys.keys = manager:machine():input():seq_from_tokens(val.keys)
+ local keysstr = {}
+ val.keys:gsub("([^ ]+)", function(s) keysstr[#keysstr + 1] = keymap[s] return s end)
+ cheat.hotkeys.keysstr = keysstr
+ cheat.hotkeys.pressed = false
+ end
+ end
+ end
+ end
+
+ local function save_hotkeys()
+ local hotkeys = {}
+ for num, cheat in ipairs(cheats) do
+ if cheat.hotkeys then
+ local keymap = require("cheat/keycodemap")
+ local hotkey = {}
+ hotkey.desc = cheat.desc
+ hotkey.keys = ""
+ for num2, key in ipairs(cheat.hotkeys.keysstr) do
+ if #hotkey.keys > 0 then
+ hotkey.keys = hotkey.keys .. " "
+ end
+ hotkey.keys = hotkey.keys .. keymap[key]
+ end
+ hotkeys[#hotkeys + 1] = hotkey
+ end
+ end
+ if #hotkeys > 0 then
+ local json = require("json")
+ local file = io.open(manager:machine():options().entries.cheatpath:value():match("([^;]+)") .. "/" .. cheatname .. "_hotkeys.json", "w+")
+ if file then
+ file:write(json.stringify(hotkeys, {indent = true}))
+ file:close()
+ end
end
- return newcheats
end
local function draw_text(screen, x, y, color, form, ...)
@@ -284,8 +330,103 @@ function cheat.startplugin()
cheat.cheat_env.param = param.min
end
+ local hotkeymenu = false
+ local hotkeysel = 0
+ local hotkey = 1
+ local hotmod = 1
+ local hotkeylist = {}
+ local function run_if(func) if func then func() end return func or false end
+ local function is_oneshot(cheat) return cheat.script and not cheat.script.run and not cheat.script.on end
+
local function menu_populate()
local menu = {}
+ if hotkeymenu then
+ if hotkeysel > 0 then
+ return hotkeylist[hotkeysel].pop()
+ end
+ local keys = {"1","2","3","4","5","6","7","8","9","0"}
+ local mods = {"LSHFT","RSHFT","LALT","RALT","LCTRL","RCTRL","LWIN","RWIN","MENU"}
+
+ local function hkpopfunc(cheat)
+ local hkmenu = {}
+ hkmenu[1] = {"Set hotkey", "", "off"}
+ hkmenu[2] = {cheat.desc, "", "off"}
+ hkmenu[3] = {"Current Keys", cheat.hotkeys and table.concat(cheat.hotkeys.keysstr, " ") or "None", "off"}
+ hkmenu[4] = {"---", "", "off"}
+ hkmenu[5] = {"Key", keys[hotkey], "lr"}
+ if hotkey == 1 then
+ hkmenu[5][3] = "r"
+ elseif hotkey == #keys then
+ hkmenu[5][3] = "l"
+ end
+ hkmenu[6] = {"Modifier", mods[hotmod], "lr"}
+ if hotkey == 1 then
+ hkmenu[6][3] = "r"
+ elseif hotkey == #keys then
+ hkmenu[6][3] = "l"
+ end
+ hkmenu[7] = {"---", "", ""}
+ hkmenu[8] = {"Done", "", ""}
+ hkmenu[9] = {"Clear and Exit", "", ""}
+ hkmenu[10] = {"Cancel", "", ""}
+ return hkmenu
+ end
+
+ local function hkcbfunc(cheat, index, event)
+ if event == "right" then
+ if index == 5 then
+ hotkey = math.min(hotkey + 1, #keys)
+ return true
+ elseif index == 6 then
+ hotmod = math.min(hotmod + 1, #mods)
+ return true
+ end
+ elseif event == "left" then
+ if index == 5 then
+ hotkey = math.max(hotkey - 1, 1)
+ return true
+ elseif index == 6 then
+ hotmod = math.max(hotmod - 1, 1)
+ return true
+ end
+ elseif event == "select" then
+ if index == 8 then
+ local keymap = require("cheat/keycodemap")
+ cheat.hotkeys = {}
+ cheat.hotkeys.keys = manager:machine():input():seq_from_tokens(keymap[keys[hotkey]] .. " " .. keymap[mods[hotmod]])
+ cheat.hotkeys.keysstr = {keys[hotkey], mods[hotmod]}
+ cheat.hotkeys.pressed = false
+ hotkeysel = 0
+ hotkeymenu = false
+ return true
+ elseif index == 9 then
+ cheat.hotkeys = nil
+ hotkeysel = 0
+ hotkeymenu = false
+ return true
+ elseif index == 10 then
+ hotkeysel = 0
+ return true
+ end
+ end
+ return false
+ end
+
+
+ menu[1] = {"Select cheat to set hotkey", "", "off"}
+ menu[2] = {"---", "", "off"}
+ hotkeylist = {}
+ for num, cheat in ipairs(cheats) do
+ if cheat.script then
+ menu[#menu + 1] = {cheat.desc, " ", ""}
+ hotkeylist[#hotkeylist + 1] = { pop = function() return hkpopfunc(cheat) end,
+ cb = function(index, event) return hkcbfunc(cheat, index, event) end }
+ end
+ end
+ menu[#menu + 1] = {"---", "", ""}
+ menu[#menu + 1] = {"Done", "", ""}
+ return menu
+ end
for num, cheat in ipairs(cheats) do
menu[num] = {}
menu[num][1] = cheat.desc
@@ -296,7 +437,7 @@ function cheat.startplugin()
end
menu[num][2] = ""
menu[num][3] = "off"
- elseif not cheat.script.run and not cheat.script.off then
+ elseif is_oneshot(cheat) then
menu[num][2] = "Set"
menu[num][3] = 0
else
@@ -310,7 +451,7 @@ function cheat.startplugin()
end
else
if cheat.parameter.index == 0 then
- if not cheat.script.run and not cheat.script.off then
+ if is_oneshot(cheat) then
menu[num][2] = "Set"
else
menu[num][2] = "Off"
@@ -330,6 +471,7 @@ function cheat.startplugin()
end
end
menu[#menu + 1] = {"---", "", 0}
+ menu[#menu + 1] = {"Set hotkeys", "", 0}
menu[#menu + 1] = {"Reset All", "", 0}
menu[#menu + 1] = {"Reload All", "", 0}
return menu
@@ -337,12 +479,30 @@ function cheat.startplugin()
local function menu_callback(index, event)
manager:machine():popmessage()
+ if hotkeymenu then
+ if hotkeysel > 0 then
+ return hotkeylist[hotkeysel].cb(index, event)
+ end
+ if event == "select" then
+ index = index - 2
+ if index >= 1 and index <= #hotkeylist then
+ hotkeysel = index
+ return true
+ elseif index == #hotkeylist + 2 then
+ hotkeymenu = false
+ return true
+ end
+ end
+ return false
+ end
if index > #cheats and event == "select" then
index = index - #cheats
if index == 2 then
+ hotkeymenu = true
+ elseif index == 3 then
for num, cheat in pairs(cheats) do
- if cheat.enabled and cheat.script.off then
- cheat.script.off()
+ if cheat.enabled then
+ run_if(cheat.script.off)
end
cheat.enabled = false
if cheat.parameter then
@@ -350,16 +510,17 @@ function cheat.startplugin()
cheat.parameter.index = 0
end
end
- elseif index == 3 then
+ elseif index == 4 then
for num, cheat in pairs(cheats) do
- if cheat.enabled and cheat.script.off then
- cheat.script.off()
+ if cheat.enabled then
+ run_if(cheat.script.off)
end
end
cheats = load_cheats()
for num, cheat in pairs(cheats) do
parse_cheat(cheat)
end
+ load_hotkeys()
end
return true
end
@@ -393,9 +554,7 @@ function cheat.startplugin()
param.index = 0
cheat.enabled = false
cheat.cheat_env.param = param.min
- if cheat.script.off then
- cheat.script.off()
- end
+ run_if(cheat.script.off)
return true
elseif param.index == 0 then
return false
@@ -403,19 +562,14 @@ function cheat.startplugin()
param.index = param.index - 1
param_calc(param)
cheat.cheat_env.param = param.value
- if cheat.script.change and (cheat.script.run or cheat.script.off) then
- cheat.script.change()
+ if not is_oneshot() then
+ run_if(cheat.script.change)
end
return true
else
- if not cheat.script.run and not cheat.script.off then
- return false
- end
- if cheat.enabled then
+ if cheat.enabled and not is_oneshot(cheat) then
cheat.enabled = false
- if cheat.script.off then
- cheat.script.off()
- end
+ run_if(cheat.script.off)
return true
end
return false
@@ -425,34 +579,27 @@ function cheat.startplugin()
local param = cheat.parameter
if param.index == 0 then
cheat.enabled = true
- if cheat.script.on then
- cheat.script.on()
- end
+ run_if(cheat.script.on)
elseif param.index == param.last then
return false
end
param.index = param.index + 1
param_calc(param)
cheat.cheat_env.param = param.value
- if cheat.script.change and (cheat.script.run or cheat.script.off) then
- cheat.script.change()
+ if not is_oneshot(cheat) then
+ run_if(cheat.script.change)
end
return true
else
- if not cheat.script.run and not cheat.script.off then
- return false
- end
- if not cheat.enabled then
+ if not cheat.enabled and not is_oneshot(cheat) then
cheat.enabled = true
- if cheat.script.on then
- cheat.script.on()
- end
+ run_if(cheat.script.on)
return true
end
return false
end
elseif event == "select" then
- if not cheat.script.run and not cheat.script.off then
+ if is_oneshot(cheat) then
if cheat.parameter and cheat.script.change and cheat.parameter.index ~= 0 then
param_calc(cheat.parameter)
cheat.cheat_env.param = cheat.parameter.value
@@ -496,10 +643,12 @@ function cheat.startplugin()
for num, cheat in pairs(cheats) do
parse_cheat(cheat)
end
+ load_hotkeys()
end)
emu.register_stop(function()
stop = true
+ save_hotkeys()
end)
emu.register_frame(function()
@@ -507,8 +656,31 @@ function cheat.startplugin()
return
end
for num, cheat in pairs(cheats) do
- if cheat.enabled and cheat.script.run then
- cheat.script.run()
+ if cheat.enabled then
+ run_if(cheat.script.run)
+ end
+ if cheat.hotkeys and cheat.hotkeys.keys then
+ if manager:machine():input():seq_pressed(cheat.hotkeys.keys) then
+ if not cheat.hotkeys.pressed then
+ if is_oneshot(cheat) then
+ if not run_if(cheat.script.change) then
+ run_if(cheat.script.on)
+ end
+ manager:machine():popmessage("Activated: " .. cheat.desc)
+ elseif not cheat.enabled then
+ cheat.enabled = true
+ run_if(cheat.script.on)
+ manager:machine():popmessage("Enabled: " .. cheat.desc)
+ else
+ cheat.enabled = false
+ run_if(cheat.script.off)
+ manager:machine():popmessage("Disabled: " .. cheat.desc)
+ end
+ end
+ cheat.hotkeys.pressed = true
+ else
+ cheat.hotkeys.pressed = false
+ end
end
end
end)
diff --git a/plugins/cheat/keycodemap.lua b/plugins/cheat/keycodemap.lua
new file mode 100644
index 00000000000..a607afac5b8
--- /dev/null
+++ b/plugins/cheat/keycodemap.lua
@@ -0,0 +1,241 @@
+local keycodemap =
+{
+ ["A"] = "KEYCODE_A",
+ ["B"] = "KEYCODE_B",
+ ["C"] = "KEYCODE_C",
+ ["D"] = "KEYCODE_D",
+ ["E"] = "KEYCODE_E",
+ ["F"] = "KEYCODE_F",
+ ["G"] = "KEYCODE_G",
+ ["H"] = "KEYCODE_H",
+ ["I"] = "KEYCODE_I",
+ ["J"] = "KEYCODE_J",
+ ["K"] = "KEYCODE_K",
+ ["L"] = "KEYCODE_L",
+ ["M"] = "KEYCODE_M",
+ ["N"] = "KEYCODE_N",
+ ["O"] = "KEYCODE_O",
+ ["P"] = "KEYCODE_P",
+ ["Q"] = "KEYCODE_Q",
+ ["R"] = "KEYCODE_R",
+ ["S"] = "KEYCODE_S",
+ ["T"] = "KEYCODE_T",
+ ["U"] = "KEYCODE_U",
+ ["V"] = "KEYCODE_V",
+ ["W"] = "KEYCODE_W",
+ ["X"] = "KEYCODE_X",
+ ["Y"] = "KEYCODE_Y",
+ ["Z"] = "KEYCODE_Z",
+ ["0"] = "KEYCODE_0",
+ ["1"] = "KEYCODE_1",
+ ["2"] = "KEYCODE_2",
+ ["3"] = "KEYCODE_3",
+ ["4"] = "KEYCODE_4",
+ ["5"] = "KEYCODE_5",
+ ["6"] = "KEYCODE_6",
+ ["7"] = "KEYCODE_7",
+ ["8"] = "KEYCODE_8",
+ ["9"] = "KEYCODE_9",
+ ["F1"] = "KEYCODE_F1",
+ ["F2"] = "KEYCODE_F2",
+ ["F3"] = "KEYCODE_F3",
+ ["F4"] = "KEYCODE_F4",
+ ["F5"] = "KEYCODE_F5",
+ ["F6"] = "KEYCODE_F6",
+ ["F7"] = "KEYCODE_F7",
+ ["F8"] = "KEYCODE_F8",
+ ["F9"] = "KEYCODE_F9",
+ ["F10"] = "KEYCODE_F10",
+ ["F11"] = "KEYCODE_F11",
+ ["F12"] = "KEYCODE_F12",
+ ["F13"] = "KEYCODE_F13",
+ ["F14"] = "KEYCODE_F14",
+ ["F15"] = "KEYCODE_F15",
+ ["F16"] = "KEYCODE_F16",
+ ["F17"] = "KEYCODE_F17",
+ ["F18"] = "KEYCODE_F18",
+ ["F19"] = "KEYCODE_F19",
+ ["F20"] = "KEYCODE_F20",
+ ["ESC"] = "KEYCODE_ESC",
+ ["~"] = "KEYCODE_TILDE",
+ ["-"] = "KEYCODE_MINUS",
+ ["="] = "KEYCODE_EQUALS",
+ ["BS"] = "KEYCODE_BACKSPACE",
+ ["TAB"] = "KEYCODE_TAB",
+ ["["] = "KEYCODE_OPENBRACE",
+ ["]"] = "KEYCODE_CLOSEBRACE",
+ ["ENTER"] = "KEYCODE_ENTER",
+ [":"] = "KEYCODE_COLON",
+ ["'"] = "KEYCODE_QUOTE",
+ ["/"] = "KEYCODE_BACKSLASH",
+ ["/_2"] = "KEYCODE_BACKSLASH2",
+ [","] = "KEYCODE_COMMA",
+ ["."] = "KEYCODE_STOP",
+ ["/"] = "KEYCODE_SLASH",
+ ["SPC"] = "KEYCODE_SPACE",
+ ["INSERT"] = "KEYCODE_INSERT",
+ ["DEL"] = "KEYCODE_DEL",
+ ["HOME"] = "KEYCODE_HOME",
+ ["END"] = "KEYCODE_END",
+ ["PGUP"] = "KEYCODE_PGUP",
+ ["PGDN"] = "KEYCODE_PGDN",
+ ["LEFT"] = "KEYCODE_LEFT",
+ ["RIGHT"] = "KEYCODE_RIGHT",
+ ["UP"] = "KEYCODE_UP",
+ ["DOWN"] = "KEYCODE_DOWN",
+ ["0_PAD"] = "KEYCODE_0_PAD",
+ ["1_PAD"] = "KEYCODE_1_PAD",
+ ["2_PAD"] = "KEYCODE_2_PAD",
+ ["3_PAD"] = "KEYCODE_3_PAD",
+ ["4_PAD"] = "KEYCODE_4_PAD",
+ ["5_PAD"] = "KEYCODE_5_PAD",
+ ["6_PAD"] = "KEYCODE_6_PAD",
+ ["7_PAD"] = "KEYCODE_7_PAD",
+ ["8_PAD"] = "KEYCODE_8_PAD",
+ ["9_PAD"] = "KEYCODE_9_PAD",
+ ["/_PAD"] = "KEYCODE_SLASH_PAD",
+ ["*"] = "KEYCODE_ASTERISK",
+ ["-_PAD"] = "KEYCODE_MINUS_PAD",
+ ["+_PAD"] = "KEYCODE_PLUS_PAD",
+ ["DEL_PAD"] = "KEYCODE_DEL_PAD",
+ ["ENTER_PAD"] = "KEYCODE_ENTER_PAD",
+ ["BS_PAD"] = "KEYCODE_BS_PAD",
+ ["TAB_PAD"] = "KEYCODE_TAB_PAD",
+ ["00_PAD"] = "KEYCODE_00_PAD",
+ ["000_PAD"] = "KEYCODE_000_PAD",
+ ["PRTSCR"] = "KEYCODE_PRTSCR",
+ ["PAUSE"] = "KEYCODE_PAUSE",
+ ["LSHFT"] = "KEYCODE_LSHIFT",
+ ["RSHFT"] = "KEYCODE_RSHIFT",
+ ["LCTRL"] = "KEYCODE_LCONTROL",
+ ["RCTRL"] = "KEYCODE_RCONTROL",
+ ["LALT"] = "KEYCODE_LALT",
+ ["RALT"] = "KEYCODE_RALT",
+ ["SCRLOCK"] = "KEYCODE_SCRLOCK",
+ ["NUMLOCK"] = "KEYCODE_NUMLOCK",
+ ["CAPSLOCK"] = "KEYCODE_CAPSLOCK",
+ ["LWIN"] = "KEYCODE_LWIN",
+ ["RWIN"] = "KEYCODE_RWIN",
+ ["MENU"] = "KEYCODE_MENU",
+ ["CANCEL"] = "KEYCODE_CANCEL",
+ ["KEYCODE_A"] = "A",
+ ["KEYCODE_B"] = "B",
+ ["KEYCODE_C"] = "C",
+ ["KEYCODE_D"] = "D",
+ ["KEYCODE_E"] = "E",
+ ["KEYCODE_F"] = "F",
+ ["KEYCODE_G"] = "G",
+ ["KEYCODE_H"] = "H",
+ ["KEYCODE_I"] = "I",
+ ["KEYCODE_J"] = "J",
+ ["KEYCODE_K"] = "K",
+ ["KEYCODE_L"] = "L",
+ ["KEYCODE_M"] = "M",
+ ["KEYCODE_N"] = "N",
+ ["KEYCODE_O"] = "O",
+ ["KEYCODE_P"] = "P",
+ ["KEYCODE_Q"] = "Q",
+ ["KEYCODE_R"] = "R",
+ ["KEYCODE_S"] = "S",
+ ["KEYCODE_T"] = "T",
+ ["KEYCODE_U"] = "U",
+ ["KEYCODE_V"] = "V",
+ ["KEYCODE_W"] = "W",
+ ["KEYCODE_X"] = "X",
+ ["KEYCODE_Y"] = "Y",
+ ["KEYCODE_Z"] = "Z",
+ ["KEYCODE_0"] = "0",
+ ["KEYCODE_1"] = "1",
+ ["KEYCODE_2"] = "2",
+ ["KEYCODE_3"] = "3",
+ ["KEYCODE_4"] = "4",
+ ["KEYCODE_5"] = "5",
+ ["KEYCODE_6"] = "6",
+ ["KEYCODE_7"] = "7",
+ ["KEYCODE_8"] = "8",
+ ["KEYCODE_9"] = "9",
+ ["KEYCODE_F1"] = "F1",
+ ["KEYCODE_F2"] = "F2",
+ ["KEYCODE_F3"] = "F3",
+ ["KEYCODE_F4"] = "F4",
+ ["KEYCODE_F5"] = "F5",
+ ["KEYCODE_F6"] = "F6",
+ ["KEYCODE_F7"] = "F7",
+ ["KEYCODE_F8"] = "F8",
+ ["KEYCODE_F9"] = "F9",
+ ["KEYCODE_F10"] = "F10",
+ ["KEYCODE_F11"] = "F11",
+ ["KEYCODE_F12"] = "F12",
+ ["KEYCODE_F13"] = "F13",
+ ["KEYCODE_F14"] = "F14",
+ ["KEYCODE_F15"] = "F15",
+ ["KEYCODE_F16"] = "F16",
+ ["KEYCODE_F17"] = "F17",
+ ["KEYCODE_F18"] = "F18",
+ ["KEYCODE_F19"] = "F19",
+ ["KEYCODE_F20"] = "F20",
+ ["KEYCODE_ESC"] = "ESC",
+ ["KEYCODE_TILDE"] = "~",
+ ["KEYCODE_MINUS"] = "-",
+ ["KEYCODE_EQUALS"] = "=",
+ ["KEYCODE_BACKSPACE"] = "BS",
+ ["KEYCODE_TAB"] = "TAB",
+ ["KEYCODE_OPENBRACE"] = "[",
+ ["KEYCODE_CLOSEBRACE"] = "]",
+ ["KEYCODE_ENTER"] = "ENTER",
+ ["KEYCODE_COLON"] = ":",
+ ["KEYCODE_QUOTE"] = "'",
+ ["KEYCODE_BACKSLASH"] = "/",
+ ["KEYCODE_BACKSLASH2"] = "/_2",
+ ["KEYCODE_COMMA"] = ",",
+ ["KEYCODE_STOP"] = ".",
+ ["KEYCODE_SLASH"] = "/",
+ ["KEYCODE_SPACE"] = "SPC",
+ ["KEYCODE_INSERT"] = "INSERT",
+ ["KEYCODE_DEL"] = "DEL",
+ ["KEYCODE_HOME"] = "HOME",
+ ["KEYCODE_END"] = "END",
+ ["KEYCODE_PGUP"] = "PGUP",
+ ["KEYCODE_PGDN"] = "PGDN",
+ ["KEYCODE_LEFT"] = "LEFT",
+ ["KEYCODE_RIGHT"] = "RIGHT",
+ ["KEYCODE_UP"] = "UP",
+ ["KEYCODE_DOWN"] = "DOWN",
+ ["KEYCODE_0_PAD"] = "0_PAD",
+ ["KEYCODE_1_PAD"] = "1_PAD",
+ ["KEYCODE_2_PAD"] = "2_PAD",
+ ["KEYCODE_3_PAD"] = "3_PAD",
+ ["KEYCODE_4_PAD"] = "4_PAD",
+ ["KEYCODE_5_PAD"] = "5_PAD",
+ ["KEYCODE_6_PAD"] = "6_PAD",
+ ["KEYCODE_7_PAD"] = "7_PAD",
+ ["KEYCODE_8_PAD"] = "8_PAD",
+ ["KEYCODE_9_PAD"] = "9_PAD",
+ ["KEYCODE_SLASH_PAD"] = "/_PAD",
+ ["KEYCODE_ASTERISK"] = "*",
+ ["KEYCODE_MINUS_PAD"] = "-_PAD",
+ ["KEYCODE_PLUS_PAD"] = "+_PAD",
+ ["KEYCODE_DEL_PAD"] = "DEL_PAD",
+ ["KEYCODE_ENTER_PAD"] = "ENTER_PAD",
+ ["KEYCODE_BS_PAD"] = "BS_PAD",
+ ["KEYCODE_TAB_PAD"] = "TAB_PAD",
+ ["KEYCODE_00_PAD"] = "00_PAD",
+ ["KEYCODE_000_PAD"] = "000_PAD",
+ ["KEYCODE_PRTSCR"] = "PRTSCR",
+ ["KEYCODE_PAUSE"] = "PAUSE",
+ ["KEYCODE_LSHIFT"] = "LSHFT",
+ ["KEYCODE_RSHIFT"] = "RSHFT",
+ ["KEYCODE_LCONTROL"] = "LCTRL",
+ ["KEYCODE_RCONTROL"] = "RCTRL",
+ ["KEYCODE_LALT"] = "LALT",
+ ["KEYCODE_RALT"] = "RALT",
+ ["KEYCODE_SCRLOCK"] = "SCRLOCK",
+ ["KEYCODE_NUMLOCK"] = "NUMLOCK",
+ ["KEYCODE_CAPSLOCK"] = "CAPSLOCK",
+ ["KEYCODE_LWIN"] = "LWIN",
+ ["KEYCODE_RWIN"] = "RWIN",
+ ["KEYCODE_MENU"] = "MENU",
+ ["KEYCODE_CANCEL"] = "CANCEL"
+}
+
+return keycodemap
diff --git a/plugins/cheat/conv_cheat.lua b/plugins/cheat/xml_to_json.lua
index 1574a9c0f12..1273fb9885e 100644
--- a/plugins/cheat/conv_cheat.lua
+++ b/plugins/cheat/xml_to_json.lua
@@ -1,4 +1,4 @@
-xml = require("xml_conv")
+xml = require("cheat_xml")
json = dofile("../json/init.lua")
function readAll(file)
diff --git a/src/frontend/mame/luaengine.cpp b/src/frontend/mame/luaengine.cpp
index 51c6d42ccd4..0dde20fe611 100644
--- a/src/frontend/mame/luaengine.cpp
+++ b/src/frontend/mame/luaengine.cpp
@@ -777,14 +777,14 @@ void lua_engine::initialize()
});
/*
- * emu.file(opt searchpath, flags) - flags can be as in osdcore "OPEN_FLAG_*" or lua style with 'rwc' with addtional c for create *and truncate* (be careful)
- * support zipped files on the searchpath
+ * emu.file([opt] searchpath, flags) - flags can be as in osdcore "OPEN_FLAG_*" or lua style with 'rwc' with addtional c for create *and truncate* (be careful)
+ * support zipped files on the searchpath
* file:open(name) - open first file matching name in searchpath, supports read and write sockets as "socket.127.0.0.1:1234"
* file:open_next() - open next file matching name in searchpath
* file:read(len) - only reads len bytes, doen't do lua style formats
* file:write(data) - write data to file
* file:seek(offset, whence) - whence is as C "SEEK_*" int
- * file:seek(opt whence, opt offset) - lua style "set"|"cur"|"end", returns cur offset
+ * file:seek([opt] whence, [opt] offset) - lua style "set"|"cur"|"end", returns cur offset
* file:size() -
* file:filename() - name of current file, container name if file is in zip
* file:fullpath() -
@@ -1100,7 +1100,8 @@ void lua_engine::initialize()
* machine:parameters() - get parameter_manager
* machine:options() - get machine core_options
* machine:output() - get output_manager
- * machine:input() - get ui_input_manager
+ * machine:input() - get input_manager
+ * machine:uiinput() - get ui_input_manager
* machine.paused - get paused state
* machine.devices - get device table
* machine.screens - get screens table
@@ -1123,7 +1124,8 @@ void lua_engine::initialize()
"memory", &running_machine::memory,
"options", [](running_machine &m) { return static_cast<core_options *>(&m.options()); },
"outputs", &running_machine::output,
- "input", &running_machine::ui_input,
+ "input", &running_machine::input,
+ "uiinput", &running_machine::ui_input,
"paused", sol::property(&running_machine::paused),
"devices", sol::property([this](running_machine &m) {
std::function<void(device_t &, sol::table)> tree;
@@ -1418,11 +1420,24 @@ void lua_engine::initialize()
"throttle_rate", sol::property(&video_manager::throttle_rate, &video_manager::set_throttle_rate));
/* machine:input()
- * input:find_mouse() - returns x, y, button state, ui render target
- * input:pressed(key) - get pressed state for key
+ * input:code_from_token(token) - get input_code for KEYCODE_* string token
+ * input:code_pressed(code) - get pressed state for input_code
+ * input:seq_from_tokens(tokens) - get input_seq for multiple space separated KEYCODE_* string tokens
+ * input:seq_pressed(seq) - get pressed state for input_seq
*/
- sol().registry().new_usertype<ui_input_manager>("input", "new", sol::no_constructor,
+ sol().registry().new_usertype<input_manager>("input", "new", sol::no_constructor,
+ "code_from_token", [](input_manager &input, const char *token) { return sol::make_user(input.code_from_token(token)); },
+ "code_pressed", [](input_manager &input, sol::user<input_code> code) { return input.code_pressed(code); },
+ "seq_from_tokens", [](input_manager &input, const char *tokens) { input_seq seq; input.seq_from_tokens(seq, tokens); return sol::make_user(seq); },
+ "seq_pressed", [](input_manager &input, sol::user<input_seq> seq) { return input.seq_pressed(seq); });
+
+/* machine:uiinput()
+ * uiinput:find_mouse() - returns x, y, button state, ui render target
+ * uiinput:pressed(key) - get pressed state for ui key
+ */
+
+ sol().registry().new_usertype<ui_input_manager>("uiinput", "new", sol::no_constructor,
"find_mouse", [](ui_input_manager &ui) {
int32_t x, y;
bool button;
diff --git a/src/mame/layout/mdndclab.lay b/src/mame/layout/mdndclab.lay
index 10d9f9a2ff4..c9b3e033b7b 100644
--- a/src/mame/layout/mdndclab.lay
+++ b/src/mame/layout/mdndclab.lay
@@ -14,7 +14,7 @@
local last_state = false
local function get_mouse()
- local x, y, button, target = machine:input():find_mouse()
+ local x, y, button, target = machine:uiinput():find_mouse()
if not button then
last_state = false
return nil