added controller support and factored out input source