diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2021-01-10 20:25:14 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-10 20:25:14 +0100 |
commit | c3b23f02031dbdc96afa09e40fe51ffe345038ef (patch) | |
tree | 35f0cad8cdb36bcaa3160c68286ae97b89a80a35 /modules | |
parent | a594243eee07b1237572cfae3291e3694e8395a3 (diff) | |
parent | 7a0d4275a2369c939b5f2ee2cc3ac5088628ca68 (diff) |
Merge pull request #45054 from dsnopek/webxr-yaxis-master
Invert the Y-axis on thumbsticks and trackpads in WebXR
Diffstat (limited to 'modules')
-rw-r--r-- | modules/webxr/native/library_godot_webxr.js | 8 |
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; }, |