1
0
Fork 0
mirror of https://github.com/notwa/mm synced 2024-11-05 02:39:02 -08:00
mm/Lua/lib/menu input handlers.lua

59 lines
1.7 KiB
Lua
Raw Normal View History

local function handle_alt_input(handle, ctrl, pressed)
2015-11-14 16:30:04 -08:00
for _, v in ipairs{'left', 'right', 'up', 'down'} do
ctrl[v] = ctrl['d_'..v]
pressed[v] = pressed['d_'..v]
end
pressed.enter = false
ctrl.enter = false
local open_close = ctrl.L and ctrl.R and (pressed.L or pressed.R)
local hide = ctrl.L and ctrl.Z and (pressed.L or pressed.Z)
if open_close then
if handle.menu then -- if menu is open
handle:navigate('close')
else
pressed.enter = true
ctrl.enter = true
end
else
if hide then
handle:navigate('hide')
elseif pressed.L then
handle:navigate('back')
elseif handle.menu then
pressed.enter = pressed.R
ctrl.enter = ctrl.R
end
end
handle:update(ctrl, pressed)
end
local function handle_eat_input(handle, ctrl, pressed)
2015-11-14 16:30:04 -08:00
for _, v in ipairs{'left', 'right', 'up', 'down'} do
ctrl[v] = ctrl['d_'..v] or ctrl['j_'..v] or ctrl['c_'..v]
pressed[v] = pressed['d_'..v] or pressed['j_'..v] or pressed['c_'..v]
end
if not handle.menu then
pressed.enter = pressed.L
else
2015-11-14 16:42:50 -08:00
if pressed.L then
handle:navigate('close')
elseif pressed.Z then
2015-11-14 16:30:04 -08:00
handle:navigate('hide')
elseif pressed.R or pressed.B then
handle:navigate('back')
2015-11-14 16:42:50 -08:00
else
pressed.enter = pressed.A or pressed.L
ctrl.enter = ctrl.A
2015-11-14 16:30:04 -08:00
end
joypad.set({}, 1)
joypad.setanalog({["X Axis"]=false, ["Y Axis"]=false}, 1)
end
handle:update(ctrl, pressed)
end
return globalize{
handle_eat_input = handle_eat_input,
handle_alt_input = handle_alt_input,
}