InputMangler was intended to solve a different set of problems than, say, boipushy. I wanted something that would make it easier to map chords—multiple keys or buttons pressed at the same time—to single commands (things like the B+Select combination in the original Final Fantasy), and that could "remember" different mappings for the same key combination depending on game state. It does not abstract away the various [foo]pressed I/O callbacks that Löve provides.
I've placed the code on Github: https://github.com/eliddell/inputmangler. MIT License.
Simple usage:
Code: Select all
local input = require "inputmangler"
function love.load()
input:addKeyCommand("command 1", "1")
input:addButtonCommand("command 1", "a")
end
function love.keypressed(key, scancode, isrepeat)
local cmd = input:testKey(key)
if cmd then
--do something with cmd
end
end
Bugs here, at Github, or by email to ejlddll [at] googlemail [dot] com. It may take me a few days to respond, depending. Variables that slop over unexpectedly into the global namespace are bugs.
Here's a screen capture of the boring demo application: