Created
February 1, 2014 02:09
-
-
Save ethanclevenger91/8746991 to your computer and use it in GitHub Desktop.
Dirty gist for getting Ouya input
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
OuyaController c = OuyaController.getControllerByPlayer(i); | |
if(c != null) { | |
if(c.getButton(OuyaController.BUTTON_A)) { | |
//Do whatever it is you need to do. | |
//This can be repeated for each button on the controller | |
} | |
float axisY = c.getAxisValue(OuyaController.AXIS_LS_Y); | |
if(axisY > OuyaController.STICK_DEADZONE) { | |
switch(i) { //'i' being the player number if you're looping through the number of players | |
case 0: | |
playerOne.moveDown(axisY); | |
break; | |
case 1: | |
playerTwo.moveDown(axisY); | |
break; | |
} | |
} | |
else if(axisY < -OuyaController.STICK_DEADZONE) { | |
switch(i) { | |
case 0: | |
playerOne.moveUp(axisY); | |
break; | |
case 1: | |
playerTwo.moveUp(axisY); | |
break; | |
} | |
} | |
else { | |
switch(i) { | |
case 0: | |
playerOne.stopDown(); | |
playerOne.stopUp(); | |
break; | |
case 1: | |
playerTwo.stopDown(); | |
playerTwo.stopUp(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment