Skip to content

Instantly share code, notes, and snippets.

@robmiracle
Created August 6, 2015 02:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robmiracle/63eec6de3cb51635844c to your computer and use it in GitHub Desktop.
Save robmiracle/63eec6de3cb51635844c to your computer and use it in GitHub Desktop.
Code snippets for the Corona SDK Tutorial: Game controllers and axes (https://coronalabs.com/blog/2013/09/24/tutorial-controllers-and-axis)
-- Map the names to identify an axis with a device's physical inputs
local axisMap = {}
axisMap["OUYA Game Controller"] = {}
axisMap["OUYA Game Controller"][1] = "left_x"
axisMap["OUYA Game Controller"][2] = "left_y"
axisMap["OUYA Game Controller"][3] = "left_trigger"
axisMap["OUYA Game Controller"][4] = "right_x"
axisMap["OUYA Game Controller"][5] = "right_y"
axisMap["OUYA Game Controller"][6] = "right_trigger"
axisMap["DualShock Controller"] = {}
axisMap["DualShock Controller"][1] = "left_x"
axisMap["DualShock Controller"][2] = "left_y"
axisMap["DualShock Controller"][13] = "left_trigger"
axisMap["DualShock Controller"][3] = "right_x"
axisMap["DualShock Controller"][4] = "right_y"
axisMap["DualShock Controller"][14] = "right_trigger"
-- Create table to map each controller's axis number to a usable name
local axis = {}
axis["Joystick 1"] = {}
axis["Joystick 1"]["left_x"] = 0
axis["Joystick 1"]["left_y"] = 0
axis["Joystick 1"]["left_trigger"] = 0
axis["Joystick 1"]["right_x"] = 0
axis["Joystick 1"]["right_y"] = 0
axis["Joystick 1"]["right_trigger"] = 0
axis["Joystick 2"] = {}
axis["Joystick 2"]["left_x"] = 0
axis["Joystick 2"]["left_y"] = 0
axis["Joystick 2"]["left_trigger"] = 0
axis["Joystick 2"]["right_x"] = 0
axis["Joystick 2"]["right_y"] = 0
axis["Joystick 2"]["right_trigger"] = 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment