Add support for newer Gamepad API. Fix left stick handling.

This commit is contained in:
Thibaut Despoulain
2014-05-24 16:17:47 -07:00
parent 6dbafa4047
commit fdc7e913fc
3 changed files with 22 additions and 13 deletions
+4 -4
View File
@@ -386,17 +386,17 @@ bkcore.hexgl.ShipControls.prototype.update = function(dt)
angularAmount -= this.touchController.stickVector.x/100 * this.angularSpeed * dt;
rollAmount += this.touchController.stickVector.x/100 * this.rollAngle;
}
if(this.orientationController != null)
else if(this.orientationController != null)
{
angularAmount += this.orientationController.beta/45 * this.angularSpeed * dt;
rollAmount -= this.orientationController.beta/45 * this.rollAngle;
}
if(this.gamepadController != null && this.gamepadController.updateAvailable())
else if(this.gamepadController != null && this.gamepadController.updateAvailable())
{
angularAmount -= this.gamepadController.lstickx * 0.2 * this.angularSpeed * dt;
angularAmount -= this.gamepadController.lstickx * this.angularSpeed * dt;
rollAmount += this.gamepadController.lstickx * this.rollAngle;
}
if(this.leapBridge != null && this.leapBridge.hasHands)
else if(this.leapBridge != null && this.leapBridge.hasHands)
{
angularAmount += this.leapBridge.palmNormal[0] * 2 * this.angularSpeed * dt;
this.speed += Math.max(0.0, (0.5 + this.leapBridge.palmNormal[2])) * 3 * this.thrust * dt;