Add Moga controller support.

This commit is contained in:
Cameron Gutman 2013-11-12 03:10:23 -05:00
parent aa4e07ea2f
commit ae65bbe3ca

View File

@ -345,15 +345,27 @@ public class Game extends Activity implements OnGenericMotionListener, OnTouchLi
float RS_X, RS_Y, L2, R2;
InputDevice.MotionRange l2Range = dev.getMotionRange(MotionEvent.AXIS_LTRIGGER);
InputDevice.MotionRange r2Range = dev.getMotionRange(MotionEvent.AXIS_RTRIGGER);
if (l2Range != null && r2Range != null)
InputDevice.MotionRange leftTriggerRange = dev.getMotionRange(MotionEvent.AXIS_LTRIGGER);
InputDevice.MotionRange rightTriggerRange = dev.getMotionRange(MotionEvent.AXIS_RTRIGGER);
if (leftTriggerRange != null && rightTriggerRange != null)
{
// Ouya controller
RS_X = event.getAxisValue(MotionEvent.AXIS_Z);
RS_Y = event.getAxisValue(MotionEvent.AXIS_RZ);
L2 = event.getAxisValue(MotionEvent.AXIS_LTRIGGER);
R2 = event.getAxisValue(MotionEvent.AXIS_RTRIGGER);
RS_X = event.getAxisValue(MotionEvent.AXIS_Z);
RS_Y = event.getAxisValue(MotionEvent.AXIS_RZ);
}
else
{
InputDevice.MotionRange brakeRange = dev.getMotionRange(MotionEvent.AXIS_BRAKE);
InputDevice.MotionRange gasRange = dev.getMotionRange(MotionEvent.AXIS_GAS);
if (brakeRange != null && gasRange != null)
{
// Moga controller
RS_X = event.getAxisValue(MotionEvent.AXIS_Z);
RS_Y = event.getAxisValue(MotionEvent.AXIS_RZ);
L2 = event.getAxisValue(MotionEvent.AXIS_BRAKE);
R2 = event.getAxisValue(MotionEvent.AXIS_GAS);
}
else
{
@ -363,6 +375,8 @@ public class Game extends Activity implements OnGenericMotionListener, OnTouchLi
L2 = (event.getAxisValue(MotionEvent.AXIS_Z) + 1) / 2;
R2 = (event.getAxisValue(MotionEvent.AXIS_RZ) + 1) / 2;
}
}
InputDevice.MotionRange hatXRange = dev.getMotionRange(MotionEvent.AXIS_HAT_X);
InputDevice.MotionRange hatYRange = dev.getMotionRange(MotionEvent.AXIS_HAT_Y);