Skip to content

Instantly share code, notes, and snippets.

@ethanclevenger91
Created February 1, 2014 02:09
Show Gist options
  • Save ethanclevenger91/8746991 to your computer and use it in GitHub Desktop.
Save ethanclevenger91/8746991 to your computer and use it in GitHub Desktop.
Dirty gist for getting Ouya input
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