summaryrefslogtreecommitdiffstatshomepage
path: root/plugins/autofire/autofire_menu.lua
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2021-10-21 04:11:43 +1100
committer Vas Crabb <vas@vastheman.com>2021-10-21 04:11:43 +1100
commitb1c764415931c9700552cd456bfeb20fe41ba622 (patch)
tree83484512a26252374612f51d1683ced38b5e5770 /plugins/autofire/autofire_menu.lua
parentd42a9fd87e737c0526d35624163f110b290c6d79 (diff)
-plugins: Added an input macro plugin.
-plugins: Sort input selection menus for autofire plugin. -frontend: Fixed another case where the menus may not automatically scroll the first item into view.
Diffstat (limited to 'plugins/autofire/autofire_menu.lua')
-rw-r--r--plugins/autofire/autofire_menu.lua27
1 files changed, 25 insertions, 2 deletions
diff --git a/plugins/autofire/autofire_menu.lua b/plugins/autofire/autofire_menu.lua
index 3742747d912..c9afa90e94f 100644
--- a/plugins/autofire/autofire_menu.lua
+++ b/plugins/autofire/autofire_menu.lua
@@ -234,13 +234,14 @@ end
-- Button selection menu
local function populate_button_menu()
+ local ioport = manager.machine.ioport
menu = {}
inputs = {}
menu[#menu + 1] = {_('Select an input for autofire'), '', 'off'}
menu[#menu + 1] = {'---', '', ''}
header_height = #menu
- for port_key, port in pairs(manager.machine.ioport.ports) do
+ for port_key, port in pairs(ioport.ports) do
for field_key, field in pairs(port.fields) do
if is_supported_input(field) then
inputs[#inputs + 1] = {
@@ -251,7 +252,29 @@ local function populate_button_menu()
end
end
end
- -- TODO: group by device so we can sort table.sort(inputs, function(x, y) return x.ioport_field.name < y.ioport_field.name end)
+
+ local function compare(x, y)
+ if x.ioport_field.device.tag < y.ioport_field.device.tag then
+ return true
+ elseif x.ioport_field.device.tag > y.ioport_field.device.tag then
+ return false
+ end
+ groupx = ioport:type_group(x.ioport_field.type, x.ioport_field.player)
+ groupy = ioport:type_group(y.ioport_field.type, y.ioport_field.player)
+ if groupx < groupy then
+ return true
+ elseif groupx > groupy then
+ return false
+ elseif x.ioport_field.type < y.ioport_field.type then
+ return true
+ elseif x.ioport_field.type > y.ioport_field.type then
+ return false
+ else
+ return x.ioport_field.name < y.ioport_field.name
+ end
+ end
+ table.sort(inputs, compare)
+
for i, input in pairs(inputs) do
menu[header_height + i] = { _p('input-name', input.ioport_field.name), '', '' }
end