simplify gameconfig button specification
This commit is contained in:
parent
9b23327df4
commit
5f85b92b6d
1 changed files with 33 additions and 40 deletions
|
@ -1,6 +1,26 @@
|
|||
-- "gameconfig" is kind of a misnomer, to be honest.
|
||||
-- it's more like things the end user shouldn't have to change.
|
||||
|
||||
local function jp_buttons(s)
|
||||
s = string.lower(s or "")
|
||||
local t = {
|
||||
up = false, down = false, left = false, right = false,
|
||||
select = false, start = false, B = false, A = false,
|
||||
}
|
||||
for w in s:gmatch("%a+") do
|
||||
if w == 'up' then t.up = true
|
||||
elseif w == 'down' then t.down = true
|
||||
elseif w == 'left' then t.left = true
|
||||
elseif w == 'right' then t.right = true
|
||||
elseif w == 'select' then t.select = true
|
||||
elseif w == 'start' then t.start = true
|
||||
elseif w == 'a' then t.A = true
|
||||
elseif w == 'b' then t.B = true
|
||||
else error(("unknown button: %s"):format(w)) end
|
||||
end
|
||||
return t
|
||||
end
|
||||
|
||||
local gcfg = {
|
||||
input_size = 60 + 4, -- TODO: let the script figure this out for us.
|
||||
tile_count = 17 * 13,
|
||||
|
@ -25,46 +45,19 @@ local gcfg = {
|
|||
},
|
||||
|
||||
jp_lut = {
|
||||
{ -- none
|
||||
up = false, down = false, left = false, right = false,
|
||||
select = false, start = false, B = false, A = false,
|
||||
}, { -- A
|
||||
up = false, down = false, left = false, right = false,
|
||||
select = false, start = false, B = false, A = true,
|
||||
}, { -- L
|
||||
up = false, down = false, left = true, right = false,
|
||||
select = false, start = false, B = false, A = false,
|
||||
}, { -- R
|
||||
up = false, down = false, left = false, right = true,
|
||||
select = false, start = false, B = false, A = false,
|
||||
}, { -- L + B
|
||||
up = false, down = false, left = true, right = false,
|
||||
select = false, start = false, B = true, A = false,
|
||||
}, { -- R + B
|
||||
up = false, down = false, left = false, right = true,
|
||||
select = false, start = false, B = true, A = false,
|
||||
}, { -- L + A
|
||||
up = false, down = false, left = true, right = false,
|
||||
select = false, start = false, B = false, A = true,
|
||||
}, { -- R + A
|
||||
up = false, down = false, left = false, right = true,
|
||||
select = false, start = false, B = false, A = true,
|
||||
}, { -- L + A + B
|
||||
up = false, down = false, left = true, right = false,
|
||||
select = false, start = false, B = true, A = true,
|
||||
}, { -- R + A + B
|
||||
up = false, down = false, left = false, right = true,
|
||||
select = false, start = false, B = true, A = true,
|
||||
}, { -- D
|
||||
up = false, down = true, left = false, right = false,
|
||||
select = false, start = false, B = false, A = false,
|
||||
}, { -- D + A
|
||||
up = false, down = true, left = false, right = false,
|
||||
select = false, start = false, B = false, A = true,
|
||||
}, { -- U
|
||||
up = true, down = false, left = false, right = false,
|
||||
select = false, start = false, B = false, A = false,
|
||||
},
|
||||
jp_buttons(),
|
||||
jp_buttons("a"),
|
||||
jp_buttons("left"),
|
||||
jp_buttons("right"),
|
||||
jp_buttons("b left"),
|
||||
jp_buttons("b right"),
|
||||
jp_buttons("a left"),
|
||||
jp_buttons("a right"),
|
||||
jp_buttons("b a left"),
|
||||
jp_buttons("b a right"),
|
||||
jp_buttons("down"),
|
||||
jp_buttons("a down"),
|
||||
jp_buttons("up"),
|
||||
},
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue