Type library
Revision 2015.2692
Keywords greenthrottle, joystick, controller, bluetooth
Sample code
See also GreenThrottle
Availability Starter, Basic, Pro, Enterprise


This library provides access to GreenThrottle's bluetooth joystick controllers


The following platforms are supported:


local greenthrottle = require "plugin.greenthrottle"



greenthrottle.getButtonState(int buttonState, int controllerId, int button)

Get the state of any of the buttons pressed by any of the controllers

  • buttonState is either BUTTON_STATE_HELD, BUTTON_STATE_DOWN or BUTTON_STATE_UP. BUTTON_STATE_HELD means if it is held down. BUTTON_STATE_DOWN means if it was pressed down this frame. BUTTON_STATE_UP means it was released this frame.
  • controllerId is the id of the controller to query. See above
  • button. Button constant for button to check. see above
  • returns true or false based on the state


greenthrottle.getAnalogState(axis, controllerId, analogControl)

Get the state of the various analog controls on the controller

  • Axis is the X or Y axis constant defined above. Single axis controls only have an X value, Y value will always return 0 for single axis.
  • controllerId is the id of the controller to query. See above
  • analogControl id as defined above.
  • return floating point axis value based on inputs


greenthrottle.getAnalogChanged(controllerId, analogControl)

Is set per frame if there was activity for an analog control

  • controllerId is the id of the controller to query. See above
  • analogControl id as defined above
  • returns true or false base on if there was an analog event for this control on the current frame



Is true if the service has sent a connect message to the plugin. false if no connection has been received or a disconnect message has been received

  • controllerId is the id of the controller to query. See above
  • returns true or false based on if the controller is connected



Is true if the service has been connected. False if not. The service should connect automatically on startup of the corona app. If the service is not installed or is broken this will be false.

  • returns true or false based on if the service is connected



Clear the state of the specified controller. Useful for controller disconnects so that controllers stop reporting values that will never be updated causing on screen problems.

  • controllerId is the id of the controller to query. See above



Remaps the left analog stick to the DPAD buttons so that you get DPAD pressed from the left analog stick. This function is called on startup by default.



Removes the left analog stick to dpad button remap.



Remaps the right analog stick to the AYXB (A is Down and then clockwise) buttons respectively. This is disabled by default



Removes the right analog stick to AYXB remap.



Convenience function that hides the onscreen Android System UI when called. This is called by default on startup and onResume. Any on screen touch even twill bring it back typically so you made need to call it within your code if you want it to disappear again.



This function should be called at the beginning of every GameLoop in order to manage state around BUTTON_STATE_DOWN, BUTTON_STATE_UP and analogChanged() Also issues every button press to the state buffers since the last call. Unless this function is called once per frame you will not see any button state changes.



The follwoing are button constants used for button in GetButtonState:

  • greenthrottle.BUTTON_A
  • greenthrottle.BUTTON_B
  • greenthrottle.BUTTON_Y
  • greenthrottle.BUTTON_X
  • greenthrottle.BUTTON_DOWN
  • greenthrottle.BUTTON_UP
  • greenthrottle.BUTTON_LEFT
  • greenthrottle.BUTTON_RIGHT
  • greenthrottle.BUTTON_L1
  • greenthrottle.BUTTON_L2
  • greenthrottle.BUTTON_L3
  • greenthrottle.BUTTON_R1
  • greenthrottle.BUTTON_R2
  • greenthrottle.BUTTON_R3
  • greenthrottle.BUTTON_ANALOG_LEFT_UP
  • greenthrottle.BUTTON_ANALOG_LEFT_DOWN
  • greenthrottle.BUTTON_ANALOG_LEFT_LEFT
  • greenthrottle.BUTTON_ANALOG_LEFT_RIGHT
  • greenthrottle.BUTTON_ANALOG_RIGHT_UP
  • greenthrottle.BUTTON_ANALOG_RIGHT_DOWN
  • greenthrottle.BUTTON_ANALOG_RIGHT_LEFT
  • greenthrottle.BUTTON_BACK
  • greenthrottle.BUTTON_START
  • greenthrottle.BUTTON_GTHOME


These are the constants that define each of the potentially available controllers. Used in many functions:

  • greenthrottle.CONTROLLER_1
  • greenthrottle.CONTROLLER_2
  • greenthrottle.CONTROLLER_3
  • greenthrottle.CONTROLLER_4

Button States

  • greenthrottle.BUTTON_STATE_HELD if the button is down
  • greenthrottle.BUTTON_STATE_DOWN if the button was pressed down this frame
  • greenthrottle.BUTTON_STATE_UP if the button was released up this frame

Analog controls

Used in getAnalogState and getAnalogChanged:

  • greenthrottle.ANALOG_LEFT Left analog Stick, x and y axis information ( -127 to 127, 0 centered)
  • greenthrottle.ANALOG_RIGHT Right analog Stick, x and y axis information ( -127 to 127, 0 centered)
  • greenthrottle.ANALOG_L2 Left Trigger, x axis info ( 0 to 255 (fully engaged))
  • greenthrottle.ANALOG_R2 Right Trigger, x axis info ( 0 to 255 (fully engaged))

Analog AXIS. Used in getAnalogState

  • greenthrottle.ANALOG_AXIS_X X Data for dual axis controls, only value for single axis.
  • greenthrottle.ANALOG_AXIS_Y Y Data for dual axis controls. Not used for single axis.

Project Settings


When you build using the Corona Simulator, the server automatically takes care of integrating the plugin into your project.

All you need to do is add an entry into a plugins table of your build.settings. The following is an example of a minimal build.settings file:

settings =
    plugins =
        -- key is the name passed to Lua's 'require()'
        ["plugin.greenthrottle"] =
            -- required
            publisherId = "com.greenthrottle",


This plugin is prebundled in the Plugins-3rd-Party folder of the CoronaEnterprise download.

Copy the following JAR files to the libs directory of your Android project:

  • JavaInputUnifier.jar
  • plugin.greenthrottle.jar

Sample Code

You can access sample code here.


More support is available from the GreenThrottle team: