InputMangler: Yet another input library for Löve

Showcase your libraries, tools and other projects that help your fellow love users.
Post Reply
eliddell
Prole
Posts: 20
Joined: Sat Dec 10, 2016 6:38 pm

InputMangler: Yet another input library for Löve

Post by eliddell »

Yes, I know, it's an awful name. Alternative suggestions welcome.

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
The Github README contains a lot more example code, and the repository includes a full-length example that demonstrates mapping commands in response to user input.

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:
Image
Post Reply

Who is online

Users browsing this forum: No registered users and 46 guests