Controller

Status: Beta

Version: 0.4

Documentation

What's new?

version 0.4
Added Amazon Fire TV Remote and Controller support

About Controller

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.

What Controller Interface provides:
Using same interface across all supported Operating systems
Using same interface across all supported controllers
Support for multiple controller types on same market/device (As playing with Xbox or Moga controller on OUYA)
Easier additions of support for future controllers
Providing controller layer, which would easily allow you to combine gameplay with or without controllers in the same app
Controller layer would easily allow you to port your touch based interface (as menu buttons) to controller selectable buttons

Installation

Android

Copy libs folder into your exported project
Copy src folder into your exported project
Add System.loadLibrary("controller"); to your main activity
Add "com.giderosmobile.android.plugins.controller.GControllerManager" as external class in your main activity
Modify Input events as described here: http://docs.giderosmobile.com/interface/controller


IOS

Copy Plugins folder into your Xcode project and add files to xcode project


Windows

Copy controller.dll into Plugins folder inside your Gideros installation directory


Mac

Copy libcontroller.dylib into Plugins folder inside your Gideros installation directory

Code 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)