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.
|
-- "gameconfig" is kind of a misnomer, to be honest.
|
||||||
-- it's more like things the end user shouldn't have to change.
|
-- 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 = {
|
local gcfg = {
|
||||||
input_size = 60 + 4, -- TODO: let the script figure this out for us.
|
input_size = 60 + 4, -- TODO: let the script figure this out for us.
|
||||||
tile_count = 17 * 13,
|
tile_count = 17 * 13,
|
||||||
|
@ -25,46 +45,19 @@ local gcfg = {
|
||||||
},
|
},
|
||||||
|
|
||||||
jp_lut = {
|
jp_lut = {
|
||||||
{ -- none
|
jp_buttons(),
|
||||||
up = false, down = false, left = false, right = false,
|
jp_buttons("a"),
|
||||||
select = false, start = false, B = false, A = false,
|
jp_buttons("left"),
|
||||||
}, { -- A
|
jp_buttons("right"),
|
||||||
up = false, down = false, left = false, right = false,
|
jp_buttons("b left"),
|
||||||
select = false, start = false, B = false, A = true,
|
jp_buttons("b right"),
|
||||||
}, { -- L
|
jp_buttons("a left"),
|
||||||
up = false, down = false, left = true, right = false,
|
jp_buttons("a right"),
|
||||||
select = false, start = false, B = false, A = false,
|
jp_buttons("b a left"),
|
||||||
}, { -- R
|
jp_buttons("b a right"),
|
||||||
up = false, down = false, left = false, right = true,
|
jp_buttons("down"),
|
||||||
select = false, start = false, B = false, A = false,
|
jp_buttons("a down"),
|
||||||
}, { -- L + B
|
jp_buttons("up"),
|
||||||
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,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue