current version (as of writing this) on GitHub
entire project(if the file was moved and I was too lazy to change the link, you should look here)
Simple test code that dumps all key and control states:
Code: Select all
local Controls = require 'Controls'--require 'raincoat.Game.Controls'
function love.load( arg )
Controls.addKeyToControl( 'forward', 'up', 'w' )
Controls.addKeyToControl( 'backward', 'down', 's' )
Controls.addKeyToControl( 'steer-left', 'left', 'a' )
Controls.addKeyToControl( 'steer-right', 'right', 'd' )
end
function love.keypressed( key, isRepeat )
Controls.updateKey( key, true )
end
function love.keyreleased( key )
Controls.updateKey( key, false )
end
function love.draw()
local buf, i = { 'controls' }, 2
for k, v in pairs( Controls.controls ) do
buf[ i ], i = string.format( '\t%s: %s', k, v ), i + 1
end
buf[ i ], i = 'keys', i + 1
for k, v in pairs( Controls.keys ) do
buf[ i ], i = string.format( '\t%s: %s', k, v ), i + 1
end
love.graphics.print( table.concat( buf, '\n' ) )
end
-key to control
-keys to control
-key to controls
Sorry for the lack of comments in the code, if anyone needs them, I'll add them, but I tried writing it to be easy to read anyways.
I may or may not add analog control states in the future. They will most likely be a separate module.