Testing Controller 'game'
Posted: Fri Feb 19, 2021 12:26 pm
I'm creating a controller 'test' game. Which essentially will show you if your controller is giving issues. (Mine is)
My only issue is that I cannot see currently if either of the triggers are being pressed.
My code is:
But this shows nothing when I press the triggers. I guess I can't check the triggers with 'gamepadpressed' so I need another command, and I'm not very good at Love so I don't know what it is. If someone could point me to where I can check the % that a trigger is down (or int value whatever they measure it in) I'd appreciate it.
My only issue is that I cannot see currently if either of the triggers are being pressed.
My code is:
Code: Select all
local keysPressed = {}
function love.keypressed(k)
keysPressed[k] = true
end
function love.keyreleased(k)
keysPressed[k] = nil
end
function love.gamepadpressed(joystick, button)
keysPressed[button] = true
end
function love.gamepadreleased(joystick, button)
keysPressed[button] = nil
end
function love.draw()
love.graphics.print("Keys pressed:", 10, 10)
local y = 30
for k,_ in pairs(keysPressed) do
if (k == " ") then st = "Space" else st = k end
love.graphics.print(st, 20, y)
y = y + 15
end
end