From b086f4cf192053bceac61255993c1b2ba276f30b Mon Sep 17 00:00:00 2001 From: Andrew Minnich Date: Tue, 19 Feb 2019 03:21:18 -0500 Subject: [PATCH] fix error when using joystick button sources --- baton.lua | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/baton.lua b/baton.lua index 13b930b..e5316c3 100644 --- a/baton.lua +++ b/baton.lua @@ -62,9 +62,11 @@ function sourceFunction.joystick.axis(joystick, value) end function sourceFunction.joystick.button(joystick, button) - local isDown = tonumber(button) and joystick:isDown(tonumber(button)) - or joystick:isGamepadDown(button) - return isDown and 1 or 0 + if tonumber(button) then + return joystick:isDown(tonumber(button)) and 1 or 0 + else + return joystick:isGamepadDown(button) and 1 or 0 + end end function sourceFunction.joystick.hat(joystick, value)