Hello everyone.
I wanted to add gamepad support for my game, however I am stuck. Gamepads work fine on desktop, however when I test them on Android TV it doesn’t work as inteded.
The issue is in key event, when I press “button1” on both gamepads at the same time, only one will react. Interestingly enough, axis event behaves properly, and axis events work fine even simultaneously.
I’ve tried run Pew Pew example on my Android TV, and there game reacts to gamepads properly, so it must be doable. Unfortunately pewpew example is rather complicated, and was not able to find the reason why the example works and my code does not.
Here is snippet of my code related to the issue.
local function onKeyEvent( event )
if ( event.phase == "down" ) then
local player = M.getPlayer( event )
if ( event.keyName == "button1" ) then
shootingHandler.shoot( event, player )
end
end
end
M.createControlButtons = function()
Runtime:addEventListener("key", onKeyEvent )
Runtime:addEventListener("axis", onAxisEvent )
end
If anyone has any idea why my code doesn’t work as intended, please let me know.
Have a nice day.