Difference between revisions of "Controller"
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
+ | <!-- GIDEROSOBJ:Controller --> | ||
'''<translate>Supported platforms</translate>:''' <br/> | '''<translate>Supported platforms</translate>:''' <br/> | ||
'''<translate>Available since</translate>:''' Gideros 2014.01<br/> | '''<translate>Available since</translate>:''' Gideros 2014.01<br/> | ||
Line 55: | Line 56: | ||
| style="width: 50%; vertical-align:top;"| | | style="width: 50%; vertical-align:top;"| | ||
=== <translate>Methods</translate> === | === <translate>Methods</translate> === | ||
− | [[Special:MyLanguage/Controller:getControllerName|Controller:getControllerName]] ''<translate>gets the name of controller</translate>''<br/> | + | [[Special:MyLanguage/Controller:getControllerName|Controller:getControllerName]] ''<translate>gets the name of controller</translate>''<br/><!-- GIDEROSMTD:Controller:getControllerName --> |
− | [[Special:MyLanguage/Controller:getPlayerCount|Controller:getPlayerCount]] ''<translate>returns amount of connected controllers</translate>''<br/> | + | [[Special:MyLanguage/Controller:getPlayerCount|Controller:getPlayerCount]] ''<translate>returns amount of connected controllers</translate>''<br/><!-- GIDEROSMTD:Controller:getPlayerCount --> |
− | [[Special:MyLanguage/Controller:getPlayers|Controller:getPlayers]] ''<translate>returns table with controller IDs</translate>''<br/> | + | [[Special:MyLanguage/Controller:getPlayers|Controller:getPlayers]] ''<translate>returns table with controller IDs</translate>''<br/><!-- GIDEROSMTD:Controller:getPlayers --> |
− | [[Special:MyLanguage/Controller:isAnyAvailable|Controller:isAnyAvailable]] ''<translate>return true if any controller is connected</translate>''<br/> | + | [[Special:MyLanguage/Controller:isAnyAvailable|Controller:isAnyAvailable]] ''<translate>return true if any controller is connected</translate>''<br/><!-- GIDEROSMTD:Controller:isAnyAvailable --> |
− | [[Special:MyLanguage/Controller:vibrate|Controller:vibrate]] ''<translate>vibrate the controller for provided amount of miliseconds</translate>''<br/> | + | [[Special:MyLanguage/Controller:vibrate|Controller:vibrate]] ''<translate>vibrate the controller for provided amount of miliseconds</translate>''<br/><!-- GIDEROSMTD:Controller:vibrate --> |
| style="width: 50%; vertical-align:top;"| | | style="width: 50%; vertical-align:top;"| | ||
=== <translate>Events</translate> === | === <translate>Events</translate> === | ||
− | [[Special:MyLanguage/Event.CONNECTED|Event.CONNECTED]]<br/> | + | [[Special:MyLanguage/Event.CONNECTED|Event.CONNECTED]]<br/><!-- GIDEROSEVT:Event.CONNECTED --> |
− | [[Special:MyLanguage/Event.DISCONNECTED|Event.DISCONNECTED]]<br/> | + | [[Special:MyLanguage/Event.DISCONNECTED|Event.DISCONNECTED]]<br/><!-- GIDEROSEVT:Event.DISCONNECTED --> |
− | [[Special:MyLanguage/Event.KEY_DOWN|Event.KEY_DOWN]]<br/> | + | [[Special:MyLanguage/Event.KEY_DOWN|Event.KEY_DOWN]]<br/><!-- GIDEROSEVT:Event.KEY_DOWN --> |
− | [[Special:MyLanguage/Event.KEY_UP|Event.KEY_UP]]<br/> | + | [[Special:MyLanguage/Event.KEY_UP|Event.KEY_UP]]<br/><!-- GIDEROSEVT:Event.KEY_UP --> |
− | [[Special:MyLanguage/Event.LEFT_JOYSTICK|Event.LEFT_JOYSTICK]]<br/> | + | [[Special:MyLanguage/Event.LEFT_JOYSTICK|Event.LEFT_JOYSTICK]]<br/><!-- GIDEROSEVT:Event.LEFT_JOYSTICK --> |
− | [[Special:MyLanguage/Event.LEFT_TRIGGER|Event.LEFT_TRIGGER]]<br/> | + | [[Special:MyLanguage/Event.LEFT_TRIGGER|Event.LEFT_TRIGGER]]<br/><!-- GIDEROSEVT:Event.LEFT_TRIGGER --> |
− | [[Special:MyLanguage/Event.RIGHT_JOYSTICK|Event.RIGHT_JOYSTICK]]<br/> | + | [[Special:MyLanguage/Event.RIGHT_JOYSTICK|Event.RIGHT_JOYSTICK]]<br/><!-- GIDEROSEVT:Event.RIGHT_JOYSTICK --> |
− | [[Special:MyLanguage/Event.RIGHT_TRIGGER|Event.RIGHT_TRIGGER]]<br/> | + | [[Special:MyLanguage/Event.RIGHT_TRIGGER|Event.RIGHT_TRIGGER]]<br/><!-- GIDEROSEVT:Event.RIGHT_TRIGGER --> |
=== <translate>Constants</translate> === | === <translate>Constants</translate> === | ||
|} | |} |
Revision as of 14:56, 31 August 2018
Supported platforms:
Available since: Gideros 2014.01
Inherits from: EventDispatcher
Description
Controller interface allows you to use most popular controllers on all supported operating systems under the same interface.
Internally Controller Interface also matches all buttons and controller behavior under the same scheme so you won't have to worry about that anymore.
For more information check out [1](Controller Interface Guide)
Examples
Using Controller example
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)
MethodsController:getControllerName gets the name of controller |
EventsEvent.CONNECTED Constants |