I'm new to Gideros, it's my first asking here!
With the Controller plugin added to my project, I tried using the sample code on the documentation:
--------------------------------------------------------------------------------
require "controller"
controller:addEventListener(Event.KEY_DOWN, function(e)
print("Button Down ", e.playerId, e.keyCode, findKeyCode(e.keyCode))
end)
controller:addEventListener(Event.KEY_UP, function(e)
print("Button Up ", e.playerId, e.keyCode, findKeyCode(e.keyCode))
end)
controller:addEventListener(Event.RIGHT_JOYSTICK, function(e)
print("Player: ", e.playerId)
print("RIGHT_JOYSTICK:", "x:"..e.x, "y:"..e.y, "angle:"..e.angle, "strength:"..e.strength)
end)
controller:addEventListener(Event.LEFT_JOYSTICK, function(e)
print("Player: ", e.playerId)
print("LEFT_JOYSTICK:", "x:"..e.x, "y:"..e.y, "angle:"..e.angle, "strength:"..e.strength)
end)
controller:addEventListener(Event.RIGHT_TRIGGER, function(e)
print("Player: ", e.playerId)
print("RIGHT_TRIGGER:", "strength:"..e.strength)
end)
controller:addEventListener(Event.LEFT_TRIGGER, function(e)
print("Player: ", e.playerId)
print("LEFT_TRIGGER:", "strength:"..e.strength)
end)
controller:addEventListener(Event.CONNECTED, function(e)
print("Player: ", e.playerId, "connected")
print("Are there any controllers?", controller:isAnyAvailable())
print("Controller count", controller:getPlayerCount())
print("Name of controller "..e.playerId, controller:getControllerName(e.playerId))
print("players", #controller:getPlayers())
end)
controller:addEventListener(Event.DISCONNECTED, function(e)
print("Player: ", e.playerId, "disconnected")
end)
--------------------------------------------------------------------------------
When I connect my joystick it appears on console that there is a player. When I try moving the analogic or the arrows it prints on the screen correctly. But any other keys returns an error like this:
"main.lua:4: attempt to call a nil value"
And the console simply don't work anymore.
What am I doing wrong? Thanks in advance!
Comments
I have never used that plugin and I don't have a controller to check but you can check with a print_r what is the event receiving: if your code is the one taken from the documentation I guess that something inside the print function doesn't exist and throws an error.
Likes: MoKaLux, Gabriel_Mercês
There is also a Gideros Studio sample project for the controller plugin, you can test it as well.
Likes: Gabriel_Mercês
Likes: MoKaLux