Implemented joystick input.

I had to redo how input is done entirely, so more than one source of input can be used for game inputs.

I added new inputs, menu_decide and menu_back. Return and escape still have their reserved status, sending menu_decide and menu_back, respectively. Other keys are reserved too, like arrows, to ensure users can always reconfigure input.
This commit is contained in:
nightmareci
2020-11-08 12:55:06 -08:00
parent a105086ca6
commit 863c614a4c
9 changed files with 291 additions and 85 deletions

View File

@@ -57,17 +57,17 @@ function TitleScene:changeOption(rel)
self.main_menu_state = (self.main_menu_state + len + rel - 1) % len + 1
end
function TitleScene:onKeyPress(e)
if e.scancode == "return" and e.isRepeat == false then
function TitleScene:onInputPress(e)
if e.input == "menu_decide" then
playSE("main_decide")
scene = main_menu_screens[self.main_menu_state]()
elseif (e.scancode == config.input["up"] or e.scancode == "up") and e.isRepeat == false then
elseif e.input == "up" then
self:changeOption(-1)
playSE("cursor")
elseif (e.scancode == config.input["down"] or e.scancode == "down") and e.isRepeat == false then
elseif e.input == "down" then
self:changeOption(1)
playSE("cursor")
elseif e.scancode == "escape" and e.isRepeat == false then
elseif e.input == "menu_back" then
love.event.quit()
end
end