Merge pull request #45054 from dsnopek/webxr-yaxis-master

Invert the Y-axis on thumbsticks and trackpads in WebXR
This commit is contained in:
Rémi Verschelde 2021-01-10 20:25:14 +01:00 committed by GitHub
commit c3b23f0203
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -601,7 +601,13 @@ const GodotWebXR = {
const buf = GodotRuntime.malloc((axes_count + 1) * 4);
GodotRuntime.setHeapValue(buf, axes_count, 'i32');
for (let i = 0; i < axes_count; i++) {
GodotRuntime.setHeapValue(buf + 4 + (i * 4), controller.gamepad.axes[i], 'float');
let value = controller.gamepad.axes[i];
if (i === 1 || i === 3) {
// Invert the Y-axis on thumbsticks and trackpads, in order to
// match OpenXR and other XR platform SDKs.
value *= -1.0;
}
GodotRuntime.setHeapValue(buf + 4 + (i * 4), value, 'float');
}
return buf;
},