
Input = {}
Input.inputQueue = {}

----------------------------------------------------------------------------------------------------
function Input:onKey(aKey)
    table.foreach(Input.inputQueue,
        function(idx)
            Input.inputQueue[idx]:input(aKey)
        end)
end

----------------------------------------------------------------------------------------------------
function addInputListener(aListener)
    table.insert(Input.inputQueue, aListener)
    addUpdateListener(aListener)
end

----------------------------------------------------------------------------------------------------
function removeInputListener(aListener)
    local index = 0
    table.foreach(Input.inputQueue,
        function(idx)
            if Input.inputQueue[idx] == aListener then
                index = idx
            end
        end)

    if index > 0 then
        table.remove(Input.inputQueue, index)
    end
    
    removeUpdateListener(aListener)
end