Hi.
On this page https://docs.coronalabs.com/guide/hardware/gameControllers/index.html
There is this code
local controller = { device="", displayName="" }
local function setDevice( device, displayName )
-- Set current controller
controller["device"] = device
controller["displayName"] = displayName
-- Remove event listeners
Runtime:removeEventListener( "axis", onAxisEvent )
Runtime:removeEventListener( "key", onKeyEvent )
end
local function onKeyEvent( event )
setDevice( event.device, event.device.displayName )
end
local function onAxisEvent( event )
if ( math.abs(event.normalizedValue) > 0.5 ) then
setDevice( event.device, event.device.displayName )
end
end
Runtime:addEventListener( "axis", onAxisEvent )
Runtime:addEventListener( "key", onKeyEvent )
I do not understand what the removeEventListener call should do and what is it for
I first thought that this would remove the events once the gamepad is detected, but the setDevice function is called each time the controller is used!
finally, I wonder if it is really useful for something. I wonder if the function removeEventListener really does something (in this precise case).
Any explanation ?