Overview

Jail

Jail, or Just Another Input Library, is a library for LÖVE that attempts to abstract input. It combines keyboard, mouse and joystick input which are converted to actions using a keymap. These actions are then what the game reacts upon.

Sample usage

require "jail"

function love.load()
    jail.init{
        keymap = "key.map",
        default = "default.map",
        keys = {
            "x",
            "y",
            "shoot",
            "quit"
        }
    }
    --your other stuff
end

function love.update(dt)
    jail.update()
    --other update stuff
    --isDown returns true/false, it's true
    --when a button is down or an axis fully 'used'
    if jail.isDown("shoot") then
        --evil firing code
    end
    --getDown returns a value from -1 to 1,
    --buttons are either 0 or 1, axes can be anywhere in between
    --negative is also possible for buttons, keymap example:
    --bind w y
    --bind s -y
    --note that this alternate syntax exists:
    --bind w:s y
    --negative actions can be to invert axes
    px = px + jail.getDown("x")*speed*dt
end

function love.pressed(key)
    --this will be called when a button (or axis!) is down
    --love.released is for when it's released
end