summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorDavid Snopek <dsnopek@gmail.com>2021-01-08 09:23:05 -0600
committerDavid Snopek <dsnopek@gmail.com>2021-01-09 15:02:22 -0600
commit7a0d4275a2369c939b5f2ee2cc3ac5088628ca68 (patch)
tree2fd4aa49e2d0a4b9c3ac34546675c79c821277c0 /modules
parent98ccaa1bad97bdb83b2afd6a4df6f7a392745592 (diff)
Invert the Y-axis on thumbsticks and trackpads in WebXR
Diffstat (limited to 'modules')
-rw-r--r--modules/webxr/native/library_godot_webxr.js8
1 files changed, 7 insertions, 1 deletions
diff --git a/modules/webxr/native/library_godot_webxr.js b/modules/webxr/native/library_godot_webxr.js
index 447045ed27..3041c16c79 100644
--- a/modules/webxr/native/library_godot_webxr.js
+++ b/modules/webxr/native/library_godot_webxr.js
@@ -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;
},